From a533473a48ff05e84e7af3d4049dbf458b6c0f94 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 12 Dec 2023 18:40:43 +0900 Subject: [PATCH] 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. --- src/network/networkd-nexthop.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/network/networkd-nexthop.c b/src/network/networkd-nexthop.c index b10ddc46b8..367759f373 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; -- 2.25.1