Hi. What is the best way to determine on a running device (CLI command) whether or not it has network switch ports? I think I'm looking for the equivalent of determining whether or not the device's web UI will show a "Network > Switch" page for configuring VLANs and tags.
I have an x86/64 machine with multiple Ethernet ports (eth0-eth3) that does not have such a section in its UI
The Netgear WAC124 (ramips/mt7621) reports a single eth0, and also does not have those switch ports
The TP-Link Archer (ath79/generic) and Asus RT-N66U (bcm47xx/mips74k, albeit no WiFi) both report a single eth0, and do have a "Network > Switch" section in the web UI.
The closest thing I've found so far is that the Archer has a "uci show network.@switch" available (e.g., a switch in /etc/config/network), but I was wondering if there was something more robust I could use, like something I could inspect in /proc or something like that.
If you have the old switch menu in Luci (from 21.02) depends more if your device have DSA implemented or not. It doesn’t have much to do if you have a switch or not.
DSA = no switch menu.
Swconfig = switch menu
I see. So at some point when all devices have DSA support, I believe you are implying there will be no switch menu at all on any device.
What am I looking for under /sys/class/net to determine whether or not the device is swconfig vs. DSA?
I should have stated my goal. I have a script to configure my devices via UCI (I copy script to device, then run the script on the device). Configuring VLANs may or may not involve network switch configuration.
The best I have come up with so far is to query network.@switch to see if the device initially had one or not, but that feels a little fragile to me, so I would prefer to query something more intrinsic to the kernel or the OpenWrt image or something like that, that would be robust to a misconfiguration on my part.
No, it's an ath79 device and ath79 hasn't been ported to DSA yet (AFAIK just a few ath79 devices support DSA on OpenWrt at this point).
@CaptainBegin Swconfig and DSA are mutually exclusive AFAIK, and you're looking at kernel level changes, ie device drivers to talk to the switch fabric. So you cannot have both an you can't just swap them in and out at will. On how to find out if your device is using DSA and not swconfig, see this topic:
Thank you very much, this is the kind of thing I am looking for. But now I am still confused. Exactly one of swconfig or DSA must be present, or is there a third? On an x86/64 machine (4 NICs, but only eth0 has VLANs on it):
# uname -a
Linux gateway 5.4.154 #0 SMP Sun Oct 24 09:01:35 2021 x86_64 GNU/Linux
# cat /etc/openwrt_release
DISTRIB_DESCRIPTION='OpenWrt 21.02.1 r16325-88151b8303'
# grep DEVTYPE /sys/class/net/*/uevent
So neither DEVTYPE=dsa is present, nor is the swconfig tool ...
Like I said earlier, x86/x86_64 systems have separate NICs 99% of the time. Swconfig and DSA are both frameworks designed to allow you to manipulate single ports of a switch as if they were a separate interface, that does not apply when you are dealing with separate NICs already.