]> TLD Linux GIT Repositories - rc-scripts.git/commitdiff
- use ip command for configuring bond interfaces
authorMarcin Krol <hawk@tld-linux.org>
Wed, 15 May 2024 23:06:48 +0000 (01:06 +0200)
committerMarcin Krol <hawk@tld-linux.org>
Wed, 15 May 2024 23:06:48 +0000 (01:06 +0200)
lib/ifdown-bond
lib/ifup
lib/ifup-bond

index 80a2cf224bafca00943e19a922447421d52af817..f490bbe69fb645591faa0d18eaa8fc7d3cd3cf69 100755 (executable)
@@ -35,19 +35,19 @@ fi
 setup_ip_param
 
 # forget all addresses
-LC_ALL=C ip addr flush dev ${DEVICE} 2>&1 | grep -v "Nothing to flush"
+LC_ALL=C ip addr flush dev "${DEVICE}" 2>&1 | grep -v "Nothing to flush"
 
 # release slave devices
 for SLAVE_DEV in $(cat /sys/class/net/${DEVICE}/bonding/slaves 2>/dev/null); do
-       echo "-${SLAVE_DEV}" > /sys/class/net/${DEVICE}/bonding/slaves
+       ip link set "${SLAVE_DEV}" nomaster
 done
 
 # bring bonding master down
-ip link set ${DEVICE} down
+ip link set "${DEVICE}" down
 
 # remove bonding master
-if grep -wq "${DEVICE}" /sys/class/net/bonding_masters; then
-       echo "-${DEVICE}" > /sys/class/net/bonding_masters
+if [ -d "/sys/class/net/${DEVICE}" ]; then
+       ip link del "${DEVICE}" type bond
        if [ $? -ne 0 ]; then
                exit 1
        fi
index 5d6fc21ed944b02ddf6ead4236f70edb79252527..b8536af55959af9953e55f6662a8e0e9fff06881 100755 (executable)
--- a/lib/ifup
+++ b/lib/ifup
@@ -125,11 +125,13 @@ if [ -n "$ETHTOOL_OPTS" ] ; then
 fi
 
 if is_yes "$SLAVE" && [ -n "$MASTER" ] ; then
-       if ! grep -wq "${DEVICE}" /sys/class/net/${MASTER}/bonding/slaves 2>/dev/null; then
-               nls "Enslaving %s to %s" "$DEVICE" "$MASTER"
-               ip link set dev ${DEVICE} down
-               echo "+${DEVICE}" > /sys/class/net/${MASTER}/bonding/slaves 2>/dev/null
-       fi
+       # create master if it doesn't exist yet
+       [ ! -d "/sys/class/net/${MASTER}" ] && ip link add "${MASTER}" type bond
+
+       nls "Enslaving %s to %s" "${DEVICE}" "${MASTER}"
+       ip link set "${DEVICE}" master "${MASTER}"
+       ip link set "${DEVICE}" up
+
        exit 0
 fi
 
index 5651839c072d2025d80e39aeb76e7dbfc54ea725..3c1d648098817f452d7b5a455f51a58d32f93df7 100755 (executable)
@@ -35,20 +35,15 @@ fi
 if [ ! -f /sys/class/net/bonding_masters ]; then
        modprobe -s bonding || exit 1
        # delete default bond0
-       echo "-bond0" > /sys/class/net/bonding_masters
+       ip link del bond0 type bond
 fi
 
 # set all major variables
 setup_ip_param
 
 # create bonding master
-if ! grep -wq "${DEVICE}" /sys/class/net/bonding_masters; then
-       echo "+${DEVICE}" > /sys/class/net/bonding_masters
-       if [ $? -eq 0 ]; then
-               ip link set dev ${DEVICE} multicast ${MULTICAST} ${ARP}
-       else
-               exit 1
-       fi
+if [ ! -d "/sys/class/net/${DEVICE}" ]; then
+       ip link add "${DEVICE}" type bond
 fi
 
 # add the bits to setup driver parameters here