[PATCH v2] realtek: sort the port list numerically

Bjørn Mork bjorn at mork.no
Mon Nov 29 05:18:14 PST 2021


Mac adresses are assigned in the order given by the port list.  The
interfaces are also brought up in this order.  This target supports
devices with up to 52 ports.  Sorting these alphabetically is very
confusing, and assigning mac addresses in alphabetic order does not
match stock firmware behaviour.

Suggested-by: Sander Vanheule <sander at svanheule.net>
Signed-off-by: Bjørn Mork <bjorn at mork.no>
---
Hauke Mehrtens <hauke at hauke-m.de> writes:

> I applied the first and the last patch, could you please resend the
> reworked patch "realtek: sort the port list numerically ".

Thanks!  Crossing fingers that this won't break too much for those who
have gotten used to the odd defaults...

Here's a new version of the remaining patch, using Sander's much nicer
implementation.  I did a quick "sysupgrade -n" test on my GS108Tv3 and
it seems to work.  Although that one has too few ports for this to
really make any difference...



Bjørn

 target/linux/realtek/base-files/etc/board.d/02_network | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/target/linux/realtek/base-files/etc/board.d/02_network b/target/linux/realtek/base-files/etc/board.d/02_network
index 93d6d4bd1e73..e8e3f6035d56 100644
--- a/target/linux/realtek/base-files/etc/board.d/02_network
+++ b/target/linux/realtek/base-files/etc/board.d/02_network
@@ -17,10 +17,7 @@ ucidef_set_poe() {
 board=$(board_name)
 board_config_update
 
-lan_list=""
-for lan in /sys/class/net/lan*; do
-	lan_list="$lan_list $(basename $lan)"
-done
+lan_list=$(ls -1 -v -d /sys/class/net/lan* | xargs -n1 basename | xargs)
 ucidef_set_bridge_device switch
 ucidef_set_interface_lan "$lan_list"
 
-- 
2.30.2




More information about the openwrt-devel mailing list