mirror of
https://github.com/torvalds/linux.git
synced 2026-11-29 01:43:18 +00:00
This is a simple test to check that loading and dumping metadata in btftool works, whether or not metadata contents are used by the program. A C test is also added to make sure the skeleton code can read the metadata values. Signed-off-by: YiFei Zhu <[email protected]> Signed-off-by: Stanislav Fomichev <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Cc: YiFei Zhu <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
16 lines
342 B
C
16 lines
342 B
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
#include <linux/bpf.h>
|
|
#include <bpf/bpf_helpers.h>
|
|
|
|
volatile const char bpf_metadata_a[] SEC(".rodata") = "bar";
|
|
volatile const int bpf_metadata_b SEC(".rodata") = 2;
|
|
|
|
SEC("cgroup_skb/egress")
|
|
int prog(struct xdp_md *ctx)
|
|
{
|
|
return bpf_metadata_b ? 1 : 0;
|
|
}
|
|
|
|
char _license[] SEC("license") = "GPL";
|