From 510fc9e51edf1f8818e0ed488f88f7983b714b5d Mon Sep 17 00:00:00 2001 From: Joakim Eriksson Date: Tue, 24 Nov 2015 11:35:20 +0100 Subject: [PATCH] removed memcpy that cause inconsistency in nbr-table when adding nd6 neighbor with NS/NA. --- core/net/ipv6/uip-nd6.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/core/net/ipv6/uip-nd6.c b/core/net/ipv6/uip-nd6.c index 107e66369..a6b8931ad 100644 --- a/core/net/ipv6/uip-nd6.c +++ b/core/net/ipv6/uip-nd6.c @@ -492,10 +492,11 @@ na_input(void) } else { uip_lladdr_t *lladdr; nbr = uip_ds6_nbr_lookup(&UIP_ND6_NA_BUF->tgtipaddr); - lladdr = (uip_lladdr_t *)uip_ds6_nbr_get_ll(nbr); if(nbr == NULL) { goto discard; } + lladdr = (uip_lladdr_t *)uip_ds6_nbr_get_ll(nbr); + if(nd6_opt_llao != 0) { is_llchange = memcmp(&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET], (void *)lladdr, @@ -505,8 +506,16 @@ na_input(void) if(nd6_opt_llao == NULL) { goto discard; } - memcpy(lladdr, &nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET], - UIP_LLADDR_LEN); + + /* Remove this neighbor - since it has a NULL MAC address */ + uip_ds6_nbr_rm(nbr); + /* Re-add this neighbor - now with a correct MAC address */ + nbr = uip_ds6_nbr_add(&UIP_ND6_NA_BUF->tgtipaddr, + (const uip_lladdr_t *) &nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET], + is_router, NBR_STALE); + if(nbr == NULL) { + goto discard; + } if(is_solicited) { nbr->state = NBR_REACHABLE; nbr->nscount = 0;