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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMOZA0+E0AJE3fcgtVe_NPJcSpGZHm4uFzpqH8iUHJvW4ZhnhQ@mail.gmail.com>
Date:   Mon, 18 Nov 2019 16:20:02 -0800
From:   Luigi Rizzo <lrizzo@...gle.com>
To:     Jakub Kicinski <jakub.kicinski@...ronome.com>
Cc:     magnus.karlsson@...el.com, bjorn.topel@...el.com,
        jonathan.lemon@...il.com, netdev@...r.kernel.org,
        bpf@...r.kernel.org, Luigi Rizzo <rizzo@....unipi.it>
Subject: Re: [PATCH] net-af_xdp: use correct number of channels from ethtool

On Mon, Nov 18, 2019 at 3:10 PM Jakub Kicinski
<jakub.kicinski@...ronome.com> wrote:
>
> On Mon, 18 Nov 2019 14:55:23 -0800, Luigi Rizzo wrote:
> > Drivers use different fields to report the number of channels, so take
> > the maximum of all fields (rx, tx, other, combined) when determining the
> > size of the xsk map. The current code used only 'combined' which was set
> > to 0 in some drivers e.g. mlx4.
> >
> > Tested: compiled and run xdpsock -q 3 -r -S on mlx4
> > Signed-off-by: Luigi Rizzo <lrizzo@...gle.com>
>
> thanks, this seems mostly correct
>
> > diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c
> > index 74d84f36a5b24..8e12269428d08 100644
> > --- a/tools/lib/bpf/xsk.c
> > +++ b/tools/lib/bpf/xsk.c
> > @@ -412,6 +412,11 @@ static int xsk_load_xdp_prog(struct xsk_socket *xsk)
> >       return 0;
> >  }
> >
> > +static inline int max_i(int a, int b)
> > +{
> > +     return a > b ? a : b;
> > +}
>
> There's already a max in tools/lib/bpf/libbpf_internal.h, could you
> possible just use that?

Sure, will send an updated patch. Note that the compiler is actually
picking the max()
macro from tools/include/linux/kernel,h which does not lend to  nesting due to
shadowing (it also requires a cast due to stricter type checking):

make: Entering directory 'upstream/tools/lib/bpf'
  CC       staticobjs/xsk.o
In file included from upstream/tools/include/uapi/linux/ethtool.h:17,
                 from xsk.c:18:
xsk.c: In function ‘xsk_get_max_queues’:
upstream/tools/include/linux/kernel.h:43:12: error: declaration of
‘_max1’ shadows a previous local [-Werror=shadow]
  typeof(x) _max1 = (x);   \
            ^~~~~
xsk.c:443:9: note: in expansion of macro ‘max’
   ret = max(max(channels.max_rx, channels.max_tx),

cheers
luigi

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ