xref: /aosp_15_r20/external/bpftool/src/main.h (revision 858ea5e570667251cdc31d3fe7b846b591105938)
1*858ea5e5SAndroid Build Coastguard Worker /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
2*858ea5e5SAndroid Build Coastguard Worker /* Copyright (C) 2017-2018 Netronome Systems, Inc. */
3*858ea5e5SAndroid Build Coastguard Worker 
4*858ea5e5SAndroid Build Coastguard Worker #ifndef __BPF_TOOL_H
5*858ea5e5SAndroid Build Coastguard Worker #define __BPF_TOOL_H
6*858ea5e5SAndroid Build Coastguard Worker 
7*858ea5e5SAndroid Build Coastguard Worker /* BFD and kernel.h both define GCC_VERSION, differently */
8*858ea5e5SAndroid Build Coastguard Worker #undef GCC_VERSION
9*858ea5e5SAndroid Build Coastguard Worker #include <stdbool.h>
10*858ea5e5SAndroid Build Coastguard Worker #include <stdio.h>
11*858ea5e5SAndroid Build Coastguard Worker #include <stdlib.h>
12*858ea5e5SAndroid Build Coastguard Worker #include <linux/bpf.h>
13*858ea5e5SAndroid Build Coastguard Worker #include <linux/compiler.h>
14*858ea5e5SAndroid Build Coastguard Worker #include <linux/kernel.h>
15*858ea5e5SAndroid Build Coastguard Worker 
16*858ea5e5SAndroid Build Coastguard Worker #include <bpf/hashmap.h>
17*858ea5e5SAndroid Build Coastguard Worker #include <bpf/libbpf.h>
18*858ea5e5SAndroid Build Coastguard Worker 
19*858ea5e5SAndroid Build Coastguard Worker #include "json_writer.h"
20*858ea5e5SAndroid Build Coastguard Worker 
21*858ea5e5SAndroid Build Coastguard Worker /* Make sure we do not use kernel-only integer typedefs */
22*858ea5e5SAndroid Build Coastguard Worker #pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64
23*858ea5e5SAndroid Build Coastguard Worker 
ptr_to_u64(const void * ptr)24*858ea5e5SAndroid Build Coastguard Worker static inline __u64 ptr_to_u64(const void *ptr)
25*858ea5e5SAndroid Build Coastguard Worker {
26*858ea5e5SAndroid Build Coastguard Worker 	return (__u64)(unsigned long)ptr;
27*858ea5e5SAndroid Build Coastguard Worker }
28*858ea5e5SAndroid Build Coastguard Worker 
u64_to_ptr(__u64 ptr)29*858ea5e5SAndroid Build Coastguard Worker static inline void *u64_to_ptr(__u64 ptr)
30*858ea5e5SAndroid Build Coastguard Worker {
31*858ea5e5SAndroid Build Coastguard Worker 	return (void *)(unsigned long)ptr;
32*858ea5e5SAndroid Build Coastguard Worker }
33*858ea5e5SAndroid Build Coastguard Worker 
34*858ea5e5SAndroid Build Coastguard Worker #define NEXT_ARG()	({ argc--; argv++; if (argc < 0) usage(); })
35*858ea5e5SAndroid Build Coastguard Worker #define NEXT_ARGP()	({ (*argc)--; (*argv)++; if (*argc < 0) usage(); })
36*858ea5e5SAndroid Build Coastguard Worker #define BAD_ARG()	({ p_err("what is '%s'?", *argv); -1; })
37*858ea5e5SAndroid Build Coastguard Worker #define GET_ARG()	({ argc--; *argv++; })
38*858ea5e5SAndroid Build Coastguard Worker #define REQ_ARGS(cnt)							\
39*858ea5e5SAndroid Build Coastguard Worker 	({								\
40*858ea5e5SAndroid Build Coastguard Worker 		int _cnt = (cnt);					\
41*858ea5e5SAndroid Build Coastguard Worker 		bool _res;						\
42*858ea5e5SAndroid Build Coastguard Worker 									\
43*858ea5e5SAndroid Build Coastguard Worker 		if (argc < _cnt) {					\
44*858ea5e5SAndroid Build Coastguard Worker 			p_err("'%s' needs at least %d arguments, %d found", \
45*858ea5e5SAndroid Build Coastguard Worker 			      argv[-1], _cnt, argc);			\
46*858ea5e5SAndroid Build Coastguard Worker 			_res = false;					\
47*858ea5e5SAndroid Build Coastguard Worker 		} else {						\
48*858ea5e5SAndroid Build Coastguard Worker 			_res = true;					\
49*858ea5e5SAndroid Build Coastguard Worker 		}							\
50*858ea5e5SAndroid Build Coastguard Worker 		_res;							\
51*858ea5e5SAndroid Build Coastguard Worker 	})
52*858ea5e5SAndroid Build Coastguard Worker 
53*858ea5e5SAndroid Build Coastguard Worker #define ERR_MAX_LEN	1024
54*858ea5e5SAndroid Build Coastguard Worker 
55*858ea5e5SAndroid Build Coastguard Worker #define BPF_TAG_FMT	"%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
56*858ea5e5SAndroid Build Coastguard Worker 
57*858ea5e5SAndroid Build Coastguard Worker #define HELP_SPEC_PROGRAM						\
58*858ea5e5SAndroid Build Coastguard Worker 	"PROG := { id PROG_ID | pinned FILE | tag PROG_TAG | name PROG_NAME }"
59*858ea5e5SAndroid Build Coastguard Worker #define HELP_SPEC_OPTIONS						\
60*858ea5e5SAndroid Build Coastguard Worker 	"OPTIONS := { {-j|--json} [{-p|--pretty}] | {-d|--debug}"
61*858ea5e5SAndroid Build Coastguard Worker #define HELP_SPEC_MAP							\
62*858ea5e5SAndroid Build Coastguard Worker 	"MAP := { id MAP_ID | pinned FILE | name MAP_NAME }"
63*858ea5e5SAndroid Build Coastguard Worker #define HELP_SPEC_LINK							\
64*858ea5e5SAndroid Build Coastguard Worker 	"LINK := { id LINK_ID | pinned FILE }"
65*858ea5e5SAndroid Build Coastguard Worker 
66*858ea5e5SAndroid Build Coastguard Worker /* keep in sync with the definition in skeleton/pid_iter.bpf.c */
67*858ea5e5SAndroid Build Coastguard Worker enum bpf_obj_type {
68*858ea5e5SAndroid Build Coastguard Worker 	BPF_OBJ_UNKNOWN,
69*858ea5e5SAndroid Build Coastguard Worker 	BPF_OBJ_PROG,
70*858ea5e5SAndroid Build Coastguard Worker 	BPF_OBJ_MAP,
71*858ea5e5SAndroid Build Coastguard Worker 	BPF_OBJ_LINK,
72*858ea5e5SAndroid Build Coastguard Worker 	BPF_OBJ_BTF,
73*858ea5e5SAndroid Build Coastguard Worker };
74*858ea5e5SAndroid Build Coastguard Worker 
75*858ea5e5SAndroid Build Coastguard Worker extern const char *bin_name;
76*858ea5e5SAndroid Build Coastguard Worker 
77*858ea5e5SAndroid Build Coastguard Worker extern json_writer_t *json_wtr;
78*858ea5e5SAndroid Build Coastguard Worker extern bool json_output;
79*858ea5e5SAndroid Build Coastguard Worker extern bool show_pinned;
80*858ea5e5SAndroid Build Coastguard Worker extern bool show_pids;
81*858ea5e5SAndroid Build Coastguard Worker extern bool block_mount;
82*858ea5e5SAndroid Build Coastguard Worker extern bool verifier_logs;
83*858ea5e5SAndroid Build Coastguard Worker extern bool relaxed_maps;
84*858ea5e5SAndroid Build Coastguard Worker extern bool use_loader;
85*858ea5e5SAndroid Build Coastguard Worker extern struct btf *base_btf;
86*858ea5e5SAndroid Build Coastguard Worker extern struct hashmap *refs_table;
87*858ea5e5SAndroid Build Coastguard Worker 
88*858ea5e5SAndroid Build Coastguard Worker void __printf(1, 2) p_err(const char *fmt, ...);
89*858ea5e5SAndroid Build Coastguard Worker void __printf(1, 2) p_info(const char *fmt, ...);
90*858ea5e5SAndroid Build Coastguard Worker 
91*858ea5e5SAndroid Build Coastguard Worker bool is_prefix(const char *pfx, const char *str);
92*858ea5e5SAndroid Build Coastguard Worker int detect_common_prefix(const char *arg, ...);
93*858ea5e5SAndroid Build Coastguard Worker void fprint_hex(FILE *f, void *arg, unsigned int n, const char *sep);
94*858ea5e5SAndroid Build Coastguard Worker void usage(void) __noreturn;
95*858ea5e5SAndroid Build Coastguard Worker 
96*858ea5e5SAndroid Build Coastguard Worker void set_max_rlimit(void);
97*858ea5e5SAndroid Build Coastguard Worker 
98*858ea5e5SAndroid Build Coastguard Worker int mount_tracefs(const char *target);
99*858ea5e5SAndroid Build Coastguard Worker 
100*858ea5e5SAndroid Build Coastguard Worker struct obj_ref {
101*858ea5e5SAndroid Build Coastguard Worker 	int pid;
102*858ea5e5SAndroid Build Coastguard Worker 	char comm[16];
103*858ea5e5SAndroid Build Coastguard Worker };
104*858ea5e5SAndroid Build Coastguard Worker 
105*858ea5e5SAndroid Build Coastguard Worker struct obj_refs {
106*858ea5e5SAndroid Build Coastguard Worker 	int ref_cnt;
107*858ea5e5SAndroid Build Coastguard Worker 	bool has_bpf_cookie;
108*858ea5e5SAndroid Build Coastguard Worker 	struct obj_ref *refs;
109*858ea5e5SAndroid Build Coastguard Worker 	__u64 bpf_cookie;
110*858ea5e5SAndroid Build Coastguard Worker };
111*858ea5e5SAndroid Build Coastguard Worker 
112*858ea5e5SAndroid Build Coastguard Worker struct btf;
113*858ea5e5SAndroid Build Coastguard Worker struct bpf_line_info;
114*858ea5e5SAndroid Build Coastguard Worker 
115*858ea5e5SAndroid Build Coastguard Worker int build_pinned_obj_table(struct hashmap *table,
116*858ea5e5SAndroid Build Coastguard Worker 			   enum bpf_obj_type type);
117*858ea5e5SAndroid Build Coastguard Worker void delete_pinned_obj_table(struct hashmap *table);
118*858ea5e5SAndroid Build Coastguard Worker __weak int build_obj_refs_table(struct hashmap **table,
119*858ea5e5SAndroid Build Coastguard Worker 				enum bpf_obj_type type);
120*858ea5e5SAndroid Build Coastguard Worker __weak void delete_obj_refs_table(struct hashmap *table);
121*858ea5e5SAndroid Build Coastguard Worker __weak void emit_obj_refs_json(struct hashmap *table, __u32 id,
122*858ea5e5SAndroid Build Coastguard Worker 			       json_writer_t *json_wtr);
123*858ea5e5SAndroid Build Coastguard Worker __weak void emit_obj_refs_plain(struct hashmap *table, __u32 id,
124*858ea5e5SAndroid Build Coastguard Worker 				const char *prefix);
125*858ea5e5SAndroid Build Coastguard Worker void print_dev_plain(__u32 ifindex, __u64 ns_dev, __u64 ns_inode);
126*858ea5e5SAndroid Build Coastguard Worker void print_dev_json(__u32 ifindex, __u64 ns_dev, __u64 ns_inode);
127*858ea5e5SAndroid Build Coastguard Worker 
128*858ea5e5SAndroid Build Coastguard Worker struct cmd {
129*858ea5e5SAndroid Build Coastguard Worker 	const char *cmd;
130*858ea5e5SAndroid Build Coastguard Worker 	int (*func)(int argc, char **argv);
131*858ea5e5SAndroid Build Coastguard Worker };
132*858ea5e5SAndroid Build Coastguard Worker 
133*858ea5e5SAndroid Build Coastguard Worker int cmd_select(const struct cmd *cmds, int argc, char **argv,
134*858ea5e5SAndroid Build Coastguard Worker 	       int (*help)(int argc, char **argv));
135*858ea5e5SAndroid Build Coastguard Worker 
136*858ea5e5SAndroid Build Coastguard Worker #define MAX_PROG_FULL_NAME 128
137*858ea5e5SAndroid Build Coastguard Worker void get_prog_full_name(const struct bpf_prog_info *prog_info, int prog_fd,
138*858ea5e5SAndroid Build Coastguard Worker 			char *name_buff, size_t buff_len);
139*858ea5e5SAndroid Build Coastguard Worker 
140*858ea5e5SAndroid Build Coastguard Worker int get_fd_type(int fd);
141*858ea5e5SAndroid Build Coastguard Worker const char *get_fd_type_name(enum bpf_obj_type type);
142*858ea5e5SAndroid Build Coastguard Worker char *get_fdinfo(int fd, const char *key);
143*858ea5e5SAndroid Build Coastguard Worker int open_obj_pinned(const char *path, bool quiet);
144*858ea5e5SAndroid Build Coastguard Worker int open_obj_pinned_any(const char *path, enum bpf_obj_type exp_type);
145*858ea5e5SAndroid Build Coastguard Worker int mount_bpffs_for_pin(const char *name, bool is_dir);
146*858ea5e5SAndroid Build Coastguard Worker int do_pin_any(int argc, char **argv, int (*get_fd_by_id)(int *, char ***));
147*858ea5e5SAndroid Build Coastguard Worker int do_pin_fd(int fd, const char *name);
148*858ea5e5SAndroid Build Coastguard Worker 
149*858ea5e5SAndroid Build Coastguard Worker /* commands available in bootstrap mode */
150*858ea5e5SAndroid Build Coastguard Worker int do_gen(int argc, char **argv);
151*858ea5e5SAndroid Build Coastguard Worker int do_btf(int argc, char **argv);
152*858ea5e5SAndroid Build Coastguard Worker 
153*858ea5e5SAndroid Build Coastguard Worker /* non-bootstrap only commands */
154*858ea5e5SAndroid Build Coastguard Worker int do_prog(int argc, char **arg) __weak;
155*858ea5e5SAndroid Build Coastguard Worker int do_map(int argc, char **arg) __weak;
156*858ea5e5SAndroid Build Coastguard Worker int do_link(int argc, char **arg) __weak;
157*858ea5e5SAndroid Build Coastguard Worker int do_event_pipe(int argc, char **argv) __weak;
158*858ea5e5SAndroid Build Coastguard Worker int do_cgroup(int argc, char **arg) __weak;
159*858ea5e5SAndroid Build Coastguard Worker int do_perf(int argc, char **arg) __weak;
160*858ea5e5SAndroid Build Coastguard Worker int do_net(int argc, char **arg) __weak;
161*858ea5e5SAndroid Build Coastguard Worker int do_tracelog(int argc, char **arg) __weak;
162*858ea5e5SAndroid Build Coastguard Worker int do_feature(int argc, char **argv) __weak;
163*858ea5e5SAndroid Build Coastguard Worker int do_struct_ops(int argc, char **argv) __weak;
164*858ea5e5SAndroid Build Coastguard Worker int do_iter(int argc, char **argv) __weak;
165*858ea5e5SAndroid Build Coastguard Worker 
166*858ea5e5SAndroid Build Coastguard Worker int parse_u32_arg(int *argc, char ***argv, __u32 *val, const char *what);
167*858ea5e5SAndroid Build Coastguard Worker int prog_parse_fd(int *argc, char ***argv);
168*858ea5e5SAndroid Build Coastguard Worker int prog_parse_fds(int *argc, char ***argv, int **fds);
169*858ea5e5SAndroid Build Coastguard Worker int map_parse_fd(int *argc, char ***argv);
170*858ea5e5SAndroid Build Coastguard Worker int map_parse_fds(int *argc, char ***argv, int **fds);
171*858ea5e5SAndroid Build Coastguard Worker int map_parse_fd_and_info(int *argc, char ***argv, struct bpf_map_info *info,
172*858ea5e5SAndroid Build Coastguard Worker 			  __u32 *info_len);
173*858ea5e5SAndroid Build Coastguard Worker 
174*858ea5e5SAndroid Build Coastguard Worker struct bpf_prog_linfo;
175*858ea5e5SAndroid Build Coastguard Worker #if defined(HAVE_LLVM_SUPPORT) || defined(HAVE_LIBBFD_SUPPORT)
176*858ea5e5SAndroid Build Coastguard Worker int disasm_print_insn(unsigned char *image, ssize_t len, int opcodes,
177*858ea5e5SAndroid Build Coastguard Worker 		      const char *arch, const char *disassembler_options,
178*858ea5e5SAndroid Build Coastguard Worker 		      const struct btf *btf,
179*858ea5e5SAndroid Build Coastguard Worker 		      const struct bpf_prog_linfo *prog_linfo,
180*858ea5e5SAndroid Build Coastguard Worker 		      __u64 func_ksym, unsigned int func_idx,
181*858ea5e5SAndroid Build Coastguard Worker 		      bool linum);
182*858ea5e5SAndroid Build Coastguard Worker int disasm_init(void);
183*858ea5e5SAndroid Build Coastguard Worker #else
184*858ea5e5SAndroid Build Coastguard Worker static inline
disasm_print_insn(unsigned char * image,ssize_t len,int opcodes,const char * arch,const char * disassembler_options,const struct btf * btf,const struct bpf_prog_linfo * prog_linfo,__u64 func_ksym,unsigned int func_idx,bool linum)185*858ea5e5SAndroid Build Coastguard Worker int disasm_print_insn(unsigned char *image, ssize_t len, int opcodes,
186*858ea5e5SAndroid Build Coastguard Worker 		      const char *arch, const char *disassembler_options,
187*858ea5e5SAndroid Build Coastguard Worker 		      const struct btf *btf,
188*858ea5e5SAndroid Build Coastguard Worker 		      const struct bpf_prog_linfo *prog_linfo,
189*858ea5e5SAndroid Build Coastguard Worker 		      __u64 func_ksym, unsigned int func_idx,
190*858ea5e5SAndroid Build Coastguard Worker 		      bool linum)
191*858ea5e5SAndroid Build Coastguard Worker {
192*858ea5e5SAndroid Build Coastguard Worker 	return 0;
193*858ea5e5SAndroid Build Coastguard Worker }
disasm_init(void)194*858ea5e5SAndroid Build Coastguard Worker static inline int disasm_init(void)
195*858ea5e5SAndroid Build Coastguard Worker {
196*858ea5e5SAndroid Build Coastguard Worker 	p_err("No JIT disassembly support");
197*858ea5e5SAndroid Build Coastguard Worker 	return -1;
198*858ea5e5SAndroid Build Coastguard Worker }
199*858ea5e5SAndroid Build Coastguard Worker #endif
200*858ea5e5SAndroid Build Coastguard Worker void print_data_json(uint8_t *data, size_t len);
201*858ea5e5SAndroid Build Coastguard Worker void print_hex_data_json(uint8_t *data, size_t len);
202*858ea5e5SAndroid Build Coastguard Worker 
203*858ea5e5SAndroid Build Coastguard Worker unsigned int get_page_size(void);
204*858ea5e5SAndroid Build Coastguard Worker unsigned int get_possible_cpus(void);
205*858ea5e5SAndroid Build Coastguard Worker const char *
206*858ea5e5SAndroid Build Coastguard Worker ifindex_to_arch(__u32 ifindex, __u64 ns_dev, __u64 ns_ino, const char **opt);
207*858ea5e5SAndroid Build Coastguard Worker 
208*858ea5e5SAndroid Build Coastguard Worker struct btf_dumper {
209*858ea5e5SAndroid Build Coastguard Worker 	const struct btf *btf;
210*858ea5e5SAndroid Build Coastguard Worker 	json_writer_t *jw;
211*858ea5e5SAndroid Build Coastguard Worker 	bool is_plain_text;
212*858ea5e5SAndroid Build Coastguard Worker 	bool prog_id_as_func_ptr;
213*858ea5e5SAndroid Build Coastguard Worker };
214*858ea5e5SAndroid Build Coastguard Worker 
215*858ea5e5SAndroid Build Coastguard Worker /* btf_dumper_type - print data along with type information
216*858ea5e5SAndroid Build Coastguard Worker  * @d: an instance containing context for dumping types
217*858ea5e5SAndroid Build Coastguard Worker  * @type_id: index in btf->types array. this points to the type to be dumped
218*858ea5e5SAndroid Build Coastguard Worker  * @data: pointer the actual data, i.e. the values to be printed
219*858ea5e5SAndroid Build Coastguard Worker  *
220*858ea5e5SAndroid Build Coastguard Worker  * Returns zero on success and negative error code otherwise
221*858ea5e5SAndroid Build Coastguard Worker  */
222*858ea5e5SAndroid Build Coastguard Worker int btf_dumper_type(const struct btf_dumper *d, __u32 type_id,
223*858ea5e5SAndroid Build Coastguard Worker 		    const void *data);
224*858ea5e5SAndroid Build Coastguard Worker void btf_dumper_type_only(const struct btf *btf, __u32 func_type_id,
225*858ea5e5SAndroid Build Coastguard Worker 			  char *func_only, int size);
226*858ea5e5SAndroid Build Coastguard Worker 
227*858ea5e5SAndroid Build Coastguard Worker void btf_dump_linfo_plain(const struct btf *btf,
228*858ea5e5SAndroid Build Coastguard Worker 			  const struct bpf_line_info *linfo,
229*858ea5e5SAndroid Build Coastguard Worker 			  const char *prefix, bool linum);
230*858ea5e5SAndroid Build Coastguard Worker void btf_dump_linfo_json(const struct btf *btf,
231*858ea5e5SAndroid Build Coastguard Worker 			 const struct bpf_line_info *linfo, bool linum);
232*858ea5e5SAndroid Build Coastguard Worker void btf_dump_linfo_dotlabel(const struct btf *btf,
233*858ea5e5SAndroid Build Coastguard Worker 			     const struct bpf_line_info *linfo, bool linum);
234*858ea5e5SAndroid Build Coastguard Worker 
235*858ea5e5SAndroid Build Coastguard Worker struct nlattr;
236*858ea5e5SAndroid Build Coastguard Worker struct ifinfomsg;
237*858ea5e5SAndroid Build Coastguard Worker struct tcmsg;
238*858ea5e5SAndroid Build Coastguard Worker int do_xdp_dump(struct ifinfomsg *ifinfo, struct nlattr **tb);
239*858ea5e5SAndroid Build Coastguard Worker int do_filter_dump(struct tcmsg *ifinfo, struct nlattr **tb, const char *kind,
240*858ea5e5SAndroid Build Coastguard Worker 		   const char *devname, int ifindex);
241*858ea5e5SAndroid Build Coastguard Worker 
242*858ea5e5SAndroid Build Coastguard Worker int print_all_levels(__maybe_unused enum libbpf_print_level level,
243*858ea5e5SAndroid Build Coastguard Worker 		     const char *format, va_list args);
244*858ea5e5SAndroid Build Coastguard Worker 
245*858ea5e5SAndroid Build Coastguard Worker size_t hash_fn_for_key_as_id(long key, void *ctx);
246*858ea5e5SAndroid Build Coastguard Worker bool equal_fn_for_key_as_id(long k1, long k2, void *ctx);
247*858ea5e5SAndroid Build Coastguard Worker 
248*858ea5e5SAndroid Build Coastguard Worker /* bpf_attach_type_input_str - convert the provided attach type value into a
249*858ea5e5SAndroid Build Coastguard Worker  * textual representation that we accept for input purposes.
250*858ea5e5SAndroid Build Coastguard Worker  *
251*858ea5e5SAndroid Build Coastguard Worker  * This function is similar in nature to libbpf_bpf_attach_type_str, but
252*858ea5e5SAndroid Build Coastguard Worker  * recognizes some attach type names that have been used by the program in the
253*858ea5e5SAndroid Build Coastguard Worker  * past and which do not follow the string inference scheme that libbpf uses.
254*858ea5e5SAndroid Build Coastguard Worker  * These textual representations should only be used for user input.
255*858ea5e5SAndroid Build Coastguard Worker  *
256*858ea5e5SAndroid Build Coastguard Worker  * @t: The attach type
257*858ea5e5SAndroid Build Coastguard Worker  * Returns a pointer to a static string identifying the attach type. NULL is
258*858ea5e5SAndroid Build Coastguard Worker  * returned for unknown bpf_attach_type values.
259*858ea5e5SAndroid Build Coastguard Worker  */
260*858ea5e5SAndroid Build Coastguard Worker const char *bpf_attach_type_input_str(enum bpf_attach_type t);
261*858ea5e5SAndroid Build Coastguard Worker 
hashmap__empty(struct hashmap * map)262*858ea5e5SAndroid Build Coastguard Worker static inline bool hashmap__empty(struct hashmap *map)
263*858ea5e5SAndroid Build Coastguard Worker {
264*858ea5e5SAndroid Build Coastguard Worker 	return map ? hashmap__size(map) == 0 : true;
265*858ea5e5SAndroid Build Coastguard Worker }
266*858ea5e5SAndroid Build Coastguard Worker 
267*858ea5e5SAndroid Build Coastguard Worker int pathname_concat(char *buf, int buf_sz, const char *path,
268*858ea5e5SAndroid Build Coastguard Worker 		    const char *name);
269*858ea5e5SAndroid Build Coastguard Worker 
270*858ea5e5SAndroid Build Coastguard Worker /* print netfilter bpf_link info */
271*858ea5e5SAndroid Build Coastguard Worker void netfilter_dump_plain(const struct bpf_link_info *info);
272*858ea5e5SAndroid Build Coastguard Worker void netfilter_dump_json(const struct bpf_link_info *info, json_writer_t *wtr);
273*858ea5e5SAndroid Build Coastguard Worker #endif
274