From 21b71224ac2ad48d15870b6b4a2ca3837e47acfa Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Tue, 21 Jan 2025 13:12:34 +0100 Subject: [PATCH] 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 --- subsys/net/l2/ethernet/ethernet.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/subsys/net/l2/ethernet/ethernet.c b/subsys/net/l2/ethernet/ethernet.c index fc34251a6a1..fd1fcb0cd66 100644 --- a/subsys/net/l2/ethernet/ethernet.c +++ b/subsys/net/l2/ethernet/ethernet.c @@ -671,23 +671,6 @@ static void ethernet_update_tx_stats(struct net_if *iface, struct net_pkt *pkt) #define ethernet_update_tx_stats(...) #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) { 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); if (ret != 0) { eth_stats_update_errors_tx(iface); - ethernet_remove_l2_header(pkt); goto arp_error; } ethernet_update_tx_stats(iface, pkt); ret = net_pkt_get_len(pkt); - ethernet_remove_l2_header(pkt); net_pkt_unref(pkt); error: