Questions about UCI network config vs. iproute2 output, and network concepts in general

I'll flag up front that I have always struggled with networking configuration and topology, so please be patient if I confuse even fundamental concepts. I have read through OpenWrt's basic network guide, and understand that there is a difference between logical interfaces eg. wwan and physical interfaces eg. eth0.1.

So I fired up a Vocore2 (MT7628 based with 802.11n wireless and 100Mbps ethernet plus USB GSM modem support), built and flashed a 18.06.5 image with a few extra utilities, and tried to understand how it all fits together.

Firstly, with uci show network I can see the logical and physical interfaces. I've trimmed out a lot of lines here, just to show the interfaces:

network.loopback=interface
network.loopback.ifname='lo'
network.lan=interface
network.lan.ifname='eth0.1'
network.lan_dev=device
network.lan_dev.name='eth0.1'
network.lan_dev.macaddr='b8:d8:12:65:e4:a1'
network.wan=interface
network.wan.ifname='eth0.2'
network.wwan=interface
network.wwan.ifname='apcli0'

So I have logical interface lan which uses physical interface eth0.1, and logical interface wwan which uses physical interface apcli0, and so on.

So then I run ip link show to see the status of various interfaces, and get:

root@OpenWrt:/# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN qlen 1000
    link/ether b8:d8:12:65:e4:a1 brd ff:ff:ff:ff:ff:ff
3: ra0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br-lan state UNKNOWN qlen 1000
    link/ether b8:d8:12:65:e4:a0 brd ff:ff:ff:ff:ff:ff
4: wwan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 1e:b2:e7:ec:c3:26 brd ff:ff:ff:ff:ff:ff
5: br-lan: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
    link/ether b8:d8:12:65:e4:a1 brd ff:ff:ff:ff:ff:ff
6: eth0.1@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-lan state UP qlen 1000
    link/ether b8:d8:12:65:e4:a1 brd ff:ff:ff:ff:ff:ff
7: eth0.2@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
    link/ether b8:d8:12:65:e4:a1 brd ff:ff:ff:ff:ff:ff
8: apcli0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN qlen 1000
    link/ether ba:d8:12:05:e4:a0 brd ff:ff:ff:ff:ff:ff
9: apcli1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether ba:d8:12:05:e4:a1 brd ff:ff:ff:ff:ff:ff
10: mon0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether b8:d8:12:65:e4:a0 brd ff:ff:ff:ff:ff:ff

I recognise wwan0 and apcli0 from the UCI output. ra0 is managed elsewhere I think (wireless config?). But...

  • Where did br-lan come from? Where is it configured?
  • Why is there both a eth0.1@eth0 and a eth0?
  • Is there a way to identify what device (eg. kernel module, PCI address, USB address) is associated with what physical interface?

More generally:

  • I can read (and have done) plenty of material on Linux networking in general, but it's hard to tell how much of it applies to OpenWrt. Can anyone recommend any other resources that apply to OpenWrt, or even if they don't specifically apply to OpenWrt, would not be so vastly different that they lead me astray?
1 Like

See also:

brctl show

The upper abstraction layer is typically an L3 device built upon L2 devices:

  • eth0.1 is built upon eth0 using VLAN.
  • br-lan is built upon eth0.1 using bridging.
  • wwan0 is likely an abstraction above apcli0.

See also: Linux Network Interfaces

ls -l /sys/class/net /sys/class/net/*/device/driver

OpenWrt Networking

3 Likes

Thank you @vgaetera, this is extremely useful! I also found this little primer on terminology: Clarifying the term "Interface" which goes through the difference between interface, ifname etc.

1 Like

Two more questions after reading those resources:

Say I have this in my /etc/config/wireless:

config wifi-device 'ra0'
	option type 'ralink'
	option variant 'mt7628'
[... cut out a bunch of options]
config wifi-iface 'ap'
	option device 'ra0'
	option mode 'ap'
	option network 'lan'
	option ifname 'ra0'

Do I understand correctly that the ra0 that's the name of the wifi device, and the ra0 that's the ifname of the wifi-iface labelled ap are actually referring to different things? That is, the first ra0 refers to a device that can (potentially) be used by other wifi-iface sections, but the second ra0 is a higher level name that can be used by eg. sections in /etc/network/config?

(I would test this hypothesis by changing them to be different, but see next question.)

Second question: brctl show does indeed show me a bridge joining eth0.1 and ra0:

bridge name	bridge id		STP enabled	interfaces
br-lan		7fff.b8d81265e4a1	no		eth0.1
							            ra0

But where is this configured? I assume I can change it in the buildroot, but what about at runtime? I can't find anything in /etc/config/ that contains this link. There is this:

config interface 'lan'
	option type 'bridge'
	option ifname 'eth0.1'
	option proto 'static'
	option ipaddr '192.168.61.1'
	option netmask '255.255.255.0'
	option ip6assign '60'

...but there is no mention of ra0 being the other part of the bridge.

Yep, the device option should match the wifi-device section name, but the ifname of the wifi-iface section is optional and can be dynamic.

However, the option network of the wifi-iface section is listed as compulsory and should answer your second question:

I'm not seeing it. Note that this device (under 18.06.5 anyway) can only operate as a simultaneous access point and station. But /etc/config/wireless has:

config wifi-device 'ra0'
	option type 'ralink'
	option variant 'mt7628'
	option country 'CN'
	option hwmode '11g'
	option htmode 'HT40'
	option channel 'auto'
	option disabled '0'

config wifi-iface 'ap'
	option device 'ra0'
	option mode 'ap'
	option network 'lan'
	option ifname 'ra0'
	option encryption 'none'
	option ssid 'VoCore2-e4a0'

config wifi-iface 'sta'
	option device 'ra0'
	option mode 'sta'
	option network 'wwan'
	option ifname 'apcli0'
	option encryption 'psk2'
	option disabled '1'
        option ssid 'MySSID'
        option key 'secret'

Wait, wait. If I look at wifi interface ap I see it refers to network lan. In /etc/config/network I have:

config interface 'lan'
	option type 'bridge'
	option ifname 'eth0.1'
	option proto 'static'
	option ipaddr '192.168.61.1'
	option netmask '255.255.255.0'
	option ip6assign '60'

Is that what I'm looking for re. br-lan?

And do I interpret this as: the wifi interface labelled ap in the config uses device ra0 and is (coincidentally) given the name ra0. It is connected to the network named lan which is a bridge. eth0.1 is a VLAN (per 802.1Q) using device eth0 and is also connected to the bridge lan.

1 Like

That's correct.

Thanks, this has been extremely illuminating. I'll add one more thing for anyone else with the question I had earlier:

Is there a way to identify what device (eg. kernel module, PCI address, USB address) is associated with what physical interface?

There is also a nifty tool called ethtool - it's not installed by default, but if you're building images or packages you can select it. It provides output for any interface including virtual interfaces like this:

# ethtool -i eth0
driver: mtk_soc_eth
version: 0.1.2
firmware-version: 
expansion-rom-version: 
bus-info: 10100000.ethernet
supports-statistics: no
supports-test: no
supports-eeprom-access: no
supports-register-dump: no
supports-priv-flags: no

# ethtool -i br-lan
driver: bridge
version: 2.3
firmware-version: N/A
expansion-rom-version: 
bus-info: N/A
supports-statistics: no
supports-test: no
supports-eeprom-access: no
supports-register-dump: no
supports-priv-flags: no

# ethtool -i ra0
driver: RALINK WLAN
version: 
firmware-version: 
expansion-rom-version: 
bus-info: CSR 0xb0300000
supports-statistics: no
supports-test: no
supports-eeprom-access: no
supports-register-dump: no
supports-priv-flags: no
1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.