summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2010-11-11 15:59:48 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2010-11-11 16:07:16 -0800
commitb35b69d728d1210153a3e23d25b7b4c96aba0f51 (patch)
tree10865f2e277be1bb0be5009a5604143ca5d0a015 /templates
parent799354c7b9fd06fe8ebe8a36dde14cfa3f93d610 (diff)
downloadvyatta-cfg-quagga-b35b69d728d1210153a3e23d25b7b4c96aba0f51.tar.gz
vyatta-cfg-quagga-b35b69d728d1210153a3e23d25b7b4c96aba0f51.zip
Add more checks on VLAN
Bug 4695 If ethernet hardware does not allow VLAN's than produce error. Ignore delete if device doesn't exist.
Diffstat (limited to 'templates')
-rw-r--r--templates/interfaces/bonding/node.tag/vif/node.def4
-rw-r--r--templates/interfaces/ethernet/node.tag/vif/node.def12
2 files changed, 11 insertions, 5 deletions
diff --git a/templates/interfaces/bonding/node.tag/vif/node.def b/templates/interfaces/bonding/node.tag/vif/node.def
index 5d6a5478..35a00835 100644
--- a/templates/interfaces/bonding/node.tag/vif/node.def
+++ b/templates/interfaces/bonding/node.tag/vif/node.def
@@ -13,4 +13,6 @@ create: read -a SLAVES </sys/class/net/$VAR(../@)/bonding/slaves
ip link add link $VAR(../@) name "$VAR(../@).$VAR(@)" type vlan id $VAR(@) || exit 1
ip link set "$VAR(../@).$VAR(@)" up
sudo sh -c "/opt/vyatta/sbin/vyatta-link-detect $VAR(../@).$VAR(@) on"
-delete: ip link delete dev "$VAR(../@).$VAR(@)" type vlan id $VAR(@)
+
+delete: [ -d /sys/class/net/$VAR(../@).$VAR(@) ] || exit 0
+ ip link delete dev "$VAR(../@).$VAR(@)" type vlan id $VAR(@)
diff --git a/templates/interfaces/ethernet/node.tag/vif/node.def b/templates/interfaces/ethernet/node.tag/vif/node.def
index 388ad332..d184f4bc 100644
--- a/templates/interfaces/ethernet/node.tag/vif/node.def
+++ b/templates/interfaces/ethernet/node.tag/vif/node.def
@@ -5,15 +5,19 @@ help: Virtual Local Area Network (VLAN) ID
syntax:expression: $VAR(@) >= 0 && $VAR(@) <= 4094; "VLAN ID must be between 0 and 4094"
val_help: u32:0-4094; VLAN ID
-create: if ! ip link add link $VAR(../@) name "$VAR(../@).$VAR(@)" type vlan id $VAR(@)
+create: if [ $(( $(cat /sys/class/net/$VAR(../@)/features) & 1024 )) -eq 1024 ]
+ then echo "Error creating VLAN device on $VAR(../@): hardware feature not supported"
+ exit 1
+ fi
+ if ! ip link add link $VAR(../@) name "$VAR(../@).$VAR(@)" type vlan id $VAR(@)
then echo "Error creating VLAN device $VAR(../@).$VAR(@)"
exit 1
fi
# if parent is up, then bring VLAN up
- if [ $(( $(cat /sys/class/net/$VAR(../@)/flags) & 1 )) -eq 1 ]; then
- ip link set "$VAR(../@).$VAR(@)" up
+ if [ $(( $(cat /sys/class/net/$VAR(../@)/flags) & 1 )) -eq 1 ]
+ then ip link set "$VAR(../@).$VAR(@)" up
fi
/opt/vyatta/sbin/vyatta-link-detect "$VAR(../@).$VAR(@)" on
-delete: [ -d /sys/class/net/$VAR(../@) ] || exit 0
+delete: [ -d /sys/class/net/$VAR(../@).$VAR(@) ] || exit 0
ip link delete dev "$VAR(../@).$VAR(@)" type vlan id $VAR(@)