Skip to contentSkip to conversation

fix get_vid to return correct value for vlan ids larger than 255

PATCH New Florian Feldhaus 1 participant 1 message Feb 6, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix get_vid to return correct value for vlan ids larger than 255

The function get_vid in the ifup.sh script in 40network uses the return statement to return the vlan id, but exit values greater than 255 return an exit code modulo 256 (see [1]). Thus vlan IDs greater than 255 always fail. The attached patch fixes the issue.

[1] http://tldp.org/LDP/abs/html/exitcodes.html#AEN23444

[PATCH]

modules.d/40network/ifup.sh +2 -2
index 6c3133e..1164af9 100755
@@ -219,10 +219,10 @@ fi
 get_vid() {
     case "$1" in
     vlan*)
-        return ${1#vlan}
+        echo ${1#vlan}
         ;;
     *.*)
-        return ${1##*.}
+        echo ${1##*.}
         ;;
     esac
 }
@@ -234,7 +234,7 @@ if [ "$netif" = "$vlanname" ] && [ ! -e

/tmp/net.$vlanname.up ]; then
else
linkup "$phydevice"
fi
- ip link add dev "$vlanname" link "$phydevice" type vlan id "$(get_vid
$vlanname; echo $?)"
+ ip link add dev "$vlanname" link "$phydevice" type vlan id "$(get_vid
$vlanname)"
fi

 # setup nameserver
[END]