Files
Joachim Wiberg 221fea13a2 netd: watch conf.d with inotify, retry on backend failure
Two races could prevent DHCP-learned default routes from being installed
at boot:

1. The signal from the DHCP client script could be lost leaving conf.d
   updated but frr.conf stale.

2. Even when the signal was received, 'vtysh -b' could fail because the
   FRR daemon chain (mgmtd→zebra→staticd) writes PID files before being
   fully operational, causing netd to give up with no retry.

Fix both by refactoring netd to use libev:

- Use an inotify watch of CONF_DIR, so netd reacts directly to file
  changes without depending on signal delivery.

- On backend_apply() failure, schedule a retry in 5s and call pidfile()
  unconditionally so dependent services are not blocked waiting for the
  Finit condition 'pid/netd' to be satisfied.

We also take this opportunity to rename /etc/netd/conf.d/ to /etc/net.d/
The extra /etc/netd/ directory level served no purpose — nothing else
lives there.  Flatten to /etc/net.d/ which reads more naturally as the
drop-in directory for network configuration snippets.

Also, reduce logging a bit since each netd backend already logs success
or fail which is sufficient to know that a configuration change has been
applied or not.

Finally, with the new inotify processing in netd it's redundant to call
'initctl reload netd' from the udhcpc script, in fact it will only cause
unnecessary overhead, so we drop it.

Fixes #1438

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2026-03-12 12:07:49 +01:00

61 lines
1.6 KiB
Plaintext

config BR2_PACKAGE_NETD
bool "netd"
select BR2_PACKAGE_LIBITE
select BR2_PACKAGE_LIBCONFUSE
select BR2_PACKAGE_LIBEV
help
Network route daemon. Manages static routes and RIP routing.
Reads configuration from /etc/net.d/*.conf.
With FRR: Full routing via gRPC, vtysh, or frr.conf.
Without FRR: Standalone Linux backend via rtnetlink.
https://github.com/kernelkit/infix
if BR2_PACKAGE_NETD
choice
prompt "FRR backend"
default BR2_PACKAGE_NETD_FRR_VTYSH if BR2_PACKAGE_FRR
default BR2_PACKAGE_NETD_LINUX
config BR2_PACKAGE_NETD_FRR_VTYSH
bool "FRR vtysh"
depends on BR2_PACKAGE_FRR
help
Enable FRR integration via vtysh -b.
netd generates incremental config diffs and applies
them to running FRR daemons via vtysh -b.
FRR daemons run as standalone finit services (no watchfrr).
Provides static routes and RIP support.
config BR2_PACKAGE_NETD_FRR_CONF
bool "FRR frr.conf"
depends on BR2_PACKAGE_FRR
help
Enable FRR integration via frr.conf file generation.
netd assembles a single /etc/frr/frr.conf from routing
config and signals FRR to reload via frrinit.sh/watchfrr.
Provides full routing support (static routes, RIP, OSPF).
config BR2_PACKAGE_NETD_FRR_GRPC
bool "FRR gRPC"
depends on BR2_PACKAGE_FRR
select BR2_PACKAGE_FRR_GRPC
select BR2_PACKAGE_HOST_PROTOBUF
help
Enable FRR integration via gRPC northbound API.
Provides full routing support (static routes, RIP, OSPF).
config BR2_PACKAGE_NETD_LINUX
bool "Linux kernel"
help
Use Linux kernel backend (rtnetlink) with static routes
only. No FRR dependency.
endchoice
endif