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