Compare commits

...

4 Commits

2 changed files with 40 additions and 18 deletions

View File

@ -614,7 +614,11 @@ sub set_route {
}
} else {
if (xCAT::Utils->isLinux()) {
$cmd="route add -net $net netmask $mask gw $gw_ip";
if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) {
$cmd="route add -net $net netmask $mask dev $ifname";
} else {
$cmd="route add -net $net netmask $mask gw $gw_ip";
}
} else {
$cmd="route add -net $net -netmask $mask $gw_ip";
}
@ -966,7 +970,7 @@ sub addPersistentRoute_RH {
if ($net =~ /:/) {
$filename="/etc/sysconfig/static-routes-ipv6";
} else {
$filename="/etc/sysconfig/static-routes";
$filename="/etc/sysconfig/sysconfig/route-$ifname";
}
my @output=getConfig($filename);
#print "old output=" . join("\n", @output) . "\n";
@ -987,7 +991,7 @@ sub addPersistentRoute_RH {
$new_config="$ifname $net/$mask $gw_ip";
} else {
$new_config="any net $net netmask $mask gw $gw_ip $ifname\n";
$new_config="$net/$mask via $gw_ip dev $ifname\n";
}
if (!$hasConfiged) {
push(@output, $new_config);
@ -1024,7 +1028,7 @@ sub deletePersistentRoute_RH {
if ($net =~ /:/) {
$filename="/etc/sysconfig/static-routes-ipv6";
} else {
$filename="/etc/sysconfig/static-routes";
$filename="/etc/sysconfig/network-scripts/route-$ifname";
}
my @output=getConfig($filename);
#print "old output=" . join("\n", @output) . "\n";
@ -1046,7 +1050,7 @@ sub deletePersistentRoute_RH {
if ($net =~ /:/) {
$rsp->{data}->[0]= "$host: Removed persistent route \"$ifname $net/$mask $gw_ip\" from $filename.";
} else {
$rsp->{data}->[0]= "$host: Removed persistent route \"any net $net netmask $mask gw $gw_ip $ifname\" from $filename.";
$rsp->{data}->[0]= "$host: Removed persistent route \"$net/$mask via $gw_ip dev $ifname\" from $filename.";
}
$callback->($rsp);
} else {
@ -1054,7 +1058,7 @@ sub deletePersistentRoute_RH {
if ($net =~ /:/) {
$rsp->{data}->[0]= "$host: Persistent route \"$ifname $net/$mask $gw_ip\" does not exist in $filename.";
} else {
$rsp->{data}->[0]= "$host: Persistent route \"any net $net netmask $mask gw $gw_ip $ifname\" does not exist in $filename.";
$rsp->{data}->[0]= "$host: Persistent route \"$net/$mask via $gw_ip dev $ifname\" does not exist in $filename.";
}
$callback->($rsp);
}
@ -1125,7 +1129,11 @@ sub addPersistentRoute_Debian{
}
else { #ipv4
$cmd = "grep \"-net $net netmask $mask gw $gw_ip\" $conf_file";
$route_conf = " up route add -net $net netmask $mask gw $gw_ip \n down route del -net $net netmask $mask gw $gw_ip \n";
if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) {
$route_conf = " up route add -net $net netmask $mask dev $ifname \n down route del -net $net netmask $mask dev $ifname\n";
} else {
$route_conf = " up route add -net $net netmask $mask gw $gw_ip \n down route del -net $net netmask $mask gw $gw_ip\n";
}
}
#fine the corresponding config in the config file

View File

@ -240,8 +240,13 @@ add_persistent_route()
echo " up route -A inet6 add $net/$mask gw $gw" >> $tempfile
echo " down route -A inet6 del $net/$mask gw $gw" >> $tempfile
else
echo " up route add -net $net netmask $mask gw $gw" >> $tempfile
echo " down route del -net $net netmask $mask gw $gw" >> $tempfile
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
echo " up route add -net $net netmask $mask dev $ifname" >> $tempfile
echo " down route del -net $net netmask $mask dev $ifname" >> $tempfile
else
echo " up route add -net $net netmask $mask gw $gw" >> $tempfile
echo " down route del -net $net netmask $mask gw $gw" >> $tempfile
fi
fi
fi
echo $LINE | grep "iface $ifname " 2>&1 1>/dev/null
@ -258,8 +263,13 @@ add_persistent_route()
echo " up route -A inet6 add $net/$mask gw $gw" >> $tempfile
echo " down route -A inet6 del $net/$mask gw $gw" >> $tempfile
else
echo " up route add -net $net netmask $mask gw $gw" >> $tempfile
echo " down route del -net $net netmask $mask gw $gw" >> $tempfile
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
echo " up route add -net $net netmask $mask dev $ifname" >> $tempfile
echo " down route del -net $net netmask $mask dev $ifname" >> $tempfile
else
echo " up route add -net $net netmask $mask gw $gw" >> $tempfile
echo " down route del -net $net netmask $mask gw $gw" >> $tempfile
fi
fi
fi
mv -f $tempfile $filename
@ -278,9 +288,9 @@ add_persistent_route()
# $net/mask does not work with sed cmd
route1="$ifname $net\/$mask $gw";
else
filename="/etc/sysconfig/static-routes";
route="any net $net netmask $mask gw $gw $ifname";
route1="any net $net netmask $mask gw $gw $ifname";
filename="/etc/sysconfig/network-scripts/route-$ifname";
route="$net/$mask via $gw dev $ifname";
route1="$net\/$mask via $gw dev $ifname";
fi
if [ -f $filename ]; then
grep "$route" $filename 2>&1 1>/dev/null
@ -400,9 +410,9 @@ rm_persistent_route()
route="$ifname $net\/$mask $gw"
route1="$ifname $net/$mask $gw"
else
filename="/etc/sysconfig/static-routes";
route="any net $net netmask $mask gw $gw $ifname";
route1="any net $net netmask $mask gw $gw $ifname";
filename="/etc/sysconfig/network-scripts/route-$ifname";
route="$net/$mask via $gw dev $ifname";
route1="$net\/$mask via $gw dev $ifname";
fi
if [ -f $filename ]; then
grep "$route" $filename 2>&1 1>/dev/null
@ -438,7 +448,11 @@ if [ "$op" = "add" ]; then
fi
else
if [ "$(uname -s)" = "Linux" ]; then
cmd="route add -net $net netmask $mask gw $gw"
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
cmd="route add -net $net netmask $mask dev $ifname"
else
cmd="route add -net $net netmask $mask gw $gw"
fi
else
cmd="route add -net $net -netmask $mask $gw"
fi