From 3fde0ef8f81646da6a00d011857b30de8a0d0730 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Thu, 8 Nov 2018 12:52:48 +0100 Subject: [PATCH] gnrc_ipv6: remove special handling for encapsulated IPv6 headers Since the packet is now guaranteed to be preparsed, the currently handled IPv6 header will always be in the first snip. Because of this the packet parser can't get confused anymore which IPv6 header is the one to be handled so we don't need to remove the more outer ones. Because of this we can just use the normal packet dispatching (which is already used by other `GNRC_NETTYPE_*`-known protocol numbers such as UDP). This also reverts d54ac38f8403e7fc8f409225652e0174d059d129. --- sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c | 38 ++------------------- 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c b/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c index 68d10ce224..a4dfcd1d52 100644 --- a/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c +++ b/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c @@ -72,9 +72,6 @@ static void _send(gnrc_pktsnip_t *pkt, bool prep_hdr); /* Main event loop for IPv6 */ static void *_event_loop(void *args); -/* Handles encapsulated IPv6 packets: http://tools.ietf.org/html/rfc2473 */ -static void _decapsulate(gnrc_pktsnip_t *pkt); - kernel_pid_t gnrc_ipv6_init(void) { if (gnrc_ipv6_pid == KERNEL_PID_UNDEF) { @@ -128,11 +125,6 @@ void gnrc_ipv6_demux(gnrc_netif_t *netif, gnrc_pktsnip_t *current, break; #endif - case PROTNUM_IPV6: - assert(current == pkt); - interested = true; - - break; default: (void)netif; #ifdef MODULE_GNRC_SIXLOWPAN_IPHC_NHC @@ -181,10 +173,6 @@ void gnrc_ipv6_demux(gnrc_netif_t *netif, gnrc_pktsnip_t *current, return; #endif - case PROTNUM_IPV6: - DEBUG("ipv6: handle encapsulated IPv6 packet (nh = %u)\n", nh); - _decapsulate(pkt); - return; default: assert(false); break; @@ -213,11 +201,9 @@ static void _dispatch_next_header(gnrc_pktsnip_t *current, gnrc_pktsnip_t *pkt, { #ifdef MODULE_GNRC_IPV6_EXT const bool should_dispatch_current_type = ((current->type != GNRC_NETTYPE_IPV6_EXT) || - (current->next->type == GNRC_NETTYPE_IPV6)) && - (current->type != GNRC_NETTYPE_IPV6); + (current->next->type == GNRC_NETTYPE_IPV6)); #else - const bool should_dispatch_current_type = (current->next->type == GNRC_NETTYPE_IPV6) && - (current->type != GNRC_NETTYPE_IPV6); + const bool should_dispatch_current_type = (current->next->type == GNRC_NETTYPE_IPV6); #endif DEBUG("ipv6: forward nh = %u to other threads\n", nh); @@ -880,24 +866,4 @@ static void _receive(gnrc_pktsnip_t *pkt) gnrc_ipv6_demux(netif, pkt, pkt, hdr->nh); } -static void _decapsulate(gnrc_pktsnip_t *pkt) -{ - gnrc_pktsnip_t *ptr = pkt; - - pkt->type = GNRC_NETTYPE_UNDEF; /* prevent payload (the encapsulated packet) - * from being removed */ - - /* Remove encapsulating IPv6 header */ - while ((ptr->next != NULL) && (ptr->next->type == GNRC_NETTYPE_IPV6)) { - gnrc_pktbuf_remove_snip(pkt, pkt->next); - } - - pkt->type = GNRC_NETTYPE_IPV6; - - if (gnrc_netapi_dispatch_receive(GNRC_NETTYPE_IPV6, - GNRC_NETREG_DEMUX_CTX_ALL, pkt) == 0) { - gnrc_pktbuf_release(pkt); - } -} - /** @} */