From 91dfee7ee056a5dffeea603c3be0c984b33af9ee Mon Sep 17 00:00:00 2001 From: "Martine S. Lenders" Date: Fri, 28 Aug 2020 13:53:30 +0200 Subject: [PATCH] gnrc_ipv6_nib: fix duplicate handling for ARO When `nce` is NULL on the duplicate check, the later re-fetching of the `nce` might result in an actual NCE entry that then contains a duplicate, so we need to re-check the EUI-64 again as well. --- sys/net/gnrc/network_layer/ipv6/nib/_nib-6lr.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sys/net/gnrc/network_layer/ipv6/nib/_nib-6lr.c b/sys/net/gnrc/network_layer/ipv6/nib/_nib-6lr.c index c892fde2f4..c73ea9d3ed 100644 --- a/sys/net/gnrc/network_layer/ipv6/nib/_nib-6lr.c +++ b/sys/net/gnrc/network_layer/ipv6/nib/_nib-6lr.c @@ -69,6 +69,21 @@ uint8_t _reg_addr_upstream(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6, _handle_sl2ao(netif, ipv6, icmpv6, sl2ao); /* re-get NCE in case it was updated */ nce = _nib_onl_get(&ipv6->src, netif->pid); + /* and re-check EUI-64 in case nce was not an NC before */ + if ((memcmp(&nce->eui64, &aro->eui64, + sizeof(aro->eui64)) != 0) && + (_get_ar_state(nce) != GNRC_IPV6_NIB_NC_INFO_AR_STATE_GC)) { + /* ignore address registration requests from upstream */ + DEBUG("nib: Could not register %s, duplicate entry with " + "EUI-64 %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n", + ipv6_addr_to_str(addr_str, &ipv6->src, + sizeof(addr_str)), + nce->eui64.uint8[0], nce->eui64.uint8[1], + nce->eui64.uint8[2], nce->eui64.uint8[3], + nce->eui64.uint8[4], nce->eui64.uint8[5], + nce->eui64.uint8[6], nce->eui64.uint8[7]); + return SIXLOWPAN_ND_STATUS_DUP; + } return _update_nce_ar_state(aro, nce); } else if (nce != NULL) {