* [PATCH bpf-next] selftests/bpf: Do not fail build if CONFIG_NF_CONNTRACK=m/n
@ 2022-01-20 16:49 Kumar Kartikeya Dwivedi
2022-01-20 22:36 ` Andrii Nakryiko
0 siblings, 1 reply; 2+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2022-01-20 16:49 UTC (permalink / raw)
To: bpf, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
Some users have complained that selftests fail to build when
CONFIG_NF_CONNTRACK=m. It would be useful to allow building as long as
it is set to module or built-in, even though in case of building as
module, user would need to load it before running the selftest. Note
that this also allows building selftest when CONFIG_NF_CONNTRACK is
disabled.
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
tools/testing/selftests/bpf/progs/test_bpf_nf.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/bpf/progs/test_bpf_nf.c b/tools/testing/selftests/bpf/progs/test_bpf_nf.c
index 6f131c993c0b..d048d355a69f 100644
--- a/tools/testing/selftests/bpf/progs/test_bpf_nf.c
+++ b/tools/testing/selftests/bpf/progs/test_bpf_nf.c
@@ -17,18 +17,27 @@ int test_enonet_netns_id = 0;
int test_enoent_lookup = 0;
int test_eafnosupport = 0;
+struct nf_conn;
+
+struct bpf_ct_opts___local {
+ s32 netns_id;
+ s32 error;
+ u8 l4proto;
+ u8 reserved[3];
+};
+
struct nf_conn *bpf_xdp_ct_lookup(struct xdp_md *, struct bpf_sock_tuple *, u32,
- struct bpf_ct_opts *, u32) __ksym;
+ struct bpf_ct_opts___local *, u32) __ksym;
struct nf_conn *bpf_skb_ct_lookup(struct __sk_buff *, struct bpf_sock_tuple *, u32,
- struct bpf_ct_opts *, u32) __ksym;
+ struct bpf_ct_opts___local *, u32) __ksym;
void bpf_ct_release(struct nf_conn *) __ksym;
static __always_inline void
nf_ct_test(struct nf_conn *(*func)(void *, struct bpf_sock_tuple *, u32,
- struct bpf_ct_opts *, u32),
+ struct bpf_ct_opts___local *, u32),
void *ctx)
{
- struct bpf_ct_opts opts_def = { .l4proto = IPPROTO_TCP, .netns_id = -1 };
+ struct bpf_ct_opts___local opts_def = { .l4proto = IPPROTO_TCP, .netns_id = -1 };
struct bpf_sock_tuple bpf_tuple;
struct nf_conn *ct;
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH bpf-next] selftests/bpf: Do not fail build if CONFIG_NF_CONNTRACK=m/n
2022-01-20 16:49 [PATCH bpf-next] selftests/bpf: Do not fail build if CONFIG_NF_CONNTRACK=m/n Kumar Kartikeya Dwivedi
@ 2022-01-20 22:36 ` Andrii Nakryiko
0 siblings, 0 replies; 2+ messages in thread
From: Andrii Nakryiko @ 2022-01-20 22:36 UTC (permalink / raw)
To: Kumar Kartikeya Dwivedi
Cc: bpf, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
On Thu, Jan 20, 2022 at 8:50 AM Kumar Kartikeya Dwivedi
<memxor@gmail.com> wrote:
>
> Some users have complained that selftests fail to build when
> CONFIG_NF_CONNTRACK=m. It would be useful to allow building as long as
> it is set to module or built-in, even though in case of building as
> module, user would need to load it before running the selftest. Note
> that this also allows building selftest when CONFIG_NF_CONNTRACK is
> disabled.
>
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> ---
> tools/testing/selftests/bpf/progs/test_bpf_nf.c | 17 +++++++++++++----
> 1 file changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/progs/test_bpf_nf.c b/tools/testing/selftests/bpf/progs/test_bpf_nf.c
> index 6f131c993c0b..d048d355a69f 100644
> --- a/tools/testing/selftests/bpf/progs/test_bpf_nf.c
> +++ b/tools/testing/selftests/bpf/progs/test_bpf_nf.c
> @@ -17,18 +17,27 @@ int test_enonet_netns_id = 0;
> int test_enoent_lookup = 0;
> int test_eafnosupport = 0;
>
> +struct nf_conn;
> +
> +struct bpf_ct_opts___local {
> + s32 netns_id;
> + s32 error;
> + u8 l4proto;
> + u8 reserved[3];
> +};
I've added __attribute__((preserve_access_index)) to make it
CO-RE-relocatable, just in case. Applied to bpf-next.
> +
> struct nf_conn *bpf_xdp_ct_lookup(struct xdp_md *, struct bpf_sock_tuple *, u32,
> - struct bpf_ct_opts *, u32) __ksym;
> + struct bpf_ct_opts___local *, u32) __ksym;
> struct nf_conn *bpf_skb_ct_lookup(struct __sk_buff *, struct bpf_sock_tuple *, u32,
> - struct bpf_ct_opts *, u32) __ksym;
> + struct bpf_ct_opts___local *, u32) __ksym;
> void bpf_ct_release(struct nf_conn *) __ksym;
>
> static __always_inline void
> nf_ct_test(struct nf_conn *(*func)(void *, struct bpf_sock_tuple *, u32,
> - struct bpf_ct_opts *, u32),
> + struct bpf_ct_opts___local *, u32),
> void *ctx)
> {
> - struct bpf_ct_opts opts_def = { .l4proto = IPPROTO_TCP, .netns_id = -1 };
> + struct bpf_ct_opts___local opts_def = { .l4proto = IPPROTO_TCP, .netns_id = -1 };
> struct bpf_sock_tuple bpf_tuple;
> struct nf_conn *ct;
>
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-20 22:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-20 16:49 [PATCH bpf-next] selftests/bpf: Do not fail build if CONFIG_NF_CONNTRACK=m/n Kumar Kartikeya Dwivedi
2022-01-20 22:36 ` Andrii Nakryiko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.