From 43f5eb623c7c038b759118c3d661db874cf72aaf Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Fri, 4 Apr 2014 01:19:09 +0100 Subject: [PATCH] fix ipv6 0.0.0.0 to ::, the equivalent ip --- xCAT-server/lib/xcat/plugins/route.pm | 22 ++++++++++-------- xCAT/postscripts/routeop | 32 +++++++++++++-------------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/route.pm b/xCAT-server/lib/xcat/plugins/route.pm index 73cac1a9e..1da3055f8 100644 --- a/xCAT-server/lib/xcat/plugins/route.pm +++ b/xCAT-server/lib/xcat/plugins/route.pm @@ -446,10 +446,10 @@ sub process_makeroutes { } else { #local on mn or sn if ($delete) { - delete_route($callback, $route_hash->{net}, $route_hash->{mask}, $gw_ip, $gw_name, $ifname, $route_hash->{ifname}); + delete_route($callback, $route_hash->{net}, $route_hash->{mask}, $gw_ip, $gw_name, $route_hash->{ifname}); } else { - set_route($callback, $route_hash->{net}, $route_hash->{mask}, $gw_ip, $gw_name, $ifname, $route_hash->{ifname}); + set_route($callback, $route_hash->{net}, $route_hash->{mask}, $gw_ip, $gw_name, $route_hash->{ifname}); } } } @@ -525,8 +525,8 @@ sub route_exists { my $net = shift; my $mask = shift; my $gw_ip = shift; - my $ifname = shift; my $gw=shift; + my $ifname = shift; my $islinux=xCAT::Utils->isLinux(); @@ -610,7 +610,7 @@ sub set_route { # ipv6 network if ($net =~ /:/) { if (xCAT::Utils->isLinux()) { - if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) { + if ( $gw_ip == "" || $gw_ip == "::" ) { $cmd="ip -6 route add $net/$mask dev $ifname"; } else { $cmd="ip -6 route add $net/$mask via $gw_ip"; @@ -691,7 +691,7 @@ sub delete_route { my $cmd; if ($net =~ /:/) { if (xCAT::Utils->isLinux()) { - if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) { + if ( $gw_ip == "" || $gw_ip == "::" ) { $cmd = "ip -6 route delete $net/$mask dev $ifname"; } else { $cmd = "ip -6 route delete $net/$mask via $gw_ip"; @@ -850,8 +850,8 @@ sub addPersistentRoute_Sles { #print "hasConfiged=$hasConfiged\n"; my $new_config; if ($net =~ /:/) { - if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) { - $new_config = "$net/$mask 0.0.0.0 - $ifname\n"; + if ( $gw_ip == "" || $gw_ip == "::" ) { + $new_config = "$net/$mask :: - $ifname\n"; } else { $new_config = "$net/$mask $gw_ip - -\n"; } @@ -938,6 +938,10 @@ sub checkConfig_Sles { my $ifname=shift; my $output=shift; + # Format: + # DESTINATION GATEWAY NETMASK INTERFACE + # DESTINATION/PREFIXLEN GATEWAY - INTERFACE + # ipv4 format: 192.168.0.0 207.68.156.51 255.255.0.0 eth1 # ipv6 format: fd59::/64 fd57:faaf:e1ab:336:21a:64ff:fe01:1 - - foreach my $line (@$output) { @@ -1166,7 +1170,7 @@ sub addPersistentRoute_Debian{ #ipv6 if ( $net =~ /:/){ - if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) { + if ( $gw_ip == "" || $gw_ip == "::" ) { $cmd = "grep \"$net/$mask dev $ifname\" $conf_file"; $route_conf = " up route -A inet6 add $net/$mask dev $ifname \n down route -A inet6 del $net/$mask dev $ifname \n"; } else { @@ -1238,7 +1242,7 @@ sub deletePersistentRoute_Debian{ preParse_Debian(); #ipv6 if ( $net =~ /:/){ - if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) { + if ( $gw_ip == "" || $gw_ip == "::" ) { $match = "$net/$mask dev $ifname"; } else { $match = "$net/$mask gw $gw_ip"; diff --git a/xCAT/postscripts/routeop b/xCAT/postscripts/routeop index 07e1e20f0..2cf80a3f1 100755 --- a/xCAT/postscripts/routeop +++ b/xCAT/postscripts/routeop @@ -175,9 +175,9 @@ add_persistent_route() filename="/etc/sysconfig/network/routes"; if echo $net | grep : 2>&1 1>/dev/null then - if [ $gw_ip = "" -o $gw_ip = "0.0.0.0" ] ; then - route="$net/$mask 0.0.0.0 - $ifname" - route1="$net\/$mask 0.0.0.0 - $ifname"; + if [ $gw_ip = "" -o $gw_ip = "::" ] ; then + route="$net/$mask :: - $ifname" + route1="$net\/$mask :: - $ifname"; else route="$net/$mask $gw - -" route1="$net\/$mask $gw - -"; @@ -232,7 +232,7 @@ add_persistent_route() echo $net | grep : 2>&1 1>/dev/null #ipv6 if [ $? -eq 0 ];then - if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then + if [ "$gw" = "" -o "$gw" = "::" ] ; then matchstr="$net/$mask dev $ifname" else matchstr="$net/$mask gw $gw" @@ -256,7 +256,7 @@ add_persistent_route() if [ $? -eq 0 -a $foundflag -eq 1 ];then foundflag=0 if [ $v6flag -eq 1 ];then - if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then + if [ "$gw" = "" -o "$gw" = "::" ] ; then echo " up route -A inet6 add $net/$mask dev $ifname" >> $tempfile echo " down route -A inet6 del $net/$mask dev $ifname" >> $tempfile else @@ -284,7 +284,7 @@ add_persistent_route() #the insert place is the last line of the config file if [ $foundflag -eq 1 ];then if [ $v6flag -eq 1 ];then - if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then + if [ "$gw" = "" -o "$gw" = "::" ] ; then echo " up route -A inet6 add $net/$mask dev $ifname" >> $tempfile echo " down route -A inet6 del $net/$mask dev $ifname" >> $tempfile else @@ -313,7 +313,7 @@ add_persistent_route() if echo $net | grep : 2>&1 1>/dev/null then if [ "$gw" = "" ] ; then - $gw = "0.0.0.0"; + $gw = "::"; fi filename="/etc/sysconfig/static-routes-ipv6"; route="$ifname $net/$mask $gw"; @@ -387,9 +387,9 @@ rm_persistent_route() # ipv6 net if echo $net | grep : 2>&1 1>/dev/null then - if [ $gw = "" -o $gw = "0.0.0.0" ] ; then - route="$net/$mask 0.0.0.0 - $ifname"; - route1="$net\/$mask 0.0.0.0 - $ifname"; + if [ $gw = "" -o $gw = "::" ] ; then + route="$net/$mask :: - $ifname"; + route1="$net\/$mask :: - $ifname"; else route="$net/$mask $gw - -"; route1="$net\/$mask $gw - -"; @@ -431,7 +431,7 @@ rm_persistent_route() echo $net | grep : 2>&1 1>/dev/null #ipv6 if [ $? -eq 0 ];then - if [ $gw = "" -o $gw = "0.0.0.0" ] ; then + if [ $gw = "" -o $gw = "::" ] ; then matchstr="$net/$mask dev $ifname" else matchstr="$net/$mask gw $gw" @@ -460,9 +460,9 @@ rm_persistent_route() then filename="/etc/sysconfig/static-routes-ipv6"; # $net/$mask does not work with sed - if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then - route="$ifname $net\/$mask 0.0.0.0" - route1="$ifname $net/$mask 0.0.0.0" + if [ "$gw" = "" -o "$gw" = "::" ] ; then + route="$ifname $net\/$mask ::" + route1="$ifname $net/$mask ::" else route="$ifname $net\/$mask $gw" route1="$ifname $net/$mask $gw" @@ -504,7 +504,7 @@ if [ "$op" = "add" ]; then if echo $net | grep : 2>&1 1>/dev/null then if [ "$(uname -s)" = "Linux" ]; then - if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then + if [ "$gw" = "" -o "$gw" = "::" ] ; then cmd="ip -6 route add $net/$mask dev $ifname" else cmd="ip -6 route add $net/$mask via $gw" @@ -553,7 +553,7 @@ elif [ "$op" = "delete" ]; then if echo $net | grep : 2>&1 1>/dev/null then if [ "$(uname -s)" = "Linux" ]; then - if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then + if [ "$gw" = "" -o "$gw" = "::" ] ; then cmd="ip -6 route delete $net/$mask dev $ifname" else cmd="ip -6 route delete $net/$mask via $gw"