From 675d9325b9918d166236c291f30170b01da09fe7 Mon Sep 17 00:00:00 2001 From: Mohamed Seliem Date: Sat, 10 Sep 2016 10:56:19 +0200 Subject: [PATCH] DAD: Remove useless "if" that tests if the source address is unspecified No need to do the unspecified address twice. #if UIP_ND6_DEF_MAXDADNS > 0 if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) { /* DAD CASE */ .......... #else /* UIP_ND6_DEF_MAXDADNS > 0 */ if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) { /* DAD CASE */ goto discard; #endif /* UIP_ND6_DEF_MAXDADNS > 0 */ this logic will bring confusion, especially if you analyze the other ND functions (NUD, address resolution) . --- core/net/ipv6/uip-nd6.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/core/net/ipv6/uip-nd6.c b/core/net/ipv6/uip-nd6.c index d938ac2a0..f61c4b21a 100644 --- a/core/net/ipv6/uip-nd6.c +++ b/core/net/ipv6/uip-nd6.c @@ -238,9 +238,9 @@ ns_input(void) addr = uip_ds6_addr_lookup(&UIP_ND6_NS_BUF->tgtipaddr); if(addr != NULL) { -#if UIP_ND6_DEF_MAXDADNS > 0 if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) { /* DAD CASE */ +#if UIP_ND6_DEF_MAXDADNS > 0 #if UIP_CONF_IPV6_CHECKS if(!uip_is_addr_solicited_node(&UIP_IP_BUF->destipaddr)) { PRINTF("NS received is bad\n"); @@ -258,9 +258,7 @@ ns_input(void) goto discard; } #else /* UIP_ND6_DEF_MAXDADNS > 0 */ - if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) { - /* DAD CASE */ - goto discard; + goto discard; /* DAD CASE */ #endif /* UIP_ND6_DEF_MAXDADNS > 0 */ } #if UIP_CONF_IPV6_CHECKS