commit: 8b98728ce0b3249da5cc2e6571bf19d57fe75a14 Author: Alon Bar-Lev <alonbl <AT> gentoo <DOT> org> AuthorDate: Sat Nov 7 20:02:22 2015 +0000 Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> CommitDate: Sat Nov 7 20:02:22 2015 +0000 URL: https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=8b98728c
Revert "bridge: use/prefer iproute2/sysfs where possible" This reverts commit 6befe06a7e72b5b7f17c7f1118fc16000a0cce13. net/bridge.sh | 89 ++++------------------------------------------------------- 1 file changed, 6 insertions(+), 83 deletions(-) diff --git a/net/bridge.sh b/net/bridge.sh index 87e4055..60d3eeb 100644 --- a/net/bridge.sh +++ b/net/bridge.sh @@ -4,7 +4,7 @@ bridge_depend() { before interface macnet - program ip brctl + program brctl } _config_vars="$_config_vars bridge bridge_add brctl" @@ -29,83 +29,6 @@ _bridge_ports() done } -_brctl() -{ - if [ -z "${_bridge_use_ip}" ]; then - if ip -V >/dev/null 2>&1 && [ "$(ip -V | cut -c 24-29)" -ge 130430 ]; then - _bridge_use_ip=1 - else - _bridge_use_ip=0 - fi - fi - if [ "${_bridge_use_ip}" -eq 1 ]; then - case "$1" in - addbr) - ip link add "$2" type bridge - ;; - delbr) - ip link del "$2" - ;; - addif) - ip link set "$3" master "$2" - ;; - delif) - ip link set "$3" nomaster - ;; - setageing) - echo "$3" > /sys/class/net/"$2"/bridge/ageing_time - ;; - setgcint) - # appears to have been dropped in Debian, and I don't see a sysfs file for it - eerror "brctl setgcint is not supported!" - return 1 - ;; - stp) - if [ "$3" = "on" -o "$3" = "yes" -o "$3" = "1" ]; then - _stp_state=1 - elif [ "$3" = "off" -o "$3" = "no" -o "$3" = "0" ]; then - _stp_state=0 - else - eerror "Invalid STP state for brctl stp!" - return 1 - fi - echo ${_stp_state} > /sys/class/net/"$2"/bridge/stp_state - ;; - setbridgeprio) - echo "$3" > /sys/class/net/"$2"/bridge/priority - ;; - setfd) - echo "$3" > /sys/class/net/"$2"/bridge/forward_delay - ;; - sethello) - echo "$3" > /sys/class/net/"$2"/bridge/hello_time - ;; - setmaxage) - echo "$3" > /sys/class/net/"$2"/bridge/max_age - ;; - setpathcost) - echo "$4" > /sys/class/net/"$2"/brif/"$3"/path_cost - ;; - setportprio) - echo "$4" > /sys/class/net/"$2"/brif/"$3"/priority - ;; - hairpin) - if [ "$4" -eq "on" -o "$4" -eq "yes" -o "$4" -eq "1" ]; then - _hairpin_mode=1 - elif [ "$4" -eq "off" -o "$4" -eq "no" -o "$4" -eq "0" ]; then - _hairpin_mode=0 - else - eerror "Invalid hairpin mode for brctl hairpin!" - return 1 - fi - echo ${_hairpin_mode} > /sys/class/net/"$2"/brif/"$3"/hairpin_mode - ;; - esac - else - brctl "$@" - fi -} - bridge_pre_start() { local brif= oiface="${IFACE}" e= x= @@ -147,7 +70,7 @@ bridge_pre_start() if ! _is_bridge ; then ebegin "Creating bridge ${IFACE}" - if ! _brctl addbr "${IFACE}"; then + if ! brctl addbr "${IFACE}"; then eend 1 return 1 fi @@ -166,7 +89,7 @@ bridge_pre_start() x=$1 shift set -- "${x}" "${IFACE}" "$@" - _brctl "$@" + brctl "$@" done unset IFS @@ -197,7 +120,7 @@ bridge_pre_start() fi # The interface is known to exist now _up - if ! _brctl addif "${BR_IFACE}" "${x}"; then + if ! brctl addif "${BR_IFACE}" "${x}"; then eend 1 return 1 fi @@ -253,13 +176,13 @@ bridge_post_stop() ebegin "Removing port ${port}${extra}" local IFACE="${port}" _set_flag -promisc - _brctl delif "${iface}" "${port}" + brctl delif "${iface}" "${port}" eend $? done if ${delete}; then eoutdent - _brctl delbr "${iface}" + brctl delbr "${iface}" eend $? fi