[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c744b787-1f46-fc2e-d921-e2c356a9f849@fb.com>
Date: Wed, 9 Oct 2019 17:37:50 +0000
From: Alexei Starovoitov <ast@...com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>,
Alexei Starovoitov <ast@...nel.org>
CC: "David S. Miller" <davem@...emloft.net>,
Daniel Borkmann <daniel@...earbox.net>,
"x86@...nel.org" <x86@...nel.org>,
Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
Kernel Team <Kernel-team@...com>
Subject: Re: [PATCH bpf-next 10/10] selftests/bpf: add kfree_skb raw_tp test
On 10/8/19 10:36 PM, Andrii Nakryiko wrote:
> On Fri, Oct 4, 2019 at 10:04 PM Alexei Starovoitov <ast@...nel.org> wrote:
>>
>> Load basic cls_bpf program.
>> Load raw_tracepoint program and attach to kfree_skb raw tracepoint.
>> Trigger cls_bpf via prog_test_run.
>> At the end of test_run kernel will call kfree_skb
>> which will trigger trace_kfree_skb tracepoint.
>> Which will call our raw_tracepoint program.
>> Which will take that skb and will dump it into perf ring buffer.
>> Check that user space received correct packet.
>>
>> Signed-off-by: Alexei Starovoitov <ast@...nel.org>
>> ---
>
> LGTM, few minor nits below.
>
> Acked-by: Andrii Nakryiko <andriin@...com>
>
>
>> .../selftests/bpf/prog_tests/kfree_skb.c | 90 +++++++++++++++++++
>> tools/testing/selftests/bpf/progs/kfree_skb.c | 76 ++++++++++++++++
>> 2 files changed, 166 insertions(+)
>> create mode 100644 tools/testing/selftests/bpf/prog_tests/kfree_skb.c
>> create mode 100644 tools/testing/selftests/bpf/progs/kfree_skb.c
>>
>> diff --git a/tools/testing/selftests/bpf/prog_tests/kfree_skb.c b/tools/testing/selftests/bpf/prog_tests/kfree_skb.c
>> new file mode 100644
>> index 000000000000..238bc7024b36
>> --- /dev/null
>> +++ b/tools/testing/selftests/bpf/prog_tests/kfree_skb.c
>> @@ -0,0 +1,90 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +#include <test_progs.h>
>> +
>> +static void on_sample(void *ctx, int cpu, void *data, __u32 size)
>> +{
>> + int ifindex = *(int *)data, duration = 0;
>> + struct ipv6_packet * pkt_v6 = data + 4;
>> +
>> + if (ifindex != 1)
>> + /* spurious kfree_skb not on loopback device */
>> + return;
>> + if (CHECK(size != 76, "check_size", "size %d != 76\n", size))
>
> compiler doesn't complain about %d and size being unsigned?
compile didn't complain. but I fixed it.
>> +SEC("raw_tracepoint/kfree_skb")
>> +int trace_kfree_skb(struct trace_kfree_skb* ctx)
>> +{
>> + struct sk_buff *skb = ctx->skb;
>> + struct net_device *dev;
>> + int ifindex;
>> + struct callback_head *ptr;
>> + void *func;
>
> nit: style checker should have complained about missing empty line
good point. Fixed checkpatch errors.
Powered by blists - more mailing lists