From 1af622ab0332f583c842cad1dd9ff9f9c5dcc42d Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 11 Mar 2009 08:21:42 -0700 Subject: Disable creating vlan on disabled interface Print message and fail commit if interface is disabled. --- templates/interfaces/ethernet/node.tag/vif/node.def | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'templates') diff --git a/templates/interfaces/ethernet/node.tag/vif/node.def b/templates/interfaces/ethernet/node.tag/vif/node.def index e496a7c..e8554fa 100644 --- a/templates/interfaces/ethernet/node.tag/vif/node.def +++ b/templates/interfaces/ethernet/node.tag/vif/node.def @@ -2,8 +2,14 @@ tag: type: u32 help: Set Virtual Local Area Network (VLAN) ID syntax:expression: $VAR(@) >= 0 && $VAR(@) <= 4094; "VLAN ID must be between 0 and 4094" -create: sudo ip link add link $VAR(../@) name "$VAR(../@).$VAR(@)" type vlan id $VAR(@) - sudo ip link set "$VAR(../@).$VAR(@)" up +create: read flags < /sys/class/net/$VAR(../@)/flags + if [ $(( flags & 1 )) -eq 0 ] + then + echo "Can not create VLAN on disabled interface: " $VAR(../@) + exit 1 + fi + sudo ip link add link $VAR(../@) name "$VAR(../@).$VAR(@)" type vlan id $VAR(@) || exit 1 + sudo ip link set "$VAR(../@).$VAR(@)" up /opt/vyatta/sbin/vyatta-link-detect "$VAR(../@).$VAR(@)" on delete: sudo ip link delete "$VAR(../@).$VAR(@)" type vlan id $VAR(@) comp_help: possible completions: -- cgit v1.2.3