From 3912d49d0da2aefaf92148096ea527b98d4c0a37 Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Mon, 24 Jul 2023 15:04:59 +0530 Subject: [PATCH] network: ndisc - Ignore route information if reserved (10) value is received MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RFC4191 – Section 2.3 Route Information Option's Prf field: If the Reserved (10) value is received, the Route Information Option MUST be ignored. --- src/libsystemd-network/ndisc-router.c | 6 +++--- src/network/networkd-ndisc.c | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) 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");