Commit 533de4ae authored by Andrii Nakryiko's avatar Andrii Nakryiko
Browse files

Merge branch 'libbpf: deprecate xdp_cpumap, xdp_devmap and classifier sec definitions'



Lorenzo Bianconi says:

====================

Deprecate xdp_cpumap, xdp_devmap and classifier sec definitions.
Update cpumap/devmap samples and kselftests.

Changes since v2:
- update warning log
- split libbpf and samples/kselftests changes
- deprecate classifier sec definition

Changes since v1:
- refer to Libbpf-1.0-migration-guide in the warning rised by libbpf
====================

Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
parents 5ee32ea2 8bab5322
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -491,7 +491,7 @@ int xdp_prognum5_lb_hash_ip_pairs(struct xdp_md *ctx)
	return bpf_redirect_map(&cpu_map, cpu_dest, 0);
}

SEC("xdp_cpumap/redirect")
SEC("xdp/cpumap")
int xdp_redirect_cpu_devmap(struct xdp_md *ctx)
{
	void *data_end = (void *)(long)ctx->data_end;
@@ -507,19 +507,19 @@ int xdp_redirect_cpu_devmap(struct xdp_md *ctx)
	return bpf_redirect_map(&tx_port, 0, 0);
}

SEC("xdp_cpumap/pass")
SEC("xdp/cpumap")
int xdp_redirect_cpu_pass(struct xdp_md *ctx)
{
	return XDP_PASS;
}

SEC("xdp_cpumap/drop")
SEC("xdp/cpumap")
int xdp_redirect_cpu_drop(struct xdp_md *ctx)
{
	return XDP_DROP;
}

SEC("xdp_devmap/egress")
SEC("xdp/devmap")
int xdp_redirect_egress_prog(struct xdp_md *ctx)
{
	void *data_end = (void *)(long)ctx->data_end;
+1 −1
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ int xdp_redirect_map_native(struct xdp_md *ctx)
	return xdp_redirect_map(ctx, &tx_port_native);
}

SEC("xdp_devmap/egress")
SEC("xdp/devmap")
int xdp_redirect_map_egress(struct xdp_md *ctx)
{
	void *data_end = (void *)(long)ctx->data_end;
+1 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ int xdp_redirect_map_native(struct xdp_md *ctx)
	return xdp_redirect_map(ctx, &forward_map_native);
}

SEC("xdp_devmap/egress")
SEC("xdp/devmap")
int xdp_devmap_prog(struct xdp_md *ctx)
{
	void *data_end = (void *)(long)ctx->data_end;
+11 −3
Original line number Diff line number Diff line
@@ -237,6 +237,8 @@ enum sec_def_flags {
	SEC_SLOPPY_PFX = 16,
	/* BPF program support non-linear XDP buffer */
	SEC_XDP_FRAGS = 32,
	/* deprecated sec definitions not supposed to be used */
	SEC_DEPRECATED = 64,
};

struct bpf_sec_def {
@@ -6575,6 +6577,10 @@ static int libbpf_preload_prog(struct bpf_program *prog,
	if (prog->type == BPF_PROG_TYPE_XDP && (def & SEC_XDP_FRAGS))
		opts->prog_flags |= BPF_F_XDP_HAS_FRAGS;

	if (def & SEC_DEPRECATED)
		pr_warn("SEC(\"%s\") is deprecated, please see https://github.com/libbpf/libbpf/wiki/Libbpf-1.0-migration-guide#bpf-program-sec-annotation-deprecations for details\n",
			prog->sec_name);

	if ((prog->type == BPF_PROG_TYPE_TRACING ||
	     prog->type == BPF_PROG_TYPE_LSM ||
	     prog->type == BPF_PROG_TYPE_EXT) && !prog->attach_btf_id) {
@@ -8596,7 +8602,7 @@ static const struct bpf_sec_def section_defs[] = {
	SEC_DEF("kretprobe/",		KPROBE, 0, SEC_NONE, attach_kprobe),
	SEC_DEF("uretprobe/",		KPROBE, 0, SEC_NONE),
	SEC_DEF("tc",			SCHED_CLS, 0, SEC_NONE),
	SEC_DEF("classifier",		SCHED_CLS, 0, SEC_NONE | SEC_SLOPPY_PFX),
	SEC_DEF("classifier",		SCHED_CLS, 0, SEC_NONE | SEC_SLOPPY_PFX | SEC_DEPRECATED),
	SEC_DEF("action",		SCHED_ACT, 0, SEC_NONE | SEC_SLOPPY_PFX),
	SEC_DEF("tracepoint/",		TRACEPOINT, 0, SEC_NONE, attach_tp),
	SEC_DEF("tp/",			TRACEPOINT, 0, SEC_NONE, attach_tp),
@@ -8618,9 +8624,11 @@ static const struct bpf_sec_def section_defs[] = {
	SEC_DEF("iter.s/",		TRACING, BPF_TRACE_ITER, SEC_ATTACH_BTF | SEC_SLEEPABLE, attach_iter),
	SEC_DEF("syscall",		SYSCALL, 0, SEC_SLEEPABLE),
	SEC_DEF("xdp.frags/devmap",	XDP, BPF_XDP_DEVMAP, SEC_XDP_FRAGS),
	SEC_DEF("xdp_devmap/",		XDP, BPF_XDP_DEVMAP, SEC_ATTACHABLE),
	SEC_DEF("xdp/devmap",		XDP, BPF_XDP_DEVMAP, SEC_ATTACHABLE),
	SEC_DEF("xdp_devmap/",		XDP, BPF_XDP_DEVMAP, SEC_ATTACHABLE | SEC_DEPRECATED),
	SEC_DEF("xdp.frags/cpumap",	XDP, BPF_XDP_CPUMAP, SEC_XDP_FRAGS),
	SEC_DEF("xdp_cpumap/",		XDP, BPF_XDP_CPUMAP, SEC_ATTACHABLE),
	SEC_DEF("xdp/cpumap",		XDP, BPF_XDP_CPUMAP, SEC_ATTACHABLE),
	SEC_DEF("xdp_cpumap/",		XDP, BPF_XDP_CPUMAP, SEC_ATTACHABLE | SEC_DEPRECATED),
	SEC_DEF("xdp.frags",		XDP, BPF_XDP, SEC_XDP_FRAGS),
	SEC_DEF("xdp",			XDP, BPF_XDP, SEC_ATTACHABLE_OPT | SEC_SLOPPY_PFX),
	SEC_DEF("perf_event",		PERF_EVENT, 0, SEC_NONE | SEC_SLOPPY_PFX),
+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ struct {
	__uint(max_entries, 4);
} cpu_map SEC(".maps");

SEC("xdp_cpumap/dummy_cm")
SEC("xdp/cpumap")
int xdp_dummy_cm(struct xdp_md *ctx)
{
	return XDP_PASS;
Loading