All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Xingui Yang <yangxingui@huawei.com>
Cc: <dev@dpdk.org>, <david.marchand@redhat.com>,
	<aman.deep.singh@intel.com>, <fengchengwen@huawei.com>,
	<lihuisong@huawei.com>, <liuyonglong@huawei.com>,
	<kangfenglong@huawei.com>
Subject: Re: [PATCH v4] app/testpmd: support runt frames in txonly
Date: Sun, 9 Aug 2026 12:18:08 -0700	[thread overview]
Message-ID: <20260809121808.6cdaabe6@phoenix.local> (raw)
In-Reply-To: <20260807061727.1687254-1-yangxingui@huawei.com>

On Fri, 7 Aug 2026 14:17:27 +0800
Xingui Yang <yangxingui@huawei.com> wrote:

> Allow setting transmit size to be a small value which has Ethernet
> header but no IP or UDP header, since control level protocols can be
> very short.
> 
> Checksum offloads are disabled when headers are incomplete.
> copy_buf_to_pkt_segs stops at the last segment to prevent OOB access.
> 
> Suggested-by: Stephen Hemminger <stephen@networkplumber.org>
> Signed-off-by: Xingui Yang <yangxingui@huawei.com>
> ---
> Changes in v4:
> - Removed ultra-small frame support (< 14 bytes) per Stephen's review.
> ---

Still some issues reported by AI.
Also not sure why your email keeps ending up in Spam folder.

Reviewed v4 against main (c1a46b9). Applies cleanly, builds clean with
-Dwerror=true.

Error
-----

app/test-pmd/config.c: set_tx_pkt_segments() is shared with the flowgen
forwarding engine ("set txpkts" is documented as setting the length for
FLOWGEN too), and flowgen still assumes the old 42 byte minimum:

	unsigned pkt_size = tx_pkt_length - 4;	/* Adjust FCS */
	...
	pkt->data_len = pkt_size;
	ip_hdr->total_length = RTE_CPU_TO_BE_16(pkt_size - sizeof(*eth_hdr));
	udp_hdr->dgram_len = RTE_CPU_TO_BE_16(pkt_size - sizeof(*eth_hdr) -
					      sizeof(*udp_hdr));

With "set txpkts 14", pkt_size is 10. Both length fields underflow in
unsigned arithmetic and are truncated to 16 bits, and flowgen emits
10 byte frames - shorter than the Ethernet header this patch is trying
to guarantee. It also writes 42 bytes of header into an mbuf whose
data_len is 10.

Confirmed:

  dpdk-testpmd --vdev='net_pcap0,rx_iface=lo,tx_pcap=/tmp/fg.pcap' -- \
	--txpkts=14 --forward-mode=flowgen

  every captured frame is 10 bytes: 00010203040100010203

flowgen_begin() should reject tx_pkt_length below
sizeof(rte_ether_hdr) + sizeof(rte_ipv4_hdr) + sizeof(rte_udp_hdr) + 4,
the same way tx_only_begin() guards the split and multi-flow cases.

Warning
-------

doc/guides/testpmd_app_ug/testpmd_funcs.rst: the note listing what
cannot be combined with runt lengths omits "set txtimes".
tx_only_begin() additionally requires sizeof(struct tx_timestamp)
beyond the 42 byte header stack when timestamping is enabled, so runt
lengths fail with -EINVAL there as well.

Info
----

app/test-pmd/txonly.c: the l3_len clamp and the ol_flags masking are
recomputed per packet in the fast path, but the result is invariant.
TX_PKT_SPLIT_RND is already rejected when the first segment is short,
so pkt_len does not vary across packets. Both could be decided once in
tx_only_begin().

app/test-pmd/config.c: the first sentence of the rewritten comment is
still wrong - the loop rejects segments *larger* than
mbuf_data_size[0], not smaller. Worth fixing while touching it.

doc/guides/testpmd_app_ug/testpmd_funcs.rst: spelling out "14 bytes"
reads better than sizeof(struct rte_ether_hdr) in a user guide.

      reply	other threads:[~2026-08-09 19:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-07  6:17 [PATCH v4] app/testpmd: support runt frames in txonly Xingui Yang
2026-08-09 19:18 ` Stephen Hemminger [this message]

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=20260809121808.6cdaabe6@phoenix.local \
    --to=stephen@networkplumber.org \
    --cc=aman.deep.singh@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=fengchengwen@huawei.com \
    --cc=kangfenglong@huawei.com \
    --cc=lihuisong@huawei.com \
    --cc=liuyonglong@huawei.com \
    --cc=yangxingui@huawei.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.