From 50066f4f7e8d53fe7b7a3acb039c7db5573f42dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Mon, 9 Mar 2015 12:14:29 -0400 Subject: [PATCH] Prefer iproute over ifconfig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber Acked-by: Serge E. Hallyn --- 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 dcbe15565..988d2f907 100644 --- a/config/init/common/lxc-net.in +++ b/config/init/common/lxc-net.in @@ -35,29 +35,31 @@ _netmask2cidr () } ifdown() { + which ip >/dev/null 2>&1 + if [ $? = 0 ]; then + ip link set dev $1 down + return + fi 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 - fi } ifup() { - which ifconfig >/dev/null 2>&1 - if [ $? = 0 ]; then - ifconfig $1 $2 netmask $3 up - return - fi 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 1725dc3a9..6ae3c1988 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))