summaryrefslogtreecommitdiff
path: root/templates/interfaces/ethernet/node.tag/vif-s/node.def
blob: 963dbb1895f38f7b6d9a69ac2ac6610b873262ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
tag:
priority: 319
type: u32
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/@)"`
        if [ $ETHERTYPE == "0x88A8" ]; then ETHTYPE=802.1ad; 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(@)"
             exit 1
        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
        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(@)