Support for RTL838x based managed switches

Thanks for the information. My concern was that with this patch the driver doesn't behave like other DSA drivers (and the general DSA documentation), where you can use the interfaces for each port separately if you like, and that this might ultimately make configuration more difficult (and device-specific).

Without it, the forwarding depends on the MAC and a station ID and while this is the default hardware behaviour, it is neither documented how it works nor is it the default software configuration of these switches with the OEM software.

The default behaviour here sounds like the expected default DSA behaviour (assuming that the "station ID" identifies the physical port?). If the OEM behaviour is desired, can't that be achieved through the configuration interface, rather than as a default setup in the driver?

I don't think it's that concerning that the OEM software is always configured like this, because it was presumably only designed to do normal switch things, whereas with openwrt it seems really useful to be able to use each port separately if we want.

Anyway, sorry if this has already been discussed... to answer your question:

This VLAN 1 is probably set up too late for the failsafe mode.
Could you investigate to which point the VLANs are configured already at the time the failsafe starts and what the bridge configuration fixes?

By default the failsafe / preinit network configuration just does something like this (repeating myself slightly to make it clearer):

ip link set dev $ifname up
ip -4 address add 192.168.1.1/24 broadcast 192.168.1.255 dev $ifname

On other DSA targets, it's something like this:

ip link set dev eth0 up
ip link set dev lan1 up
ip -4 address add 192.168.1.1/24 broadcast 192.168.1.255 dev lan1

With my script above, that turns into:

ip link set eth0 up
brctl addbr lan
brctl addif lan lan1
ip link set lan1 up
ip link set dev lan up
ip -4 address add 192.168.1.1/24 broadcast 192.168.1.255 dev lan

It knows how to configure vlans by adding a vlan interface on top of the specified interface, but this also doesn't seem to work. The code is here if you're interested. I'll have a poke around to try to find out why the bridge makes it work.