From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
Reshma Pattan <reshma.pattan@intel.com>
Subject: [PATCH 2/7] pcapng: add additional mbuf if space required on copy
Date: Sun, 28 Dec 2025 10:40:15 -0800 [thread overview]
Message-ID: <20251228184300.541639-3-stephen@networkplumber.org> (raw)
In-Reply-To: <20251228184300.541639-1-stephen@networkplumber.org>
If comment is passed to rte_pcapng_copy(), additional space
maybe needed at the end of the mbuf. To handle this case generate
a segmented mbuf with additional space for the options.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/pcapng/rte_pcapng.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c
index 3067033e89..7c3c400c71 100644
--- a/lib/pcapng/rte_pcapng.c
+++ b/lib/pcapng/rte_pcapng.c
@@ -540,11 +540,24 @@ rte_pcapng_copy(uint16_t port_id, uint32_t queue,
if (comment)
optlen += pcapng_optlen(strlen(comment));
- /* reserve trailing options and block length */
+ /*
+ * Try to put options at the end of this mbuf.
+ * If not use an mbuf chain.
+ */
opt = (struct pcapng_option *)
rte_pktmbuf_append(mc, optlen + sizeof(uint32_t));
- if (unlikely(opt == NULL))
- goto fail;
+ if (unlikely(opt == NULL)) {
+ struct rte_mbuf *ml = rte_pktmbuf_alloc(mp);
+
+ if (unlikely(ml == NULL))
+ goto fail;
+
+ opt = (struct pcapng_option *)rte_pktmbuf_append(ml, optlen + sizeof(uint32_t));
+ if (unlikely(opt == NULL || rte_pktmbuf_chain(mc, ml) != 0)) {
+ rte_pktmbuf_free(ml);
+ goto fail;
+ }
+ }
switch (direction) {
case RTE_PCAPNG_DIRECTION_IN:
--
2.51.0
next prev parent reply other threads:[~2025-12-28 18:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-28 18:40 [PATCH 0/7] Fix build with gcc-16 Stephen Hemminger
2025-12-28 18:40 ` [PATCH 1/7] pcapng: use alloca instead of fixed buffer Stephen Hemminger
2025-12-28 18:40 ` Stephen Hemminger [this message]
2025-12-28 18:40 ` [PATCH 3/7] test: add more tests for comments in pcapng Stephen Hemminger
2025-12-28 18:40 ` [PATCH 4/7] test: vary size of packets in pcapng test Stephen Hemminger
2025-12-28 18:40 ` [PATCH 5/7] net/bnxt: fix uninitialized warning Stephen Hemminger
2025-12-28 18:40 ` [PATCH 6/7] common/cnxk: fix array out of bounds Stephen Hemminger
2025-12-28 18:40 ` [PATCH 7/7] examples/fips_validation: avoid rte_memcpy alignment restriction 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=20251228184300.541639-3-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=reshma.pattan@intel.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 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).