Re: [PATCH bpf-next v3 9/9] selftests/bpf: Add test for unstable CT lookup API

Kumar Kartikeya Dwivedi
2021-12-14T14:34:28Z

On Tue, Dec 14, 2021 at 07:43:13PM IST, Maxim Mikityanskiy wrote:
> On 2021-12-10 15:02, Kumar Kartikeya Dwivedi wrote:
> > This tests that we return errors as documented, and also that the kfunc
> > calls work from both XDP and TC hooks.
> >
> > Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> > ---
> > [...]
> > +
> > +#define nf_ct_test(func, ctx) \
> > + ({ \
> > + struct bpf_ct_opts opts_def = { .l4proto = IPPROTO_TCP, \
> > + .netns_id = -1 }; \
>
> I noticed that when CONFIG_NF_CONNTRACK=m, struct bpf_ct_opts doesn't get
> added to vmlinux.h. What is the right way to get definitions of structs from
> modules in BPF programs? Are they supposed to be part of vmlinux.h?
>

Right, you'll have to do:
# bpftool btf dump file /sys/kernel/btf/nf_conntrack format c > vmlinux.h
after loading the module. This will have the definitions for vmlinux BTF +
nf_conntrack BTF.

> [...]

--
Kartikeya