diff options
author | Anthony Ruhier <anthony.ruhier@gmail.com> | 2017-10-16 23:08:14 +0200 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2018-03-26 14:24:23 +0000 |
commit | 6073409488faf0051dc1f188042f444bbd4c4743 (patch) | |
tree | bb71c586192d07e131e291561f4142f324fcb52a /main/vlan/vlan.pre-up | |
parent | e462ed0aa2eb4c2049f6b20a56b54f6bd7c90644 (diff) | |
download | aports-6073409488faf0051dc1f188042f444bbd4c4743.tar.bz2 aports-6073409488faf0051dc1f188042f444bbd4c4743.tar.xz |
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.
Diffstat (limited to 'main/vlan/vlan.pre-up')
-rw-r--r-- | main/vlan/vlan.pre-up | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/main/vlan/vlan.pre-up b/main/vlan/vlan.pre-up index f72f7cb666..bdb07fb8ff 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 |