[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y8epfNbNDYikDYSr@krava>
Date: Wed, 18 Jan 2023 09:10:36 +0100
From: Jiri Olsa <olsajiri@...il.com>
To: Tiezhu Yang <yangtiezhu@...ngson.cn>
Cc: Andrii Nakryiko <andrii@...nel.org>,
Mykola Lysenko <mykolal@...com>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Martin KaFai Lau <martin.lau@...ux.dev>,
Song Liu <song@...nel.org>, Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>,
Stanislav Fomichev <sdf@...gle.com>,
Hao Luo <haoluo@...gle.com>,
Lorenzo Bianconi <lorenzo@...nel.org>, bpf@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH bpf-next v2] selftests/bpf: Fix build errors if
CONFIG_NF_CONNTRACK=m
On Wed, Jan 18, 2023 at 03:56:44PM +0800, Tiezhu Yang wrote:
> If CONFIG_NF_CONNTRACK=m, there are no definitions of NF_NAT_MANIP_SRC
> and NF_NAT_MANIP_DST in vmlinux.h, build test_bpf_nf.c failed.
>
> $ 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,
> in order to avoid redefinitions if CONFIG_NF_CONNTRACK=y, rename them with
> ___local suffix. This is similar with commit 1058b6a78db2 ("selftests/bpf:
> Do not fail build if CONFIG_NF_CONNTRACK=m/n").
>
> Fixes: b06b45e82b59 ("selftests/bpf: add tests for bpf_ct_set_nat_info kfunc")
> Signed-off-by: Tiezhu Yang <yangtiezhu@...ngson.cn>
I hit the same problem, thanks
Acked-by: Jiri Olsa <jolsa@...nel.org>
Tested-by: Jiri Olsa <jolsa@...nel.org>
jirka
> ---
> tools/testing/selftests/bpf/progs/test_bpf_nf.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/progs/test_bpf_nf.c b/tools/testing/selftests/bpf/progs/test_bpf_nf.c
> index 227e85e..9fc603c 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___local {
> + NF_NAT_MANIP_SRC___local,
> + NF_NAT_MANIP_DST___local
> +};
> +
> struct nf_conn;
>
> struct bpf_ct_opts___local {
> @@ -58,7 +63,7 @@ int bpf_ct_change_timeout(struct nf_conn *, u32) __ksym;
> int bpf_ct_set_status(struct nf_conn *, u32) __ksym;
> int bpf_ct_change_status(struct nf_conn *, u32) __ksym;
> int bpf_ct_set_nat_info(struct nf_conn *, union nf_inet_addr *,
> - int port, enum nf_nat_manip_type) __ksym;
> + int port, enum nf_nat_manip_type___local) __ksym;
>
> static __always_inline void
> nf_ct_test(struct nf_conn *(*lookup_fn)(void *, struct bpf_sock_tuple *, u32,
> @@ -157,10 +162,10 @@ nf_ct_test(struct nf_conn *(*lookup_fn)(void *, struct bpf_sock_tuple *, u32,
>
> /* snat */
> saddr.ip = bpf_get_prandom_u32();
> - bpf_ct_set_nat_info(ct, &saddr, sport, NF_NAT_MANIP_SRC);
> + bpf_ct_set_nat_info(ct, &saddr, sport, NF_NAT_MANIP_SRC___local);
> /* dnat */
> daddr.ip = bpf_get_prandom_u32();
> - bpf_ct_set_nat_info(ct, &daddr, dport, NF_NAT_MANIP_DST);
> + bpf_ct_set_nat_info(ct, &daddr, dport, NF_NAT_MANIP_DST___local);
>
> ct_ins = bpf_ct_insert_entry(ct);
> if (ct_ins) {
> --
> 2.1.0
>
Powered by blists - more mailing lists