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-15 21:12:14 +0200
commit51ecaf7842e8bf35544fbbe5f245410cf83d78ed (patch)
treeadc74752a68ee9fb94565523a5d7941b0ec58663
parentc728fd8b53fefe363999354a99fd749b359feb72 (diff)
downloadvyatta-cfg-system-51ecaf7842e8bf35544fbbe5f245410cf83d78ed.tar.gz
vyatta-cfg-system-51ecaf7842e8bf35544fbbe5f245410cf83d78ed.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(@)