Netdev List
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: bpf <bpf@vger.kernel.org>,
	"Network Development" <netdev@vger.kernel.org>,
	"Lorenzo Bianconi" <lorenzo.bianconi@redhat.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Jesper Dangaard Brouer" <brouer@redhat.com>,
	"Toke Høiland-Jørgensen" <toke@redhat.com>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Toshiaki Makita" <toshiaki.makita1@gmail.com>
Subject: Re: [PATCH bpf-next] net: veth: account total xdp_frame len running ndo_xdp_xmit
Date: Thu, 10 Feb 2022 18:34:49 +0100	[thread overview]
Message-ID: <YgVMufwV+z7HYfH0@lore-desk> (raw)
In-Reply-To: <CAADnVQJoWF8co=9YNdvQkziwsOAoqw=p134aHTL9YZ82=QJcRA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1753 bytes --]

> On Tue, Feb 1, 2022 at 2:46 AM Lorenzo Bianconi <lorenzo@kernel.org> wrote:
> >
> > Introduce xdp_get_frame_len utility routine to get the xdp_frame full
> > length and account total frame size running XDP_REDIRECT of a
> > non-linear xdp frame into a veth device.
> >
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > ---
> >  drivers/net/veth.c |  4 ++--
> >  include/net/xdp.h  | 14 ++++++++++++++
> >  2 files changed, 16 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/veth.c b/drivers/net/veth.c
> > index 354a963075c5..22ecaf8b8f98 100644
> > --- a/drivers/net/veth.c
> > +++ b/drivers/net/veth.c
> > @@ -493,7 +493,7 @@ static int veth_xdp_xmit(struct net_device *dev, int n,
> >                 struct xdp_frame *frame = frames[i];
> >                 void *ptr = veth_xdp_to_ptr(frame);
> >
> > -               if (unlikely(frame->len > max_len ||
> > +               if (unlikely(xdp_get_frame_len(frame) > max_len ||
> >                              __ptr_ring_produce(&rq->xdp_ring, ptr)))
> >                         break;
> 
> Looks correct, but could you explain what happens without this fix?

I guess this is just a theoretical issue, since at the moment we can't perform
a XDP_REDIRECT with a non-linear xdp buffer, but without this patch we will fail
to account peer max packet size since we take care of just the linear part of
the xdp_buff.
I am working on adding xdp multi-buff support to veth driver so I will repost this
patch into the series.

> 
> Any other drivers might have the same issue?

I do not think so since other drivers are not able to map multi-frags yet (veth
already support it since we run __xdp_build_skb_from_frame()).

Regards,
Lorenzo

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

      reply	other threads:[~2022-02-10 17:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-01 10:46 [PATCH bpf-next] net: veth: account total xdp_frame len running ndo_xdp_xmit Lorenzo Bianconi
2022-02-08  2:39 ` Alexei Starovoitov
2022-02-10 17:34   ` Lorenzo Bianconi [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=YgVMufwV+z7HYfH0@lore-desk \
    --to=lorenzo@kernel.org \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=brouer@redhat.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=toke@redhat.com \
    --cc=toshiaki.makita1@gmail.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