cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yas...@apache.org
Subject git commit: updated refs/heads/master to 9de2034
Date Wed, 10 Jul 2013 22:54:45 GMT
Updated Branches:
  refs/heads/master 56da71e5b -> 9de203483


CLOUDSTACK-3436: Fix inconsistent ip routing table between redundant virtual routers


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9de20348
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9de20348
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9de20348

Branch: refs/heads/master
Commit: 9de2034832586afc0eef0fa82032d9d74620e9b8
Parents: 56da71e
Author: Sheng Yang <sheng.yang@citrix.com>
Authored: Wed Jul 10 15:53:31 2013 -0700
Committer: Sheng Yang <sheng.yang@citrix.com>
Committed: Wed Jul 10 15:54:39 2013 -0700

----------------------------------------------------------------------
 .../debian/config/opt/cloud/bin/ipassoc.sh      |  8 +++----
 patches/systemvm/debian/config/root/func.sh     | 23 ++++++++++++++++++++
 2 files changed, 27 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9de20348/patches/systemvm/debian/config/opt/cloud/bin/ipassoc.sh
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/opt/cloud/bin/ipassoc.sh b/patches/systemvm/debian/config/opt/cloud/bin/ipassoc.sh
index d23ec00..9efae26 100755
--- a/patches/systemvm/debian/config/opt/cloud/bin/ipassoc.sh
+++ b/patches/systemvm/debian/config/opt/cloud/bin/ipassoc.sh
@@ -106,8 +106,8 @@ remove_routing() {
   local tableNo=$(echo $ethDev | awk -F'eth' '{print $2}')
 
   local tableName="Table_$ethDev"
-  local ethMask=$(ip route list scope link dev $ethDev | awk '{print $1}')
-  if [ "$ethMask" == "" ]
+  local remainip=`ip addr show $ethDev | grep "inet "`
+  if [ "$remainip" == "" ]
   then
 # rules and routes will be deleted for the last ip of the interface.
      sudo ip rule delete fwmark $tableNo table $tableName
@@ -125,7 +125,7 @@ copy_routes_from_main() {
 #get the network masks from the main table
   local eth0Mask=$(ip route list scope link dev eth0 | awk '{print $1}')
   local eth1Mask=$(ip route list scope link dev eth1 | awk '{print $1}')
-  local ethMask=$(ip route list scope link dev $ethDev  | awk '{print $1}')
+  local ethMask=$(getcidr $ethDev)
 
 # eth0,eth1 and other know routes will be skipped, so as main routing table will decide the
route. This will be useful if the interface is down and up.  
   sudo ip route add throw $eth0Mask table $tableName proto static 
@@ -164,7 +164,7 @@ add_routing() {
   sudo ip route add default via $defaultGwIP table $tableName proto static
   sudo ip route flush cache
 
-  local ethMask=$(ip route list scope link dev $ethDev  | awk '{print $1}')
+  local ethMask=$(getcidr $ethDev)
   local rulePresent=$(ip rule show | grep $ethMask)
   if [ "$rulePresent" == "" ]
   then

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9de20348/patches/systemvm/debian/config/root/func.sh
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/root/func.sh b/patches/systemvm/debian/config/root/func.sh
index 8cc9608..9c7c494 100644
--- a/patches/systemvm/debian/config/root/func.sh
+++ b/patches/systemvm/debian/config/root/func.sh
@@ -95,3 +95,26 @@ unlock_exit() {
     exit $1
 }
 
+# calcuate the ip & network mask
+rangecalc(){
+    local IFS='.'
+    local -a oct mask ip
+
+    read -ra oct <<<"$1"
+    read -ra mask <<<"$2"
+    for i in {0..3}
+    do
+        ip+=( "$(( oct[i] & mask[i] ))" )
+    done
+    echo "${ip[*]}"
+}
+
+#get cidr of the nic
+getcidr(){
+    local dev=$1
+    local mask=`ifconfig $dev|grep "Mask"|cut -d ":" -f 4`
+    local cidrsize=`ip addr show $dev|grep inet|head -n 1|awk '{print $2}'|cut -d '/' -f
2`
+    local ipaddr=`ip addr show $dev|grep inet|head -n 1|awk '{print $2}'|cut -d '/' -f 1`
+    local base=$(rangecalc $ipaddr $mask)
+    echo $base/$cidrsize
+}


Mime
View raw message