mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 04:31:50 +00:00
Merge branch 'libbpf: rename bpf_prog_attach_xattr to bpf_prog_attach_opts'
Christy Lee says: ==================== All xattr APIs are being dropped, mark bpf_prog_attach_opts() as deprecated and rename to bpf_prog_attach_xattr(). Replace all usages of the deprecated function with the new function name. [0] Closes: https://github.com/libbpf/libbpf/issues/285 Changelog: ---------- v2 -> v3: https://lore.kernel.org/all/20220106234639.1418484-2-christylee@fb.com/ * Fixed build break v1 -> v2: https://lore.kernel.org/all/20211230000110.1068538-1-christylee@fb.com/ * Used alias instead of returning original function * Split out selftests to a different commit ==================== Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
This commit is contained in:
commit
472ee694b0
@ -754,10 +754,10 @@ int bpf_prog_attach(int prog_fd, int target_fd, enum bpf_attach_type type,
|
|||||||
.flags = flags,
|
.flags = flags,
|
||||||
);
|
);
|
||||||
|
|
||||||
return bpf_prog_attach_xattr(prog_fd, target_fd, type, &opts);
|
return bpf_prog_attach_opts(prog_fd, target_fd, type, &opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
int bpf_prog_attach_xattr(int prog_fd, int target_fd,
|
int bpf_prog_attach_opts(int prog_fd, int target_fd,
|
||||||
enum bpf_attach_type type,
|
enum bpf_attach_type type,
|
||||||
const struct bpf_prog_attach_opts *opts)
|
const struct bpf_prog_attach_opts *opts)
|
||||||
{
|
{
|
||||||
@ -778,6 +778,11 @@ int bpf_prog_attach_xattr(int prog_fd, int target_fd,
|
|||||||
return libbpf_err_errno(ret);
|
return libbpf_err_errno(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__attribute__((alias("bpf_prog_attach_opts")))
|
||||||
|
int bpf_prog_attach_xattr(int prog_fd, int target_fd,
|
||||||
|
enum bpf_attach_type type,
|
||||||
|
const struct bpf_prog_attach_opts *opts);
|
||||||
|
|
||||||
int bpf_prog_detach(int target_fd, enum bpf_attach_type type)
|
int bpf_prog_detach(int target_fd, enum bpf_attach_type type)
|
||||||
{
|
{
|
||||||
union bpf_attr attr;
|
union bpf_attr attr;
|
||||||
|
@ -391,6 +391,10 @@ struct bpf_prog_attach_opts {
|
|||||||
|
|
||||||
LIBBPF_API int bpf_prog_attach(int prog_fd, int attachable_fd,
|
LIBBPF_API int bpf_prog_attach(int prog_fd, int attachable_fd,
|
||||||
enum bpf_attach_type type, unsigned int flags);
|
enum bpf_attach_type type, unsigned int flags);
|
||||||
|
LIBBPF_API int bpf_prog_attach_opts(int prog_fd, int attachable_fd,
|
||||||
|
enum bpf_attach_type type,
|
||||||
|
const struct bpf_prog_attach_opts *opts);
|
||||||
|
LIBBPF_DEPRECATED_SINCE(0, 8, "use bpf_prog_attach_opts() instead")
|
||||||
LIBBPF_API int bpf_prog_attach_xattr(int prog_fd, int attachable_fd,
|
LIBBPF_API int bpf_prog_attach_xattr(int prog_fd, int attachable_fd,
|
||||||
enum bpf_attach_type type,
|
enum bpf_attach_type type,
|
||||||
const struct bpf_prog_attach_opts *opts);
|
const struct bpf_prog_attach_opts *opts);
|
||||||
|
@ -247,6 +247,7 @@ LIBBPF_0.0.8 {
|
|||||||
bpf_link_create;
|
bpf_link_create;
|
||||||
bpf_link_update;
|
bpf_link_update;
|
||||||
bpf_map__set_initial_value;
|
bpf_map__set_initial_value;
|
||||||
|
bpf_prog_attach_opts;
|
||||||
bpf_program__attach_cgroup;
|
bpf_program__attach_cgroup;
|
||||||
bpf_program__attach_lsm;
|
bpf_program__attach_lsm;
|
||||||
bpf_program__is_lsm;
|
bpf_program__is_lsm;
|
||||||
|
@ -194,14 +194,14 @@ void serial_test_cgroup_attach_multi(void)
|
|||||||
|
|
||||||
attach_opts.flags = BPF_F_ALLOW_OVERRIDE | BPF_F_REPLACE;
|
attach_opts.flags = BPF_F_ALLOW_OVERRIDE | BPF_F_REPLACE;
|
||||||
attach_opts.replace_prog_fd = allow_prog[0];
|
attach_opts.replace_prog_fd = allow_prog[0];
|
||||||
if (CHECK(!bpf_prog_attach_xattr(allow_prog[6], cg1,
|
if (CHECK(!bpf_prog_attach_opts(allow_prog[6], cg1,
|
||||||
BPF_CGROUP_INET_EGRESS, &attach_opts),
|
BPF_CGROUP_INET_EGRESS, &attach_opts),
|
||||||
"fail_prog_replace_override", "unexpected success\n"))
|
"fail_prog_replace_override", "unexpected success\n"))
|
||||||
goto err;
|
goto err;
|
||||||
CHECK_FAIL(errno != EINVAL);
|
CHECK_FAIL(errno != EINVAL);
|
||||||
|
|
||||||
attach_opts.flags = BPF_F_REPLACE;
|
attach_opts.flags = BPF_F_REPLACE;
|
||||||
if (CHECK(!bpf_prog_attach_xattr(allow_prog[6], cg1,
|
if (CHECK(!bpf_prog_attach_opts(allow_prog[6], cg1,
|
||||||
BPF_CGROUP_INET_EGRESS, &attach_opts),
|
BPF_CGROUP_INET_EGRESS, &attach_opts),
|
||||||
"fail_prog_replace_no_multi", "unexpected success\n"))
|
"fail_prog_replace_no_multi", "unexpected success\n"))
|
||||||
goto err;
|
goto err;
|
||||||
@ -209,7 +209,7 @@ void serial_test_cgroup_attach_multi(void)
|
|||||||
|
|
||||||
attach_opts.flags = BPF_F_ALLOW_MULTI | BPF_F_REPLACE;
|
attach_opts.flags = BPF_F_ALLOW_MULTI | BPF_F_REPLACE;
|
||||||
attach_opts.replace_prog_fd = -1;
|
attach_opts.replace_prog_fd = -1;
|
||||||
if (CHECK(!bpf_prog_attach_xattr(allow_prog[6], cg1,
|
if (CHECK(!bpf_prog_attach_opts(allow_prog[6], cg1,
|
||||||
BPF_CGROUP_INET_EGRESS, &attach_opts),
|
BPF_CGROUP_INET_EGRESS, &attach_opts),
|
||||||
"fail_prog_replace_bad_fd", "unexpected success\n"))
|
"fail_prog_replace_bad_fd", "unexpected success\n"))
|
||||||
goto err;
|
goto err;
|
||||||
@ -217,7 +217,7 @@ void serial_test_cgroup_attach_multi(void)
|
|||||||
|
|
||||||
/* replacing a program that is not attached to cgroup should fail */
|
/* replacing a program that is not attached to cgroup should fail */
|
||||||
attach_opts.replace_prog_fd = allow_prog[3];
|
attach_opts.replace_prog_fd = allow_prog[3];
|
||||||
if (CHECK(!bpf_prog_attach_xattr(allow_prog[6], cg1,
|
if (CHECK(!bpf_prog_attach_opts(allow_prog[6], cg1,
|
||||||
BPF_CGROUP_INET_EGRESS, &attach_opts),
|
BPF_CGROUP_INET_EGRESS, &attach_opts),
|
||||||
"fail_prog_replace_no_ent", "unexpected success\n"))
|
"fail_prog_replace_no_ent", "unexpected success\n"))
|
||||||
goto err;
|
goto err;
|
||||||
@ -225,14 +225,14 @@ void serial_test_cgroup_attach_multi(void)
|
|||||||
|
|
||||||
/* replace 1st from the top program */
|
/* replace 1st from the top program */
|
||||||
attach_opts.replace_prog_fd = allow_prog[0];
|
attach_opts.replace_prog_fd = allow_prog[0];
|
||||||
if (CHECK(bpf_prog_attach_xattr(allow_prog[6], cg1,
|
if (CHECK(bpf_prog_attach_opts(allow_prog[6], cg1,
|
||||||
BPF_CGROUP_INET_EGRESS, &attach_opts),
|
BPF_CGROUP_INET_EGRESS, &attach_opts),
|
||||||
"prog_replace", "errno=%d\n", errno))
|
"prog_replace", "errno=%d\n", errno))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
/* replace program with itself */
|
/* replace program with itself */
|
||||||
attach_opts.replace_prog_fd = allow_prog[6];
|
attach_opts.replace_prog_fd = allow_prog[6];
|
||||||
if (CHECK(bpf_prog_attach_xattr(allow_prog[6], cg1,
|
if (CHECK(bpf_prog_attach_opts(allow_prog[6], cg1,
|
||||||
BPF_CGROUP_INET_EGRESS, &attach_opts),
|
BPF_CGROUP_INET_EGRESS, &attach_opts),
|
||||||
"prog_replace", "errno=%d\n", errno))
|
"prog_replace", "errno=%d\n", errno))
|
||||||
goto err;
|
goto err;
|
||||||
|
Loading…
Reference in New Issue
Block a user