OpenWrt 21.02.1 AR300M -- how to poll physical port status

I want to check a physical ethernet port status on GL-Inet AR300M flashed with 21.02.1 and all the methods I’ve tried report that eth0 always has carrier even when nothing is plugged in:

  1. ethtool eth0 says Link detected: yes
  2. /sys/class/net/eth0/carrier is always 1
  3. ip link show never says NO-CARRIER for eth0
  4. ubus call network.device status '{ "name": "eth0" }' always reports "carrier": true,
  5. swconfig dev switch0 port 0 get link always reports port:0 link:up

Full disclosure I’ve merged both ports into LAN and deleted WAN:

# cat /etc/config/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'
	list ports 'eth1'

config interface 'lan'
	option device 'br-lan'
	option proto 'static'
	option netmask '255.255.255.0'
	option ipaddr '192.168.226.1'
	option ipv6 '0'

@alzhao any ideas on how I can get an actual status of eth0 on this router on 21.02?

one thing need to check is, one of eth0 and eth1 is Ethernet switch. In our stock firmware eth1 is the switch.

But if eth0 is the swtich, ethtool does not work. You need to use swconfig.

Can you show the full output of swconfig dev switch0 show ?

port 0 is connected to CPU. It is always up.

You need to find out what switch port the physical port is connected to.

@alzhao thanks for your prompt reply. By default there’s no switch configured on OpenWrt 21.02.1:

root@ar300m:~# cat /etc/config/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'
	list ports 'eth1'

config interface 'lan'
	option device 'br-lan'
	option proto 'static'
	option netmask '255.255.255.0'
	option ipaddr '192.168.226.1'
	option ipv6 '0'

Here’s the command you requested with cable plugged into LAN port:

root@ar300m:~# swconfig dev switch0 show
Global attributes:
	enable_vlan: 0
	ar8xxx_mib_poll_interval: 500
	ar8xxx_mib_type: 0
	enable_mirror_rx: 0
	enable_mirror_tx: 0
	mirror_monitor_port: 0
	mirror_source_port: 0
	arl_table: address resolution table
Port 0: MAC 94:83:c4:0e:d7:d1
Port 1: MAC 00:25:00:ed:20:6b

Port 0:
	mib: MIB counters
RxGoodByte  : 343980 (335.9 KiB)
TxByte      : 454574 (443.9 KiB)

	pvid: 0
	link: port:0 link:up speed:1000baseT full-duplex txflow rxflow
Port 1:
	mib: MIB counters
RxGoodByte  : 454540 (443.8 KiB)
TxByte      : 344166 (336.0 KiB)

	pvid: 0
	link: port:1 link:up speed:100baseT full-duplex auto
Port 2:
	mib: No MIB data
	pvid: 0
	link: port:2 link:down
Port 3:
	mib: No MIB data
	pvid: 0
	link: port:3 link:down
Port 4:
	mib: No MIB data
	pvid: 0
	link: port:4 link:down

Here’s the command you requested with cable plugged into WAN port:

root@ar300m:~# swconfig dev switch0 show
Global attributes:
	enable_vlan: 0
	ar8xxx_mib_poll_interval: 500
	ar8xxx_mib_type: 0
	enable_mirror_rx: 0
	enable_mirror_tx: 0
	mirror_monitor_port: 0
	mirror_source_port: 0
	arl_table: address resolution table
Port 0: MAC 00:25:00:ed:20:6b
Port 0: MAC 94:83:c4:0e:d7:d1

Port 0:
	mib: MIB counters
RxGoodByte  : 350022 (341.8 KiB)
TxByte      : 456936 (446.2 KiB)

	pvid: 0
	link: port:0 link:up speed:1000baseT full-duplex txflow rxflow
Port 1:
	mib: MIB counters
RxGoodByte  : 456552 (445.8 KiB)
TxByte      : 347224 (339.0 KiB)

	pvid: 0
	link: port:1 link:down
Port 2:
	mib: No MIB data
	pvid: 0
	link: port:2 link:down
Port 3:
	mib: No MIB data
	pvid: 0
	link: port:3 link:down
Port 4:
	mib: No MIB data
	pvid: 0
	link: port:4 link:down

As you can see when cable is plugged into WAN, I get the following output from swconfig:

Port 0: MAC 00:25:00:ed:20:6b
Port 0: MAC 94:83:c4:0e:d7:d1

Is the switch configuration section missing from the network config on this device in OpenWrt 21.02.1? How is switch configured with your own firmware?

I think this is very clear.

LAN port: eth0 is swtich and you need to check if the cable connected on port 1.

WAN port is eth1 is not switch, you need to use ethtool to check if cable connected.

1 Like