[PATCH] base-files: simplify setting device MAC

Rafał Miłecki zajec5 at gmail.com
Mon May 31 22:04:48 PDT 2021

On 28.05.2021 20:18, Evgeny K wrote:
>> 3. Drop section name
>>     It's not required by netifd or LuCI & it's not needed by this script
>>     as $device contains a single device name now.
> It could be convenient to have it, though. In the former scheme of
> things, if one would like to know the interface behind, say, lan it
> was possible to do with just 'uci -q get network.lan.ifname`. Now it
> has become pretty complicated. Adding a name to the device section
> would allow one to at least do it in 2 steps: `uci -q get
> network.lan.device` and `uci -q get network.$device.ports`.

There was never a direct mapping between "config device" UCI section
name and its "option name" value. See this example from bcm53xx:

config device 'wan_eth0_1_dev'
	option name 'eth0.1'
	option macaddr '00:11:22:33:44:55'

It was actually impossible due to limitations of UCI section names (they
can't contain any characters as options can).

So yes, you need to search all "config device" looking for the one with
the proper name.

I suggest you using netifd's ubus objects.

ubus call network.device status '{ "name": "br-lan" }'

Ideally you should be able to use jsonfilter too but I don't know how to
deal with "-" in a property name. Following doesn't work for me:

ubus call network.device status '{ "name": "br-lan" }' | jsonfilter -e "$.bridge-members"

More information about the openwrt-devel mailing list