gnrc_netapi: report errors on dispatch

This commit is contained in:
Martine S. Lenders 2020-02-11 18:16:02 +01:00
parent f2d1e661d1
commit a0740ee535

View File

@ -93,20 +93,20 @@ int gnrc_netapi_dispatch(gnrc_nettype_t type, uint32_t demux_ctx,
while (sendto) { while (sendto) {
#if defined(MODULE_GNRC_NETAPI_MBOX) || defined(MODULE_GNRC_NETAPI_CALLBACKS) #if defined(MODULE_GNRC_NETAPI_MBOX) || defined(MODULE_GNRC_NETAPI_CALLBACKS)
uint32_t errno = 0; uint32_t status = 0;
switch (sendto->type) { switch (sendto->type) {
case GNRC_NETREG_TYPE_DEFAULT: case GNRC_NETREG_TYPE_DEFAULT:
if (_gnrc_netapi_send_recv(sendto->target.pid, pkt, if (_gnrc_netapi_send_recv(sendto->target.pid, pkt,
cmd) < 1) { cmd) < 1) {
/* unable to dispatch packet */ /* unable to dispatch packet */
errno = EIO; status = EIO;
} }
break; break;
#ifdef MODULE_GNRC_NETAPI_MBOX #ifdef MODULE_GNRC_NETAPI_MBOX
case GNRC_NETREG_TYPE_MBOX: case GNRC_NETREG_TYPE_MBOX:
if (_snd_rcv_mbox(sendto->target.mbox, cmd, pkt) < 1) { if (_snd_rcv_mbox(sendto->target.mbox, cmd, pkt) < 1) {
/* unable to dispatch packet */ /* unable to dispatch packet */
errno = EIO; status = EIO;
} }
break; break;
#endif #endif
@ -117,11 +117,11 @@ int gnrc_netapi_dispatch(gnrc_nettype_t type, uint32_t demux_ctx,
#endif #endif
default: default:
/* unknown dispatch type */ /* unknown dispatch type */
errno = ECANCELED; status = ECANCELED;
break; break;
} }
if (errno != 0) { if (status != 0) {
gnrc_pktbuf_release_error(pkt, errno); gnrc_pktbuf_release_error(pkt, status);
} }
#else #else
if (_gnrc_netapi_send_recv(sendto->target.pid, pkt, cmd) < 1) { if (_gnrc_netapi_send_recv(sendto->target.pid, pkt, cmd) < 1) {