From: Yu Watanabe Date: Tue, 12 Dec 2023 09:40:43 +0000 (+0900) Subject: network/nexthop: NextHop.id is always positive when nexthop_configure() is called X-Git-Tag: v256-rc1~1485^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a533473a48ff05e84e7af3d4049dbf458b6c0f94;p=thirdparty%2Fsystemd.git network/nexthop: NextHop.id is always positive when nexthop_configure() is called If a nexthop is requested without a valid ID, then nexthop_acquire_id() assigns an unused ID. So, at the time nexthop_configure() is called, the ID is always valid. --- diff --git a/src/network/networkd-nexthop.c b/src/network/networkd-nexthop.c index b10ddc46b8c..367759f373e 100644 --- a/src/network/networkd-nexthop.c +++ b/src/network/networkd-nexthop.c @@ -435,6 +435,7 @@ static int nexthop_configure(NextHop *nexthop, Link *link, Request *req) { int r; assert(nexthop); + assert(nexthop->id > 0); assert(IN_SET(nexthop->family, AF_UNSPEC, AF_INET, AF_INET6)); assert(link); assert(link->manager); @@ -448,11 +449,9 @@ static int nexthop_configure(NextHop *nexthop, Link *link, Request *req) { if (r < 0) return r; - if (nexthop->id > 0) { - r = sd_netlink_message_append_u32(m, NHA_ID, nexthop->id); - if (r < 0) - return r; - } + r = sd_netlink_message_append_u32(m, NHA_ID, nexthop->id); + if (r < 0) + return r; if (!hashmap_isempty(nexthop->group)) { _cleanup_free_ struct nexthop_grp *group = NULL;