public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alan Maguire <alan.maguire@oracle.com>
To: Eduard Zingerman <eddyz87@gmail.com>,
	Tiezhu Yang <yangtiezhu@loongson.cn>,
	Andrii Nakryiko <andrii@kernel.org>,
	Mykola Lysenko <mykolal@fb.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Song Liu <song@kernel.org>, Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Lorenzo Bianconi <lorenzo@kernel.org>
Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next] selftests/bpf: Fix undeclared identifier build errors of test_bpf_nf.c
Date: Mon, 16 Jan 2023 13:54:00 +0000	[thread overview]
Message-ID: <556dc633-e7fb-da8a-1fa9-757684edd3a4@oracle.com> (raw)
In-Reply-To: <14e0f634f084d0f07e447638c490da60943507d6.camel@gmail.com>

On 16/01/2023 12:30, Eduard Zingerman wrote:
> On Mon, 2023-01-16 at 12:55 +0800, Tiezhu Yang wrote:
>> $ make -C tools/testing/selftests/bpf/
>>
>>   CLNG-BPF [test_maps] test_bpf_nf.bpf.o
>> progs/test_bpf_nf.c:160:42: error: use of undeclared identifier 'NF_NAT_MANIP_SRC'
>>                 bpf_ct_set_nat_info(ct, &saddr, sport, NF_NAT_MANIP_SRC);
>>                                                        ^
>> progs/test_bpf_nf.c:163:42: error: use of undeclared identifier 'NF_NAT_MANIP_DST'
>>                 bpf_ct_set_nat_info(ct, &daddr, dport, NF_NAT_MANIP_DST);
>>                                                        ^
>> 2 errors generated.
>>
>> Copy the definitions in include/net/netfilter/nf_nat.h to test_bpf_nf.c
>> to fix the above build errors.
>>
>> Fixes: b06b45e82b59 ("selftests/bpf: add tests for bpf_ct_set_nat_info kfunc")
>> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.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 227e85e..114f961 100644
>> --- a/tools/testing/selftests/bpf/progs/test_bpf_nf.c
>> +++ b/tools/testing/selftests/bpf/progs/test_bpf_nf.c
>> @@ -34,6 +34,11 @@ __be16 dport = 0;
>>  int test_exist_lookup = -ENOENT;
>>  u32 test_exist_lookup_mark = 0;
>>  
>> +enum nf_nat_manip_type {
>> +	NF_NAT_MANIP_SRC,
>> +	NF_NAT_MANIP_DST
>> +};
>> +
> 
> This is confusing, when I build the kernel/tests I get the declaration 
> the "enum nf_nat_manip_type" from the vmlinux.h (which is included from test_bpf_nf.c).
> Which means that this patch results in compilation error with my configuration.
> Is there a chance that your kernel is configured without some necessary netfilter
> configuration options? Have you tried this patch with BPF CI?
>

Yep; I suspect if CONFIG_NF_NAT=m , the required definitions won't make it
into vmlinux.h. The reference tools/testing/seftests/bpf/config has
CONFIG_NF_NAT=y so it is at least documented in the referenced config. 

I'd suggest going the route of 

commit aa67961f3243dfff26c47769f87b4d94b07ec71f
Author: Martin KaFai Lau <martin.lau@kernel.org>
Date:   Tue Dec 6 11:35:54 2022 -0800

    selftests/bpf: Allow building bpf tests with CONFIG_XFRM_INTERFACE=[m|n]
    
...and adding/using local definitons like:

enum nf_nat_manip_type_local {
	NF_NAT_MANIP_SRC_LOCAL,
	NF_NAT_MANIP_DST_LOCAL
};

...to avoid the name clash.


Alan

  reply	other threads:[~2023-01-16 13:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-16  4:55 [PATCH bpf-next] selftests/bpf: Fix undeclared identifier build errors of test_bpf_nf.c Tiezhu Yang
2023-01-16 12:30 ` Eduard Zingerman
2023-01-16 13:54   ` Alan Maguire [this message]
2023-01-17  6:48     ` Yonghong Song
2023-01-17  9:52       ` Tiezhu Yang
2023-01-17 18:29         ` Yonghong Song
2023-01-18  6:04           ` Tiezhu Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=556dc633-e7fb-da8a-1fa9-757684edd3a4@oracle.com \
    --to=alan.maguire@oracle.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mykolal@fb.com \
    --cc=sdf@google.com \
    --cc=song@kernel.org \
    --cc=yangtiezhu@loongson.cn \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox