libbpf: Deprecate multi-instance bpf_program APIs
Schedule deprecation of a set of APIs that are related to multi-instance
bpf_programs:
- bpf_program__set_prep() ([0]);
- bpf_program__{set,unset}_instance() ([1]);
- bpf_program__nth_fd().
These APIs are obscure, very niche, and don't seem to be used much in
practice. bpf_program__set_prep() is pretty useless for anything but the
simplest BPF programs, as it doesn't allow to adjust BPF program load
attributes, among other things. In short, it already bitrotted and will
bitrot some more if not removed.
With bpf_program__insns() API, which gives access to post-processed BPF
program instructions of any given entry-point BPF program, it's now
possible to do whatever necessary adjustments were possible with
set_prep() API before, but also more. Given any such use case is
automatically an advanced use case, requiring users to stick to
low-level bpf_prog_load() APIs and managing their own prog FDs is
reasonable.
[0] Closes: https://github.com/libbpf/libbpf/issues/299
[1] Closes: https://github.com/libbpf/libbpf/issues/300
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20211025224531.1088894-4-andrii@kernel.org
This commit is contained in:
committed by
Alexei Starovoitov
parent
65a7fa2e4e
commit
e21d585cb3
@@ -7358,8 +7358,7 @@ static int check_path(const char *path)
|
||||
return err;
|
||||
}
|
||||
|
||||
int bpf_program__pin_instance(struct bpf_program *prog, const char *path,
|
||||
int instance)
|
||||
static int bpf_program_pin_instance(struct bpf_program *prog, const char *path, int instance)
|
||||
{
|
||||
char *cp, errmsg[STRERR_BUFSIZE];
|
||||
int err;
|
||||
@@ -7394,8 +7393,7 @@ int bpf_program__pin_instance(struct bpf_program *prog, const char *path,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bpf_program__unpin_instance(struct bpf_program *prog, const char *path,
|
||||
int instance)
|
||||
static int bpf_program_unpin_instance(struct bpf_program *prog, const char *path, int instance)
|
||||
{
|
||||
int err;
|
||||
|
||||
@@ -7423,6 +7421,12 @@ int bpf_program__unpin_instance(struct bpf_program *prog, const char *path,
|
||||
return 0;
|
||||
}
|
||||
|
||||
__attribute__((alias("bpf_program_pin_instance")))
|
||||
int bpf_object__pin_instance(struct bpf_program *prog, const char *path, int instance);
|
||||
|
||||
__attribute__((alias("bpf_program_unpin_instance")))
|
||||
int bpf_program__unpin_instance(struct bpf_program *prog, const char *path, int instance);
|
||||
|
||||
int bpf_program__pin(struct bpf_program *prog, const char *path)
|
||||
{
|
||||
int i, err;
|
||||
@@ -7447,7 +7451,7 @@ int bpf_program__pin(struct bpf_program *prog, const char *path)
|
||||
|
||||
if (prog->instances.nr == 1) {
|
||||
/* don't create subdirs when pinning single instance */
|
||||
return bpf_program__pin_instance(prog, path, 0);
|
||||
return bpf_program_pin_instance(prog, path, 0);
|
||||
}
|
||||
|
||||
for (i = 0; i < prog->instances.nr; i++) {
|
||||
@@ -7463,7 +7467,7 @@ int bpf_program__pin(struct bpf_program *prog, const char *path)
|
||||
goto err_unpin;
|
||||
}
|
||||
|
||||
err = bpf_program__pin_instance(prog, buf, i);
|
||||
err = bpf_program_pin_instance(prog, buf, i);
|
||||
if (err)
|
||||
goto err_unpin;
|
||||
}
|
||||
@@ -7481,7 +7485,7 @@ err_unpin:
|
||||
else if (len >= PATH_MAX)
|
||||
continue;
|
||||
|
||||
bpf_program__unpin_instance(prog, buf, i);
|
||||
bpf_program_unpin_instance(prog, buf, i);
|
||||
}
|
||||
|
||||
rmdir(path);
|
||||
@@ -7509,7 +7513,7 @@ int bpf_program__unpin(struct bpf_program *prog, const char *path)
|
||||
|
||||
if (prog->instances.nr == 1) {
|
||||
/* don't create subdirs when pinning single instance */
|
||||
return bpf_program__unpin_instance(prog, path, 0);
|
||||
return bpf_program_unpin_instance(prog, path, 0);
|
||||
}
|
||||
|
||||
for (i = 0; i < prog->instances.nr; i++) {
|
||||
@@ -7522,7 +7526,7 @@ int bpf_program__unpin(struct bpf_program *prog, const char *path)
|
||||
else if (len >= PATH_MAX)
|
||||
return libbpf_err(-ENAMETOOLONG);
|
||||
|
||||
err = bpf_program__unpin_instance(prog, buf, i);
|
||||
err = bpf_program_unpin_instance(prog, buf, i);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user