From: Susant Sahani Date: Mon, 24 Jul 2023 09:34:59 +0000 (+0530) Subject: network: ndisc - Ignore route information if reserved (10) value is X-Git-Tag: v255-rc1~731 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3912d49d0da2aefaf92148096ea527b98d4c0a37;p=thirdparty%2Fsystemd.git network: ndisc - Ignore route information if reserved (10) value is received RFC4191 – Section 2.3 Route Information Option's Prf field: If the Reserved (10) value is received, the Route Information Option MUST be ignored. --- diff --git a/src/libsystemd-network/ndisc-router.c b/src/libsystemd-network/ndisc-router.c index 43a36e4b14c..e25b3c2d9b9 100644 --- a/src/libsystemd-network/ndisc-router.c +++ b/src/libsystemd-network/ndisc-router.c @@ -530,10 +530,10 @@ int sd_ndisc_router_route_get_preference(sd_ndisc_router *rt, unsigned *ret) { if (r < 0) return r; - *ret = (ri[3] >> 3) & 3; - if (!IN_SET(*ret, SD_NDISC_PREFERENCE_LOW, SD_NDISC_PREFERENCE_HIGH)) - *ret = SD_NDISC_PREFERENCE_MEDIUM; + if (!IN_SET((ri[3] >> 3) & 3, SD_NDISC_PREFERENCE_LOW, SD_NDISC_PREFERENCE_MEDIUM, SD_NDISC_PREFERENCE_HIGH)) + return -ENOTSUP; + *ret = (ri[3] >> 3) & 3; return 0; } diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c index 5ac6e1f9ec4..b2b222147d1 100644 --- a/src/network/networkd-ndisc.c +++ b/src/network/networkd-ndisc.c @@ -585,6 +585,10 @@ static int ndisc_router_process_route(Link *link, sd_ndisc_router *rt) { } r = sd_ndisc_router_route_get_preference(rt, &preference); + if (r == -ENOTSUP) { + log_link_debug_errno(link, r, "Received route prefix with unsupported preference, ignoring: %m"); + return 0; + } if (r < 0) return log_link_warning_errno(link, r, "Failed to get default router preference from RA: %m");