All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin KaFai Lau <martin.lau@linux.dev>
To: bpf@vger.kernel.org
Cc: 'Alexei Starovoitov ' <ast@kernel.org>,
	'Andrii Nakryiko ' <andrii@kernel.org>,
	'Daniel Borkmann ' <daniel@iogearbox.net>,
	netdev@vger.kernel.org, kernel-team@meta.com,
	Eyal Birger <eyal.birger@gmail.com>
Subject: [PATCH bpf-next] selftests/bpf: Allow building bpf tests with CONFIG_XFRM_INTERFACE=[m|n]
Date: Tue,  6 Dec 2022 11:35:54 -0800	[thread overview]
Message-ID: <20221206193554.1059757-1-martin.lau@linux.dev> (raw)

From: Martin KaFai Lau <martin.lau@kernel.org>

It is useful to use vmlinux.h in the xfrm_info test like other kfunc
tests do.  In particular, it is common for kfunc bpf prog that requires
to use other core kernel structures in vmlinux.h

Although vmlinux.h is preferred, it needs a ___local flavor of
struct bpf_xfrm_info in order to build the bpf selftests
when CONFIG_XFRM_INTERFACE=[m|n].

Cc: Eyal Birger <eyal.birger@gmail.com>
Fixes: 90a3a05eb33f ("selftests/bpf: add xfrm_info tests")
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
---
 tools/testing/selftests/bpf/progs/xfrm_info.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/bpf/progs/xfrm_info.c b/tools/testing/selftests/bpf/progs/xfrm_info.c
index 3acedcdd962d..f6a501fbba2b 100644
--- a/tools/testing/selftests/bpf/progs/xfrm_info.c
+++ b/tools/testing/selftests/bpf/progs/xfrm_info.c
@@ -3,18 +3,23 @@
 #include "bpf_tracing_net.h"
 #include <bpf/bpf_helpers.h>
 
+struct bpf_xfrm_info___local {
+	u32 if_id;
+	int link;
+} __attribute__((preserve_access_index));
+
 __u32 req_if_id;
 __u32 resp_if_id;
 
 int bpf_skb_set_xfrm_info(struct __sk_buff *skb_ctx,
-			  const struct bpf_xfrm_info *from) __ksym;
+			  const struct bpf_xfrm_info___local *from) __ksym;
 int bpf_skb_get_xfrm_info(struct __sk_buff *skb_ctx,
-			  struct bpf_xfrm_info *to) __ksym;
+			  struct bpf_xfrm_info___local *to) __ksym;
 
 SEC("tc")
 int set_xfrm_info(struct __sk_buff *skb)
 {
-	struct bpf_xfrm_info info = { .if_id = req_if_id };
+	struct bpf_xfrm_info___local info = { .if_id = req_if_id };
 
 	return bpf_skb_set_xfrm_info(skb, &info) ? TC_ACT_SHOT : TC_ACT_UNSPEC;
 }
@@ -22,7 +27,7 @@ int set_xfrm_info(struct __sk_buff *skb)
 SEC("tc")
 int get_xfrm_info(struct __sk_buff *skb)
 {
-	struct bpf_xfrm_info info = {};
+	struct bpf_xfrm_info___local info = {};
 
 	if (bpf_skb_get_xfrm_info(skb, &info) < 0)
 		return TC_ACT_SHOT;
-- 
2.30.2


             reply	other threads:[~2022-12-06 19:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-06 19:35 Martin KaFai Lau [this message]
2022-12-06 21:00 ` [PATCH bpf-next] selftests/bpf: Allow building bpf tests with CONFIG_XFRM_INTERFACE=[m|n] patchwork-bot+netdevbpf

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=20221206193554.1059757-1-martin.lau@linux.dev \
    --to=martin.lau@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eyal.birger@gmail.com \
    --cc=kernel-team@meta.com \
    --cc=netdev@vger.kernel.org \
    /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 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.