[lxc-devel] [PATCH] Prefer iproute over ifconfig

Stéphane Graber stgraber at ubuntu.com
Mon Mar 9 16:14:47 UTC 2015


Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 config/init/common/lxc-net.in | 20 +++++++++++---------
 src/lxc/lxc-restore-net       |  2 +-
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/config/init/common/lxc-net.in b/config/init/common/lxc-net.in
index dcbe155..988d2f9 100644
--- a/config/init/common/lxc-net.in
+++ b/config/init/common/lxc-net.in
@@ -35,29 +35,31 @@ _netmask2cidr ()
 }
 
 ifdown() {
-    which ifconfig >/dev/null 2>&1
-    if [ $? = 0 ]; then
-        ifconfig $1 down
-        return
-    fi
     which ip >/dev/null 2>&1
     if [ $? = 0 ]; then
         ip link set dev $1 down
+        return
     fi
-}
-
-ifup() {
     which ifconfig >/dev/null 2>&1
     if [ $? = 0 ]; then
-        ifconfig $1 $2 netmask $3 up
+        ifconfig $1 down
         return
     fi
+}
+
+ifup() {
     which ip >/dev/null 2>&1
     if [ $? = 0 ]; then
         MASK=`_netmask2cidr ${LXC_NETMASK}`
         CIDR_ADDR="${LXC_ADDR}/${MASK}"
         ip addr add ${CIDR_ADDR} dev $1
         ip link set dev $1 up
+        return
+    fi
+    which ifconfig >/dev/null 2>&1
+    if [ $? = 0 ]; then
+        ifconfig $1 $2 netmask $3 up
+        return
     fi
 }
 
diff --git a/src/lxc/lxc-restore-net b/src/lxc/lxc-restore-net
index 1725dc3..6ae3c19 100755
--- a/src/lxc/lxc-restore-net
+++ b/src/lxc/lxc-restore-net
@@ -17,7 +17,7 @@ while true; do
 
 	if [ "$CRTOOLS_SCRIPT_ACTION" = "network-unlock" ]; then
 		brctl addif $bridge $veth
-		ifconfig $veth 0.0.0.0 up
+		ip link set dev $veth up
 	fi
 
 	i=$((i+1))
-- 
1.9.1



More information about the lxc-devel mailing list