defect 4033: fix device based routing in makeroutes

This commit is contained in:
Arif Ali 2014-04-01 16:16:14 +01:00
parent 5fd991246a
commit d22815398a
2 changed files with 48 additions and 12 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";
}
@ -987,7 +991,11 @@ sub addPersistentRoute_RH {
$new_config="$ifname $net/$mask $gw_ip";
} else {
$new_config="any net $net netmask $mask gw $gw_ip $ifname\n";
if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) {
$new_config="any net $net netmask $mask dev $ifname\n";
} else {
$new_config="any net $net netmask $mask gw $gw_ip $ifname\n";
}
}
if (!$hasConfiged) {
push(@output, $new_config);
@ -1125,7 +1133,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
@ -279,8 +289,13 @@ add_persistent_route()
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";
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
route="any net $net netmask $mask dev $ifname";
route1="any net $net netmask $mask dev $ifname";
else
route="any net $net netmask $mask gw $gw $ifname";
route1="any net $net netmask $mask gw $gw $ifname";
fi
fi
if [ -f $filename ]; then
grep "$route" $filename 2>&1 1>/dev/null
@ -401,8 +416,13 @@ rm_persistent_route()
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";
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
route="any net $net netmask $mask dev $ifname";
route1="any net $net netmask $mask dev $ifname";
else
route="any net $net netmask $mask gw $gw $ifname";
route1="any net $net netmask $mask gw $gw $ifname";
fi
fi
if [ -f $filename ]; then
grep "$route" $filename 2>&1 1>/dev/null
@ -438,7 +458,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