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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4BzYU2xZkUvK-JP53jrKXnWryACHsaX4JO_trEn=1N9-k1A@mail.gmail.com>
Date:   Wed, 22 Jan 2020 13:53:45 -0800
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Martin KaFai Lau <kafai@...com>
Cc:     bpf <bpf@...r.kernel.org>, Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        David Miller <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Kernel Team <kernel-team@...com>,
        Networking <netdev@...r.kernel.org>
Subject: Re: [PATCH v2 bpf-next 3/3] bpf: tcp: Add bpf_cubic example

On Tue, Jan 21, 2020 at 10:42 PM Martin KaFai Lau <kafai@...com> wrote:
>
> This patch adds a bpf_cubic example.  Some highlights:
> 1. CONFIG_HZ .kconfig map is used.
> 2. In bictcp_update(), calculation is changed to use usec
>    resolution (i.e. USEC_PER_JIFFY) instead of using jiffies.
>    Thus, usecs_to_jiffies() is not used in the bpf_cubic.c.
> 3. In bitctcp_update() [under tcp_friendliness], the original
>    "while (ca->ack_cnt > delta)" loop is changed to the equivalent
>    "ca->ack_cnt / delta" operation.
>
> Signed-off-by: Martin KaFai Lau <kafai@...com>
> ---

just my few cents below...

[...]

>
> +static void test_cubic(void)
> +{
> +       struct bpf_cubic *cubic_skel;
> +       struct bpf_link *link;
> +
> +       cubic_skel = bpf_cubic__open_and_load();
> +       if (CHECK(!cubic_skel, "bpf_cubic__open_and_load", "failed\n"))
> +               return;
> +
> +       link = bpf_map__attach_struct_ops(cubic_skel->maps.cubic);

we should probably teach bpftool and libbpf to generate a link for
struct_ops map and also auto-attach it as part of skeleton's attach...
I'll add it if noone gets to it sooner

> +       if (CHECK(IS_ERR(link), "bpf_map__attach_struct_ops", "err:%ld\n",
> +                 PTR_ERR(link))) {
> +               bpf_cubic__destroy(cubic_skel);
> +               return;
> +       }
> +
> +       do_test("bpf_cubic");
> +
> +       bpf_link__destroy(link);
> +       bpf_cubic__destroy(cubic_skel);
> +}
> +

[...]

> +
> +extern unsigned long CONFIG_HZ __kconfig __weak;

you probably don't want __weak, if CONFIG_HZ is not defined in
Kconfig, then something wrong is going on, probably, so it's better to
error out early

> +#define HZ CONFIG_HZ
> +#define USEC_PER_MSEC  1000UL
> +#define USEC_PER_SEC   1000000UL
> +#define USEC_PER_JIFFY (USEC_PER_SEC / HZ)
> +

[...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ