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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAF=yD-KSZnnA+ntcBnW5Ohrb--OedbSuhqWVhcrxze6zH0-mFw@mail.gmail.com>
Date:   Tue, 24 Apr 2018 12:58:04 -0400
From:   Willem de Bruijn <willemdebruijn.kernel@...il.com>
To:     Björn Töpel <bjorn.topel@...il.com>
Cc:     "Karlsson, Magnus" <magnus.karlsson@...el.com>,
        Alexander Duyck <alexander.h.duyck@...el.com>,
        Alexander Duyck <alexander.duyck@...il.com>,
        John Fastabend <john.fastabend@...il.com>,
        Alexei Starovoitov <ast@...com>,
        Jesper Dangaard Brouer <brouer@...hat.com>,
        Daniel Borkmann <daniel@...earbox.net>,
        "Michael S. Tsirkin" <mst@...hat.com>,
        Network Development <netdev@...r.kernel.org>,
        michael.lundkvist@...csson.com,
        "Brandeburg, Jesse" <jesse.brandeburg@...el.com>,
        "Singhai, Anjali" <anjali.singhai@...el.com>,
        "Zhang, Qi Z" <qi.z.zhang@...el.com>
Subject: Re: [PATCH bpf-next 14/15] xsk: statistics support

On Mon, Apr 23, 2018 at 9:56 AM, Björn Töpel <bjorn.topel@...il.com> wrote:
> From: Magnus Karlsson <magnus.karlsson@...el.com>
>
> In this commit, a new getsockopt is added: XDP_STATISTICS. This is
> used to obtain stats from the sockets.
>
> Signed-off-by: Magnus Karlsson <magnus.karlsson@...el.com>

> +static int xsk_getsockopt(struct socket *sock, int level, int optname,
> +                         char __user *optval, int __user *optlen)
> +{
> +       struct sock *sk = sock->sk;
> +       struct xdp_sock *xs = xdp_sk(sk);
> +       int len;
> +
> +       if (level != SOL_XDP)
> +               return -ENOPROTOOPT;
> +
> +       if (get_user(len, optlen))
> +               return -EFAULT;
> +       if (len < 0)
> +               return -EINVAL;
> +
> +       switch (optname) {
> +       case XDP_STATISTICS:
> +       {
> +               struct xdp_statistics stats;
> +
> +               if (len != sizeof(stats))
> +                       return -EINVAL;
> +
> +               mutex_lock(&xs->mutex);
> +               stats.rx_dropped = xs->rx_dropped;
> +               stats.rx_invalid_descs = xskq_nb_invalid_descs(xs->rx);
> +               stats.tx_invalid_descs = xskq_nb_invalid_descs(xs->tx);
> +               mutex_unlock(&xs->mutex);
> +
> +               if (copy_to_user(optval, &stats, sizeof(stats)))
> +                       return -EFAULT;
> +               return 0;

For forward compatibility, could allow caller to pass a struct larger
than stats and return the number of bytes filled in.

The lock can also be elided with something like gnet_stats, but it is probably
taken rarely enough that that is not worth the effort, at least right now.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ