From 29ccba3e2f5b97cf964fe2ffd42b964585972e18 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cenk=20G=C3=BCndo=C4=9Fan?= <cnkgndgn@gmail.com>
Date: Thu, 20 Aug 2015 00:10:37 +0200
Subject: [PATCH] gnrc_ipv6.c: remove padding added by lower layers

---
 sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c b/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c
index b7a8932979..276ce10ea9 100644
--- a/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c
+++ b/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c
@@ -656,6 +656,12 @@ static void _receive(gnrc_pktsnip_t *pkt)
     /* extract header */
     hdr = (ipv6_hdr_t *)ipv6->data;
 
+    /* if available, remove any padding that was added by lower layers
+     * to fulfill their minimum size requirements (e.g. ethernet) */
+    if (byteorder_ntohs(hdr->len) < pkt->size) {
+        gnrc_pktbuf_realloc_data(pkt, byteorder_ntohs(hdr->len));
+    }
+
     DEBUG("ipv6: Received (src = %s, ",
           ipv6_addr_to_str(addr_str, &(hdr->src), sizeof(addr_str)));
     DEBUG("dst = %s, next header = %" PRIu8 ", length = %" PRIu16 ")\n",
-- 
GitLab