[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180120035944.xzpvvuikso46v7tt@ast-mbp>
Date: Fri, 19 Jan 2018 19:59:45 -0800
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Lawrence Brakmo <brakmo@...com>
Cc: netdev <netdev@...r.kernel.org>, Kernel Team <kernel-team@...com>,
Blake Matheny <bmatheny@...com>,
Alexei Starovoitov <ast@...com>,
Daniel Borkmann <daniel@...earbox.net>,
Eric Dumazet <eric.dumazet@...il.com>,
Neal Cardwell <ncardwell@...gle.com>,
Yuchung Cheng <ycheng@...gle.com>
Subject: Re: [PATCH bpf-next v6 11/11] bpf: add selftest for tcpbpf
On Fri, Jan 19, 2018 at 05:45:48PM -0800, Lawrence Brakmo wrote:
> Added a selftest for tcpbpf (sock_ops) that checks that the appropriate
> callbacks occured and that it can access tcp_sock fields and that their
> values are correct.
>
> Run with command: ./test_tcpbpf_user
>
> Signed-off-by: Lawrence Brakmo <brakmo@...com>
...
> + __u32 key = 0;
> + struct tcpbpf_globals g, *gp;
> +
> + gp = bpf_map_lookup_elem(&global_map, &key);
> + if (gp == NULL) {
> + struct tcpbpf_globals g = {0, 0, 0, 0, 0, 0, 0, 0};
> +
> + g.event_map |= (1 << event);
> + bpf_map_update_elem(&global_map, &key, &g,
> + BPF_ANY);
> + } else {
> + g = *gp;
> + g.event_map |= (1 << event);
> + bpf_map_update_elem(&global_map, &key, &g,
> + BPF_ANY);
...
> + __u32 key = 0;
> + struct tcpbpf_globals g, *gp;
> +
> + gp = bpf_map_lookup_elem(&global_map, &key);
> + if (!gp)
> + break;
> + g = *gp;
> + g.bad_cb_test_rv = bad_call_rv;
> + g.good_cb_test_rv = good_call_rv;
> + bpf_map_update_elem(&global_map, &key, &g,
> + BPF_ANY);
since 'g' is an array of one element and the tests designed
for single flow anyway, there is no need to use map_update_elem.
the program can directly assign into fields like:
gp->bad_cb_test_rv = bad_call_rv;
gp->good_cb_test_rv = good_call_rv;
probably not worth respining just for that. Mainly fyi.
Acked-by: Alexei Starovoitov <ast@...nel.org>
Powered by blists - more mailing lists