diff mbox series

[bpf-next] selftests/bpf: Fix error undeclared identifier 'NF_NAT_MANIP_SRC'

Message ID tencent_29D7ABD1744417031AA1B52C914B61158E07@qq.com (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series [bpf-next] selftests/bpf: Fix error undeclared identifier 'NF_NAT_MANIP_SRC' | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 18 of 18 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 11 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-VM_Test-4 fail Logs for build for aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-9 success Logs for set-matrix
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-2 fail Logs for build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-3 fail Logs for build for aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-5 fail Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-6 fail Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-7 success Logs for llvm-toolchain
bpf/vmtest-bpf-next-VM_Test-8 success Logs for set-matrix

Commit Message

Rong Tao Nov. 11, 2022, 3:26 a.m. UTC
From: Rong Tao <rongtao@cestc.cn>

commit 472caa69183f("netfilter: nat: un-export nf_nat_used_tuple")
introduce NF_NAT_MANIP_SRC/DST enum in include/net/netfilter/nf_nat.h,
and commit b06b45e82b59("selftests/bpf: add tests for bpf_ct_set_nat_info
kfunc") use NF_NAT_MANIP_SRC/DST in test_bpf_nf.c. We copy enum
nf_nat_manip_type to test_bpf_nf.c fix this error.

How to reproduce the error:

    $ make -C tools/testing/selftests/bpf/
    ...
      CLNG-BPF [test_maps] test_bpf_nf.bpf.o
      error: use of undeclared identifier 'NF_NAT_MANIP_SRC'
            bpf_ct_set_nat_info(ct, &saddr, sport, NF_NAT_MANIP_SRC);
                                                           ^
      error: use of undeclared identifier 'NF_NAT_MANIP_DST'
            bpf_ct_set_nat_info(ct, &daddr, dport, NF_NAT_MANIP_DST);
                                                           ^
    2 errors generated.

Link: https://lore.kernel.org/lkml/202210280447.STsT1gvq-lkp@intel.com/
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Rong Tao <rongtao@cestc.cn>
---
 tools/testing/selftests/bpf/progs/test_bpf_nf.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Stanislav Fomichev Nov. 11, 2022, 5:25 p.m. UTC | #1
On 11/11, Rong Tao wrote:
> From: Rong Tao <rongtao@cestc.cn>

> commit 472caa69183f("netfilter: nat: un-export nf_nat_used_tuple")
> introduce NF_NAT_MANIP_SRC/DST enum in include/net/netfilter/nf_nat.h,
> and commit b06b45e82b59("selftests/bpf: add tests for bpf_ct_set_nat_info
> kfunc") use NF_NAT_MANIP_SRC/DST in test_bpf_nf.c. We copy enum
> nf_nat_manip_type to test_bpf_nf.c fix this error.

> How to reproduce the error:

>      $ make -C tools/testing/selftests/bpf/
>      ...
>        CLNG-BPF [test_maps] test_bpf_nf.bpf.o
>        error: use of undeclared identifier 'NF_NAT_MANIP_SRC'
>              bpf_ct_set_nat_info(ct, &saddr, sport, NF_NAT_MANIP_SRC);
>                                                             ^
>        error: use of undeclared identifier 'NF_NAT_MANIP_DST'
>              bpf_ct_set_nat_info(ct, &daddr, dport, NF_NAT_MANIP_DST);
>                                                             ^
>      2 errors generated.

$ grep  
NF_NAT_MANIP_SRC ./tools/testing/selftests/bpf/tools/include/vmlinux.h
         NF_NAT_MANIP_SRC = 0,

Doesn't look like your kernel config compiles netfilter nat modules?

> Link: https://lore.kernel.org/lkml/202210280447.STsT1gvq-lkp@intel.com/
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Rong Tao <rongtao@cestc.cn>
> ---
>   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..307ca166ff34 100644
> --- a/tools/testing/selftests/bpf/progs/test_bpf_nf.c
> +++ b/tools/testing/selftests/bpf/progs/test_bpf_nf.c
> @@ -3,6 +3,11 @@
>   #include <bpf/bpf_helpers.h>
>   #include <bpf/bpf_endian.h>

> +enum nf_nat_manip_type {
> +	NF_NAT_MANIP_SRC,
> +	NF_NAT_MANIP_DST
> +};
> +
>   #define EAFNOSUPPORT 97
>   #define EPROTO 71
>   #define ENONET 64
> --
> 2.31.1
Lorenzo Bianconi Nov. 11, 2022, 5:54 p.m. UTC | #2
> On 11/11, Rong Tao wrote:
> > From: Rong Tao <rongtao@cestc.cn>
> 
> > commit 472caa69183f("netfilter: nat: un-export nf_nat_used_tuple")
> > introduce NF_NAT_MANIP_SRC/DST enum in include/net/netfilter/nf_nat.h,
> > and commit b06b45e82b59("selftests/bpf: add tests for bpf_ct_set_nat_info
> > kfunc") use NF_NAT_MANIP_SRC/DST in test_bpf_nf.c. We copy enum
> > nf_nat_manip_type to test_bpf_nf.c fix this error.
> 
> > How to reproduce the error:
> 
> >      $ make -C tools/testing/selftests/bpf/
> >      ...
> >        CLNG-BPF [test_maps] test_bpf_nf.bpf.o
> >        error: use of undeclared identifier 'NF_NAT_MANIP_SRC'
> >              bpf_ct_set_nat_info(ct, &saddr, sport, NF_NAT_MANIP_SRC);
> >                                                             ^
> >        error: use of undeclared identifier 'NF_NAT_MANIP_DST'
> >              bpf_ct_set_nat_info(ct, &daddr, dport, NF_NAT_MANIP_DST);
> >                                                             ^
> >      2 errors generated.
> 
> $ grep NF_NAT_MANIP_SRC
> ./tools/testing/selftests/bpf/tools/include/vmlinux.h
>         NF_NAT_MANIP_SRC = 0,
> 
> Doesn't look like your kernel config compiles netfilter nat modules?

yes, in bpf kself-test config (tools/testing/selftests/bpf/config) nf_nat
is compiled as built-in. This issue occurs just if it is compiled as module.

Regards,
Lorenzo

> 
> > Link: https://lore.kernel.org/lkml/202210280447.STsT1gvq-lkp@intel.com/
> > Reported-by: kernel test robot <lkp@intel.com>
> > Signed-off-by: Rong Tao <rongtao@cestc.cn>
> > ---
> >   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..307ca166ff34 100644
> > --- a/tools/testing/selftests/bpf/progs/test_bpf_nf.c
> > +++ b/tools/testing/selftests/bpf/progs/test_bpf_nf.c
> > @@ -3,6 +3,11 @@
> >   #include <bpf/bpf_helpers.h>
> >   #include <bpf/bpf_endian.h>
> 
> > +enum nf_nat_manip_type {
> > +	NF_NAT_MANIP_SRC,
> > +	NF_NAT_MANIP_DST
> > +};
> > +
> >   #define EAFNOSUPPORT 97
> >   #define EPROTO 71
> >   #define ENONET 64
> > --
> > 2.31.1
>
Stanislav Fomichev Nov. 11, 2022, 6:08 p.m. UTC | #3
On Fri, Nov 11, 2022 at 9:54 AM Lorenzo Bianconi <lorenzo@kernel.org> wrote:
>
> > On 11/11, Rong Tao wrote:
> > > From: Rong Tao <rongtao@cestc.cn>
> >
> > > commit 472caa69183f("netfilter: nat: un-export nf_nat_used_tuple")
> > > introduce NF_NAT_MANIP_SRC/DST enum in include/net/netfilter/nf_nat.h,
> > > and commit b06b45e82b59("selftests/bpf: add tests for bpf_ct_set_nat_info
> > > kfunc") use NF_NAT_MANIP_SRC/DST in test_bpf_nf.c. We copy enum
> > > nf_nat_manip_type to test_bpf_nf.c fix this error.
> >
> > > How to reproduce the error:
> >
> > >      $ make -C tools/testing/selftests/bpf/
> > >      ...
> > >        CLNG-BPF [test_maps] test_bpf_nf.bpf.o
> > >        error: use of undeclared identifier 'NF_NAT_MANIP_SRC'
> > >              bpf_ct_set_nat_info(ct, &saddr, sport, NF_NAT_MANIP_SRC);
> > >                                                             ^
> > >        error: use of undeclared identifier 'NF_NAT_MANIP_DST'
> > >              bpf_ct_set_nat_info(ct, &daddr, dport, NF_NAT_MANIP_DST);
> > >                                                             ^
> > >      2 errors generated.
> >
> > $ grep NF_NAT_MANIP_SRC
> > ./tools/testing/selftests/bpf/tools/include/vmlinux.h
> >         NF_NAT_MANIP_SRC = 0,
> >
> > Doesn't look like your kernel config compiles netfilter nat modules?
>
> yes, in bpf kself-test config (tools/testing/selftests/bpf/config) nf_nat
> is compiled as built-in. This issue occurs just if it is compiled as module.

Right, but if we unconditionally define this enum, I think you'll
break the case where it's compiled as a built-in?
Since at least in my vmlinux.h I have all the defines and this test
includes vmlinux.h...

> Regards,
> Lorenzo
>
> >
> > > Link: https://lore.kernel.org/lkml/202210280447.STsT1gvq-lkp@intel.com/
> > > Reported-by: kernel test robot <lkp@intel.com>
> > > Signed-off-by: Rong Tao <rongtao@cestc.cn>
> > > ---
> > >   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..307ca166ff34 100644
> > > --- a/tools/testing/selftests/bpf/progs/test_bpf_nf.c
> > > +++ b/tools/testing/selftests/bpf/progs/test_bpf_nf.c
> > > @@ -3,6 +3,11 @@
> > >   #include <bpf/bpf_helpers.h>
> > >   #include <bpf/bpf_endian.h>
> >
> > > +enum nf_nat_manip_type {
> > > +   NF_NAT_MANIP_SRC,
> > > +   NF_NAT_MANIP_DST
> > > +};
> > > +
> > >   #define EAFNOSUPPORT 97
> > >   #define EPROTO 71
> > >   #define ENONET 64
> > > --
> > > 2.31.1
> >
Lorenzo Bianconi Nov. 11, 2022, 6:12 p.m. UTC | #4
> On Fri, Nov 11, 2022 at 9:54 AM Lorenzo Bianconi <lorenzo@kernel.org> wrote:
> >
> > > On 11/11, Rong Tao wrote:
> > > > From: Rong Tao <rongtao@cestc.cn>
> > >
> > > > commit 472caa69183f("netfilter: nat: un-export nf_nat_used_tuple")
> > > > introduce NF_NAT_MANIP_SRC/DST enum in include/net/netfilter/nf_nat.h,
> > > > and commit b06b45e82b59("selftests/bpf: add tests for bpf_ct_set_nat_info
> > > > kfunc") use NF_NAT_MANIP_SRC/DST in test_bpf_nf.c. We copy enum
> > > > nf_nat_manip_type to test_bpf_nf.c fix this error.
> > >
> > > > How to reproduce the error:
> > >
> > > >      $ make -C tools/testing/selftests/bpf/
> > > >      ...
> > > >        CLNG-BPF [test_maps] test_bpf_nf.bpf.o
> > > >        error: use of undeclared identifier 'NF_NAT_MANIP_SRC'
> > > >              bpf_ct_set_nat_info(ct, &saddr, sport, NF_NAT_MANIP_SRC);
> > > >                                                             ^
> > > >        error: use of undeclared identifier 'NF_NAT_MANIP_DST'
> > > >              bpf_ct_set_nat_info(ct, &daddr, dport, NF_NAT_MANIP_DST);
> > > >                                                             ^
> > > >      2 errors generated.
> > >
> > > $ grep NF_NAT_MANIP_SRC
> > > ./tools/testing/selftests/bpf/tools/include/vmlinux.h
> > >         NF_NAT_MANIP_SRC = 0,
> > >
> > > Doesn't look like your kernel config compiles netfilter nat modules?
> >
> > yes, in bpf kself-test config (tools/testing/selftests/bpf/config) nf_nat
> > is compiled as built-in. This issue occurs just if it is compiled as module.
> 
> Right, but if we unconditionally define this enum, I think you'll
> break the case where it's compiled as a built-in?
> Since at least in my vmlinux.h I have all the defines and this test
> includes vmlinux.h...

yes, it is correct.

> 
> > Regards,
> > Lorenzo
> >
> > >
> > > > Link: https://lore.kernel.org/lkml/202210280447.STsT1gvq-lkp@intel.com/
> > > > Reported-by: kernel test robot <lkp@intel.com>
> > > > Signed-off-by: Rong Tao <rongtao@cestc.cn>
> > > > ---
> > > >   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..307ca166ff34 100644
> > > > --- a/tools/testing/selftests/bpf/progs/test_bpf_nf.c
> > > > +++ b/tools/testing/selftests/bpf/progs/test_bpf_nf.c
> > > > @@ -3,6 +3,11 @@
> > > >   #include <bpf/bpf_helpers.h>
> > > >   #include <bpf/bpf_endian.h>
> > >
> > > > +enum nf_nat_manip_type {
> > > > +   NF_NAT_MANIP_SRC,
> > > > +   NF_NAT_MANIP_DST
> > > > +};
> > > > +
> > > >   #define EAFNOSUPPORT 97
> > > >   #define EPROTO 71
> > > >   #define ENONET 64
> > > > --
> > > > 2.31.1
> > >
Stanislav Fomichev Nov. 11, 2022, 6:55 p.m. UTC | #5
On Fri, Nov 11, 2022 at 10:12 AM Lorenzo Bianconi <lorenzo@kernel.org> wrote:
>
> > On Fri, Nov 11, 2022 at 9:54 AM Lorenzo Bianconi <lorenzo@kernel.org> wrote:
> > >
> > > > On 11/11, Rong Tao wrote:
> > > > > From: Rong Tao <rongtao@cestc.cn>
> > > >
> > > > > commit 472caa69183f("netfilter: nat: un-export nf_nat_used_tuple")
> > > > > introduce NF_NAT_MANIP_SRC/DST enum in include/net/netfilter/nf_nat.h,
> > > > > and commit b06b45e82b59("selftests/bpf: add tests for bpf_ct_set_nat_info
> > > > > kfunc") use NF_NAT_MANIP_SRC/DST in test_bpf_nf.c. We copy enum
> > > > > nf_nat_manip_type to test_bpf_nf.c fix this error.
> > > >
> > > > > How to reproduce the error:
> > > >
> > > > >      $ make -C tools/testing/selftests/bpf/
> > > > >      ...
> > > > >        CLNG-BPF [test_maps] test_bpf_nf.bpf.o
> > > > >        error: use of undeclared identifier 'NF_NAT_MANIP_SRC'
> > > > >              bpf_ct_set_nat_info(ct, &saddr, sport, NF_NAT_MANIP_SRC);
> > > > >                                                             ^
> > > > >        error: use of undeclared identifier 'NF_NAT_MANIP_DST'
> > > > >              bpf_ct_set_nat_info(ct, &daddr, dport, NF_NAT_MANIP_DST);
> > > > >                                                             ^
> > > > >      2 errors generated.
> > > >
> > > > $ grep NF_NAT_MANIP_SRC
> > > > ./tools/testing/selftests/bpf/tools/include/vmlinux.h
> > > >         NF_NAT_MANIP_SRC = 0,
> > > >
> > > > Doesn't look like your kernel config compiles netfilter nat modules?
> > >
> > > yes, in bpf kself-test config (tools/testing/selftests/bpf/config) nf_nat
> > > is compiled as built-in. This issue occurs just if it is compiled as module.
> >
> > Right, but if we unconditionally define this enum, I think you'll
> > break the case where it's compiled as a built-in?
> > Since at least in my vmlinux.h I have all the defines and this test
> > includes vmlinux.h...
>
> yes, it is correct.

And it will break the CI:

$ grep NETFILTER tools/testing/selftests/bpf/config
CONFIG_NETFILTER=y

So yeah, not sure what to do here. The selftests expect "sane" configs
(see that bpf/config above) which is not what the bot seems to be
doing...

> > > Regards,
> > > Lorenzo
> > >
> > > >
> > > > > Link: https://lore.kernel.org/lkml/202210280447.STsT1gvq-lkp@intel.com/
> > > > > Reported-by: kernel test robot <lkp@intel.com>
> > > > > Signed-off-by: Rong Tao <rongtao@cestc.cn>
> > > > > ---
> > > > >   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..307ca166ff34 100644
> > > > > --- a/tools/testing/selftests/bpf/progs/test_bpf_nf.c
> > > > > +++ b/tools/testing/selftests/bpf/progs/test_bpf_nf.c
> > > > > @@ -3,6 +3,11 @@
> > > > >   #include <bpf/bpf_helpers.h>
> > > > >   #include <bpf/bpf_endian.h>
> > > >
> > > > > +enum nf_nat_manip_type {
> > > > > +   NF_NAT_MANIP_SRC,
> > > > > +   NF_NAT_MANIP_DST
> > > > > +};
> > > > > +
> > > > >   #define EAFNOSUPPORT 97
> > > > >   #define EPROTO 71
> > > > >   #define ENONET 64
> > > > > --
> > > > > 2.31.1
> > > >
Andrii Nakryiko Nov. 11, 2022, 8:44 p.m. UTC | #6
On Fri, Nov 11, 2022 at 10:55 AM Stanislav Fomichev <sdf@google.com> wrote:
>
> On Fri, Nov 11, 2022 at 10:12 AM Lorenzo Bianconi <lorenzo@kernel.org> wrote:
> >
> > > On Fri, Nov 11, 2022 at 9:54 AM Lorenzo Bianconi <lorenzo@kernel.org> wrote:
> > > >
> > > > > On 11/11, Rong Tao wrote:
> > > > > > From: Rong Tao <rongtao@cestc.cn>
> > > > >
> > > > > > commit 472caa69183f("netfilter: nat: un-export nf_nat_used_tuple")
> > > > > > introduce NF_NAT_MANIP_SRC/DST enum in include/net/netfilter/nf_nat.h,
> > > > > > and commit b06b45e82b59("selftests/bpf: add tests for bpf_ct_set_nat_info
> > > > > > kfunc") use NF_NAT_MANIP_SRC/DST in test_bpf_nf.c. We copy enum
> > > > > > nf_nat_manip_type to test_bpf_nf.c fix this error.
> > > > >
> > > > > > How to reproduce the error:
> > > > >
> > > > > >      $ make -C tools/testing/selftests/bpf/
> > > > > >      ...
> > > > > >        CLNG-BPF [test_maps] test_bpf_nf.bpf.o
> > > > > >        error: use of undeclared identifier 'NF_NAT_MANIP_SRC'
> > > > > >              bpf_ct_set_nat_info(ct, &saddr, sport, NF_NAT_MANIP_SRC);
> > > > > >                                                             ^
> > > > > >        error: use of undeclared identifier 'NF_NAT_MANIP_DST'
> > > > > >              bpf_ct_set_nat_info(ct, &daddr, dport, NF_NAT_MANIP_DST);
> > > > > >                                                             ^
> > > > > >      2 errors generated.
> > > > >
> > > > > $ grep NF_NAT_MANIP_SRC
> > > > > ./tools/testing/selftests/bpf/tools/include/vmlinux.h
> > > > >         NF_NAT_MANIP_SRC = 0,
> > > > >
> > > > > Doesn't look like your kernel config compiles netfilter nat modules?
> > > >
> > > > yes, in bpf kself-test config (tools/testing/selftests/bpf/config) nf_nat
> > > > is compiled as built-in. This issue occurs just if it is compiled as module.
> > >
> > > Right, but if we unconditionally define this enum, I think you'll
> > > break the case where it's compiled as a built-in?
> > > Since at least in my vmlinux.h I have all the defines and this test
> > > includes vmlinux.h...
> >
> > yes, it is correct.
>
> And it will break the CI:
>

It does break CI ([0]). We could use BPF CO-RE and ___suffix rule to
avoid this. But we can also say that selftests/bpf/config{,<arch>} has
to be used by bots that want to build BPF selftests.

  [0] https://github.com/kernel-patches/bpf/actions/runs/3446651033/jobs/5752592868

> $ grep NETFILTER tools/testing/selftests/bpf/config
> CONFIG_NETFILTER=y
>
> So yeah, not sure what to do here. The selftests expect "sane" configs
> (see that bpf/config above) which is not what the bot seems to be
> doing...
>
> > > > Regards,
> > > > Lorenzo
> > > >
> > > > >
> > > > > > Link: https://lore.kernel.org/lkml/202210280447.STsT1gvq-lkp@intel.com/
> > > > > > Reported-by: kernel test robot <lkp@intel.com>
> > > > > > Signed-off-by: Rong Tao <rongtao@cestc.cn>
> > > > > > ---
> > > > > >   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..307ca166ff34 100644
> > > > > > --- a/tools/testing/selftests/bpf/progs/test_bpf_nf.c
> > > > > > +++ b/tools/testing/selftests/bpf/progs/test_bpf_nf.c
> > > > > > @@ -3,6 +3,11 @@
> > > > > >   #include <bpf/bpf_helpers.h>
> > > > > >   #include <bpf/bpf_endian.h>
> > > > >
> > > > > > +enum nf_nat_manip_type {
> > > > > > +   NF_NAT_MANIP_SRC,
> > > > > > +   NF_NAT_MANIP_DST
> > > > > > +};
> > > > > > +
> > > > > >   #define EAFNOSUPPORT 97
> > > > > >   #define EPROTO 71
> > > > > >   #define ENONET 64
> > > > > > --
> > > > > > 2.31.1
> > > > >
Rong Tao Nov. 17, 2022, 2:15 p.m. UTC | #7
First of all, thank you all for your suggestions on this compilation
issue.

> It does break CI ([0]). We could use BPF CO-RE and ___suffix rule to
> avoid this. But we can also say that selftests/bpf/config{,<arch>} has
> to be used by bots that want to build BPF selftests.
>
>  [0] https://github.com/kernel-patches/bpf/actions/runs/3446651033/jobs/5752592868

I try to use bpf_core_enum_value_exists() and bpf_core_enum_value(), However, 
as far as my knowledge is concerned, I have to redefine a NF_NAT_MANIP_SRC 
enumeration, but this would conflict with the situation where there is no 
secondary compilation problem. How do I fix this with CO-RE, it seems that 
there is no similar CO-RE+ __suffix solution for enumerations in selftests. 
Can you give me some tips or help me?
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/progs/test_bpf_nf.c b/tools/testing/selftests/bpf/progs/test_bpf_nf.c
index 227e85e85dda..307ca166ff34 100644
--- a/tools/testing/selftests/bpf/progs/test_bpf_nf.c
+++ b/tools/testing/selftests/bpf/progs/test_bpf_nf.c
@@ -3,6 +3,11 @@ 
 #include <bpf/bpf_helpers.h>
 #include <bpf/bpf_endian.h>
 
+enum nf_nat_manip_type {
+	NF_NAT_MANIP_SRC,
+	NF_NAT_MANIP_DST
+};
+
 #define EAFNOSUPPORT 97
 #define EPROTO 71
 #define ENONET 64