Swconfig logs and status

Hello everyone,
My device is having 3 ports in switch call switch0.
by cmd:swconfig dev switch0 show i get status of all ports and vlan. But i can not find logs of port plug/unplug or up/down in dmesg/logread. I am not able to find the wired connected clients in my router.
swconfig list :Found: switch0 - ag71xx-mdio.0

dmsg logs :

[    0.763282] switch0: Atheros AR8337 rev. 2 switch registered on ag71xx-mdio.0
[    1.456959] libphy: ag71xx_mdio: probed
[    2.083040] ag71xx ag71xx.0: connected to PHY at ag71xx-mdio.0:00 [uid=004dd036, driver=Atheros AR8216/AR8236/AR8316]
[    2.094515] eth0: Atheros AG71xx at 0xb9000000, irq 4, mode:SGMII

is there any way to catch event of port ??

Would ubus be of any use? I just tried ubus -v listen network.interface and saw { "network.interface": {"action":"ifup","interface":"wan"} }

Nope, switch port state changes are not propagated to userspace.

1 Like

wan interface is layer 3 interface which goes up and down based on wan protocols.i want the events of physical interface plug/unplug events.
e.g. Port 3:link up or Port 3:link down in logs or dmesg.

Depending on how fast you need a change identified, and how much CPU you're willing to put into it, you could poll the switch

jeff@office:~$ swconfig dev switch0 port 2 get link
port:2 link:down

to get this status i need to fire the get link cmd.event generation helps to create action like connected wired clients.Atleast to get mac address at the time.Like hostapd_cli which passes instant connected or disconnected status.

The switch chips generally don't "push" changes back through the driver.

Edit: The MAC addresses are available through swconfig as well. You may need to "play games" with tracking it as Ethernet doesn't / can't distinguish between clients on the physical wire and those that may be on the same link by virtue of additional switches and/or hubs.

is there any way to get details by changing driver?

What are you trying to accomplish?

As I think about this, with your OpenWrt-managed switch chip connected to a downstream switch, you can't "see" link-state changes of clients that connect through that switch.

Yes sir, that is absolutely not possible.But i want to get clients which are connected to port directly.e.g Desktop,laptop,1 to 1 link devices.clients can be in bridge mode(e.g. on external dhcp server) or in NAT mode.

i have found below logs of dmesg,

[ 22.850000] br-lan: port 1(eth0.1) entered forwarding state
[ 48.850000] Atheros AR8216/AR8236/AR8316 ag71xx-mdio.0:00: Port 3 is down
[ 52.850000] Atheros AR8216/AR8236/AR8316 ag71xx-mdio.0:00: Port 2 is up