mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #20983 from benpicco/gnrc_netif_netdev_new_api-leak
gnrc_netif: fix packet leak with gnrc_netif_pktq & netdev_new_api
This commit is contained in:
commit
fbf5c66f78
@ -176,9 +176,11 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
|
|||||||
at86rf215_tx_exec(dev);
|
at86rf215_tx_exec(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return the number of bytes that were actually loaded into the frame
|
/* store successfully sent number of bytes */
|
||||||
* buffer/send out */
|
dev->tx_frame_len = len;
|
||||||
return (int)len;
|
|
||||||
|
/* netdev_new just returns 0 on success */
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _confirm_send(netdev_t *netdev, void *info)
|
static int _confirm_send(netdev_t *netdev, void *info)
|
||||||
|
@ -1810,7 +1810,7 @@ static void _tx_done(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt,
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else if (gnrc_netif_netdev_legacy_api(netif)) {
|
||||||
/* remove previously held packet */
|
/* remove previously held packet */
|
||||||
gnrc_pktbuf_release(pkt);
|
gnrc_pktbuf_release(pkt);
|
||||||
return;
|
return;
|
||||||
@ -1882,7 +1882,9 @@ static void _send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt, bool push_back)
|
|||||||
}
|
}
|
||||||
/* hold in case device was busy to not having to rewrite *all* the link
|
/* hold in case device was busy to not having to rewrite *all* the link
|
||||||
* layer implementations in case `gnrc_netif_pktq` is included */
|
* layer implementations in case `gnrc_netif_pktq` is included */
|
||||||
gnrc_pktbuf_hold(pkt, 1);
|
if (gnrc_netif_netdev_legacy_api(netif)) {
|
||||||
|
gnrc_pktbuf_hold(pkt, 1);
|
||||||
|
}
|
||||||
#endif /* IS_USED(MODULE_GNRC_NETIF_PKTQ) */
|
#endif /* IS_USED(MODULE_GNRC_NETIF_PKTQ) */
|
||||||
|
|
||||||
/* Record send in neighbor statistics if destination is unicast */
|
/* Record send in neighbor statistics if destination is unicast */
|
||||||
|
@ -104,13 +104,24 @@ static gnrc_pktsnip_t *_recv(gnrc_netif_t *netif)
|
|||||||
return pkt;
|
return pkt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gnrc_pktsnip_t *_skip_pkt_head(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
|
||||||
|
{
|
||||||
|
if (gnrc_netif_netdev_legacy_api(netif)) {
|
||||||
|
/* we don't need the netif snip: remove it */
|
||||||
|
return gnrc_pktbuf_remove_snip(pkt, pkt);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* _tx_done() will free the entire list */
|
||||||
|
return pkt->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int _send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
|
static int _send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
|
||||||
{
|
{
|
||||||
int res = -ENOBUFS;
|
int res = -ENOBUFS;
|
||||||
|
|
||||||
if (pkt->type == GNRC_NETTYPE_NETIF) {
|
if (pkt->type == GNRC_NETTYPE_NETIF) {
|
||||||
/* we don't need the netif snip: remove it */
|
pkt = _skip_pkt_head(netif, pkt);
|
||||||
pkt = gnrc_pktbuf_remove_snip(pkt, pkt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
netdev_t *dev = netif->dev;
|
netdev_t *dev = netif->dev;
|
||||||
|
Loading…
Reference in New Issue
Block a user