From b0d9e5cbb9ba5b2b772f51fc38b34b45773c28ea 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 99a48a09f87..d8401b6b960 100644 --- a/patches/systemvm/debian/config/root/ipassoc.sh +++ b/patches/systemvm/debian/config/root/ipassoc.sh @@ -110,7 +110,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 @@ -166,6 +166,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" @@ -233,7 +240,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 @@ -297,7 +304,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 @@ -331,7 +338,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