diff options
-rw-r--r-- | templates/interfaces/bonding/node.tag/vif/node.def | 4 | ||||
-rw-r--r-- | templates/interfaces/ethernet/node.tag/vif/node.def | 12 |
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(@) |