From: Yu Watanabe Date: Thu, 4 Jan 2024 19:58:37 +0000 (+0900) Subject: network/nexthop: wait for requests for group members being processed X-Git-Tag: v256-rc1~1258^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ccc55b5ec5ac15cb961e919ad5b48184f835821c;p=thirdparty%2Fsystemd.git network/nexthop: wait for requests for group members being processed This also split out the check as nexthop_is_ready(). --- diff --git a/src/network/networkd-nexthop.c b/src/network/networkd-nexthop.c index 086f246c965..8c963f03a32 100644 --- a/src/network/networkd-nexthop.c +++ b/src/network/networkd-nexthop.c @@ -552,8 +552,38 @@ static int static_nexthop_handler(sd_netlink *rtnl, sd_netlink_message *m, Reque return 1; } +int nexthop_is_ready(Manager *manager, uint32_t id, NextHop **ret) { + NextHop *nexthop; + + assert(manager); + + if (id == 0) + return -EINVAL; + + if (nexthop_get_request_by_id(manager, id, NULL) >= 0) + goto not_ready; + + if (nexthop_get_by_id(manager, id, &nexthop) < 0) + goto not_ready; + + if (!nexthop_exists(nexthop)) + goto not_ready; + + if (ret) + *ret = nexthop; + + return true; + +not_ready: + if (ret) + *ret = NULL; + + return false; +} + static bool nexthop_is_ready_to_configure(Link *link, const NextHop *nexthop) { struct nexthop_grp *nhg; + int r; assert(link); assert(nexthop); @@ -576,13 +606,9 @@ static bool nexthop_is_ready_to_configure(Link *link, const NextHop *nexthop) { /* All group members must be configured first. */ HASHMAP_FOREACH(nhg, nexthop->group) { - NextHop *g; - - if (nexthop_get_by_id(link->manager, nhg->id, &g) < 0) - return false; - - if (!nexthop_exists(g)) - return false; + 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); diff --git a/src/network/networkd-nexthop.h b/src/network/networkd-nexthop.h index 564b52532fa..62429670e79 100644 --- a/src/network/networkd-nexthop.h +++ b/src/network/networkd-nexthop.h @@ -51,6 +51,7 @@ void link_foreignize_nexthops(Link *link); int link_request_static_nexthops(Link *link, bool only_ipv4); int nexthop_get_by_id(Manager *manager, uint32_t id, NextHop **ret); +int nexthop_is_ready(Manager *manager, uint32_t id, NextHop **ret); int manager_rtnl_process_nexthop(sd_netlink *rtnl, sd_netlink_message *message, Manager *m); int manager_build_nexthop_ids(Manager *manager);