MT7628: Switch/VLAN improperly handled?

Device: Cudy TR1200, (custom) 24.10.2

Using wifi-wan, when inserting LAN-cable I see following logmessages:

 Wed Sep 10 08:59:11 2025 user.notice root: LAN CABLE TO BE INSERTED
Wed Sep 10 08:59:22 2025 kern.info kernel: [ 4247.153875] rt3050-esw 10110000.esw: port 0 link up
Wed Sep 10 08:59:22 2025 daemon.notice netifd: Network device 'eth0' link is up
Wed Sep 10 08:59:22 2025 daemon.notice netifd: VLAN 'eth0.1' link is up
Wed Sep 10 08:59:22 2025 daemon.notice netifd: VLAN 'eth0.2' link is up
Wed Sep 10 08:59:22 2025 daemon.notice netifd: Interface 'wan' has link connectivity
Wed Sep 10 08:59:22 2025 daemon.notice netifd: Interface 'wan' is setting up now
Wed Sep 10 08:59:22 2025 kern.info kernel: [ 4247.161113] br-lan: port 1(eth0.1) entered blocking state
Wed Sep 10 08:59:22 2025 kern.info kernel: [ 4247.166704] br-lan: port 1(eth0.1) entered forwarding state
Wed Sep 10 08:59:22 2025 daemon.notice netifd: wan (5540): udhcpc: started, v1.36.1
Wed Sep 10 08:59:22 2025 daemon.notice netifd: wan (5540): udhcpc: broadcasting discover
Wed Sep 10 08:59:25 2025 daemon.notice netifd: wan (5540): udhcpc: broadcasting discover
Wed Sep 10 08:59:28 2025 daemon.notice netifd: wan (5540): udhcpc: broadcasting discover
Wed Sep 10 08:59:33 2025 user.notice root: LAN CABLE TO BE REMOVED
Wed Sep 10 08:59:35 2025 daemon.notice netifd: Network device 'eth0' link is down
Wed Sep 10 08:59:35 2025 kern.info kernel: [ 4260.256595] rt3050-esw 10110000.esw: port 0 link down
Wed Sep 10 08:59:35 2025 kern.info kernel: [ 4260.263548] br-lan: port 1(eth0.1) entered disabled state
Wed Sep 10 08:59:35 2025 daemon.notice netifd: VLAN 'eth0.1' link is down
Wed Sep 10 08:59:35 2025 daemon.notice netifd: VLAN 'eth0.2' link is down
Wed Sep 10 08:59:35 2025 daemon.notice netifd: Interface 'wan' has link connectivity loss
Wed Sep 10 08:59:35 2025 daemon.notice netifd: wan (5540): udhcpc: received SIGTERM
Wed Sep 10 08:59:35 2025 daemon.notice netifd: wan (5540): udhcpc: entering released state
Wed Sep 10 08:59:35 2025 daemon.notice netifd: wan (5540): Command failed: ubus call network.interface notify_proto { "action": 0, "link-up": false, "keep": false, "interf
Wed Sep 10 08:59:35 2025 daemon.notice netifd: Interface 'wan' is now down
~

Is it to be expected, that wan is activated, when LAN-cable inserted ?

/etc/conf/network:

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

config device
        option name 'br-lan'
        option type 'bridge'
        list ports 'eth0.1'

config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        option ipaddr '192.168.10.1'
        option netmask '255.255.255.0'

config interface 'wan'
        option device 'eth0.2'
        option proto 'dhcp'
        option metric '0'

config switch
        option name 'switch0'
        option reset '1'
        option enable_vlan '1'

config switch_vlan
        option device 'switch0'
        option vlan '1'
        option ports '0 6t'

config switch_vlan
        option device 'switch0'
        option vlan '2'
        option ports '1 6t'

config device
        option name 'br-nop'
        option type 'bridge'
        option bridge_empty '1'
        list ports 'phy1-ap1'

config interface 'nop'
        option device 'br-nop'
        option proto 'static'
        option ipaddr '192.168.11.1'
        option netmask '255.255.255.0'

config interface 'tetherwan'
        option device 'usb0'
        option proto 'dhcp'
        option metric '20'

config interface 'wifiwan'
        option proto 'dhcp'
        option metric '10'

/etc/board.json:

{
        "model": {
                "id": "cudy,tr1200-v1",
                "name": "Cudy TR1200 v1"
        },
        "switch": {
                "switch0": {
                        "enable": true,
                        "reset": true,
                        "ports": [
                                {
                                        "num": 0,
                                        "role": "lan"
                                },
                                {
                                        "num": 1,
                                        "role": "wan"
                                },
                                {
                                        "num": 6,
                                        "device": "eth0",
                                        "need_tag": false,
                                        "want_untag": false
                                }
                        ],
                        "roles": [
                                {
                                        "role": "lan",
                                        "ports": "0 6t",
                                        "device": "eth0.1"
                                },
                                {
                                        "role": "wan",
                                        "ports": "1 6t",
                                        "device": "eth0.2"
                                }
                        ]
                }
        },
        "network": {
                "lan": {
                        "device": "eth0.1",
                        "protocol": "static"
                },
                "wan": {
                        "device": "eth0.2",
                        "protocol": "dhcp"
                }
        },
        "wlan": {
                "phy0": {
                        "path": "platform/10300000.wmac",
                        "info": {
                                "antenna_rx": 3,
                                "antenna_tx": 3,
                                "bands": {
                                        "2G": {
                                                "ht": true,
                                                "max_width": 40,
                                                "modes": [
                                                        "NOHT",
                                                        "HT20",
                                                        "HT40"
                                                ],
                                                "default_channel": 1
                                        }
                                },
                                "radios": [
                                ]
                        }
                },
                "phy1": {
                        "path": "pci0000:00/0000:00:00.0/0000:01:00.0",
                        "info": {
                                "antenna_rx": 3,
                                "antenna_tx": 3,
                                "bands": {
                                        "5G": {
                                                "ht": true,
                                                "vht": true,
                                                "max_width": 160,
                                                "modes": [
                                                        "NOHT",
                                                        "HT20",
                                                        "VHT20",
                                                        "HT40",
                                                        "VHT40",
                                                        "VHT80",
                                                        "VHT160"
                                                ],
                                                "default_channel": 36
                                        }
                                },
                                "radios": [
                                ]
                        }
                }
        }
}

Set “reset” to zero.

config switch
option name 'switch0'
option reset '0'
option enable_vlan '1'

does not make any difference. wan still starting, when LAN cable inserted.

LAN/WAN leaking ?

Your device uses swconfig for the switch. This means that there is just the single network interface eth0 for the entire switch (unlike devices with a more modern DSA switch driver, where each port has its own interface). And this network interface is up, whenever any of the switch ports has a link. So this seems like normal behaviour to me (although it has been a while since I have used a device using swconfig myself).

3 Likes

Interesting.

But swconfig correctly displays the port states, when only LAN cable attached (active client):

cat /tmp/swconfig.out
Global attributes:
enable_vlan: 1
alternate_vlan_disable: 0
bc_storm_protect: 0
led_frequency: 0
Port 0:
disable: 0
doubletag: 0
untag: 1
led: 5
lan: 1
recv_bad: 0
recv_good: 128
tr_bad: 0
tr_good: 111
pvid: 1
link: port:0 link:up speed:100baseT full-duplex
Port 1:
disable: 0
doubletag: 0
untag: 1
led: 5
lan: 0
recv_bad: 0
recv_good: 0
tr_bad: 0
tr_good: 0
pvid: 2
link: port:1 link:down
Port 2:
disable: 1
doubletag: 0
untag: 0
led: 5
lan: 1
recv_bad: 0
recv_good: 0
tr_bad: 0
tr_good: 0
pvid: 0
link: port:2 link:down
Port 3:
disable: 1
doubletag: 0
untag: 0
led: 5
lan: 1
recv_bad: 0
recv_good: 0
tr_bad: 0
tr_good: 0
pvid: 0
link: port:3 link:down
Port 4:
disable: 1
doubletag: 0
untag: 0
led: 5
lan: 1
recv_bad: 0
recv_good: 0
tr_bad: 0
tr_good: 0
pvid: 0
link: port:4 link:down
Port 5:
disable: 1
doubletag: 0
untag: 0
led: ???
lan: 1
recv_bad: 0
recv_good: 0
tr_bad: 0
tr_good: 0
pvid: 0
link: port:5 link:down
Port 6:
disable: 0
doubletag: 0
untag: 0
led: ???
lan: ???
recv_bad: ???
recv_good: ???
tr_bad: ???
tr_good: ???
pvid: 0
link: port:6 link:up speed:1000baseT full-duplex
VLAN 1:
ports: 0 6t
VLAN 2:
ports: 1 6t

But netifd wants to bring up wan (port 1), after attaching LAN cable.

Ref. to logs above.

Looks like a bug to me (old one ?), and NOT a feature.

Of course this is not a desirable behaviour, but I think it is just one of the limitations of swconfig, which comes from a time when the upstream Linux kernel didn't have any support for switches.

I guess you can think of swconfig like having a separate managed switch which is connected to the router via a trunk port. And the networking subsystem of the kernel just sees the trunk port, but not the individual switch ports.

Someone has worked on a DSA driver for this hardware a few years ago: https://github.com/stroese/linux/blob/gardena-v5.5/drivers/net/dsa/mt7628-esw.c

I'm not sure about the state of that driver. But maybe it could be useful if someone wants to work on moving this device to DSA.

1 Like

Sorry, I do not understand.

Fact is, swconfig is able to detect and display the real scenario.

And obviously, the higher level, more modern stuff, like netifd etc. can not do the same.

Although the MT7628 is a supported, not so exotic SoC, you might argue, that such (an old ?) bug not likely to be taken care of. But to mask it as a feature, is a very special approach.

I'm not trying to claim this is a feature. It is a limitation of the legacy swconfig architecture.

The fix is to switch this hardware to DSA (the framework for switch drivers in upstream Linux). But for that to happen someone has to write a driver (or finish/improve the one I linked earlier).

4 Likes

You must not mix up logical and physical interfaces. The only physical interface that the CPU has is eth0. Regardless of how many or few VLANs you have configured on eth0, they will all go “up” once the physical port is up, and “down” once the physical port is down - “up” or “down” is a physical state, not a logical one!

It’s no different from your PC - your PC’s NIC also won’t know which other port on the switch it’s connected to goes “up” or “down”. And your PC will also see all VLANs as “up” if its NIC is connected - even if the VLANs in question don’t even exist on the switch! Just be happy that your MT7628 device is at least wired in a way that the “down” state gets propagated to the CPU once all external ports are down…

There are swconfig-based devices with multiple physical interfaces in their SoC - on these, you will actually see the wan logical i/f go “up” or “down” separately from the lan logical i/f - if and only if one of the CPU’s physical i/f is wired directly to the external WAN port. Most 100M-based QCA95xx devices are wired that way. So if you replace your MT7628 device with one based on QCA9533 (or its predecessors), you should get what you expect.

DSA on the other hand “virtualizes” the hardware for you - you only see in software what you see on the outside of your device, regardless of how it’s implemented in hardware. Ie. you don’t have to know its internals anymore. DSA (or rather: the developer who implemented DSA support for your device) “translates” everything behind your back. With DSA, you’ll also get what you expect, even if it’s just "fake”, just programmatically implemented. DSA has its own problems, e.g. what’s not there in hardware will get emulated in software without you knowing, potentially causing major performance regressions. But that’s another story.

1 Like

Physical state is LOWER_UP. Up/Down is "administrative state"