Re: [PATCH net-next v3 5/7] net: devmem: add ring parameter filtering

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 4, 2024 at 3:29 AM Mina Almasry <almasrymina@xxxxxxxxxx> wrote:
>

Hi Mina,
Thanks a lot for the review!

> On Thu, Oct 3, 2024 at 9:07 AM Taehee Yoo <ap420073@xxxxxxxxx> wrote:
> >
> > If driver doesn't support ring parameter or tcp-data-split configuration
> > is not sufficient, the devmem should not be set up.
> > Before setup the devmem, tcp-data-split should be ON and
> > tcp-data-split-thresh value should be 0.
> >
> > Signed-off-by: Taehee Yoo <ap420073@xxxxxxxxx>
> > ---
> >
> > v3:
> >  - Patch added.
> >
> >  net/core/devmem.c | 18 ++++++++++++++++++
> >  1 file changed, 18 insertions(+)
> >
> > diff --git a/net/core/devmem.c b/net/core/devmem.c
> > index 11b91c12ee11..a9e9b15028e0 100644
> > --- a/net/core/devmem.c
> > +++ b/net/core/devmem.c
> > @@ -8,6 +8,8 @@
> >   */
> >
> >  #include <linux/dma-buf.h>
> > +#include <linux/ethtool.h>
> > +#include <linux/ethtool_netlink.h>
> >  #include <linux/genalloc.h>
> >  #include <linux/mm.h>
> >  #include <linux/netdevice.h>
> > @@ -131,6 +133,8 @@ int net_devmem_bind_dmabuf_to_queue(struct net_device *dev, u32 rxq_idx,
> >                                     struct net_devmem_dmabuf_binding *binding,
> >                                     struct netlink_ext_ack *extack)
> >  {
> > +       struct kernel_ethtool_ringparam kernel_ringparam = {};
> > +       struct ethtool_ringparam ringparam = {};
> >         struct netdev_rx_queue *rxq;
> >         u32 xa_idx;
> >         int err;
> > @@ -146,6 +150,20 @@ int net_devmem_bind_dmabuf_to_queue(struct net_device *dev, u32 rxq_idx,
> >                 return -EEXIST;
> >         }
> >
> > +       if (!dev->ethtool_ops->get_ringparam) {
> > +               NL_SET_ERR_MSG(extack, "can't get ringparam");
> > +               return -EINVAL;
> > +       }
> > +
> > +       dev->ethtool_ops->get_ringparam(dev, &ringparam,
> > +                                       &kernel_ringparam, extack);
> > +       if (kernel_ringparam.tcp_data_split != ETHTOOL_TCP_DATA_SPLIT_ENABLED ||
>
> The way I had set this up is that the driver checks whether header
> split is enabled, and only sets PP_FLAG_ALLOW_UNREADABLE_NETMEM if it
> is. Then core detects that the driver did not allow unreadable netmem
> and it fails that way.
>
> This check is redundant with that. I'm not 100% opposed to redundant
> checks. Maybe they will add some reliability, but also maybe they will
> be confusing to check the same thing essentially in 2 places.
>
> Is the PP_FLAG_ALLOW_UNREADABLE_NETMEM trick not sufficient for you?

Ah okay, I understand.
It looks like it's already validated enough based on
PP_FLAG_ALLOW_UNREADABLE_NETMEM.
I tested how you guided it, and it works as you intended.
It's a duplicated validation indeed, so I will drop this patch in a v4.

Thanks a lot!
Taehee Yoo

>
> > +           kernel_ringparam.tcp_data_split_thresh) {
> > +               NL_SET_ERR_MSG(extack,
> > +                              "tcp-header-data-split is disabled or threshold is not zero");
> > +               return -EINVAL;
> > +       }
> > +
> >  #ifdef CONFIG_XDP_SOCKETS
> >         if (rxq->pool) {
> >                 NL_SET_ERR_MSG(extack, "designated queue already in use by AF_XDP");
> > --
> > 2.34.1
> >
>
>
> --
> Thanks,
> Mina





[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux