Skip to content

Commit

Permalink
net: ethernet: Remove L2 header stripping after TX
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
rlubos authored and kartben committed Jan 23, 2025
1 parent 78c3996 commit 21b7122
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions subsys/net/l2/ethernet/ethernet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -794,14 +777,12 @@ static int ethernet_send(struct net_if *iface, struct net_pkt *pkt)
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:
Expand Down

0 comments on commit 21b7122

Please sign in to comment.