From 0ac0949b03cdfc2c06ba997e9b3b890a5ca17b1f Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Thu, 3 Dec 2020 14:33:07 +0100 Subject: network: add option to keep the link down Some interfaces like Open vSwitch bridges using the userspace datapath, needs the link to be kept down to avoid issues. Add a LINKSTATUS=[down|up] ifcfg parameter to add this functionality. If not specified, the link will default to up as before. Patch provided by Matteo Croce --- network-scripts/network-functions | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'network-scripts/network-functions') diff --git a/network-scripts/network-functions b/network-scripts/network-functions index 42d01f31..2d4a907a 100644 --- a/network-scripts/network-functions +++ b/network-scripts/network-functions @@ -457,11 +457,18 @@ check_device_down () fi } -check_link_down () +set_link_up () { - if ! LC_ALL=C ip link show dev $1 2>/dev/null| grep -q ",UP" ; then + if [ "$LINKSTATUS" = down ]; then ip link set dev $1 up >/dev/null 2>&1 + else + grep -qsx 1 /sys/class/net/$1/carrier fi +} + +check_link_down () +{ + set_link_up $1 timeout=0 delay=10 [ -n "$LINKDELAY" ] && delay=$(($LINKDELAY * 2)) -- cgit v1.2.1