From b3ea82afbe66312ecba2c6ac76e335b24b71d4e4 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 28 Mar 2024 13:22:06 +0900 Subject: [PATCH] network/ndisc: remove routes if lifetime is zero Fixes #31979. --- src/network/networkd-ndisc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c index 264ecff34d4..249103b7035 100644 --- a/src/network/networkd-ndisc.c +++ b/src/network/networkd-ndisc.c @@ -920,9 +920,15 @@ static int ndisc_router_process_route(Link *link, sd_ndisc_router *rt) { route->dst_prefixlen = prefixlen; route->lifetime_usec = lifetime_usec; - r = ndisc_request_route(route, link, rt); - if (r < 0) - return log_link_warning_errno(link, r, "Could not request additional route: %m"); + if (lifetime_usec != 0) { + r = ndisc_request_route(route, link, rt); + if (r < 0) + return log_link_warning_errno(link, r, "Could not request additional route: %m"); + } else { + r = ndisc_remove_route(route, link); + if (r < 0) + return log_link_warning_errno(link, r, "Could not remove additional route with zero lifetime: %m"); + } return 0; } -- 2.47.3