From: Martin Weiser <martin.weiser@allegro-packets.com>
To: "dev@dpdk.org" <dev@dpdk.org>
Subject: [PATCH] igc: fix invalid length and corrupted multi-segment mbufs
Date: Mon, 28 Oct 2024 14:51:23 +0100 [thread overview]
Message-ID: <5f0486a2-eb1e-4349-bdca-ee2c241379b3@allegro-packets.com> (raw)
The issue only appeared with hardware-timestamping enabled
(RTE_ETH_RX_OFFLOAD_TIMESTAMP).
The length of the prepended hardware timestamp was not subtracted from
the data length so that received packets were 16 bytes longer than
expected.
In scatter-gather mode only the first mbuf has a timestamp but the
data offset of the follow-up mbufs was not adjusted accordingly.
This caused 16 bytes of packet data to be missing between
the segments.
Signed-off-by: Martin Weiser <martin.weiser@allegro-packets.com>
---
drivers/net/igc/igc_txrx.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/net/igc/igc_txrx.c b/drivers/net/igc/igc_txrx.c
index d0cee1b016..2fafa91bd5 100644
--- a/drivers/net/igc/igc_txrx.c
+++ b/drivers/net/igc/igc_txrx.c
@@ -347,6 +347,8 @@ igc_recv_pkts(void *rx_queue, struct rte_mbuf
**rx_pkts, uint16_t nb_pkts)
rxm->data_off = RTE_PKTMBUF_HEADROOM;
data_len = rte_le_to_cpu_16(rxd.wb.upper.length) - rxq->crc_len;
+ if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
+ data_len -= IGC_TS_HDR_LEN;
rxm->data_len = data_len;
rxm->pkt_len = data_len;
rxm->nb_segs = 1;
@@ -509,6 +511,12 @@ igc_recv_scattered_pkts(void *rx_queue, struct
rte_mbuf **rx_pkts,
*/
rxm->data_off = RTE_PKTMBUF_HEADROOM;
data_len = rte_le_to_cpu_16(rxd.wb.upper.length);
+ if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
+ if (first_seg == NULL)
+ data_len -= IGC_TS_HDR_LEN;
+ else
+ rxm->data_off -= IGC_TS_HDR_LEN;
+ }
rxm->data_len = data_len;
/*
@@ -557,6 +565,7 @@ igc_recv_scattered_pkts(void *rx_queue, struct
rte_mbuf **rx_pkts,
last_seg->data_len = last_seg->data_len -
(RTE_ETHER_CRC_LEN - data_len);
last_seg->next = NULL;
+ rxm = last_seg;
} else {
rxm->data_len = (uint16_t)
(data_len - RTE_ETHER_CRC_LEN);
--
2.47.0
next reply other threads:[~2024-10-28 13:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-28 13:51 Martin Weiser [this message]
2024-10-28 14:17 Martin Weiser
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5f0486a2-eb1e-4349-bdca-ee2c241379b3@allegro-packets.com \
--to=martin.weiser@allegro-packets.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).