aboutsummaryrefslogtreecommitdiffstats
path: root/main/vlan/mvlan.post-down
diff options
context:
space:
mode:
authorAlex Laskin <alex@lask.in>2017-09-25 21:54:05 +0300
committerNatanael Copa <ncopa@alpinelinux.org>2017-09-27 09:55:55 +0000
commit8faf34e75443a768375e2250f961952183d30858 (patch)
tree98da6ebcf4e39b8c5581939d8129c5bcf3125008 /main/vlan/mvlan.post-down
parented7bfce2007122394886c658e0db30a6ba91d751 (diff)
downloadaports-8faf34e75443a768375e2250f961952183d30858.tar.bz2
aports-8faf34e75443a768375e2250f961952183d30858.tar.xz
main/vlan: rewrite to /sbin/ip and better error handling
Diffstat (limited to 'main/vlan/mvlan.post-down')
-rw-r--r--main/vlan/mvlan.post-down31
1 files changed, 21 insertions, 10 deletions
diff --git a/main/vlan/mvlan.post-down b/main/vlan/mvlan.post-down
index 229fc0e7f5..a18db48822 100644
--- a/main/vlan/mvlan.post-down
+++ b/main/vlan/mvlan.post-down
@@ -1,14 +1,25 @@
#!/bin/sh
+set -eu
+
+# guessing parameters
case "$IFACE" in
- *#[0-9]*)
- MVLANID="${IFACE##*#}"
- IF_MVLAN_RAW_DEVICE="${IFACE%#*}"
- ;;
- *)
- ;;
+ *:*) exit 0 ;;
+ *.*) exit 0 ;;
+ vlan*) exit 0 ;;
+ *#[0-9]*) GUESSED_RAW_DEVICE="${IFACE%#*}" ;;
+ *) [ -n "${IF_MVLAN_RAW_DEVICE:-}" ] || exit 0 ;;
esac
-if [ -n "$IF_MVLAN_RAW_DEVICE" ]
-then
- # Kernel new style configuration
- ip link del link dev "$IFACE"
+
+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