[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YR0NFQCsNH3x6kfx@lore-desk>
Date: Wed, 18 Aug 2021 15:37:25 +0200
From: Lorenzo Bianconi <lorenzo.bianconi@...hat.com>
To: Toke Høiland-Jørgensen <toke@...hat.com>
Cc: Lorenzo Bianconi <lorenzo@...nel.org>, bpf@...r.kernel.org,
netdev@...r.kernel.org, davem@...emloft.net, kuba@...nel.org,
ast@...nel.org, daniel@...earbox.net, shayagr@...zon.com,
john.fastabend@...il.com, dsahern@...nel.org, brouer@...hat.com,
echaudro@...hat.com, jasowang@...hat.com,
alexander.duyck@...il.com, saeed@...nel.org,
maciej.fijalkowski@...el.com, magnus.karlsson@...el.com,
tirthendu.sarkar@...el.com
Subject: Re: [PATCH v11 bpf-next 17/18] net: xdp: introduce
bpf_xdp_adjust_data helper
> Lorenzo Bianconi <lorenzo.bianconi@...hat.com> writes:
>
> >> Lorenzo Bianconi <lorenzo@...nel.org> writes:
> >>
> > [...]
> >> > + * Description
> >> > + * For XDP frames split over multiple buffers, the
> >> > + * *xdp_md*\ **->data** and*xdp_md *\ **->data_end** pointers
> >> > + * will point to the start and end of the first fragment only.
> >> > + * This helper can be used to access subsequent fragments by
> >> > + * moving the data pointers. To use, an XDP program can call
> >> > + * this helper with the byte offset of the packet payload that
> >> > + * it wants to access; the helper will move *xdp_md*\ **->data**
> >> > + * and *xdp_md *\ **->data_end** so they point to the requested
> >> > + * payload offset and to the end of the fragment containing this
> >> > + * byte offset, and return the byte offset of the start of the
> >> > + * fragment.
> >>
> >> This comment is wrong now :)
> >
> > actually we are still returning the byte offset of the start of the fragment
> > (base_offset).
>
> Hmm, right, I was looking at the 'return 0':
>
> > +BPF_CALL_2(bpf_xdp_adjust_data, struct xdp_buff *, xdp, u32, offset)
> > +{
> > + struct skb_shared_info *sinfo = xdp_get_shared_info_from_buff(xdp);
> > + u32 base_offset = xdp->mb.headlen;
> > + int i;
> > +
> > + if (!xdp_buff_is_mb(xdp) || offset > sinfo->xdp_frags_size)
> > + return -EINVAL;
> > +
> > + if (offset < xdp->mb.headlen) {
> > + /* linear area */
> > + xdp->data = xdp->data_hard_start + xdp->mb.headroom;
> > + xdp->data_end = xdp->data + xdp->mb.headlen;
> > + return 0;
> > + }
>
> But I guess that's an offset; but that means the helper is not doing
> what it says it's doing if it's within the first fragment. That should
> probably be made consistent... :)
ack, right. I will fix it in v12, thanks.
Regards,
Lorenzo
>
> -Toke
>
Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)
Powered by blists - more mailing lists