net/ethernet: Remove inserted L2 header buffer
The packet can be referenced somewhere else and letting the newly added L2 header will generate corrupt packet. If the same packet is being resent, ethernet will add again its L2 header. Thus the need to remove such L2 header every time a packet has been sent, successfully or not. Fixes #12560 Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
parent
3610ec71f5
commit
499ffd6573
5 changed files with 22 additions and 20 deletions
|
@ -493,6 +493,18 @@ static void ethernet_update_tx_stats(struct net_if *iface, struct net_pkt *pkt)
|
|||
}
|
||||
#endif /* CONFIG_NET_STATISTICS_ETHERNET */
|
||||
|
||||
static void ethernet_remove_l2_header(struct net_pkt *pkt)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
|
||||
/* Remove the buffer added in ethernet_fill_header() */
|
||||
buf = pkt->buffer;
|
||||
pkt->buffer = buf->frags;
|
||||
buf->frags = NULL;
|
||||
|
||||
net_pkt_frag_unref(buf);
|
||||
}
|
||||
|
||||
static int ethernet_send(struct net_if *iface, struct net_pkt *pkt)
|
||||
{
|
||||
const struct ethernet_api *api = net_if_get_device(iface)->driver_api;
|
||||
|
@ -570,12 +582,14 @@ send:
|
|||
ret = api->send(net_if_get_device(iface), pkt);
|
||||
if (ret != 0) {
|
||||
eth_stats_update_errors_tx(iface);
|
||||
ethernet_remove_l2_header(pkt);
|
||||
goto error;
|
||||
}
|
||||
#if defined(CONFIG_NET_STATISTICS_ETHERNET)
|
||||
ethernet_update_tx_stats(iface, pkt);
|
||||
#endif
|
||||
ret = net_pkt_get_len(pkt);
|
||||
ethernet_remove_l2_header(pkt);
|
||||
|
||||
net_pkt_unref(pkt);
|
||||
error:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue