public inbox for dev@dpdk.org
 help / color / mirror / Atom feed
From: "Morten Brørup" <mb@smartsharesystems.com>
To: "Konstantin Ananyev" <konstantin.ananyev@huawei.com>,
	<dev@dpdk.org>, "Marat Khalili" <marat.khalili@huawei.com>
Cc: "Stephen Hemminger" <stephen@networkplumber.org>,
	"Christophe Fontaine" <cfontain@redhat.com>,
	"Konstantin Ananyev" <konstantin.v.ananyev@yandex.ru>,
	"Wathsala Vithanage" <wathsala.vithanage@arm.com>,
	<stable@dpdk.org>
Subject: RE: [PATCH v2] mbuf: fix read packet data
Date: Thu, 19 Mar 2026 14:55:11 +0100	[thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35F657A6@smartserver.smartshare.dk> (raw)
In-Reply-To: <71be4d5ba80847d3994012a082fc42d6@huawei.com>

> > diff --git a/lib/mbuf/rte_mbuf.c b/lib/mbuf/rte_mbuf.c
> > index a5d16e4c97..c2476e7704 100644
> > --- a/lib/mbuf/rte_mbuf.c
> > +++ b/lib/mbuf/rte_mbuf.c
> > @@ -795,7 +795,7 @@ const void *__rte_pktmbuf_read(const struct
> rte_mbuf
> > *m, uint32_t off,
> >  	const struct rte_mbuf *seg = m;
> >  	uint32_t buf_off = 0, copy_len;
> >
> > -	if (off + len > rte_pktmbuf_pkt_len(m))
> > +	if ((uint64_t)off + len > rte_pktmbuf_pkt_len(m))
> 
> Thanks Morten for addressing it.
> Just as a nit, for 32-bit systems, wouldn't it be more friendly:
> If (off + len < off || off + len > rte_pktmbuf_pkt_len(m))
> ?
> Same for comparison in rte_pktmbuf_read().

Neat trick.
I think expanding to 64 bit is easier readable, so I'd rather stick with that.

Also, while the trick is probably faster for 32 bit, there is a risk it could be slower for 64 bit, where I expect expanding to 64 bit has near zero cost.
We could solve that by adding #ifdefs for 32/64 bit architectures, but I think many people in the community would consider it clutter and object to it.

> With or without suggested change:
> Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>

Thanks, Konstantin. I'll keep it as is.

> 
> >  		return NULL;
> >
> >  	while (off >= rte_pktmbuf_data_len(seg)) {
> > diff --git a/lib/mbuf/rte_mbuf.h b/lib/mbuf/rte_mbuf.h
> > index 592af2388c..d6602f74bc 100644
> > --- a/lib/mbuf/rte_mbuf.h
> > +++ b/lib/mbuf/rte_mbuf.h
> > @@ -1843,7 +1843,7 @@ const void *__rte_pktmbuf_read(const struct
> rte_mbuf
> > *m, uint32_t off,
> >  static inline const void *rte_pktmbuf_read(const struct rte_mbuf *m,
> >  	uint32_t off, uint32_t len, void *buf)
> >  {
> > -	if (likely(off + len <= rte_pktmbuf_data_len(m)))
> > +	if (likely((uint64_t)off + len <= rte_pktmbuf_data_len(m)))
> >  		return rte_pktmbuf_mtod_offset(m, char *, off);
> >  	else
> >  		return __rte_pktmbuf_read(m, off, len, buf);
> > --
> > 2.43.0


  reply	other threads:[~2026-03-19 13:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-19  8:40 [PATCH] mbuf: fix read packet data Morten Brørup
2026-03-19  9:36 ` Marat Khalili
2026-03-19 12:43 ` [PATCH v2] " Morten Brørup
2026-03-19 13:15   ` Konstantin Ananyev
2026-03-19 13:55     ` Morten Brørup [this message]
2026-03-19 14:21   ` Marat Khalili
2026-03-19 14:31     ` Morten Brørup
2026-03-25 22:33   ` Thomas Monjalon

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=98CBD80474FA8B44BF855DF32C47DC35F657A6@smartserver.smartshare.dk \
    --to=mb@smartsharesystems.com \
    --cc=cfontain@redhat.com \
    --cc=dev@dpdk.org \
    --cc=konstantin.ananyev@huawei.com \
    --cc=konstantin.v.ananyev@yandex.ru \
    --cc=marat.khalili@huawei.com \
    --cc=stable@dpdk.org \
    --cc=stephen@networkplumber.org \
    --cc=wathsala.vithanage@arm.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