From 8a07f8c548e5ee6292e933543cce3d30b6ed79eb Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Tue, 25 Aug 2015 17:48:17 +0200 Subject: [PATCH 1/2] gnrc_ipv6: fix #3707 --- sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c b/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c index 5e429a2baa..6ea6ff897a 100644 --- a/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c +++ b/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c @@ -519,6 +519,9 @@ static void _send(gnrc_pktsnip_t *pkt, bool prep_hdr) if (ipv6 != pkt) { /* in case packet has netif header */ pkt->next = payload;/* pkt is already write-protected so we can do that */ } + else { + pkt = payload; /* pkt is the IPv6 header so we just write-protected it */ + } ipv6 = payload; /* Reset ipv6 from temporary variable */ hdr = ipv6->data; From f81f43ea381fdab5c8767d73802b23f91b5d1149 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Tue, 25 Aug 2015 18:12:05 +0200 Subject: [PATCH 2/2] gnrc_udp: fix #3707 --- sys/net/gnrc/transport_layer/udp/gnrc_udp.c | 27 ++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/sys/net/gnrc/transport_layer/udp/gnrc_udp.c b/sys/net/gnrc/transport_layer/udp/gnrc_udp.c index e6f3c78908..e630d3d088 100644 --- a/sys/net/gnrc/transport_layer/udp/gnrc_udp.c +++ b/sys/net/gnrc/transport_layer/udp/gnrc_udp.c @@ -139,13 +139,34 @@ static void _receive(gnrc_pktsnip_t *pkt) static void _send(gnrc_pktsnip_t *pkt) { udp_hdr_t *hdr; - gnrc_pktsnip_t *udp_snip; + gnrc_pktsnip_t *udp_snip, *tmp; - /* get udp snip and hdr */ - LL_SEARCH_SCALAR(pkt, udp_snip, type, GNRC_NETTYPE_UDP); + /* write protect first header */ + tmp = gnrc_pktbuf_start_write(pkt); + if (tmp == NULL) { + DEBUG("udp: cannot send packet: unable to allocate packet\n"); + gnrc_pktbuf_release(pkt); + return; + } + pkt = tmp; + udp_snip = tmp->next; + + /* get and write protect until udp snip */ + while ((udp_snip != NULL) && (udp_snip->type != GNRC_NETTYPE_UDP)) { + udp_snip = gnrc_pktbuf_start_write(udp_snip); + if (udp_snip == NULL) { + DEBUG("udp: cannot send packet: unable to allocate packet\n"); + gnrc_pktbuf_release(pkt); + return; + } + tmp->next = udp_snip; + tmp = udp_snip; + udp_snip = udp_snip->next; + } assert(udp_snip != NULL); + /* write protect UDP snip */ udp_snip = gnrc_pktbuf_start_write(udp_snip); if (udp_snip == NULL) { DEBUG("udp: cannot send packet: unable to allocate packet\n");