From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
mukawa@igel.co.jp, stable@dpdk.org,
Tetsuya Mukawa <mtetsuyah@gmail.com>,
Bernard Iremonger <bernard.iremonger@intel.com>
Subject: [PATCH 2/4] net/null: fix packet copy
Date: Wed, 26 Mar 2025 14:35:26 -0700 [thread overview]
Message-ID: <20250326213608.581345-3-stephen@networkplumber.org> (raw)
In-Reply-To: <20250326213608.581345-1-stephen@networkplumber.org>
If doing copy on transmit, can potentially copy past the data
in the mbuf. Change to only copy data from that segment.
Fixes: c743e50c475f ("null: new poll mode driver")
Cc: mukawa@igel.co.jp
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/null/rte_eth_null.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 3a05af2e32..baae81c572 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -35,7 +35,7 @@ struct null_queue {
struct pmd_internals *internals;
struct rte_mempool *mb_pool;
- struct rte_mbuf *dummy_packet;
+ void *dummy_packet;
RTE_ATOMIC(uint64_t) rx_pkts;
RTE_ATOMIC(uint64_t) tx_pkts;
@@ -156,14 +156,14 @@ eth_null_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
static uint16_t
eth_null_copy_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
{
- int i;
struct null_queue *h = q;
- unsigned int packet_size;
+ unsigned int i;
- packet_size = h->internals->packet_size;
for (i = 0; i < nb_bufs; i++) {
- rte_memcpy(h->dummy_packet, rte_pktmbuf_mtod(bufs[i], void *),
- packet_size);
+ struct rte_mbuf *m = bufs[i];
+ unsigned int len = RTE_MIN(h->internals->packet_size, m->data_len);
+
+ rte_memcpy(h->dummy_packet, rte_pktmbuf_mtod(m, void *), len);
rte_pktmbuf_free(bufs[i]);
}
--
2.47.2
next prev parent reply other threads:[~2025-03-26 21:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-26 21:35 [PATCH 0/4] net/null optimizations Stephen Hemminger
2025-03-26 21:35 ` [PATCH 1/4] net/null: Tx optimizations Stephen Hemminger
2025-03-26 21:35 ` Stephen Hemminger [this message]
2025-03-26 21:35 ` [PATCH 3/4] net/null: optimize Rx Stephen Hemminger
2025-03-26 21:35 ` [PATCH 4/4] net/null: count all queues Stephen Hemminger
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=20250326213608.581345-3-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=bernard.iremonger@intel.com \
--cc=dev@dpdk.org \
--cc=mtetsuyah@gmail.com \
--cc=mukawa@igel.co.jp \
--cc=stable@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).