[LEDE-DEV] [RFC/RFT 3/7] base-files: allow failsafe to configure vlans

Jonas Gorski jonas.gorski at gmail.com
Fri Jul 29 02:07:51 PDT 2016


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 at gmail.com>
---
 .../base-files/files/lib/preinit/10_indicate_preinit    | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/package/base-files/files/lib/preinit/10_indicate_preinit b/package/base-files/files/lib/preinit/10_indicate_preinit
index 4be4f30..e9ecfb8 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_config_netdev() {
-	grep -q "$1" /proc/net/dev || return
+	local netdev vid
 
-	ip link set dev $1 up
+	netdev=${1%\.*}
+	vid=${1#eth*\.}
+
+	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
 }
 
-- 
2.1.4




More information about the Lede-dev mailing list