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]
Date:   Thu, 22 Jul 2021 20:42:50 -0700
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Kumar Kartikeya Dwivedi <memxor@...il.com>
Cc:     bpf <bpf@...r.kernel.org>, Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>,
        Jesper Dangaard Brouer <brouer@...hat.com>,
        Toke Høiland-Jørgensen <toke@...hat.com>,
        Networking <netdev@...r.kernel.org>
Subject: Re: [PATCH bpf-next v2 3/8] samples: bpf: Add BPF support for XDP
 samples helper

On Wed, Jul 21, 2021 at 2:28 PM Kumar Kartikeya Dwivedi
<memxor@...il.com> wrote:
>
> These eBPF tracepoint programs export data that is consumed by the
> helpers added in the previous commit.
>
> Also add support int the Makefile to generate a vmlinux.h header that
> would be used by other bpf.c files in later commits.
>
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@...il.com>
> ---
>  samples/bpf/Makefile         |  25 ++++
>  samples/bpf/xdp_sample.bpf.c | 215 +++++++++++++++++++++++++++++++++++
>  samples/bpf/xdp_sample.bpf.h |  57 ++++++++++
>  3 files changed, 297 insertions(+)
>  create mode 100644 samples/bpf/xdp_sample.bpf.c
>  create mode 100644 samples/bpf/xdp_sample.bpf.h
>

[...]

> +
> +SEC("tp_btf/xdp_cpumap_kthread")
> +int BPF_PROG(tp_xdp_cpumap_kthread, int map_id, unsigned int processed,
> +            unsigned int drops, int sched, struct xdp_cpumap_stats *xdp_stats)
> +{
> +       // Using xdp_stats directly fails verification

nit: C++ style comment

> +       u32 cpu = bpf_get_smp_processor_id();
> +       struct datarec *rec;
> +
> +       if (cpu < MAX_CPUS) {

tip: if you invert condition and exit early, the rest of your logic
will be less nested (same in few other places)

> +               rec = &sample_data.cpumap_kthread_cnt[cpu];
> +
> +               ATOMIC_ADD_NORMW(rec->processed, processed);
> +               ATOMIC_ADD_NORMW(rec->dropped, drops);
> +               ATOMIC_ADD_NORMW(rec->xdp_pass, xdp_stats->pass);
> +               ATOMIC_ADD_NORMW(rec->xdp_drop, xdp_stats->drop);
> +               ATOMIC_ADD_NORMW(rec->xdp_redirect, xdp_stats->redirect);
> +               /* Count times kthread yielded CPU via schedule call */
> +               if (sched)
> +                       ATOMIC_INC_NORMW(rec->issue);
> +       }
> +       return 0;
> +}
> +

[...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ