On Fri, 7 Aug 2026 14:17:27 +0800 Xingui Yang <[email protected]> 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 <[email protected]> > Signed-off-by: Xingui Yang <[email protected]> > --- > 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.

