1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
2 #ifndef FLOW_DISSECTOR_LOAD
3 #define FLOW_DISSECTOR_LOAD
6 #include <bpf/libbpf.h>
8 static inline int bpf_flow_load(struct bpf_object
**obj
,
10 const char *section_name
,
12 const char *keys_map_name
,
16 struct bpf_program
*prog
, *main_prog
;
17 struct bpf_map
*prog_array
, *keys
;
21 ret
= bpf_prog_load(path
, BPF_PROG_TYPE_FLOW_DISSECTOR
, obj
,
27 bpf_object__for_each_program(prog
, *obj
) {
28 if (strcmp(section_name
, bpf_program__section_name(prog
)) == 0) {
36 *prog_fd
= bpf_program__fd(main_prog
);
40 prog_array
= bpf_object__find_map_by_name(*obj
, map_name
);
44 prog_array_fd
= bpf_map__fd(prog_array
);
45 if (prog_array_fd
< 0)
48 if (keys_map_name
&& keys_fd
) {
49 keys
= bpf_object__find_map_by_name(*obj
, keys_map_name
);
53 *keys_fd
= bpf_map__fd(keys
);
59 bpf_object__for_each_program(prog
, *obj
) {
60 fd
= bpf_program__fd(prog
);
65 bpf_map_update_elem(prog_array_fd
, &i
, &fd
, BPF_ANY
);
73 #endif /* FLOW_DISSECTOR_LOAD */