Skip to content

Commit eeb23b5

Browse files
alan-maguireAlexei Starovoitov
authored andcommitted
selftests/bpf: fix compilation failure when CONFIG_NF_FLOW_TABLE=m
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: c77e572 ("selftests/bpf: Add selftest for bpf_xdp_flow_lookup kfunc") Signed-off-by: Alan Maguire <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent c13fda9 commit eeb23b5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tools/testing/selftests/bpf/progs/xdp_flowtable.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ static bool xdp_flowtable_offload_check_tcp_state(void *ports, void *data_end,
5858
return true;
5959
}
6060

61+
struct flow_ports___local {
62+
__be16 source, dest;
63+
} __attribute__((preserve_access_index));
64+
6165
SEC("xdp.frags")
6266
int xdp_flowtable_do_lookup(struct xdp_md *ctx)
6367
{
@@ -69,7 +73,7 @@ int xdp_flowtable_do_lookup(struct xdp_md *ctx)
6973
};
7074
void *data = (void *)(long)ctx->data;
7175
struct ethhdr *eth = data;
72-
struct flow_ports *ports;
76+
struct flow_ports___local *ports;
7377
__u32 *val, key = 0;
7478

7579
if (eth + 1 > data_end)
@@ -79,7 +83,7 @@ int xdp_flowtable_do_lookup(struct xdp_md *ctx)
7983
case bpf_htons(ETH_P_IP): {
8084
struct iphdr *iph = data + sizeof(*eth);
8185

82-
ports = (struct flow_ports *)(iph + 1);
86+
ports = (struct flow_ports___local *)(iph + 1);
8387
if (ports + 1 > data_end)
8488
return XDP_PASS;
8589

@@ -106,7 +110,7 @@ int xdp_flowtable_do_lookup(struct xdp_md *ctx)
106110
struct in6_addr *dst = (struct in6_addr *)tuple.ipv6_dst;
107111
struct ipv6hdr *ip6h = data + sizeof(*eth);
108112

109-
ports = (struct flow_ports *)(ip6h + 1);
113+
ports = (struct flow_ports___local *)(ip6h + 1);
110114
if (ports + 1 > data_end)
111115
return XDP_PASS;
112116

0 commit comments

Comments
 (0)