Fix the issues the Copilot review found in the code moved from the
routing feed:
- The init script wrote "option ignore '0'" of an interface section as
"interface <dev> ignore false" into the babeld configuration, which
babeld rejects. Skip the option like ifname.
- The handlers of get_xroutes, get_routes and get_neighbours didn't
check their allocations. Free the collected entries and return an
error instead of crashing.
- add_filter allocated and returned success for an invalid filter type
and leaked the filter. Reject the type before the allocation, and
handle a failure of strdup() and add_filter().
- babeld doesn't use uloop, so the default handler of libubus did
nothing when ubusd restarted. The stale socket stayed readable and
babeld spun in its select loop, and the babeld object was never
added again. Reconnect from the main loop instead, waiting longer
after each failed attempt, up to 32 seconds. ubus_reconnect() adds
the object again.
- The notifications used the helpers for array elements, so their
fields were in an unnamed table. Put them at the root of the message.
- Neighbour notifications were named neigh.*, while ubus.h documents
neighbour.*. Use the documented names.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Nick Hainke <vincent@systemli.org>
The metric is optional in filter_policy: only ifname and type are
rejected when missing, so `ubus call babeld add_filter
'{"ifname":"eth0","type":0}'` reaches
filter->action.add_metric = metric;
with metric never assigned, i.e. whatever was left on the stack. In
babeld an add_metric of INFINITY means "deny", so an uninitialized
read can silently turn an allow filter into a deny filter.
Initialize it to 0, which is the neutral value the filter would have
had if the caller had passed it explicitly.
Reported-by: openwrt-ai[bot]
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Babel is a loop-avoiding distance-vector routing protocol for
IPv6 and IPv4 with fast convergence properties (RFC 8966).
Moved from the openwrt/routing feed, as discussed in
https://github.com/openwrt/routing/issues/184.
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
[fix the default conf_dir in babeld.config and the indentation of the
lines 600-add-ubus.patch adds to local.c, as suggested in the review]
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Nick Hainke <vincent@systemli.org>