lkml.org 
[lkml]   [2022]   [Nov]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: Re: [PATCH bpf-next] samples/bpf: Fix sockex3: missing BPF prog type
On Thu, Nov 3, 2022 at 8:17 PM Rong Tao <rtoax@foxmail.com> wrote:
>
> We can not just remove the number of program like:
>
> -#define PROG(F) SEC("socket/"__stringify(F)) int bpf_func_##F
> +#define PROG(F) SEC("socket_filter") int bpf_func_##F
>
> because "sockex3" use the _NUMBER_ as index(see map "jmp_table"), if we
> apply the following patch, it's still not recognize "socket_filter/xxx"
> as "socket_filter", still have "missing BPF prog type" error:

Ok, let's keep unwinding this. This is an old and manual way to set up
tail call map. Libbpf supports declarative way to do, so
sockex3_user.c won't have to do anything at all.

See progs/test_prog_array_init.c for an example. Let's convert samples
to use this as well.

This programmatic setting of program type works, there is no doubt
about this. But it's a signal that something is not exactly how it
should be. So let's use this as an opportunity to modernize samples,
instead of adding workarounds.

I hope you sympathize with this goal.

>
> diff --git a/samples/bpf/sockex3_kern.c b/samples/bpf/sockex3_kern.c
> index b363503357e5..ab5a7bde66d0 100644
> --- a/samples/bpf/sockex3_kern.c
> +++ b/samples/bpf/sockex3_kern.c
> @@ -17,7 +17,7 @@
> #define IP_MF 0x2000
> #define IP_OFFSET 0x1FFF
>

[...]

\
 
 \ /
  Last update: 2022-11-04 23:55    [W:0.113 / U:0.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site