Files
linux/tools/testing/selftests/bpf/progs/changes_pkt_data.c
Eduard Zingerman 89ff40890d selftests/bpf: freplace tests for tracking of changes_packet_data
Try different combinations of global functions replacement:
- replace function that changes packet data with one that doesn't;
- replace function that changes packet data with one that does;
- replace function that doesn't change packet data with one that does;
- replace function that doesn't change packet data with one that doesn't;

Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20241210041100.1898468-7-eddyz87@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2024-12-10 10:24:57 -08:00

27 lines
452 B
C

// SPDX-License-Identifier: GPL-2.0
#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>
__noinline
long changes_pkt_data(struct __sk_buff *sk, __u32 len)
{
return bpf_skb_pull_data(sk, len);
}
__noinline __weak
long does_not_change_pkt_data(struct __sk_buff *sk, __u32 len)
{
return 0;
}
SEC("tc")
int dummy(struct __sk_buff *sk)
{
changes_pkt_data(sk, 0);
does_not_change_pkt_data(sk, 0);
return 0;
}
char _license[] SEC("license") = "GPL";