1 // SPDX-License-Identifier: GPL-2.0 2 3 #include "vmlinux.h" 4 #include <bpf/bpf_helpers.h> 5 #include <bpf/bpf_tracing.h> 6 7 SEC("xdp") 8 int xdp_devmap(struct xdp_md *ctx) 9 { 10 return ctx->egress_ifindex; 11 } 12 13 struct { 14 __uint(type, BPF_MAP_TYPE_PROG_ARRAY); 15 __uint(max_entries, 1); 16 __uint(key_size, sizeof(__u32)); 17 __array(values, int (void *)); 18 } xdp_map SEC(".maps") = { 19 .values = { 20 [0] = (void *)&xdp_devmap, 21 }, 22 }; 23 24 SEC("xdp") 25 int xdp_entry(struct xdp_md *ctx) 26 { 27 bpf_tail_call(ctx, &xdp_map, 0); 28 return 0; 29 } 30