From: Yu Watanabe Date: Thu, 11 Apr 2024 19:38:42 +0000 (+0900) Subject: network/ndisc: drop onlink prefix when valid lifetime is zero X-Git-Tag: v256-rc1~216^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b26336225453ec8d2a3072c074e3bd926ce08e7a;p=thirdparty%2Fsystemd.git network/ndisc: drop onlink prefix when valid lifetime is zero Replaces 155d7a2c049cf866a0bfde8de371f09dfb3b6f29. --- diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c index 65d2f82286c..5d1c895f0d8 100644 --- a/src/network/networkd-ndisc.c +++ b/src/network/networkd-ndisc.c @@ -1224,9 +1224,23 @@ static int ndisc_router_process_onlink_prefix(Link *link, sd_ndisc_router *rt) { route->pref = preference; route->lifetime_usec = lifetime_usec; - r = ndisc_request_router_route(route, link, rt); - if (r < 0) - return log_link_warning_errno(link, r, "Could not request prefix route: %m"); + /* RFC 4861 section 6.3.4: + * - If the prefix is not already present in the Prefix List, and the Prefix Information option's + * Valid Lifetime field is non-zero, create a new entry for the prefix and initialize its + * invalidation timer to the Valid Lifetime value in the Prefix Information option. + * + * - If the prefix is already present in the host's Prefix List as the result of a previously + * received advertisement, reset its invalidation timer to the Valid Lifetime value in the Prefix + * Information option. If the new Lifetime value is zero, time-out the prefix immediately. */ + if (lifetime_usec == 0) { + r = ndisc_remove_route(route, link); + if (r < 0) + return log_link_warning_errno(link, r, "Failed to remove prefix route: %m"); + } else { + r = ndisc_request_router_route(route, link, rt); + if (r < 0) + return log_link_warning_errno(link, r, "Failed to request prefix route: %m"); + } return 0; }