summaryrefslogtreecommitdiff
path: root/templates/interfaces/ethernet/node.tag/vif/node.def
blob: d20fefdaf7b9aff2440dbfe8199c1459e616296b (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
tag:
priority: 319
type: u32
help: 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: if [ -n "$VAR(./egress-qos)" ]; then
		opt_e=" egress-qos-map $VAR(./egress-qos/@) "
	fi
	if [ -n "$VAR(./ingress-qos)" ]; then
		opt_in=" ingress-qos-map $VAR(./ingress-qos/@) "
	fi
	if ! sudo ip link add link $VAR(../@) name "$VAR(../@).$VAR(@)" type vlan id $VAR(@) ${opt_e} ${opt_in}
	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: [ -d /sys/class/net/$VAR(../@).$VAR(@) ] || exit 0
        sudo ip link delete dev "$VAR(../@).$VAR(@)" type vlan id $VAR(@)