From 1f38348cf9b5843876cccb3d2d9d559bacd33833 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Tue, 2 Jul 2013 13:52:11 +0200 Subject: [PATCH 1/2] Added a flag to optionally disable IPv6 NA/NS at compile time --- core/net/tcpip.c | 4 ++++ core/net/uip-nd6.h | 26 +++++++++++++++----------- core/net/uip6.c | 10 ++++++++++ 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/core/net/tcpip.c b/core/net/tcpip.c index 2f6c76255..20e504bc7 100644 --- a/core/net/tcpip.c +++ b/core/net/tcpip.c @@ -602,6 +602,7 @@ tcpip_ipv6_output(void) } #endif /* UIP_CONF_IPV6_RPL */ if((nbr = uip_ds6_nbr_lookup(nexthop)) == NULL) { +#if UIP_ND6_SEND_NA if((nbr = uip_ds6_nbr_add(nexthop, NULL, 0, NBR_INCOMPLETE)) == NULL) { uip_len = 0; return; @@ -628,7 +629,9 @@ tcpip_ipv6_output(void) stimer_set(&nbr->sendns, uip_ds6_if.retrans_timer / 1000); nbr->nscount = 1; } +#endif /* UIP_ND6_SEND_NA */ } else { +#if UIP_ND6_SEND_NA if(nbr->state == NBR_INCOMPLETE) { PRINTF("tcpip_ipv6_output: nbr cache entry incomplete\n"); #if UIP_CONF_IPV6_QUEUE_PKT @@ -650,6 +653,7 @@ tcpip_ipv6_output(void) nbr->nscount = 0; PRINTF("tcpip_ipv6_output: nbr cache entry stale moving to delay\n"); } +#endif /* UIP_ND6_SEND_NA */ tcpip_output(&nbr->lladdr); diff --git a/core/net/uip-nd6.h b/core/net/uip-nd6.h index 265c4f3db..b4b97889f 100644 --- a/core/net/uip-nd6.h +++ b/core/net/uip-nd6.h @@ -57,17 +57,6 @@ #define UIP_ND6_INFINITE_LIFETIME 0xFFFFFFFF /** @} */ -#ifndef UIP_CONF_ND6_DEF_MAXDADNS -/** \brief Do not try DAD when using EUI-64 as allowed by draft-ietf-6lowpan-nd-15 section 8.2 */ -#if UIP_CONF_LL_802154 -#define UIP_ND6_DEF_MAXDADNS 0 -#else /* UIP_CONF_LL_802154 */ -#define UIP_ND6_DEF_MAXDADNS 1 -#endif /* UIP_CONF_LL_802154 */ -#else /* UIP_CONF_ND6_DEF_MAXDADNS */ -#define UIP_ND6_DEF_MAXDADNS UIP_CONF_ND6_DEF_MAXDADNS -#endif /* UIP_CONF_ND6_DEF_MAXDADNS */ - /** \name RFC 4861 Host constant */ /** @{ */ #define UIP_ND6_MAX_RTR_SOLICITATION_DELAY 1 @@ -82,6 +71,11 @@ #else #define UIP_ND6_SEND_RA UIP_CONF_ND6_SEND_RA #endif +#ifndef UIP_CONF_ND6_SEND_NA +#define UIP_ND6_SEND_NA 1 /* enable/disable NA sending */ +#else +#define UIP_ND6_SEND_NA UIP_CONF_ND6_SEND_NA +#endif #define UIP_ND6_MAX_RA_INTERVAL 600 #define UIP_ND6_MIN_RA_INTERVAL (UIP_ND6_MAX_RA_INTERVAL / 3) #define UIP_ND6_M_FLAG 0 @@ -95,6 +89,16 @@ #define UIP_ND6_MAX_RA_DELAY_TIME_MS 500 /*milli seconds*/ /** @} */ +#ifndef UIP_CONF_ND6_DEF_MAXDADNS +/** \brief Do not try DAD when using EUI-64 as allowed by draft-ietf-6lowpan-nd-15 section 8.2 */ +#if UIP_CONF_LL_802154 +#define UIP_ND6_DEF_MAXDADNS 0 +#else /* UIP_CONF_LL_802154 */ +#define UIP_ND6_DEF_MAXDADNS UIP_ND6_SEND_NA +#endif /* UIP_CONF_LL_802154 */ +#else /* UIP_CONF_ND6_DEF_MAXDADNS */ +#define UIP_ND6_DEF_MAXDADNS UIP_CONF_ND6_DEF_MAXDADNS +#endif /* UIP_CONF_ND6_DEF_MAXDADNS */ /** \name RFC 4861 Node constant */ #define UIP_ND6_MAX_MULTICAST_SOLICIT 3 diff --git a/core/net/uip6.c b/core/net/uip6.c index e562b0f04..75cd2fb32 100644 --- a/core/net/uip6.c +++ b/core/net/uip6.c @@ -1391,10 +1391,20 @@ uip_process(uint8_t flag) switch(UIP_ICMP_BUF->type) { case ICMP6_NS: +#if UIP_ND6_SEND_NA uip_nd6_ns_input(); +#else /* UIP_ND6_SEND_NA */ + UIP_STAT(++uip_stat.icmp.drop); + uip_len = 0; +#endif /* UIP_ND6_SEND_NA */ break; case ICMP6_NA: +#if UIP_ND6_SEND_NA uip_nd6_na_input(); +#else /* UIP_ND6_SEND_NA */ + UIP_STAT(++uip_stat.icmp.drop); + uip_len = 0; +#endif /* UIP_ND6_SEND_NA */ break; case ICMP6_RS: #if UIP_CONF_ROUTER && UIP_ND6_SEND_RA From 0e81b91fa6bcc2178ddf33d0387c96aff7154190 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Tue, 2 Jul 2013 15:20:21 +0200 Subject: [PATCH 2/2] Simplify periodic ds6 neighbor processing in case NA/NS is disabled. Strips out uip_nd6_ns_output from the binary. --- core/net/uip-ds6.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/core/net/uip-ds6.c b/core/net/uip-ds6.c index 644e49e00..49b7be5d3 100644 --- a/core/net/uip-ds6.c +++ b/core/net/uip-ds6.c @@ -204,6 +204,15 @@ uip_ds6_periodic(void) locnbr++) { if(locnbr->isused) { switch(locnbr->state) { + case NBR_REACHABLE: + if(stimer_expired(&locnbr->reachable)) { + PRINTF("REACHABLE: moving to STALE ("); + PRINT6ADDR(&locnbr->ipaddr); + PRINTF(")\n"); + locnbr->state = NBR_STALE; + } + break; +#if UIP_ND6_SEND_NA case NBR_INCOMPLETE: if(locnbr->nscount >= UIP_ND6_MAX_MULTICAST_SOLICIT) { uip_ds6_nbr_rm(locnbr); @@ -214,14 +223,6 @@ uip_ds6_periodic(void) stimer_set(&locnbr->sendns, uip_ds6_if.retrans_timer / 1000); } break; - case NBR_REACHABLE: - if(stimer_expired(&locnbr->reachable)) { - PRINTF("REACHABLE: moving to STALE ("); - PRINT6ADDR(&locnbr->ipaddr); - PRINTF(")\n"); - locnbr->state = NBR_STALE; - } - break; case NBR_DELAY: if(stimer_expired(&locnbr->reachable)) { locnbr->state = NBR_PROBE; @@ -246,6 +247,7 @@ uip_ds6_periodic(void) stimer_set(&locnbr->sendns, uip_ds6_if.retrans_timer / 1000); } break; +#endif /* UIP_ND6_SEND_NA */ default: break; }