From eed3f590c9db7cd9cd4d5fb4722fc7257a278ea6 Mon Sep 17 00:00:00 2001 From: Jouke Witteveen Date: Thu, 1 Mar 2012 01:33:12 +0100 Subject: Code quality upgrade This is what you get when Dave Reisner points you at some bash anti-patterns. Also in this commit: - updated documentation - bugfix revision of the IPv6 SLAAC address/route bug --- src/connections/bridge | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'src/connections/bridge') diff --git a/src/connections/bridge b/src/connections/bridge index 3cf60c1..e134647 100644 --- a/src/connections/bridge +++ b/src/connections/bridge @@ -6,27 +6,23 @@ bridge_up() { local bridge_interface load_profile "$1" - if [ -e "/sys/class/net/$INTERFACE" ]; then - if [ ! -d "/sys/class/net/$INTERFACE/brif" ]; then + if [[ -e "/sys/class/net/$INTERFACE" ]]; then + if [[ ! -d "/sys/class/net/$INTERFACE/brif" ]]; then report_fail "Interface $INTERFACE already exists and is not a bridge." exit 1 fi else - $BRCTL addbr $INTERFACE + $BRCTL addbr "$INTERFACE" fi for bridge_client in $BRIDGE_INTERFACES; do - ip link set $bridge_client promisc on up - ip addr flush dev $bridge_client - $BRCTL addif $INTERFACE $bridge_client + ip link set "$bridge_client" promisc on up + ip addr flush dev "$bridge_client" + $BRCTL addif "$INTERFACE" "$bridge_client" done # Set options - if [ -n "$FWD_DELAY" ]; then - $BRCTL setfd $INTERFACE "$FWD_DELAY" - fi - if [ -n "$MAX_AGE" ]; then - $BRCTL setmaxage $INTERFACE "$MAX_AGE" - fi + [[ "$FWD_DELAY" ]] && $BRCTL setfd "$INTERFACE" "$FWD_DELAY" + [[ "$MAX_AGE" ]] && $BRCTL setmaxage "$INTERFACE" "$MAX_AGE" bring_interface up "$INTERFACE" "$CONN_DIR/ethernet" up "$1" @@ -38,14 +34,14 @@ bridge_down() { load_profile "$1" for bridge_client in $BRIDGE_INTERFACES; do - ip link set $bridge_client promisc off down - $BRCTL delif $INTERFACE $bridge_client + ip link set "$bridge_client" promisc off down + $BRCTL delif "$INTERFACE" "$bridge_client" done "$CONN_DIR/ethernet" down "$1" bring_interface down "$INTERFACE" - $BRCTL delbr $INTERFACE - return 0 + $BRCTL delbr "$INTERFACE" + return 0 } # Returns status of profile - is it still functional? -- cgit v1.2.3-24-g4f1b