BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next] selftests/bpf: fix compilation failure when CONFIG_NF_FLOW_TABLE=m
@ 2024-07-10 15:00 Alan Maguire
  2024-07-10 18:50 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Alan Maguire @ 2024-07-10 15:00 UTC (permalink / raw)
  To: ast, daniel
  Cc: davem, kuba, hawk, john.fastabend, andrii, eddyz87, mykolal,
	martin.lau, song, yonghong.song, kpsingh, sdf, haoluo, jolsa,
	lorenzo, bpf, Alan Maguire

In many cases, kernel netfilter functionality is built as modules.
If CONFIG_NF_FLOW_TABLE=m in particular, progs/xdp_flowtable.c
(and hence selftests) will fail to compile, so add a ___local
version of "struct flow_ports".

Fixes: c77e572d3a8c ("selftests/bpf: Add selftest for bpf_xdp_flow_lookup kfunc")
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
---
 tools/testing/selftests/bpf/progs/xdp_flowtable.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/bpf/progs/xdp_flowtable.c b/tools/testing/selftests/bpf/progs/xdp_flowtable.c
index 15209650f73b..7fdc7b23ee74 100644
--- a/tools/testing/selftests/bpf/progs/xdp_flowtable.c
+++ b/tools/testing/selftests/bpf/progs/xdp_flowtable.c
@@ -58,6 +58,10 @@ static bool xdp_flowtable_offload_check_tcp_state(void *ports, void *data_end,
 	return true;
 }
 
+struct flow_ports___local {
+	__be16 source, dest;
+} __attribute__((preserve_access_index));
+
 SEC("xdp.frags")
 int xdp_flowtable_do_lookup(struct xdp_md *ctx)
 {
@@ -69,7 +73,7 @@ int xdp_flowtable_do_lookup(struct xdp_md *ctx)
 	};
 	void *data = (void *)(long)ctx->data;
 	struct ethhdr *eth = data;
-	struct flow_ports *ports;
+	struct flow_ports___local *ports;
 	__u32 *val, key = 0;
 
 	if (eth + 1 > data_end)
@@ -79,7 +83,7 @@ int xdp_flowtable_do_lookup(struct xdp_md *ctx)
 	case bpf_htons(ETH_P_IP): {
 		struct iphdr *iph = data + sizeof(*eth);
 
-		ports = (struct flow_ports *)(iph + 1);
+		ports = (struct flow_ports___local *)(iph + 1);
 		if (ports + 1 > data_end)
 			return XDP_PASS;
 
@@ -106,7 +110,7 @@ int xdp_flowtable_do_lookup(struct xdp_md *ctx)
 		struct in6_addr *dst = (struct in6_addr *)tuple.ipv6_dst;
 		struct ipv6hdr *ip6h = data + sizeof(*eth);
 
-		ports = (struct flow_ports *)(ip6h + 1);
+		ports = (struct flow_ports___local *)(ip6h + 1);
 		if (ports + 1 > data_end)
 			return XDP_PASS;
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-07-10 18:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-10 15:00 [PATCH bpf-next] selftests/bpf: fix compilation failure when CONFIG_NF_FLOW_TABLE=m Alan Maguire
2024-07-10 18:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox