ramips: mt7621: bringup dsa master on preinit
authorChuanhong Guo <gch981213@gmail.com>
Sat, 4 Apr 2020 08:30:16 +0000 (16:30 +0800)
committerChuanhong Guo <gch981213@gmail.com>
Sat, 4 Apr 2020 08:30:16 +0000 (16:30 +0800)
DSA requires master netdev to be up before any of its slave ports.
Bring it up during preinit so that the first lan port can be used
on failsafe.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
target/linux/ramips/mt7621/base-files/lib/preinit/07_mt7621_bringup_dsa_master [new file with mode: 0644]

diff --git a/target/linux/ramips/mt7621/base-files/lib/preinit/07_mt7621_bringup_dsa_master b/target/linux/ramips/mt7621/base-files/lib/preinit/07_mt7621_bringup_dsa_master
new file mode 100644 (file)
index 0000000..7a11252
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+. /lib/functions.sh
+
+mt7621_bringup_dsa_master() {
+    local board=$(board_name)
+    local masterif
+
+    case "$board" in
+    ubiquiti,edgerouterx|\
+       ubiquiti,edgerouterx-sfp)
+        masterif="dsa"
+        ;;
+    *)
+        masterif="eth0"
+        ;;
+    esac
+
+    ifconfig $masterif up
+}
+
+boot_hook_add preinit_main mt7621_bringup_dsa_master
\ No newline at end of file