net: ethernet: Remove L2 header stripping after TX

It seems that this change was solely added to address issues with old
TCP stack, which blindly queued packets intended for TX for potential
further retransmission, expecting that the packet would remain intact
during transmission.

I think this assumption was wrong, as it's natural that lower layers
append respective headers to the packet, and this "header stripping"
behavior was specific for Ethernet L2 only. If an upper layer expects
that the packet would need to be retransmitted at some point, it should
clone it instead.

Therefore, remove the L2 header stripping from the Ethernet L2 to avoid
any potential issues in zero-copy case.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
Robert Lubos 2025-01-21 13:12:34 +01:00 committed by Benjamin Cabé
parent 78c3996b59
commit 21b71224ac

View file

@ -671,23 +671,6 @@ static void ethernet_update_tx_stats(struct net_if *iface, struct net_pkt *pkt)
#define ethernet_update_tx_stats(...) #define ethernet_update_tx_stats(...)
#endif /* CONFIG_NET_STATISTICS_ETHERNET */ #endif /* CONFIG_NET_STATISTICS_ETHERNET */
static void ethernet_remove_l2_header(struct net_pkt *pkt)
{
size_t reserve = get_reserve_ll_header_size(net_pkt_iface(pkt));
struct net_buf *buf;
/* Remove the buffer added in ethernet_fill_header() */
if (reserve == 0U) {
buf = pkt->buffer;
pkt->buffer = buf->frags;
buf->frags = NULL;
net_pkt_frag_unref(buf);
} else {
net_buf_pull(pkt->buffer, reserve);
}
}
static int ethernet_send(struct net_if *iface, struct net_pkt *pkt) static int ethernet_send(struct net_if *iface, struct net_pkt *pkt)
{ {
const struct ethernet_api *api = net_if_get_device(iface)->api; const struct ethernet_api *api = net_if_get_device(iface)->api;
@ -794,14 +777,12 @@ send:
ret = net_l2_send(api->send, net_if_get_device(iface), iface, pkt); ret = net_l2_send(api->send, net_if_get_device(iface), iface, pkt);
if (ret != 0) { if (ret != 0) {
eth_stats_update_errors_tx(iface); eth_stats_update_errors_tx(iface);
ethernet_remove_l2_header(pkt);
goto arp_error; goto arp_error;
} }
ethernet_update_tx_stats(iface, pkt); ethernet_update_tx_stats(iface, pkt);
ret = net_pkt_get_len(pkt); ret = net_pkt_get_len(pkt);
ethernet_remove_l2_header(pkt);
net_pkt_unref(pkt); net_pkt_unref(pkt);
error: error: