Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gnrc_netif: fix packet leak with gnrc_netif_pktq & netdev_new_api #20983

Merged
merged 3 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions drivers/at86rf215/at86rf215_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,11 @@
at86rf215_tx_exec(dev);
}

/* return the number of bytes that were actually loaded into the frame
* buffer/send out */
return (int)len;
/* store successfully sent number of bytes */
dev->tx_frame_len = len;

/* netdev_new just returns 0 on success */
return 0;
}

static int _confirm_send(netdev_t *netdev, void *info)
Expand Down Expand Up @@ -1151,7 +1153,7 @@
}

/* CCATX signals medium busy */
if ((dev->flags & AT86RF215_OPT_CCATX) && (rf_irq_mask & RF_IRQ_EDC) && (bb_irq_mask & BB_IRQ_TXFE)) {

Check warning on line 1156 in drivers/at86rf215/at86rf215_netdev.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
bb_irq_mask &= ~BB_IRQ_TXFE;
rf_irq_mask &= ~RF_IRQ_EDC;
_handle_edc(dev);
Expand Down
6 changes: 4 additions & 2 deletions sys/net/gnrc/netif/gnrc_netif.c
Original file line number Diff line number Diff line change
Expand Up @@ -1810,7 +1810,7 @@
}
return;
}
else {
else if (gnrc_netif_netdev_legacy_api(netif)) {
/* remove previously held packet */
gnrc_pktbuf_release(pkt);
return;
Expand Down Expand Up @@ -1882,7 +1882,9 @@
}
/* hold in case device was busy to not having to rewrite *all* the link
* 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) */

/* Record send in neighbor statistics if destination is unicast */
Expand Down Expand Up @@ -2150,4 +2152,4 @@
}
}
}
/** @} */

Check warning on line 2155 in sys/net/gnrc/netif/gnrc_netif.c

View workflow job for this annotation

GitHub Actions / static-tests

source file is too long
15 changes: 13 additions & 2 deletions sys/net/gnrc/netif/gnrc_netif_raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,24 @@ static gnrc_pktsnip_t *_recv(gnrc_netif_t *netif)
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;
benpicco marked this conversation as resolved.
Show resolved Hide resolved
}
}

static int _send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
{
int res = -ENOBUFS;

if (pkt->type == GNRC_NETTYPE_NETIF) {
/* we don't need the netif snip: remove it */
pkt = gnrc_pktbuf_remove_snip(pkt, pkt);
pkt = _skip_pkt_head(netif, pkt);
}

netdev_t *dev = netif->dev;
Expand Down
Loading