From 02595f1b33542fbbc2b996321b24d9274aacc186 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 10 Feb 2012 15:51:39 -0800 Subject: [PATCH] bug 12706: Add broadcast address for the network interface status 12706: resolved fixed --- patches/systemvm/debian/config/root/ipassoc.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/patches/systemvm/debian/config/root/ipassoc.sh b/patches/systemvm/debian/config/root/ipassoc.sh index 3fdc3f17d9f..0e2c57764a6 100644 --- a/patches/systemvm/debian/config/root/ipassoc.sh +++ b/patches/systemvm/debian/config/root/ipassoc.sh @@ -114,7 +114,7 @@ convert_primary_to_32() { fi if [ "$mask" != "32" ] then - sudo ip addr add dev $ethDev $ipNoMask/32 + ip_addr_add $ethDev $ipNoMask/32 fi done #delete primaries @@ -170,6 +170,13 @@ copy_routes_from_main() { return 0; } +ip_addr_add() { + local dev="$1" + local ip="$2" + local brd=`TERM=linux ipcalc $ip|grep Broadcast|awk -F' ' '{print $2}'` + sudo ip addr add dev $dev $ip broadcast $brd +} + add_routing() { local pubIp=$1 logger -t cloud "$(basename $0):Add routing $pubIp on interface $ethDev" @@ -237,7 +244,7 @@ add_first_ip() { local old_state=$? convert_primary_to_32 $pubIp - sudo ip addr add dev $ethDev $pubIp + ip_addr_add $ethDev $pubIp if [ "$mask" != "32" ] && [ "$mask" != "" ] then # remove if duplicat ip with 32 mask, this happens when we are promting the ip to primary @@ -301,7 +308,7 @@ add_an_ip () { sudo ip link show $ethDev | grep "state DOWN" > /dev/null local old_state=$? - sudo ip addr add dev $ethDev $pubIp ; + ip_addr_add $ethDev $pubIp add_snat $1 if [ $if_keep_state -ne 1 -o $old_state -ne 0 ] then @@ -335,7 +342,7 @@ remove_an_ip () { if [ -n "$replaceIpMask" ]; then sudo ip addr del dev $ethDev $replaceIpMask; replaceIp=`echo $replaceIpMask | awk -F/ '{print $1}'`; - sudo ip addr add dev $ethDev $replaceIp/$existingMask; + ip_addr_add $ethDev $replaceIp/$existingMask fi result=$? fi