summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-08-13 16:15:59 +0200
committerChristian Poessinger <christian@poessinger.com>2019-08-13 16:15:59 +0200
commit28be52b8965b87f98395ec21aea6c042c6bf7fd8 (patch)
tree368f70ea2a940e9b0f7aeba5dd0ce2af43d5abaf /templates
parentf25e955910e6744d3334a90cff2c78327da995f0 (diff)
downloadvyatta-cfg-system-28be52b8965b87f98395ec21aea6c042c6bf7fd8.tar.gz
vyatta-cfg-system-28be52b8965b87f98395ec21aea6c042c6bf7fd8.zip
vlan: q-in-q: T1551: add missing if statement to check if vlan interface exists
When adding the interface and getting a commit error e.g. due to missing firewall this resulted in an additional error when committing again after adding the missing firewall rule. This can be fixed by only creating the outer vif-s interface if it yet does not exist.
Diffstat (limited to 'templates')
-rw-r--r--templates/interfaces/ethernet/node.tag/vif-s/node.def24
1 files changed, 14 insertions, 10 deletions
diff --git a/templates/interfaces/ethernet/node.tag/vif-s/node.def b/templates/interfaces/ethernet/node.tag/vif-s/node.def
index 963dbb18..53f2c76c 100644
--- a/templates/interfaces/ethernet/node.tag/vif-s/node.def
+++ b/templates/interfaces/ethernet/node.tag/vif-s/node.def
@@ -5,22 +5,26 @@ help: QinQ TAG-S 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: ETHERTYPE=`echo "$VAR(ethertype/@)"`
+create:
+ ETHERTYPE=`echo "$VAR(ethertype/@)"`
if [ $ETHERTYPE == "0x88A8" ]; then ETHTYPE=802.1ad; fi
- if [ $ETHERTYPE == "0x8100" ]; then ETHTYPE=802.1Q; fi
+ if [ $ETHERTYPE == "0x8100" ]; then ETHTYPE=802.1q; fi
- if ! sudo ip link add link $VAR(../@) name "$VAR(../@).$VAR(@)" type vlan proto $ETHTYPE id $VAR(@)
- then echo "Error creating VLAN device $VAR(../@).$VAR(@)"
+ if [ ! -d /sys/class/net/$VAR(../@).$VAR(@) ]; then
+ if ! sudo ip link add link $VAR(../@) name "$VAR(../@).$VAR(@)" type vlan proto $ETHTYPE id $VAR(@); then
+ echo "Error creating VLAN device $VAR(../@).$VAR(@)"
exit 1
+ fi
fi
+
# if parent is up, then bring VLAN up
- if [ $(( $(cat /sys/class/net/$VAR(../@)/flags) & 1 )) -eq 1 ]
- then sudo ip link set "$VAR(../@).$VAR(@)" up
+ if [ $(( $(cat /sys/class/net/$VAR(../@)/flags) & 1 )) -eq 1 ]; then
+ sudo ip link set "$VAR(../@).$VAR(@)" up
fi
/opt/vyatta/sbin/vyatta-link-detect "$VAR(../@).$VAR(@)" on
delete: ETHERTYPE=`echo "$VAR(ethertype/@)"`
- if [ $ETHERTYPE == "0x88A8" ]; then ETHTYPE=802.1ad; fi
- if [ $ETHERTYPE == "0x8100" ]; then ETHTYPE=802.1Q; fi
- [ -d /sys/class/net/$VAR(../@).$VAR(@) ] || exit 0
- sudo ip link delete dev "$VAR(../@).$VAR(@)" type vlan proto $ETHTYPE id $VAR(@)
+ if [ $ETHERTYPE == "0x88A8" ]; then ETHTYPE=802.1ad; fi
+ if [ $ETHERTYPE == "0x8100" ]; then ETHTYPE=802.1Q; fi
+ [ -d /sys/class/net/$VAR(../@).$VAR(@) ] || exit 0
+ sudo ip link delete dev "$VAR(../@).$VAR(@)" type vlan proto $ETHTYPE id $VAR(@)