1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2 /* Copyright (C) 2017-2018 Netronome Systems, Inc. */
14 #include <sys/types.h>
17 #include <linux/err.h>
25 #include "xlated_dumper.h"
27 static const char * const attach_type_strings
[] = {
28 [BPF_SK_SKB_STREAM_PARSER
] = "stream_parser",
29 [BPF_SK_SKB_STREAM_VERDICT
] = "stream_verdict",
30 [BPF_SK_MSG_VERDICT
] = "msg_verdict",
31 [BPF_FLOW_DISSECTOR
] = "flow_dissector",
32 [__MAX_BPF_ATTACH_TYPE
] = NULL
,
35 static enum bpf_attach_type
parse_attach_type(const char *str
)
37 enum bpf_attach_type type
;
39 for (type
= 0; type
< __MAX_BPF_ATTACH_TYPE
; type
++) {
40 if (attach_type_strings
[type
] &&
41 is_prefix(str
, attach_type_strings
[type
]))
45 return __MAX_BPF_ATTACH_TYPE
;
48 static void print_boot_time(__u64 nsecs
, char *buf
, unsigned int size
)
50 struct timespec real_time_ts
, boot_time_ts
;
51 time_t wallclock_secs
;
56 if (clock_gettime(CLOCK_REALTIME
, &real_time_ts
) ||
57 clock_gettime(CLOCK_BOOTTIME
, &boot_time_ts
)) {
58 perror("Can't read clocks");
59 snprintf(buf
, size
, "%llu", nsecs
/ 1000000000);
63 wallclock_secs
= (real_time_ts
.tv_sec
- boot_time_ts
.tv_sec
) +
64 (real_time_ts
.tv_nsec
- boot_time_ts
.tv_nsec
+ nsecs
) /
68 if (!localtime_r(&wallclock_secs
, &load_tm
)) {
69 snprintf(buf
, size
, "%llu", nsecs
/ 1000000000);
74 strftime(buf
, size
, "%s", &load_tm
);
76 strftime(buf
, size
, "%FT%T%z", &load_tm
);
79 static int prog_fd_by_tag(unsigned char *tag
)
86 struct bpf_prog_info info
= {};
87 __u32 len
= sizeof(info
);
89 err
= bpf_prog_get_next_id(id
, &id
);
91 p_err("%s", strerror(errno
));
95 fd
= bpf_prog_get_fd_by_id(id
);
97 p_err("can't get prog by id (%u): %s",
102 err
= bpf_obj_get_info_by_fd(fd
, &info
, &len
);
104 p_err("can't get prog info (%u): %s",
105 id
, strerror(errno
));
110 if (!memcmp(tag
, info
.tag
, BPF_TAG_SIZE
))
117 int prog_parse_fd(int *argc
, char ***argv
)
121 if (is_prefix(**argv
, "id")) {
127 id
= strtoul(**argv
, &endptr
, 0);
129 p_err("can't parse %s as ID", **argv
);
134 fd
= bpf_prog_get_fd_by_id(id
);
136 p_err("get by id (%u): %s", id
, strerror(errno
));
138 } else if (is_prefix(**argv
, "tag")) {
139 unsigned char tag
[BPF_TAG_SIZE
];
143 if (sscanf(**argv
, BPF_TAG_FMT
, tag
, tag
+ 1, tag
+ 2,
144 tag
+ 3, tag
+ 4, tag
+ 5, tag
+ 6, tag
+ 7)
146 p_err("can't parse tag");
151 return prog_fd_by_tag(tag
);
152 } else if (is_prefix(**argv
, "pinned")) {
160 return open_obj_pinned_any(path
, BPF_OBJ_PROG
);
163 p_err("expected 'id', 'tag' or 'pinned', got: '%s'?", **argv
);
167 static void show_prog_maps(int fd
, u32 num_maps
)
169 struct bpf_prog_info info
= {};
170 __u32 len
= sizeof(info
);
171 __u32 map_ids
[num_maps
];
175 info
.nr_map_ids
= num_maps
;
176 info
.map_ids
= ptr_to_u64(map_ids
);
178 err
= bpf_obj_get_info_by_fd(fd
, &info
, &len
);
179 if (err
|| !info
.nr_map_ids
)
183 jsonw_name(json_wtr
, "map_ids");
184 jsonw_start_array(json_wtr
);
185 for (i
= 0; i
< info
.nr_map_ids
; i
++)
186 jsonw_uint(json_wtr
, map_ids
[i
]);
187 jsonw_end_array(json_wtr
);
190 for (i
= 0; i
< info
.nr_map_ids
; i
++)
191 printf("%u%s", map_ids
[i
],
192 i
== info
.nr_map_ids
- 1 ? "" : ",");
196 static void print_prog_json(struct bpf_prog_info
*info
, int fd
)
200 jsonw_start_object(json_wtr
);
201 jsonw_uint_field(json_wtr
, "id", info
->id
);
202 if (info
->type
< ARRAY_SIZE(prog_type_name
))
203 jsonw_string_field(json_wtr
, "type",
204 prog_type_name
[info
->type
]);
206 jsonw_uint_field(json_wtr
, "type", info
->type
);
209 jsonw_string_field(json_wtr
, "name", info
->name
);
211 jsonw_name(json_wtr
, "tag");
212 jsonw_printf(json_wtr
, "\"" BPF_TAG_FMT
"\"",
213 info
->tag
[0], info
->tag
[1], info
->tag
[2], info
->tag
[3],
214 info
->tag
[4], info
->tag
[5], info
->tag
[6], info
->tag
[7]);
216 jsonw_bool_field(json_wtr
, "gpl_compatible", info
->gpl_compatible
);
217 if (info
->run_time_ns
) {
218 jsonw_uint_field(json_wtr
, "run_time_ns", info
->run_time_ns
);
219 jsonw_uint_field(json_wtr
, "run_cnt", info
->run_cnt
);
222 print_dev_json(info
->ifindex
, info
->netns_dev
, info
->netns_ino
);
224 if (info
->load_time
) {
227 print_boot_time(info
->load_time
, buf
, sizeof(buf
));
229 /* Piggy back on load_time, since 0 uid is a valid one */
230 jsonw_name(json_wtr
, "loaded_at");
231 jsonw_printf(json_wtr
, "%s", buf
);
232 jsonw_uint_field(json_wtr
, "uid", info
->created_by_uid
);
235 jsonw_uint_field(json_wtr
, "bytes_xlated", info
->xlated_prog_len
);
237 if (info
->jited_prog_len
) {
238 jsonw_bool_field(json_wtr
, "jited", true);
239 jsonw_uint_field(json_wtr
, "bytes_jited", info
->jited_prog_len
);
241 jsonw_bool_field(json_wtr
, "jited", false);
244 memlock
= get_fdinfo(fd
, "memlock");
246 jsonw_int_field(json_wtr
, "bytes_memlock", atoi(memlock
));
249 if (info
->nr_map_ids
)
250 show_prog_maps(fd
, info
->nr_map_ids
);
252 if (!hash_empty(prog_table
.table
)) {
253 struct pinned_obj
*obj
;
255 jsonw_name(json_wtr
, "pinned");
256 jsonw_start_array(json_wtr
);
257 hash_for_each_possible(prog_table
.table
, obj
, hash
, info
->id
) {
258 if (obj
->id
== info
->id
)
259 jsonw_string(json_wtr
, obj
->path
);
261 jsonw_end_array(json_wtr
);
264 jsonw_end_object(json_wtr
);
267 static void print_prog_plain(struct bpf_prog_info
*info
, int fd
)
271 printf("%u: ", info
->id
);
272 if (info
->type
< ARRAY_SIZE(prog_type_name
))
273 printf("%s ", prog_type_name
[info
->type
]);
275 printf("type %u ", info
->type
);
278 printf("name %s ", info
->name
);
281 fprint_hex(stdout
, info
->tag
, BPF_TAG_SIZE
, "");
282 print_dev_plain(info
->ifindex
, info
->netns_dev
, info
->netns_ino
);
283 printf("%s", info
->gpl_compatible
? " gpl" : "");
284 if (info
->run_time_ns
)
285 printf(" run_time_ns %lld run_cnt %lld",
286 info
->run_time_ns
, info
->run_cnt
);
289 if (info
->load_time
) {
292 print_boot_time(info
->load_time
, buf
, sizeof(buf
));
294 /* Piggy back on load_time, since 0 uid is a valid one */
295 printf("\tloaded_at %s uid %u\n", buf
, info
->created_by_uid
);
298 printf("\txlated %uB", info
->xlated_prog_len
);
300 if (info
->jited_prog_len
)
301 printf(" jited %uB", info
->jited_prog_len
);
303 printf(" not jited");
305 memlock
= get_fdinfo(fd
, "memlock");
307 printf(" memlock %sB", memlock
);
310 if (info
->nr_map_ids
)
311 show_prog_maps(fd
, info
->nr_map_ids
);
313 if (!hash_empty(prog_table
.table
)) {
314 struct pinned_obj
*obj
;
316 hash_for_each_possible(prog_table
.table
, obj
, hash
, info
->id
) {
317 if (obj
->id
== info
->id
)
318 printf("\n\tpinned %s", obj
->path
);
325 static int show_prog(int fd
)
327 struct bpf_prog_info info
= {};
328 __u32 len
= sizeof(info
);
331 err
= bpf_obj_get_info_by_fd(fd
, &info
, &len
);
333 p_err("can't get prog info: %s", strerror(errno
));
338 print_prog_json(&info
, fd
);
340 print_prog_plain(&info
, fd
);
345 static int do_show(int argc
, char **argv
)
352 build_pinned_obj_table(&prog_table
, BPF_OBJ_PROG
);
355 fd
= prog_parse_fd(&argc
, &argv
);
359 return show_prog(fd
);
366 jsonw_start_array(json_wtr
);
368 err
= bpf_prog_get_next_id(id
, &id
);
370 if (errno
== ENOENT
) {
374 p_err("can't get next program: %s%s", strerror(errno
),
375 errno
== EINVAL
? " -- kernel too old?" : "");
380 fd
= bpf_prog_get_fd_by_id(id
);
384 p_err("can't get prog by id (%u): %s",
385 id
, strerror(errno
));
397 jsonw_end_array(json_wtr
);
402 static int do_dump(int argc
, char **argv
)
404 struct bpf_prog_info_linear
*info_linear
;
405 struct bpf_prog_linfo
*prog_linfo
= NULL
;
406 enum {DUMP_JITED
, DUMP_XLATED
} mode
;
407 const char *disasm_opt
= NULL
;
408 struct bpf_prog_info
*info
;
409 struct dump_data dd
= {};
410 void *func_info
= NULL
;
411 struct btf
*btf
= NULL
;
412 char *filepath
= NULL
;
413 bool opcodes
= false;
423 if (is_prefix(*argv
, "jited")) {
427 } else if (is_prefix(*argv
, "xlated")) {
430 p_err("expected 'xlated' or 'jited', got: %s", *argv
);
438 fd
= prog_parse_fd(&argc
, &argv
);
442 if (is_prefix(*argv
, "file")) {
445 p_err("expected file path");
451 } else if (is_prefix(*argv
, "opcodes")) {
454 } else if (is_prefix(*argv
, "visual")) {
457 } else if (is_prefix(*argv
, "linum")) {
467 if (mode
== DUMP_JITED
)
468 arrays
= 1UL << BPF_PROG_INFO_JITED_INSNS
;
470 arrays
= 1UL << BPF_PROG_INFO_XLATED_INSNS
;
472 arrays
|= 1UL << BPF_PROG_INFO_JITED_KSYMS
;
473 arrays
|= 1UL << BPF_PROG_INFO_JITED_FUNC_LENS
;
474 arrays
|= 1UL << BPF_PROG_INFO_FUNC_INFO
;
475 arrays
|= 1UL << BPF_PROG_INFO_LINE_INFO
;
476 arrays
|= 1UL << BPF_PROG_INFO_JITED_LINE_INFO
;
478 info_linear
= bpf_program__get_prog_info_linear(fd
, arrays
);
480 if (IS_ERR_OR_NULL(info_linear
)) {
481 p_err("can't get prog info: %s", strerror(errno
));
485 info
= &info_linear
->info
;
486 if (mode
== DUMP_JITED
) {
487 if (info
->jited_prog_len
== 0) {
488 p_info("no instructions returned");
491 buf
= (unsigned char *)(info
->jited_prog_insns
);
492 member_len
= info
->jited_prog_len
;
493 } else { /* DUMP_XLATED */
494 if (info
->xlated_prog_len
== 0) {
495 p_err("error retrieving insn dump: kernel.kptr_restrict set?");
498 buf
= (unsigned char *)info
->xlated_prog_insns
;
499 member_len
= info
->xlated_prog_len
;
502 if (info
->btf_id
&& btf__get_from_id(info
->btf_id
, &btf
)) {
503 p_err("failed to get btf");
507 func_info
= (void *)info
->func_info
;
509 if (info
->nr_line_info
) {
510 prog_linfo
= bpf_prog_linfo__new(info
);
512 p_info("error in processing bpf_line_info. continue without it.");
516 fd
= open(filepath
, O_WRONLY
| O_CREAT
| O_TRUNC
, 0600);
518 p_err("can't open file %s: %s", filepath
,
523 n
= write(fd
, buf
, member_len
);
525 if (n
!= member_len
) {
526 p_err("error writing output file: %s",
527 n
< 0 ? strerror(errno
) : "short write");
532 jsonw_null(json_wtr
);
533 } else if (mode
== DUMP_JITED
) {
534 const char *name
= NULL
;
537 name
= ifindex_to_bfd_params(info
->ifindex
,
545 if (info
->nr_jited_func_lens
&& info
->jited_func_lens
) {
546 struct kernel_sym
*sym
= NULL
;
547 struct bpf_func_info
*record
;
548 char sym_name
[SYM_MAX_NAME
];
549 unsigned char *img
= buf
;
553 if (info
->nr_jited_ksyms
) {
554 kernel_syms_load(&dd
);
555 ksyms
= (__u64
*) info
->jited_ksyms
;
559 jsonw_start_array(json_wtr
);
561 lens
= (__u32
*) info
->jited_func_lens
;
562 for (i
= 0; i
< info
->nr_jited_func_lens
; i
++) {
564 sym
= kernel_syms_search(&dd
, ksyms
[i
]);
566 sprintf(sym_name
, "%s", sym
->name
);
568 sprintf(sym_name
, "0x%016llx", ksyms
[i
]);
570 strcpy(sym_name
, "unknown");
574 record
= func_info
+ i
* info
->func_info_rec_size
;
575 btf_dumper_type_only(btf
, record
->type_id
,
581 jsonw_start_object(json_wtr
);
582 if (func_info
&& func_sig
[0] != '\0') {
583 jsonw_name(json_wtr
, "proto");
584 jsonw_string(json_wtr
, func_sig
);
586 jsonw_name(json_wtr
, "name");
587 jsonw_string(json_wtr
, sym_name
);
588 jsonw_name(json_wtr
, "insns");
590 if (func_info
&& func_sig
[0] != '\0')
591 printf("%s:\n", func_sig
);
592 printf("%s:\n", sym_name
);
595 disasm_print_insn(img
, lens
[i
], opcodes
,
596 name
, disasm_opt
, btf
,
597 prog_linfo
, ksyms
[i
], i
,
603 jsonw_end_object(json_wtr
);
609 jsonw_end_array(json_wtr
);
611 disasm_print_insn(buf
, member_len
, opcodes
, name
,
612 disasm_opt
, btf
, NULL
, 0, 0, false);
616 jsonw_null(json_wtr
);
618 dump_xlated_cfg(buf
, member_len
);
620 kernel_syms_load(&dd
);
621 dd
.nr_jited_ksyms
= info
->nr_jited_ksyms
;
622 dd
.jited_ksyms
= (__u64
*) info
->jited_ksyms
;
624 dd
.func_info
= func_info
;
625 dd
.finfo_rec_size
= info
->func_info_rec_size
;
626 dd
.prog_linfo
= prog_linfo
;
629 dump_xlated_json(&dd
, buf
, member_len
, opcodes
,
632 dump_xlated_plain(&dd
, buf
, member_len
, opcodes
,
634 kernel_syms_destroy(&dd
);
645 static int do_pin(int argc
, char **argv
)
649 err
= do_pin_any(argc
, argv
, bpf_prog_get_fd_by_id
);
650 if (!err
&& json_output
)
651 jsonw_null(json_wtr
);
661 static int map_replace_compar(const void *p1
, const void *p2
)
663 const struct map_replace
*a
= p1
, *b
= p2
;
665 return a
->idx
- b
->idx
;
668 static int parse_attach_detach_args(int argc
, char **argv
, int *progfd
,
669 enum bpf_attach_type
*attach_type
,
675 *progfd
= prog_parse_fd(&argc
, &argv
);
679 *attach_type
= parse_attach_type(*argv
);
680 if (*attach_type
== __MAX_BPF_ATTACH_TYPE
) {
681 p_err("invalid attach/detach type");
685 if (*attach_type
== BPF_FLOW_DISSECTOR
) {
694 *mapfd
= map_parse_fd(&argc
, &argv
);
701 static int do_attach(int argc
, char **argv
)
703 enum bpf_attach_type attach_type
;
707 err
= parse_attach_detach_args(argc
, argv
,
708 &progfd
, &attach_type
, &mapfd
);
712 err
= bpf_prog_attach(progfd
, mapfd
, attach_type
, 0);
714 p_err("failed prog attach to map");
719 jsonw_null(json_wtr
);
723 static int do_detach(int argc
, char **argv
)
725 enum bpf_attach_type attach_type
;
729 err
= parse_attach_detach_args(argc
, argv
,
730 &progfd
, &attach_type
, &mapfd
);
734 err
= bpf_prog_detach2(progfd
, mapfd
, attach_type
);
736 p_err("failed prog detach from map");
741 jsonw_null(json_wtr
);
745 static int load_with_options(int argc
, char **argv
, bool first_prog_only
)
747 enum bpf_attach_type expected_attach_type
;
748 struct bpf_object_open_attr attr
= {
749 .prog_type
= BPF_PROG_TYPE_UNSPEC
,
751 struct map_replace
*map_replace
= NULL
;
752 struct bpf_program
*prog
= NULL
, *pos
;
753 unsigned int old_map_fds
= 0;
754 const char *pinmaps
= NULL
;
755 struct bpf_object
*obj
;
764 attr
.file
= GET_ARG();
768 if (is_prefix(*argv
, "type")) {
773 if (attr
.prog_type
!= BPF_PROG_TYPE_UNSPEC
) {
774 p_err("program type already specified");
775 goto err_free_reuse_maps
;
778 goto err_free_reuse_maps
;
780 /* Put a '/' at the end of type to appease libbpf */
781 type
= malloc(strlen(*argv
) + 2);
783 p_err("mem alloc failed");
784 goto err_free_reuse_maps
;
790 err
= libbpf_prog_type_by_name(type
, &attr
.prog_type
,
791 &expected_attach_type
);
794 goto err_free_reuse_maps
;
797 } else if (is_prefix(*argv
, "map")) {
798 void *new_map_replace
;
805 goto err_free_reuse_maps
;
807 if (is_prefix(*argv
, "idx")) {
810 idx
= strtoul(*argv
, &endptr
, 0);
812 p_err("can't parse %s as IDX", *argv
);
813 goto err_free_reuse_maps
;
816 } else if (is_prefix(*argv
, "name")) {
822 p_err("expected 'idx' or 'name', got: '%s'?",
824 goto err_free_reuse_maps
;
828 fd
= map_parse_fd(&argc
, &argv
);
830 goto err_free_reuse_maps
;
832 new_map_replace
= reallocarray(map_replace
,
834 sizeof(*map_replace
));
835 if (!new_map_replace
) {
836 p_err("mem alloc failed");
837 goto err_free_reuse_maps
;
839 map_replace
= new_map_replace
;
841 map_replace
[old_map_fds
].idx
= idx
;
842 map_replace
[old_map_fds
].name
= name
;
843 map_replace
[old_map_fds
].fd
= fd
;
845 } else if (is_prefix(*argv
, "dev")) {
849 p_err("offload device already specified");
850 goto err_free_reuse_maps
;
853 goto err_free_reuse_maps
;
855 ifindex
= if_nametoindex(*argv
);
857 p_err("unrecognized netdevice '%s': %s",
858 *argv
, strerror(errno
));
859 goto err_free_reuse_maps
;
862 } else if (is_prefix(*argv
, "pinmaps")) {
866 goto err_free_reuse_maps
;
870 p_err("expected no more arguments, 'type', 'map' or 'dev', got: '%s'?",
872 goto err_free_reuse_maps
;
878 obj
= __bpf_object__open_xattr(&attr
, bpf_flags
);
879 if (IS_ERR_OR_NULL(obj
)) {
880 p_err("failed to open object file");
881 goto err_free_reuse_maps
;
884 bpf_object__for_each_program(pos
, obj
) {
885 enum bpf_prog_type prog_type
= attr
.prog_type
;
887 if (attr
.prog_type
== BPF_PROG_TYPE_UNSPEC
) {
888 const char *sec_name
= bpf_program__title(pos
, false);
890 err
= libbpf_prog_type_by_name(sec_name
, &prog_type
,
891 &expected_attach_type
);
896 bpf_program__set_ifindex(pos
, ifindex
);
897 bpf_program__set_type(pos
, prog_type
);
898 bpf_program__set_expected_attach_type(pos
, expected_attach_type
);
901 qsort(map_replace
, old_map_fds
, sizeof(*map_replace
),
904 /* After the sort maps by name will be first on the list, because they
905 * have idx == -1. Resolve them.
908 while (j
< old_map_fds
&& map_replace
[j
].name
) {
910 bpf_object__for_each_map(map
, obj
) {
911 if (!strcmp(bpf_map__name(map
), map_replace
[j
].name
)) {
912 map_replace
[j
].idx
= i
;
917 if (map_replace
[j
].idx
== -1) {
918 p_err("unable to find map '%s'", map_replace
[j
].name
);
923 /* Resort if any names were resolved */
925 qsort(map_replace
, old_map_fds
, sizeof(*map_replace
),
928 /* Set ifindex and name reuse */
931 bpf_object__for_each_map(map
, obj
) {
932 if (!bpf_map__is_offload_neutral(map
))
933 bpf_map__set_ifindex(map
, ifindex
);
935 if (j
< old_map_fds
&& idx
== map_replace
[j
].idx
) {
936 err
= bpf_map__reuse_fd(map
, map_replace
[j
++].fd
);
938 p_err("unable to set up map reuse: %d", err
);
942 /* Next reuse wants to apply to the same map */
943 if (j
< old_map_fds
&& map_replace
[j
].idx
== idx
) {
944 p_err("replacement for map idx %d specified more than once",
952 if (j
< old_map_fds
) {
953 p_err("map idx '%d' not used", map_replace
[j
].idx
);
957 err
= bpf_object__load(obj
);
959 p_err("failed to load object file");
963 err
= mount_bpffs_for_pin(pinfile
);
967 if (first_prog_only
) {
968 prog
= bpf_program__next(NULL
, obj
);
970 p_err("object file doesn't contain any bpf program");
974 err
= bpf_obj_pin(bpf_program__fd(prog
), pinfile
);
976 p_err("failed to pin program %s",
977 bpf_program__title(prog
, false));
981 err
= bpf_object__pin_programs(obj
, pinfile
);
983 p_err("failed to pin all programs");
989 err
= bpf_object__pin_maps(obj
, pinmaps
);
991 p_err("failed to pin all maps");
997 jsonw_null(json_wtr
);
999 bpf_object__close(obj
);
1000 for (i
= 0; i
< old_map_fds
; i
++)
1001 close(map_replace
[i
].fd
);
1007 if (first_prog_only
)
1010 bpf_object__unpin_programs(obj
, pinfile
);
1012 bpf_object__close(obj
);
1013 err_free_reuse_maps
:
1014 for (i
= 0; i
< old_map_fds
; i
++)
1015 close(map_replace
[i
].fd
);
1020 static int do_load(int argc
, char **argv
)
1022 return load_with_options(argc
, argv
, true);
1025 static int do_loadall(int argc
, char **argv
)
1027 return load_with_options(argc
, argv
, false);
1030 static int do_help(int argc
, char **argv
)
1033 jsonw_null(json_wtr
);
1038 "Usage: %s %s { show | list } [PROG]\n"
1039 " %s %s dump xlated PROG [{ file FILE | opcodes | visual | linum }]\n"
1040 " %s %s dump jited PROG [{ file FILE | opcodes | linum }]\n"
1041 " %s %s pin PROG FILE\n"
1042 " %s %s { load | loadall } OBJ PATH \\\n"
1043 " [type TYPE] [dev NAME] \\\n"
1044 " [map { idx IDX | name NAME } MAP]\\\n"
1045 " [pinmaps MAP_DIR]\n"
1046 " %s %s attach PROG ATTACH_TYPE [MAP]\n"
1047 " %s %s detach PROG ATTACH_TYPE [MAP]\n"
1051 " " HELP_SPEC_MAP
"\n"
1052 " " HELP_SPEC_PROGRAM
"\n"
1053 " TYPE := { socket | kprobe | kretprobe | classifier | action |\n"
1054 " tracepoint | raw_tracepoint | xdp | perf_event | cgroup/skb |\n"
1055 " cgroup/sock | cgroup/dev | lwt_in | lwt_out | lwt_xmit |\n"
1056 " lwt_seg6local | sockops | sk_skb | sk_msg | lirc_mode2 |\n"
1057 " sk_reuseport | flow_dissector |\n"
1058 " cgroup/bind4 | cgroup/bind6 | cgroup/post_bind4 |\n"
1059 " cgroup/post_bind6 | cgroup/connect4 | cgroup/connect6 |\n"
1060 " cgroup/sendmsg4 | cgroup/sendmsg6 }\n"
1061 " ATTACH_TYPE := { msg_verdict | stream_verdict | stream_parser |\n"
1062 " flow_dissector }\n"
1063 " " HELP_SPEC_OPTIONS
"\n"
1065 bin_name
, argv
[-2], bin_name
, argv
[-2], bin_name
, argv
[-2],
1066 bin_name
, argv
[-2], bin_name
, argv
[-2], bin_name
, argv
[-2],
1067 bin_name
, argv
[-2], bin_name
, argv
[-2], bin_name
, argv
[-2]);
1072 static const struct cmd cmds
[] = {
1073 { "show", do_show
},
1074 { "list", do_show
},
1075 { "help", do_help
},
1076 { "dump", do_dump
},
1078 { "load", do_load
},
1079 { "loadall", do_loadall
},
1080 { "attach", do_attach
},
1081 { "detach", do_detach
},
1082 { "tracelog", do_tracelog
},
1086 int do_prog(int argc
, char **argv
)
1088 return cmd_select(cmds
, argc
, argv
, do_help
);