lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20221114193940.whiwpojrwast7tnl@soft-dev3-1>
Date:   Mon, 14 Nov 2022 20:39:40 +0100
From:   Horatiu Vultur <horatiu.vultur@...rochip.com>
To:     Alexander Lobakin <alexandr.lobakin@...el.com>
CC:     <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <bpf@...r.kernel.org>, <davem@...emloft.net>,
        <edumazet@...gle.com>, <kuba@...nel.org>, <pabeni@...hat.com>,
        <ast@...nel.org>, <daniel@...earbox.net>, <hawk@...nel.org>,
        <john.fastabend@...il.com>, <UNGLinuxDriver@...rochip.com>
Subject: Re: [PATCH net-next 1/5] net: lan966x: Add XDP_PACKET_HEADROOM

The 11/14/2022 15:16, Alexander Lobakin wrote:
> [Some people who received this message don't often get email from alexandr.lobakin@...el.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> 
> From: Horatiu Vultur <horatiu.vultur@...rochip.com>
> Date: Sun, 13 Nov 2022 12:15:55 +0100

Hi Olek,

> 
> > Update the page_pool params to allocate XDP_PACKET_HEADROOM space as
> > headroom for all received frames.
> > This is needed for when the XDP_TX and XDP_REDIRECT are implemented.
> >
> > Signed-off-by: Horatiu Vultur <horatiu.vultur@...rochip.com>
> > ---
> 
> [...]
> 
> > @@ -466,7 +472,8 @@ static struct sk_buff *lan966x_fdma_rx_get_frame(struct lan966x_rx *rx,
> >
> >       skb_mark_for_recycle(skb);
> >
> > -     skb_put(skb, FDMA_DCB_STATUS_BLOCKL(db->status));
> > +     skb_put(skb, FDMA_DCB_STATUS_BLOCKL(db->status) + XDP_PACKET_HEADROOM);
> > +     skb_pull(skb, XDP_PACKET_HEADROOM);
> 
> These two must be:
> 
> +       skb_reserve(skb, XDP_PACKET_HEADROOM);
>         skb_put(skb, FDMA_DCB_STATUS_BLOCKL(db->status));
> 
> i.e. you only need to add reserve, and that's it. It's not only
> faster, but also moves ::tail, which is essential.

Thanks for the suggestion. I will do that in the next version.

> 
> >
> >       lan966x_ifh_get_timestamp(skb->data, &timestamp);
> >
> 
> [...]
> 
> > --- a/drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c
> > +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c
> > @@ -44,8 +44,9 @@ int lan966x_xdp_run(struct lan966x_port *port, struct page *page, u32 data_len)
> >
> >       xdp_init_buff(&xdp, PAGE_SIZE << lan966x->rx.page_order,
> >                     &port->xdp_rxq);
> > -     xdp_prepare_buff(&xdp, page_address(page), IFH_LEN_BYTES,
> > -                      data_len - IFH_LEN_BYTES, false);
> > +     xdp_prepare_buff(&xdp, page_address(page),
> > +                      IFH_LEN_BYTES + XDP_PACKET_HEADROOM,
> > +                      data_len - IFH_LEN_BYTES - XDP_PACKET_HEADROOM, false);
> 
> Are you sure you need to substract %XDP_PACKET_HEADROOM from
> @data_len? I think @data_len is the frame length, so headroom is not
> included?

Actually @data_len contains also the XDP_PACKET_HEADROOM. I am calling
lan966x_xdp_run like this:

---
return lan966x_xdp_run(port, page,
		       FDMA_DCB_STATUS_BLOCKL(db->status) + XDP_PACKET_HEADROOM);
---

But from what I can see, that doesn't make too much sense.
Because I am adding here the XDP_PACKET_HEADROOM and then remove it in
xdp_prepare_buff. So it would be better not to add it at all.

> 
> >       act = bpf_prog_run_xdp(xdp_prog, &xdp);
> >       switch (act) {
> >       case XDP_PASS:
> > --
> > 2.38.0
> 
> Thanks,
> Olek

-- 
/Horatiu

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ