From b35b69d728d1210153a3e23d25b7b4c96aba0f51 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Thu, 11 Nov 2010 15:59:48 -0800 Subject: 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. --- templates/interfaces/bonding/node.tag/vif/node.def | 4 +++- templates/interfaces/ethernet/node.tag/vif/node.def | 12 ++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'templates') 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 = 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(@) -- cgit v1.2.3