aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnthony Ruhier <anthony.ruhier@gmail.com>2017-10-16 23:08:14 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2018-03-26 14:24:23 +0000
commit6073409488faf0051dc1f188042f444bbd4c4743 (patch)
treebb71c586192d07e131e291561f4142f324fcb52a
parente462ed0aa2eb4c2049f6b20a56b54f6bd7c90644 (diff)
main/vlan: check if subinterface already exists
The vlan preup script tried to create the subinterface even if it already exists. It does not work on dualstack (ipv4 + ipv6) configurations, and on subinterfaces with multiple addresses setup. Now the vlan and mvlan scripts check if the interface does not already exist, and only if it does not, try to create it.
-rw-r--r--main/vlan/APKBUILD6
-rw-r--r--main/vlan/mvlan.pre-up13
-rw-r--r--main/vlan/vlan.pre-up15
3 files changed, 19 insertions, 15 deletions
diff --git a/main/vlan/APKBUILD b/main/vlan/APKBUILD
index 111a5f2a233..23dd52fcdc9 100644
--- a/main/vlan/APKBUILD
+++ b/main/vlan/APKBUILD
@@ -1,7 +1,7 @@
# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=vlan
-pkgver=2.0
+pkgver=2.1
pkgrel=1
pkgdesc="Scripts for configuring VLAN network interfaces"
url="http://wiki.alpinelinux.org/wiki/Vlan"
@@ -31,6 +31,6 @@ package() {
done
}
sha512sums="f00c8521830b1472f1e71223943c14446d28f2667f7e2fd3690c8402c7d3f34982bc4d27201b3dc9c1eb9a635e38ea23dee6e044487615cbc68ba519d940c0f7 mvlan.post-down
-955ccc68398ed2d515f794d5ef4164fec2dcfc4504e2e29d427c1687c8b9d6ecff1ea7247dc751963bb7be1db5025940fb66efef3fb6287aa19fe014088573ac mvlan.pre-up
+c2154978882b7c73324c32f7b899bf7c0a7f07fd379109d1f770c650e9b2755272598fd7b0e416027d135cc9a17d1a10d94f458effa627bd5f8193adf3d0b385 mvlan.pre-up
7a6e74957d2fcfb04023d2cf8246e8889a780171f669ec37a56882276d96fb0219180b37cc51ecd87421bcbd0f0d489602423859a6f5605781f703cf143e5bae vlan.post-down
-54af6be8962a19f5cc3781ab6e42046c2017b58adc90464fe9e1aeea0e4151792920588c84285c727e104e3232adf1d79b0b7d5edfdd53a76b02a764af555e37 vlan.pre-up"
+3555e5f5ad3bad5e15d01309880fd4fa3cced63ed7def1c289186f18f1c7d53b67c3d3cc7490e90055b065ede7dc094d381cb0d4ae91ab83e13e4b2e281b2bf7 vlan.pre-up"
diff --git a/main/vlan/mvlan.pre-up b/main/vlan/mvlan.pre-up
index 8c6f67cbfa3..ba8cf24b46b 100644
--- a/main/vlan/mvlan.pre-up
+++ b/main/vlan/mvlan.pre-up
@@ -12,6 +12,11 @@ esac
RAW_DEVICE="${IF_MVLAN_RAW_DEVICE:-${GUESSED_RAW_DEVICE:-}}"
+device_creation_error() {
+ echo "Failed to create vlan device $IFACE on device $RAW_DEVICE with tag $VLAN_ID"
+ exit 1
+}
+
if [ -z "$RAW_DEVICE" ]; then
echo "RAW_DEVICE for $IFACE is not set"
exit 1
@@ -22,9 +27,7 @@ if ! ip link show "$RAW_DEVICE" >/dev/null; then
exit 1
fi
-ip link add link "$RAW_DEVICE" name "$IFACE" type macvlan
-
-if ! ip link show "$IFACE" >/dev/null; then
- echo "Failed to create vlan device $IFACE on device $RAW_DEVICE with tag $VLAN_ID"
- exit 1
+if ! ip link show "$IFACE" >/dev/null 2>&1; then
+ ip link add link "$RAW_DEVICE" name "$IFACE" type macvlan || \
+ device_creation_error
fi
diff --git a/main/vlan/vlan.pre-up b/main/vlan/vlan.pre-up
index f72f7cb6665..bdb07fb8ffc 100644
--- a/main/vlan/vlan.pre-up
+++ b/main/vlan/vlan.pre-up
@@ -17,6 +17,11 @@ esac
RAW_DEVICE="${IF_VLAN_RAW_DEVICE:-${GUESSED_RAW_DEVICE:-}}"
VLAN_ID="$(expr ${IF_VLAN_ID:-${GUESSED_VLAN_ID:-0}} + 0 || :)"
+device_creation_error() {
+ echo "Failed to create vlan device $IFACE on device $RAW_DEVICE with tag $VLAN_ID"
+ exit 1
+}
+
if ! [ "$VLAN_ID" -gt 0 ]; then
echo "VLAN_ID for $IFACE is not set"
exit 1
@@ -36,12 +41,8 @@ if ! [ -d /proc/net/vlan ]; then
modprobe 8021q
fi
-if ! [ -e /sys/class/net/$IFACE ]; then
- ip link set dev "$RAW_DEVICE" up
+trap "device_creation_error" ERR
+ip link set dev "$RAW_DEVICE" up
+if [ ! -e "/proc/net/vlan/${IFACE}" ]; then
ip link add link "$RAW_DEVICE" name "$IFACE" type vlan id "$VLAN_ID"
fi
-
-if ! ip link show "$IFACE" >/dev/null; then
- echo "Failed to create vlan device $IFACE on device $RAW_DEVICE with tag $VLAN_ID"
- exit 1
-fi