Re: [PATCH bpf 2/2] selftests/bpf: Add local definition of enum nf_nat_manip_type to bpf_nf test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Andrii Nakryiko <andrii.nakryiko@xxxxxxxxx> writes:

> On Wed, Nov 30, 2022 at 5:18 PM Andrii Nakryiko
> <andrii.nakryiko@xxxxxxxxx> wrote:
>>
>> On Wed, Nov 30, 2022 at 6:42 AM Toke Høiland-Jørgensen <toke@xxxxxxxxxx> wrote:
>> >
>> > The bpf_nf selftest calls the bpf_ct_set_nat_info() kfunc, which takes a
>> > parameter of type enum nf_nat_manip_type. However, if the nf_nat code is
>> > compiled as a module, that enum is not defined in vmlinux BTF, and
>> > compilation of the selftest fails.
>> >
>> > A previous patch suggested just hard-coding the enum values:
>> >
>> > https://lore.kernel.org/r/tencent_4C0B445E0305A18FACA04B4A959B57835107@xxxxxx
>> >
>> > However, this doesn't work as the compiler then complains about an
>> > incomplete type definition in the function prototype. Instead, just add a
>> > local definition of the enum to the selftest code.
>> >
>> > Fixes: b06b45e82b59 ("selftests/bpf: add tests for bpf_ct_set_nat_info kfunc")
>> > Signed-off-by: Toke Høiland-Jørgensen <toke@xxxxxxxxxx>
>> > ---
>> >  tools/testing/selftests/bpf/progs/test_bpf_nf.c | 5 +++++
>> >  1 file changed, 5 insertions(+)
>> >
>> > diff --git a/tools/testing/selftests/bpf/progs/test_bpf_nf.c b/tools/testing/selftests/bpf/progs/test_bpf_nf.c
>> > index 227e85e85dda..6350d11ec6f6 100644
>> > --- a/tools/testing/selftests/bpf/progs/test_bpf_nf.c
>> > +++ b/tools/testing/selftests/bpf/progs/test_bpf_nf.c
>> > @@ -43,6 +43,11 @@ struct bpf_ct_opts___local {
>> >         u8 reserved[3];
>> >  } __attribute__((preserve_access_index));
>> >
>> > +enum nf_nat_manip_type {
>> > +       NF_NAT_MANIP_SRC,
>> > +       NF_NAT_MANIP_DST
>> > +};
>> > +
>>
>> and enum redefinition error if vmlinux.h already defines it?...
>
>
> ... which is apparently proven by our CI already:
>
>   [0] https://github.com/kernel-patches/bpf/actions/runs/3584446939/jobs/6031141757

Doh *facepalm*! Will fix...

-Toke





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux