aboutsummaryrefslogtreecommitdiffstats
path: root/main/vlan/mvlan.post-down
blob: a18db48822a164c14ef85d617f81d1ac46f6d3bc (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
#!/bin/sh
set -eu

# guessing parameters
case "$IFACE" in
	*:*) exit 0 ;;
	*.*) exit 0 ;;
	vlan*) exit 0 ;;
	*#[0-9]*) GUESSED_RAW_DEVICE="${IFACE%#*}" ;;
	*) [ -n "${IF_MVLAN_RAW_DEVICE:-}" ] || exit 0 ;;
esac

RAW_DEVICE="${IF_MVLAN_RAW_DEVICE:-${GUESSED_RAW_DEVICE:-}}"

if [ -z "$RAW_DEVICE" ]; then
	echo "RAW_DEVICE for $IFACE is not set"
	exit 1
fi

if ! ip link show dev "$RAW_DEVICE" >/dev/null; then
	echo "Device $RAW_DEVICE for $IFACE does not exist"
	exit 1
fi

ip link delete dev "$IFACE" type macvlan