brintos

brintos / linux-shallow public Read only

0
0
Text · 580 B · 807bf89 Raw
23 lines · c
1// SPDX-License-Identifier: GPL-2.02/* fails to load without expected_attach_type = BPF_XDP_DEVMAP3 * because of access to egress_ifindex4 */5#include <linux/bpf.h>6#include <bpf/bpf_helpers.h>7 8SEC("xdp")9int xdpdm_devlog(struct xdp_md *ctx)10{11	char fmt[] = "devmap redirect: dev %u -> dev %u len %u\n";12	void *data_end = (void *)(long)ctx->data_end;13	void *data = (void *)(long)ctx->data;14	unsigned int len = data_end - data;15 16	bpf_trace_printk(fmt, sizeof(fmt),17			 ctx->ingress_ifindex, ctx->egress_ifindex, len);18 19	return XDP_PASS;20}21 22char _license[] SEC("license") = "GPL";23