From: Yu Watanabe Date: Fri, 5 Feb 2021 01:21:19 +0000 (+0900) Subject: network: nexthop: first create nexthops with ID X-Git-Tag: v248-rc1~77 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=055e4909de8f83563e3e8bba1ac64db80c916bb4;p=thirdparty%2Fsystemd.git network: nexthop: first create nexthops with ID Otherwise, an ID-less nexthop may conflict with a later nexthop with ID. --- diff --git a/src/network/networkd-nexthop.c b/src/network/networkd-nexthop.c index 629fd78226c..7a5a6481482 100644 --- a/src/network/networkd-nexthop.c +++ b/src/network/networkd-nexthop.c @@ -300,6 +300,11 @@ static int nexthop_configure(NextHop *nexthop, Link *link) { } int link_set_nexthop(Link *link) { + enum { + PHASE_ID, /* First phase: Nexthops with ID */ + PHASE_WITHOUT_ID, /* Second phase: Nexthops without ID */ + _PHASE_MAX, + } phase; NextHop *nh; int r; @@ -313,13 +318,17 @@ int link_set_nexthop(Link *link) { link->static_nexthops_configured = false; - HASHMAP_FOREACH(nh, link->network->nexthops_by_section) { - r = nexthop_configure(nh, link); - if (r < 0) - return log_link_warning_errno(link, r, "Could not set nexthop: %m"); + for (phase = PHASE_ID; phase < _PHASE_MAX; phase++) + HASHMAP_FOREACH(nh, link->network->nexthops_by_section) { + if ((nh->id > 0) != (phase == PHASE_ID)) + continue; - link->nexthop_messages++; - } + r = nexthop_configure(nh, link); + if (r < 0) + return log_link_warning_errno(link, r, "Could not set nexthop: %m"); + + link->nexthop_messages++; + } if (link->nexthop_messages == 0) { link->static_nexthops_configured = true;