Alexei Starovoitov says: ==================== pull-request: bpf-next 2021-12-30 The following pull-request contains BPF updates for your *net-next* tree. We've added 72 non-merge commits during the last 20 day(s) which contain a total of 223 files changed, 3510 insertions(+), 1591 deletions(-). The main changes are: 1) Automatic setrlimit in libbpf when bpf is memcg's in the kernel, from Andrii. 2) Beautify and de-verbose verifier logs, from Christy. 3) Composable verifier types, from Hao. 4) bpf_strncmp helper, from Hou. 5) bpf.h header dependency cleanup, from Jakub. 6) get_func_[arg|ret|arg_cnt] helpers, from Jiri. 7) Sleepable local storage, from KP. 8) Extend kfunc with PTR_TO_CTX, PTR_TO_MEM argument support, from Kumar. ====================
Showing the changes to samples (2 of 221 files). Show all
Unified · Split
| @@ -120,6 +120,9 @@ static void do_error(char *msg, bool errno_flag) · 119 unmodified lines | ||
| 120 | 120 | |
| 121 | 121 | static int prog_load(char *prog) |
| 122 | 122 | { |
| 123 | + struct bpf_program *pos; | |
| 124 | + const char *sec_name; | |
| 125 | + | |
| 123 | 126 | obj = bpf_object__open_file(prog, NULL); |
| 124 | 127 | if (libbpf_get_error(obj)) { |
| 125 | 128 | printf("ERROR: opening BPF object file failed\n"); |
| @@ -132,7 +135,13 @@ static int prog_load(char *prog) · 6 unmodified lines | ||
| 132 | 135 | goto err; |
| 133 | 136 | } |
| 134 | 137 | |
| 135 | − bpf_prog = bpf_object__find_program_by_title(obj, "cgroup_skb/egress"); | |
| 138 | + bpf_object__for_each_program(pos, obj) { | |
| 139 | + sec_name = bpf_program__section_name(pos); | |
| 140 | + if (sec_name && !strcmp(sec_name, "cgroup_skb/egress")) { | |
| 141 | + bpf_prog = pos; | |
| 142 | + break; | |
| 143 | + } | |
| 144 | + } | |
| 136 | 145 | if (!bpf_prog) { |
| 137 | 146 | printf("ERROR: finding a prog in obj file failed\n"); |
| 138 | 147 | goto err; |
| @@ -79,7 +79,9 @@ int main(int argc, char **argv) · 78 unmodified lines | ||
| 79 | 79 | .prog_type = BPF_PROG_TYPE_XDP, |
| 80 | 80 | }; |
| 81 | 81 | const char *prog_name = "xdp_fwd"; |
| 82 | − struct bpf_program *prog; | |
| 82 | + struct bpf_program *prog = NULL; | |
| 83 | + struct bpf_program *pos; | |
| 84 | + const char *sec_name; | |
| 83 | 85 | int prog_fd, map_fd = -1; |
| 84 | 86 | char filename[PATH_MAX]; |
| 85 | 87 | struct bpf_object *obj; |
| @@ -134,7 +136,13 @@ int main(int argc, char **argv) · 48 unmodified lines | ||
| 134 | 136 | return 1; |
| 135 | 137 | } |
| 136 | 138 | |
| 137 | − prog = bpf_object__find_program_by_title(obj, prog_name); | |
| 139 | + bpf_object__for_each_program(pos, obj) { | |
| 140 | + sec_name = bpf_program__section_name(pos); | |
| 141 | + if (sec_name && !strcmp(sec_name, prog_name)) { | |
| 142 | + prog = pos; | |
| 143 | + break; | |
| 144 | + } | |
| 145 | + } | |
| 138 | 146 | prog_fd = bpf_program__fd(prog); |
| 139 | 147 | if (prog_fd < 0) { |
| 140 | 148 | printf("program not found: %s\n", strerror(prog_fd)); |