Skip to content

Commit 156d3b2

Browse files
rluboskapbh
authored andcommitted
[nrf fromtree] 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 <[email protected]> (cherry picked from commit 21b7122)
1 parent 88eb600 commit 156d3b2

File tree

1 file changed

+0
-19
lines changed

1 file changed

+0
-19
lines changed

subsys/net/l2/ethernet/ethernet.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -664,23 +664,6 @@ static void ethernet_update_tx_stats(struct net_if *iface, struct net_pkt *pkt)
664664
#define ethernet_update_tx_stats(...)
665665
#endif /* CONFIG_NET_STATISTICS_ETHERNET */
666666

667-
static void ethernet_remove_l2_header(struct net_pkt *pkt)
668-
{
669-
size_t reserve = get_reserve_ll_header_size(net_pkt_iface(pkt));
670-
struct net_buf *buf;
671-
672-
/* Remove the buffer added in ethernet_fill_header() */
673-
if (reserve == 0U) {
674-
buf = pkt->buffer;
675-
pkt->buffer = buf->frags;
676-
buf->frags = NULL;
677-
678-
net_pkt_frag_unref(buf);
679-
} else {
680-
net_buf_pull(pkt->buffer, reserve);
681-
}
682-
}
683-
684667
static int ethernet_send(struct net_if *iface, struct net_pkt *pkt)
685668
{
686669
const struct ethernet_api *api = net_if_get_device(iface)->api;
@@ -816,14 +799,12 @@ static int ethernet_send(struct net_if *iface, struct net_pkt *pkt)
816799
ret = net_l2_send(api->send, net_if_get_device(iface), iface, pkt);
817800
if (ret != 0) {
818801
eth_stats_update_errors_tx(iface);
819-
ethernet_remove_l2_header(pkt);
820802
goto arp_error;
821803
}
822804

823805
ethernet_update_tx_stats(iface, pkt);
824806

825807
ret = net_pkt_get_len(pkt);
826-
ethernet_remove_l2_header(pkt);
827808

828809
net_pkt_unref(pkt);
829810
error:

0 commit comments

Comments
 (0)