Messages in this thread | | | From | Andrii Nakryiko <> | Date | Fri, 4 Nov 2022 15:53:09 -0700 | Subject | Re: 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 >
[...]
| |