From 9fc1991d5b5076a75085beaa3ebcf1e0ab79c99d Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 10 Feb 2012 18:48:02 -0800 Subject: [PATCH] bug 13606: Fix releasing of the first IP of second public nic The problem is remove_first_ip() in ipassoc.sh can't be called more than one. The call after the first time would result in iptable and ip command failure, thus result in failure of execution of IpAssocCommand. Use the same way to detect already disassociated ip address of non-first IP(remove_an_ip()) to fix the issue. reviewed-by: Edison Su status 13606: resolved fixed --- patches/systemvm/debian/config/root/ipassoc.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/patches/systemvm/debian/config/root/ipassoc.sh b/patches/systemvm/debian/config/root/ipassoc.sh index c5bcbf5211e..0ea90004405 100644 --- a/patches/systemvm/debian/config/root/ipassoc.sh +++ b/patches/systemvm/debian/config/root/ipassoc.sh @@ -272,6 +272,10 @@ remove_first_ip() { logger -t cloud "$(basename $0):Removing first ip $pubIp on interface $ethDev" local ipNoMask=$(echo $1 | awk -F'/' '{print $1}') local mask=$(echo $1 | awk -F'/' '{print $2}') + + local existingIpMask=$(sudo ip addr show dev $ethDev | grep inet | awk '{print $2}' | grep -w $ipNoMask) + [ "$existingIpMask" == "" ] && return 0 + [ "$mask" == "" ] && mask="32" sudo iptables -D FORWARD -i $ethDev -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT