mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
samples, bpf: Replace bpf_program__title() with bpf_program__section_name()
From commit5210958420
("libbpf: Deprecate notion of BPF program "title" in favor of "section name""), the term title has been replaced with section name in libbpf. Since the bpf_program__title() has been deprecated, this commit switches this function to bpf_program__section_name(). Due to this commit, the compilation warning issue has also been resolved. Fixes:5210958420
("libbpf: Deprecate notion of BPF program "title" in favor of "section name"") Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20200904063434.24963-1-danieltimlee@gmail.com
This commit is contained in:
parent
8eb629585d
commit
698584dffd
4 changed files with 10 additions and 10 deletions
|
@ -29,8 +29,8 @@ int main(int argc, char **argv)
|
||||||
struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
|
struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
|
||||||
struct bpf_program *prog;
|
struct bpf_program *prog;
|
||||||
struct bpf_object *obj;
|
struct bpf_object *obj;
|
||||||
|
const char *section;
|
||||||
char filename[256];
|
char filename[256];
|
||||||
const char *title;
|
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
|
snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
|
||||||
|
@ -58,8 +58,8 @@ int main(int argc, char **argv)
|
||||||
bpf_object__for_each_program(prog, obj) {
|
bpf_object__for_each_program(prog, obj) {
|
||||||
fd = bpf_program__fd(prog);
|
fd = bpf_program__fd(prog);
|
||||||
|
|
||||||
title = bpf_program__title(prog, false);
|
section = bpf_program__section_name(prog);
|
||||||
if (sscanf(title, "socket/%d", &key) != 1) {
|
if (sscanf(section, "socket/%d", &key) != 1) {
|
||||||
fprintf(stderr, "ERROR: finding prog failed\n");
|
fprintf(stderr, "ERROR: finding prog failed\n");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ int main(int ac, char **argv)
|
||||||
long key, next_key, value;
|
long key, next_key, value;
|
||||||
struct bpf_program *prog;
|
struct bpf_program *prog;
|
||||||
int map_fd, i, j = 0;
|
int map_fd, i, j = 0;
|
||||||
const char *title;
|
const char *section;
|
||||||
struct ksym *sym;
|
struct ksym *sym;
|
||||||
|
|
||||||
if (setrlimit(RLIMIT_MEMLOCK, &r)) {
|
if (setrlimit(RLIMIT_MEMLOCK, &r)) {
|
||||||
|
@ -51,8 +51,8 @@ int main(int ac, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
bpf_object__for_each_program(prog, obj) {
|
bpf_object__for_each_program(prog, obj) {
|
||||||
title = bpf_program__title(prog, false);
|
section = bpf_program__section_name(prog);
|
||||||
if (sscanf(title, "kprobe/%s", symbol) != 1)
|
if (sscanf(section, "kprobe/%s", symbol) != 1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Attach prog only when symbol exists */
|
/* Attach prog only when symbol exists */
|
||||||
|
|
|
@ -39,8 +39,8 @@ int main(int ac, char **argv)
|
||||||
struct bpf_program *prog;
|
struct bpf_program *prog;
|
||||||
struct bpf_object *obj;
|
struct bpf_object *obj;
|
||||||
int key, fd, progs_fd;
|
int key, fd, progs_fd;
|
||||||
|
const char *section;
|
||||||
char filename[256];
|
char filename[256];
|
||||||
const char *title;
|
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
setrlimit(RLIMIT_MEMLOCK, &r);
|
setrlimit(RLIMIT_MEMLOCK, &r);
|
||||||
|
@ -78,9 +78,9 @@ int main(int ac, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
bpf_object__for_each_program(prog, obj) {
|
bpf_object__for_each_program(prog, obj) {
|
||||||
title = bpf_program__title(prog, false);
|
section = bpf_program__section_name(prog);
|
||||||
/* register only syscalls to PROG_ARRAY */
|
/* register only syscalls to PROG_ARRAY */
|
||||||
if (sscanf(title, "kprobe/%d", &key) != 1)
|
if (sscanf(section, "kprobe/%d", &key) != 1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
fd = bpf_program__fd(prog);
|
fd = bpf_program__fd(prog);
|
||||||
|
|
|
@ -111,7 +111,7 @@ static void print_avail_progs(struct bpf_object *obj)
|
||||||
|
|
||||||
bpf_object__for_each_program(pos, obj) {
|
bpf_object__for_each_program(pos, obj) {
|
||||||
if (bpf_program__is_xdp(pos))
|
if (bpf_program__is_xdp(pos))
|
||||||
printf(" %s\n", bpf_program__title(pos, false));
|
printf(" %s\n", bpf_program__section_name(pos));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue