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
,
26 main_prog
= bpf_object__find_program_by_title(*obj
, section_name
);
30 *prog_fd
= bpf_program__fd(main_prog
);
34 prog_array
= bpf_object__find_map_by_name(*obj
, map_name
);
38 prog_array_fd
= bpf_map__fd(prog_array
);
39 if (prog_array_fd
< 0)
42 if (keys_map_name
&& keys_fd
) {
43 keys
= bpf_object__find_map_by_name(*obj
, keys_map_name
);
47 *keys_fd
= bpf_map__fd(keys
);
53 bpf_object__for_each_program(prog
, *obj
) {
54 fd
= bpf_program__fd(prog
);
59 bpf_map_update_elem(prog_array_fd
, &i
, &fd
, BPF_ANY
);
67 #endif /* FLOW_DISSECTOR_LOAD */