[PATCH] base-files: fix configuration generation of network if "bridge" exists

INAGAKI Hiroshi musashino.open at gmail.com
Sun May 23 19:50:34 PDT 2021


Hi Rafał,

thank you for your reply.

On 2021/05/24 6:06, Rafał Miłecki wrote:
> On 23.05.2021 13:30, INAGAKI Hiroshi wrote:
>> After the commit 43fc720657c6e3b30c6ed89d7227ee6e646c158b
>> ("base-files: generate "device UCI type section for bridge"), the 
>> wrong
>> network configuration is generated for the devices that already 
>> have the
>> bridge device section for VLAN, such as the devices in realtek target.
>>
>> As a result, the bridge device by additional "device" section is
>> specified to the "ports" option in the "bridge-vlan" section and 
>> netifd
>> shuts down the switch and the ethernet when the network service 
>> started.
>>
>> --- generated config ---
>>
>> config device 'switch'
>>          option name 'switch'
>>          option type 'bridge'
>>          option macaddr '34:76:c5:xx:xx:a8'
>>
>> config device
>>          option name 'br-wan'
>>          option type 'bridge'
>>          list ports 'lan1'
>>     ... (truncated)
>>          list ports 'lan9'
>>
>> config bridge-vlan 'wan_vlan'
>>          option device 'switch'
>>          option vlan '1'
>>          option ports 'br-wan'
>>
>> --- config end ---
>
> Thanks for bringing this up Hiroshi.
>
> I'm looking at existing code, at the commit be09c5a3cd65 ("base-files:
> add board.d support for bridge device") and I have some problems
> understanding those bridges.
>
> If you can, please kindly answer me two questions:
>
>
> 1. Why realtek treats lan ports as WAN?
>
> I mean this code:
>
> for lan in /sys/class/net/lan*; do
>     lan_list="$lan_list $(basename $lan)"
> done
> ucidef_set_interface_wan "$lan_list"
>
It's for "standard switching hub behavior", to disable DHCP and allow
users to connect the device to other network, such as upstream.
>
> 2. What's up with the magic VLAN ID 100?
>
> I found this:
> ucidef_set_interface "lan" ifname "lan1n:t" protocol "static" vlan 100
>
> Why "lan" logic interface requires VLAN ID 100?
>
It's a "management VLAN".

I haven't participated in the discussion that determines this
specification, so I don't know any further details, sorry.

There are some discussion about this in the forum[1] and there is a
patch series to improve the default configuration[2].

[1]: 
https://forum.openwrt.org/t/support-for-rtl838x-based-managed-switches/57875/134
[2]: 
https://patchwork.ozlabs.org/project/openwrt/list/?series=238725&submitter=&state=*&q=&archive=both&delegate=

>
> Finally: could you post your /etc/config/network from a working setup?
/etc/config/network:

--------
config interface 'loopback'
         option ifname 'lo'
         option proto 'static'
         option ipaddr '127.0.0.1'
         option netmask '255.0.0.0'

config globals 'globals'
         option ula_prefix 'fd34:7463:3cea::/48'

config device 'switch'
         option name 'switch'
         option type 'bridge'
         option macaddr '34:76:c5:d9:f0:a8'

config bridge-vlan 'wan_vlan'
         option device 'switch'
         option vlan '1'
         option ports 'lan1 lan10 lan11 lan12 lan13 lan14 lan15 lan16 
lan17 lan18 lan19 lan2 lan20 lan21 lan22 lan23 lan24 lan3 lan4 lan5 
lan6 lan7 lan8 lan9'

config interface 'wan'
         option ifname 'switch.1'
         option proto 'dhcp'

config device 'wan_switch_1_dev'
         option name 'switch.1'
         option macaddr '34:76:c5:d9:f0:a8'

config interface 'wan6'
         option ifname 'switch.1'
         option proto 'dhcpv6'

config bridge-vlan 'lan_vlan'
         option device 'switch'
         option vlan '100'
         option ports 'lan1:t'

config interface 'lan'
         option ifname 'switch.100'
         option proto 'static'
         option ipaddr '192.168.1.1'
         option netmask '255.255.255.0'
         option ip6assign '60'

config device 'lan_switch_100_dev'
         option name 'switch.100'
         option macaddr '36:76:c5:d9:f0:a8'
--------

and /etc/board.json:

--------
{
         "model": {
                 "id": "iodata,bsh-g24mb",
                 "name": "I-O DATA BSH-G24MB"
         },
         "bridge": {
                 "name": "switch",
                 "macaddr": "34:76:c5:d9:f0:a8"
         },
         "network": {
                 "wan": {
                         "ports": [
                                 "lan1",
                                 "lan10",
                                 "lan11",
                                 "lan12",
                                 "lan13",
                                 "lan14",
                                 "lan15",
                                 "lan16",
                                 "lan17",
                                 "lan18",
                                 "lan19",
                                 "lan2",
                                 "lan20",
                                 "lan21",
                                 "lan22",
                                 "lan23",
                                 "lan24",
                                 "lan3",
                                 "lan4",
                                 "lan5",
                                 "lan6",
                                 "lan7",
                                 "lan8",
                                 "lan9"
                         ],
                         "protocol": "dhcp",
                         "macaddr": "34:76:c5:d9:f0:a8"
                 },
                 "lan": {
                         "ifname": "lan1:t",
                         "protocol": "static",
                         "vlan": "100",
                         "macaddr": "36:76:c5:d9:f0:a8"
                 }
         },
         "network-device": {
                 "eth0": {
                         "macaddr": "34:76:c5:d9:f0:a8"
                 },
                 "lan1": {
                         "macaddr": "36:76:c5:d9:f0:a8"
                 },
                 "lan10": {
                         "macaddr": "36:76:c5:d9:f0:a9"
                 },
                 "lan11": {
                         "macaddr": "36:76:c5:d9:f0:aa"
                 },
                 "lan12": {
                         "macaddr": "36:76:c5:d9:f0:ab"
                 },
                 "lan13": {
                         "macaddr": "36:76:c5:d9:f0:ac"
                 },
                 "lan14": {
                         "macaddr": "36:76:c5:d9:f0:ad"
                 },
                 "lan15": {
                         "macaddr": "36:76:c5:d9:f0:ae"
                 },
                 "lan16": {
                         "macaddr": "36:76:c5:d9:f0:af"
                 },
                 "lan17": {
                         "macaddr": "36:76:c5:d9:f0:b0"
                 },
                 "lan18": {
                         "macaddr": "36:76:c5:d9:f0:b1"
                 },
                 "lan19": {
                         "macaddr": "36:76:c5:d9:f0:b2"
                 },
                 "lan2": {
                         "macaddr": "36:76:c5:d9:f0:b3"
                 },
                 "lan20": {
                         "macaddr": "36:76:c5:d9:f0:b4"
                 },
                 "lan21": {
                         "macaddr": "36:76:c5:d9:f0:b5"
                 },
                 "lan22": {
                         "macaddr": "36:76:c5:d9:f0:b6"
                 },
                 "lan23": {
                         "macaddr": "36:76:c5:d9:f0:b7"
                 },
                 "lan24": {
                         "macaddr": "36:76:c5:d9:f0:b8"
                 },
                 "lan3": {
                         "macaddr": "36:76:c5:d9:f0:b9"
                 },
                 "lan4": {
                         "macaddr": "36:76:c5:d9:f0:ba"
                 },
                 "lan5": {
                         "macaddr": "36:76:c5:d9:f0:bb"
                 },
                 "lan6": {
                         "macaddr": "36:76:c5:d9:f0:bc"
                 },
                 "lan7": {
                         "macaddr": "36:76:c5:d9:f0:bd"
                 },
                 "lan8": {
                         "macaddr": "36:76:c5:d9:f0:be"
                 },
                 "lan9": {
                         "macaddr": "36:76:c5:d9:f0:bf"
                 }
         }
}
--------

Above two files are from I-O DATA BSH-G24MB (RTL8382M, 24 ports), which
is WIP device. But there should be no special parts.

Regards,

Hiroshi




More information about the openwrt-devel mailing list