diff options
author | Jonas Gorski <jonas.gorski@gmail.com> | 2016-07-29 00:23:55 +0200 |
---|---|---|
committer | Jonas Gorski <jonas.gorski@gmail.com> | 2016-08-13 15:50:06 +0200 |
commit | 072cf26729aca15b8a0526f18bce2b5e7a27ab12 (patch) | |
tree | 3ef42996210a3aaf096b2cc0afe80033eaa94cc3 /package/base-files/files/lib/preinit | |
parent | c18edcec4500008a1dabf0b017322eb23b059c58 (diff) | |
download | upstream-072cf26729aca15b8a0526f18bce2b5e7a27ab12.tar.gz upstream-072cf26729aca15b8a0526f18bce2b5e7a27ab12.tar.bz2 upstream-072cf26729aca15b8a0526f18bce2b5e7a27ab12.zip |
base-files: allow failsafe to configure vlans
In preparation of properly setting up vlans and switches, add
support for configuring failsafe on a vlan tagged interface.
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Diffstat (limited to 'package/base-files/files/lib/preinit')
-rw-r--r-- | package/base-files/files/lib/preinit/10_indicate_preinit | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/package/base-files/files/lib/preinit/10_indicate_preinit b/package/base-files/files/lib/preinit/10_indicate_preinit index 206243390e..33e90b1d28 100644 --- a/package/base-files/files/lib/preinit/10_indicate_preinit +++ b/package/base-files/files/lib/preinit/10_indicate_preinit @@ -3,9 +3,22 @@ # Copyright (C) 2010 Vertical Communications preinit_ip_config() { - grep -q "$1" /proc/net/dev || return + local netdev vid - ip link set dev $1 up + netdev=${1%\.*} + vid=${1#*\.} + + if [ "$vid" = "$netdev" ]; then + vid= + fi + + grep -q "$netdev" /proc/net/dev || return + + if [ -n "$vid" ]; then + ip link add link $netdev name $1 type vlan id $vid + fi + + ip link set dev $netdev up ip -4 address add $pi_ip/$pi_netmask broadcast $pi_broadcast dev $1 } @@ -52,8 +65,21 @@ preinit_ip() { preinit_ip_deconfig() { [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && { + local netdev vid + + netdev=${pi_ifname%\.*} + vid=${pi_ifname#*\.} + + if [ "$vid" = "$netdev" ]; then + vid= + fi + ip -4 address flush dev $pi_ifname - ip link set dev $pi_ifname down + ip link set dev $netdev down + + if [ -n "$vid" ]; then + ip link delete $pi_ifname + fi } } |