[netifd] restarting hardware interfaces from cli not implemented?

  • Master
  • netifd 2019-11-20

Whilst ifup | ifdown works with virtual interfaces it fails with hardware interfaces however, e.g. ifdown eth2 producing:

Interface eth2 not found

As far as my understanding goes OpenWrt interprets/distinguish hardware interfaces as network.device whilst virtual interfaces as network.interface.

Perusing the netifd source code it would seem being heavily integrated with (depended on) ubus.

Calling ubus list however does not produce any network.device but various network.interface only - all of which being virtual interfaces.

Moreover, the source code [1] for the ifupdown action only calls

ubus_send_event(ubus_ctx, "network.interface", b.head);

It would seem strange that ifupdown action for hardware interfaces (devices) is not working by design.


[1] https://git.openwrt.org/?p=project/netifd.git;a=blob;f=ubus.c;hb=70b50118c7b063fab5c1383f12e6e92ca0fc82c3#l1263

Don't ip link set eth2 down and ip link set eth2 up work?

1 Like

Those ip commands do work but they are not part of netifd that provides the ifupdown routine. ip does not integrate with /etc/config/network

I don't understand the problem. The ip command is part of the cli anyway.

  1. as Linux user I would expect that the ifupdown routine works for any interface and not just virtual interfaces - why to curtail such common routine and being inconsistent by providing it for virtual interfaces but not hardware interfaces?
  2. ip does not take into account any (changed) interface settings specified in /etc/config/network

The ifdown and ifup commands in OpenWrt refer to logical interfaces as defined in /etc/config/network. They might or might not cause the shutdown of the underlying Linux network device. This is by design. An ifdown eth0 never was a valid use of OpenWrt's ifdown command (unless there happens to be a config interface eth0 in /etc/config/network).

If you want to alter the hardware state beneath netifd, using commands such ip or ifconfig are the way to go.

1 Like

Pardon but I am not sure about the semantics of logical

logical = alias name of a PHY a/o = virtual?


Rather strange (imho), afaik being the sole Linux distro to curtail the ifupdown routine in such inconsistent way. And it is rather inefficient when changing

config device
	option ifname ''

it requires a full network restart rather than a simple ifupdown call for the particular netdev since

do not parse /etc/config/network


That does not seem to work with

config device
	option ifname 'lan0'
	option mtu '1600'

ifdown lan0 && ifup lan0 still producing

Interface lan0 not found
Interface lan0 not found

OpenWrt netifd operates on logical interfaces such as lan, wan etc. which relate to one or more network devices. Neither ifup/ifdown nor the uci configuration directly operate on Linux netdevs such as eth0, br-lan etc.

OpenWrt's ifupdown routine happens to have the same name as ifup and ifdown on other distros, apart from that it neither shares the semantics, nor the design goals of these tools.

No it does not. An ubus call network reload should be enough to apply all updated settings, leaving unchanged things alone.

As explained above, ifup and ifdown solely operate on logical interfaces declared in config interface sections, such as wan, lan, loopback. To apply any other changes in the network config (such as config rule, config route, config device etc.) use ubus call network reload.

1 Like

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