From 23d3ccde6bee5bfa94fb1a8489e7f85d96c5eff8 Mon Sep 17 00:00:00 2001 From: xnumad <34810600+xnumad@users.noreply.github.com> Date: Thu, 22 Feb 2024 15:57:49 +0100 Subject: [PATCH] gnrc_ipv6_nib: Ignore PIO with on-link flag --- sys/net/gnrc/network_layer/ipv6/nib/nib.c | 4 +++- tests/net/gnrc_ipv6_nib_6ln/main.c | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/sys/net/gnrc/network_layer/ipv6/nib/nib.c b/sys/net/gnrc/network_layer/ipv6/nib/nib.c index 3195d62f6354..6c9225018c40 100644 --- a/sys/net/gnrc/network_layer/ipv6/nib/nib.c +++ b/sys/net/gnrc/network_layer/ipv6/nib/nib.c @@ -1621,7 +1621,9 @@ static uint32_t _handle_pio(gnrc_netif_t *netif, const icmpv6_hdr_t *icmpv6, valid_ltime = byteorder_ntohl(pio->valid_ltime); pref_ltime = byteorder_ntohl(pio->pref_ltime); if ((pio->len != NDP_OPT_PI_LEN) || (icmpv6->type != ICMPV6_RTR_ADV) || - ipv6_addr_is_link_local(&pio->prefix) || (valid_ltime < pref_ltime)) { + ipv6_addr_is_link_local(&pio->prefix) || (valid_ltime < pref_ltime) || + /* https://datatracker.ietf.org/doc/html/rfc6775#section-5.4 */ + (gnrc_netif_is_6ln(netif) && (pio->flags & NDP_OPT_PI_FLAGS_L))) { DEBUG("nib: ignoring PIO with invalid data\n"); return UINT32_MAX; } diff --git a/tests/net/gnrc_ipv6_nib_6ln/main.c b/tests/net/gnrc_ipv6_nib_6ln/main.c index eaa13747acd7..96aa995e055a 100644 --- a/tests/net/gnrc_ipv6_nib_6ln/main.c +++ b/tests/net/gnrc_ipv6_nib_6ln/main.c @@ -1056,6 +1056,12 @@ static void test_handle_pkt__rtr_adv__success(uint8_t rtr_adv_flags, TEST_ASSERT_EQUAL_INT(exp_netif.mtu, _mock_netif->ipv6.mtu); } state = NULL; + if (pio_flags & NDP_OPT_PI_FLAGS_L) { + pio = false; + /* Should the host erroneously receive a PIO with the L (on-link) flag set, + * then that PIO MUST be ignored. + * - https://datatracker.ietf.org/doc/html/rfc6775#section-5.4 */ + } if (pio) { if (pio_flags & NDP_OPT_PI_FLAGS_A) { TEST_ASSERT_MESSAGE(gnrc_netif_ipv6_addr_idx(_mock_netif,