summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-08-13 16:15:59 +0200
committerDaniil Baturin <daniil@baturin.org>2019-08-14 13:38:12 +0200
commit491643b1882055bbda503e9c61cf057a8542f6d9 (patch)
treeee59d8bc2148d18df7bc4f4eeab62785b75be9cb
parentf6e7607c21f7b35abe242e855a78cda04de2b0e9 (diff)
downloadvyatta-cfg-system-491643b1882055bbda503e9c61cf057a8542f6d9.tar.gz
vyatta-cfg-system-491643b1882055bbda503e9c61cf057a8542f6d9.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.
-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(@)