4 .
/lib
/functions
/uci-defaults.sh
5 .
/lib
/functions
/system.sh
9 local switchid net portid master device lan_role lan_list
11 json_select_object switch
13 for net
in $
(ls -d /sys
/class
/net
/*); do
14 switchid
=$
(cat $net/phys_switch_id
2>/dev
/null
)
15 [ -z "$switchid" ] && continue
16 device
=$
(basename $net)
17 portid
=$
(cat $net/phys_port_name
)
18 lan_role
="$lan_role ${portid##p}"
19 lan_list
="$lan_list $device"
20 json_select_object
"switch$((switchid))"
21 json_add_boolean
enable 1
22 json_add_boolean
reset 0
23 json_add_boolean dsa
1
24 json_select_array ports
26 json_add_int num
"${portid##p}"
27 json_add_string role
"lan"
28 json_add_string device
"$device"
33 # Add switch master device
34 for net
in $
(ls -d /sys
/class
/net
/*/dsa
); do
35 master
=$
(dirname $net)
36 device
=$
(basename $master)
37 portid
=$
(cat $master/phys_port_name
)
38 lan_role
="$lan_role ${portid##p}"
39 json_select_object
"switch$((switchid))"
40 json_select_array ports
42 json_add_int num
"${portid##p}"
43 json_add_string device
"$device"
44 json_add_boolean need_tag
0
45 json_add_boolean want_untag
0
46 json_add_boolean master
1
49 json_select_array roles
51 json_add_string role
"lan"
52 lan_role
=$
(echo $lan_role |
xargs -n1 |
sort -n |
xargs)
53 json_add_string ports
"$lan_role"
59 lan_list
=$
(echo $lan_list |
xargs -n1 |
sort -V |
xargs)
60 ucidef_set_interface_lan
"$lan_list"
72 lan_mac
=$
(mtd_get_mac_ascii u-boot-env ethaddr
)
76 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr
"lan" $lan_mac
77 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr
"wan" $wan_mac
78 [ -n "$label_mac" ] && ucidef_set_label_macaddr
$label_mac
84 rtl838x_setup_macs
$board