selftests/bpf: Fix erroneous bitmask operation
[platform/kernel/linux-rpi.git] / tools / testing / selftests / bpf / progs / verifier_xdp.c
1 // SPDX-License-Identifier: GPL-2.0
2 /* Converted from tools/testing/selftests/bpf/verifier/xdp.c */
3
4 #include <linux/bpf.h>
5 #include <bpf/bpf_helpers.h>
6 #include "bpf_misc.h"
7
8 SEC("xdp")
9 __description("XDP, using ifindex from netdev")
10 __success __retval(1)
11 __naked void xdp_using_ifindex_from_netdev(void)
12 {
13         asm volatile ("                                 \
14         r0 = 0;                                         \
15         r2 = *(u32*)(r1 + %[xdp_md_ingress_ifindex]);   \
16         if r2 < 1 goto l0_%=;                           \
17         r0 = 1;                                         \
18 l0_%=:  exit;                                           \
19 "       :
20         : __imm_const(xdp_md_ingress_ifindex, offsetof(struct xdp_md, ingress_ifindex))
21         : __clobber_all);
22 }
23
24 char _license[] SEC("license") = "GPL";