From: Marcin Krol Date: Wed, 15 May 2024 23:06:48 +0000 (+0200) Subject: - use ip command for configuring bond interfaces X-Git-Tag: 0.5.3~2 X-Git-Url: https://git.tld-linux.org/?a=commitdiff_plain;h=6692a4555d8b1918484db9dc5561453e5ce1b6c5;p=rc-scripts.git - use ip command for configuring bond interfaces --- diff --git a/lib/ifdown-bond b/lib/ifdown-bond index 80a2cf2..f490bbe 100755 --- a/lib/ifdown-bond +++ b/lib/ifdown-bond @@ -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 diff --git a/lib/ifup b/lib/ifup index 5d6fc21..b8536af 100755 --- 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 diff --git a/lib/ifup-bond b/lib/ifup-bond index 5651839..3c1d648 100755 --- a/lib/ifup-bond +++ b/lib/ifup-bond @@ -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