From 3295c833ca62bbe4ae3306814d87f3cabd77c838 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Mon, 30 Nov 2020 15:54:56 +0100 Subject: [PATCH] gnrc_ipv6_ext_frag: propagate error up the stack on _snd_buf_free() --- .../ipv6/ext/frag/gnrc_ipv6_ext_frag.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/sys/net/gnrc/network_layer/ipv6/ext/frag/gnrc_ipv6_ext_frag.c b/sys/net/gnrc/network_layer/ipv6/ext/frag/gnrc_ipv6_ext_frag.c index 107c70816b..2f5124363c 100644 --- a/sys/net/gnrc/network_layer/ipv6/ext/frag/gnrc_ipv6_ext_frag.c +++ b/sys/net/gnrc/network_layer/ipv6/ext/frag/gnrc_ipv6_ext_frag.c @@ -14,6 +14,7 @@ */ #include +#include #include #include "byteorder.h" @@ -85,8 +86,9 @@ static gnrc_ipv6_ext_frag_send_t *_snd_buf_alloc(void); * datagrams and fragments. * * @param[in] snd_buf A fragmentation send buffer entry + * @param[in] error Error number for the error causing the release */ -static void _snd_buf_free(gnrc_ipv6_ext_frag_send_t *snd_buf); +static void _snd_buf_free(gnrc_ipv6_ext_frag_send_t *snd_buf, int error); /** * @brief Removes a fragmentation send buffer without releasing the stored @@ -175,7 +177,7 @@ void gnrc_ipv6_ext_frag_send(gnrc_ipv6_ext_frag_send_t *snd_buf) gnrc_pktbuf_release(ptr); } } - _snd_buf_free(snd_buf); + _snd_buf_free(snd_buf, ENOSPC); return; } ptr = tmp; @@ -212,7 +214,7 @@ void gnrc_ipv6_ext_frag_send(gnrc_ipv6_ext_frag_send_t *snd_buf) if (ptr == NULL) { DEBUG("ipv6_ext_frag: unable to create fragmentation header\n"); gnrc_pktbuf_release(to_send); - _snd_buf_free(snd_buf); + _snd_buf_free(snd_buf, ENOSPC); return; } remaining -= sizeof(ipv6_ext_frag_t); @@ -237,7 +239,7 @@ void gnrc_ipv6_ext_frag_send(gnrc_ipv6_ext_frag_send_t *snd_buf) if (ptr == NULL) { DEBUG("ipv6_ext_frag: packet buffer full, canceling fragmentation\n"); gnrc_pktbuf_release(to_send); - _snd_buf_free(snd_buf); + _snd_buf_free(snd_buf, ENOSPC); return; } assert(snd_buf->pkt->next == ptr); /* we just created it with mark */ @@ -258,7 +260,7 @@ void gnrc_ipv6_ext_frag_send(gnrc_ipv6_ext_frag_send_t *snd_buf) if (msg_try_send(&msg, gnrc_ipv6_pid) <= 0) { DEBUG("ipv6_ext_frag: Unable to send fragment, canceling fragmentation\n"); gnrc_pktbuf_release(to_send); - _snd_buf_free(snd_buf); + _snd_buf_free(snd_buf, ENOMEM); return; } if (last_fragment) { @@ -274,7 +276,7 @@ void gnrc_ipv6_ext_frag_send(gnrc_ipv6_ext_frag_send_t *snd_buf) msg.content.ptr = snd_buf; if (msg_try_send(&msg, gnrc_ipv6_pid) <= 0) { DEBUG("ipv6_ext_frag: Unable to continue fragmentation, canceling\n"); - _snd_buf_free(snd_buf); + _snd_buf_free(snd_buf, ENOMEM); } } } @@ -299,13 +301,13 @@ static void _snd_buf_del(gnrc_ipv6_ext_frag_send_t *snd_buf) snd_buf->pkt = NULL; } -static void _snd_buf_free(gnrc_ipv6_ext_frag_send_t *snd_buf) +static void _snd_buf_free(gnrc_ipv6_ext_frag_send_t *snd_buf, int error) { if (snd_buf->per_frag) { gnrc_pktbuf_release(snd_buf->per_frag); } if (snd_buf->pkt) { - gnrc_pktbuf_release(snd_buf->pkt); + gnrc_pktbuf_release_error(snd_buf->pkt, error); } _snd_buf_del(snd_buf); }