From: Yu Watanabe Date: Mon, 9 Mar 2026 02:30:54 +0000 (+0900) Subject: network: check if gateway is ready only when the nexthop is bound to link X-Git-Tag: v260-rc3~43^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=43989de6427954f0755e2667bda1cf3839d27964;p=thirdparty%2Fsystemd.git network: check if gateway is ready only when the nexthop is bound to link Currently, we support three types of nexthop: 1. simple nexthop, which is bound to link, may have specific gateway address, 2. blackhole nexthop, which is global configuration and is not bound to any links, 3. group nexthop, which is also global configuration and is not bound to any links. Thus, gateway_is_ready() is only necessary to call for simple nexthop case. Let's make the logic simpler. --- diff --git a/src/network/networkd-nexthop.c b/src/network/networkd-nexthop.c index 23941527cfd..81eb85b4a06 100644 --- a/src/network/networkd-nexthop.c +++ b/src/network/networkd-nexthop.c @@ -772,26 +772,38 @@ static bool nexthop_is_ready_to_configure(Link *link, const NextHop *nexthop) { if (!link_is_ready_to_configure(link, false)) return false; + /* Currently, we support the following three types of nexthops: + * 1. Simple nexthop - bound to the link, requires the underlying link is up. + * 2. Blackhole nexthop - not bound to the link. + * 3. Group nexthop - not bound to the link, but all group members must be configured first. + * + * Note, the kernel also supports fdb nexthop, but currently we do not support it. Note, fdb nexthop + * does not require IFF_UP. See rtm_to_nh_config() in net/ipv4/nexthop.c of kernel. */ + + /* Simple nexthop */ if (nexthop_bound_to_link(nexthop)) { assert(nexthop->ifindex == link->ifindex); - /* TODO: fdb nexthop does not require IFF_UP. The conditions below needs to be updated - * when fdb nexthop support is added. See rtm_to_nh_config() in net/ipv4/nexthop.c of - * kernel. */ if (link->set_flags_messages > 0) return false; if (!link_is_up(link)) return false; + + return gateway_is_ready(link, FLAGS_SET(nexthop->flags, RTNH_F_ONLINK), nexthop->family, &nexthop->gw.address); } - /* All group members must be configured first. */ + /* Blackhole nexthop */ + if (nexthop->blackhole) + return true; + + /* Group nexthop */ HASHMAP_FOREACH(nhg, nexthop->group) { r = nexthop_is_ready(link->manager, nhg->id, NULL); if (r <= 0) return r; } - return gateway_is_ready(link, FLAGS_SET(nexthop->flags, RTNH_F_ONLINK), nexthop->family, &nexthop->gw.address); + return true; } static int nexthop_process_request(Request *req, Link *link, NextHop *nexthop) {