blob: 43e49799a624484092266eca8f05b87db6e5d683 [file] [log] [blame]
Jakub Kicinski71bb4282017-10-04 20:10:04 -07001/*
2 * Copyright (C) 2017 Netronome Systems, Inc.
3 *
4 * This software is dual licensed under the GNU General License Version 2,
5 * June 1991 as shown in the file COPYING in the top-level directory of this
6 * source tree or the BSD 2-Clause License provided below. You have the
7 * option to license this software under the complete terms of either license.
8 *
9 * The BSD 2-Clause License:
10 *
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
13 * conditions are met:
14 *
15 * 1. Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer.
18 *
19 * 2. Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials
22 * provided with the distribution.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE.
32 */
33
34/* Author: Jakub Kicinski <kubakici@wp.pl> */
35
36#include <errno.h>
37#include <fcntl.h>
Jakub Kicinskic9c35992017-10-09 10:30:13 -070038#include <stdarg.h>
Jakub Kicinski71bb4282017-10-04 20:10:04 -070039#include <stdio.h>
40#include <stdlib.h>
41#include <string.h>
42#include <time.h>
43#include <unistd.h>
44#include <sys/types.h>
45#include <sys/stat.h>
46
47#include <bpf.h>
48
49#include "main.h"
Jakub Kicinskic9c35992017-10-09 10:30:13 -070050#include "disasm.h"
Jakub Kicinski71bb4282017-10-04 20:10:04 -070051
52static const char * const prog_type_name[] = {
53 [BPF_PROG_TYPE_UNSPEC] = "unspec",
54 [BPF_PROG_TYPE_SOCKET_FILTER] = "socket_filter",
55 [BPF_PROG_TYPE_KPROBE] = "kprobe",
56 [BPF_PROG_TYPE_SCHED_CLS] = "sched_cls",
57 [BPF_PROG_TYPE_SCHED_ACT] = "sched_act",
58 [BPF_PROG_TYPE_TRACEPOINT] = "tracepoint",
59 [BPF_PROG_TYPE_XDP] = "xdp",
60 [BPF_PROG_TYPE_PERF_EVENT] = "perf_event",
61 [BPF_PROG_TYPE_CGROUP_SKB] = "cgroup_skb",
62 [BPF_PROG_TYPE_CGROUP_SOCK] = "cgroup_sock",
63 [BPF_PROG_TYPE_LWT_IN] = "lwt_in",
64 [BPF_PROG_TYPE_LWT_OUT] = "lwt_out",
65 [BPF_PROG_TYPE_LWT_XMIT] = "lwt_xmit",
66 [BPF_PROG_TYPE_SOCK_OPS] = "sock_ops",
67 [BPF_PROG_TYPE_SK_SKB] = "sk_skb",
68};
69
70static void print_boot_time(__u64 nsecs, char *buf, unsigned int size)
71{
72 struct timespec real_time_ts, boot_time_ts;
73 time_t wallclock_secs;
74 struct tm load_tm;
75
76 buf[--size] = '\0';
77
78 if (clock_gettime(CLOCK_REALTIME, &real_time_ts) ||
79 clock_gettime(CLOCK_BOOTTIME, &boot_time_ts)) {
80 perror("Can't read clocks");
81 snprintf(buf, size, "%llu", nsecs / 1000000000);
82 return;
83 }
84
85 wallclock_secs = (real_time_ts.tv_sec - boot_time_ts.tv_sec) +
86 nsecs / 1000000000;
87
88 if (!localtime_r(&wallclock_secs, &load_tm)) {
89 snprintf(buf, size, "%llu", nsecs / 1000000000);
90 return;
91 }
92
93 strftime(buf, size, "%b %d/%H:%M", &load_tm);
94}
95
96static int prog_fd_by_tag(unsigned char *tag)
97{
98 struct bpf_prog_info info = {};
99 __u32 len = sizeof(info);
100 unsigned int id = 0;
101 int err;
102 int fd;
103
104 while (true) {
105 err = bpf_prog_get_next_id(id, &id);
106 if (err) {
107 err("%s\n", strerror(errno));
108 return -1;
109 }
110
111 fd = bpf_prog_get_fd_by_id(id);
112 if (fd < 0) {
113 err("can't get prog by id (%u): %s\n",
114 id, strerror(errno));
115 return -1;
116 }
117
118 err = bpf_obj_get_info_by_fd(fd, &info, &len);
119 if (err) {
120 err("can't get prog info (%u): %s\n",
121 id, strerror(errno));
122 close(fd);
123 return -1;
124 }
125
126 if (!memcmp(tag, info.tag, BPF_TAG_SIZE))
127 return fd;
128
129 close(fd);
130 }
131}
132
133int prog_parse_fd(int *argc, char ***argv)
134{
135 int fd;
136
137 if (is_prefix(**argv, "id")) {
138 unsigned int id;
139 char *endptr;
140
141 NEXT_ARGP();
142
143 id = strtoul(**argv, &endptr, 0);
144 if (*endptr) {
145 err("can't parse %s as ID\n", **argv);
146 return -1;
147 }
148 NEXT_ARGP();
149
150 fd = bpf_prog_get_fd_by_id(id);
151 if (fd < 0)
152 err("get by id (%u): %s\n", id, strerror(errno));
153 return fd;
154 } else if (is_prefix(**argv, "tag")) {
155 unsigned char tag[BPF_TAG_SIZE];
156
157 NEXT_ARGP();
158
159 if (sscanf(**argv, BPF_TAG_FMT, tag, tag + 1, tag + 2,
160 tag + 3, tag + 4, tag + 5, tag + 6, tag + 7)
161 != BPF_TAG_SIZE) {
162 err("can't parse tag\n");
163 return -1;
164 }
165 NEXT_ARGP();
166
167 return prog_fd_by_tag(tag);
168 } else if (is_prefix(**argv, "pinned")) {
169 char *path;
170
171 NEXT_ARGP();
172
173 path = **argv;
174 NEXT_ARGP();
175
176 return open_obj_pinned_any(path, BPF_OBJ_PROG);
177 }
178
179 err("expected 'id', 'tag' or 'pinned', got: '%s'?\n", **argv);
180 return -1;
181}
182
183static void show_prog_maps(int fd, u32 num_maps)
184{
185 struct bpf_prog_info info = {};
186 __u32 len = sizeof(info);
187 __u32 map_ids[num_maps];
188 unsigned int i;
189 int err;
190
191 info.nr_map_ids = num_maps;
192 info.map_ids = ptr_to_u64(map_ids);
193
194 err = bpf_obj_get_info_by_fd(fd, &info, &len);
195 if (err || !info.nr_map_ids)
196 return;
197
Quentin Monnet743cc662017-10-23 09:24:08 -0700198 if (json_output) {
199 jsonw_name(json_wtr, "map_ids");
200 jsonw_start_array(json_wtr);
201 for (i = 0; i < info.nr_map_ids; i++)
202 jsonw_uint(json_wtr, map_ids[i]);
203 jsonw_end_array(json_wtr);
204 } else {
205 printf(" map_ids ");
206 for (i = 0; i < info.nr_map_ids; i++)
207 printf("%u%s", map_ids[i],
208 i == info.nr_map_ids - 1 ? "" : ",");
209 }
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700210}
211
Quentin Monnet743cc662017-10-23 09:24:08 -0700212static void print_prog_json(struct bpf_prog_info *info, int fd)
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700213{
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700214 char *memlock;
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700215
Quentin Monnet743cc662017-10-23 09:24:08 -0700216 jsonw_start_object(json_wtr);
217 jsonw_uint_field(json_wtr, "id", info->id);
218 if (info->type < ARRAY_SIZE(prog_type_name))
219 jsonw_string_field(json_wtr, "type",
220 prog_type_name[info->type]);
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700221 else
Quentin Monnet743cc662017-10-23 09:24:08 -0700222 jsonw_uint_field(json_wtr, "type", info->type);
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700223
Quentin Monnet743cc662017-10-23 09:24:08 -0700224 if (*info->name)
225 jsonw_string_field(json_wtr, "name", info->name);
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700226
Quentin Monnet743cc662017-10-23 09:24:08 -0700227 jsonw_name(json_wtr, "tag");
228 jsonw_printf(json_wtr, "\"" BPF_TAG_FMT "\"",
229 info->tag[0], info->tag[1], info->tag[2], info->tag[3],
230 info->tag[4], info->tag[5], info->tag[6], info->tag[7]);
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700231
Quentin Monnet743cc662017-10-23 09:24:08 -0700232 if (info->load_time) {
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700233 char buf[32];
234
Quentin Monnet743cc662017-10-23 09:24:08 -0700235 print_boot_time(info->load_time, buf, sizeof(buf));
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700236
237 /* Piggy back on load_time, since 0 uid is a valid one */
Quentin Monnet743cc662017-10-23 09:24:08 -0700238 jsonw_string_field(json_wtr, "loaded_at", buf);
239 jsonw_uint_field(json_wtr, "uid", info->created_by_uid);
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700240 }
241
Quentin Monnet743cc662017-10-23 09:24:08 -0700242 jsonw_uint_field(json_wtr, "bytes_xlated", info->xlated_prog_len);
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700243
Quentin Monnet743cc662017-10-23 09:24:08 -0700244 if (info->jited_prog_len) {
245 jsonw_bool_field(json_wtr, "jited", true);
246 jsonw_uint_field(json_wtr, "bytes_jited", info->jited_prog_len);
247 } else {
248 jsonw_bool_field(json_wtr, "jited", false);
249 }
250
251 memlock = get_fdinfo(fd, "memlock");
252 if (memlock)
253 jsonw_int_field(json_wtr, "bytes_memlock", atoi(memlock));
254 free(memlock);
255
256 if (info->nr_map_ids)
257 show_prog_maps(fd, info->nr_map_ids);
258
259 jsonw_end_object(json_wtr);
260}
261
262static void print_prog_plain(struct bpf_prog_info *info, int fd)
263{
264 char *memlock;
265
266 printf("%u: ", info->id);
267 if (info->type < ARRAY_SIZE(prog_type_name))
268 printf("%s ", prog_type_name[info->type]);
269 else
270 printf("type %u ", info->type);
271
272 if (*info->name)
273 printf("name %s ", info->name);
274
275 printf("tag ");
276 fprint_hex(stdout, info->tag, BPF_TAG_SIZE, "");
277 printf("\n");
278
279 if (info->load_time) {
280 char buf[32];
281
282 print_boot_time(info->load_time, buf, sizeof(buf));
283
284 /* Piggy back on load_time, since 0 uid is a valid one */
285 printf("\tloaded_at %s uid %u\n", buf, info->created_by_uid);
286 }
287
288 printf("\txlated %uB", info->xlated_prog_len);
289
290 if (info->jited_prog_len)
291 printf(" jited %uB", info->jited_prog_len);
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700292 else
293 printf(" not jited");
294
295 memlock = get_fdinfo(fd, "memlock");
296 if (memlock)
297 printf(" memlock %sB", memlock);
298 free(memlock);
299
Quentin Monnet743cc662017-10-23 09:24:08 -0700300 if (info->nr_map_ids)
301 show_prog_maps(fd, info->nr_map_ids);
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700302
303 printf("\n");
Quentin Monnet743cc662017-10-23 09:24:08 -0700304}
305
306static int show_prog(int fd)
307{
308 struct bpf_prog_info info = {};
309 __u32 len = sizeof(info);
310 int err;
311
312 err = bpf_obj_get_info_by_fd(fd, &info, &len);
313 if (err) {
314 err("can't get prog info: %s\n", strerror(errno));
315 return -1;
316 }
317
318 if (json_output)
319 print_prog_json(&info, fd);
320 else
321 print_prog_plain(&info, fd);
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700322
323 return 0;
324}
325
326static int do_show(int argc, char **argv)
Quentin Monnet743cc662017-10-23 09:24:08 -0700327{
328 __u32 id = 0;
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700329 int err;
330 int fd;
331
332 if (argc == 2) {
333 fd = prog_parse_fd(&argc, &argv);
334 if (fd < 0)
335 return -1;
336
337 return show_prog(fd);
338 }
339
340 if (argc)
341 return BAD_ARG();
342
Quentin Monnet743cc662017-10-23 09:24:08 -0700343 if (json_output)
344 jsonw_start_array(json_wtr);
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700345 while (true) {
346 err = bpf_prog_get_next_id(id, &id);
347 if (err) {
Quentin Monnet1739c262017-10-19 15:46:20 -0700348 if (errno == ENOENT) {
349 err = 0;
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700350 break;
Quentin Monnet1739c262017-10-19 15:46:20 -0700351 }
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700352 err("can't get next program: %s\n", strerror(errno));
353 if (errno == EINVAL)
354 err("kernel too old?\n");
Quentin Monnet743cc662017-10-23 09:24:08 -0700355 err = -1;
356 break;
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700357 }
358
359 fd = bpf_prog_get_fd_by_id(id);
360 if (fd < 0) {
361 err("can't get prog by id (%u): %s\n",
362 id, strerror(errno));
Quentin Monnet743cc662017-10-23 09:24:08 -0700363 err = -1;
364 break;
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700365 }
366
367 err = show_prog(fd);
368 close(fd);
369 if (err)
Quentin Monnet743cc662017-10-23 09:24:08 -0700370 break;
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700371 }
372
Quentin Monnet743cc662017-10-23 09:24:08 -0700373 if (json_output)
374 jsonw_end_array(json_wtr);
375
376 return err;
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700377}
378
Jakub Kicinskic9c35992017-10-09 10:30:13 -0700379static void print_insn(struct bpf_verifier_env *env, const char *fmt, ...)
380{
381 va_list args;
382
383 va_start(args, fmt);
384 vprintf(fmt, args);
385 va_end(args);
386}
387
Quentin Monnetf05e2c32017-10-23 09:24:10 -0700388static void dump_xlated_plain(void *buf, unsigned int len, bool opcodes)
Jakub Kicinskic9c35992017-10-09 10:30:13 -0700389{
390 struct bpf_insn *insn = buf;
Quentin Monnet9e2308c2017-10-19 15:46:24 -0700391 bool double_insn = false;
Jakub Kicinskic9c35992017-10-09 10:30:13 -0700392 unsigned int i;
393
394 for (i = 0; i < len / sizeof(*insn); i++) {
Quentin Monnet9e2308c2017-10-19 15:46:24 -0700395 if (double_insn) {
396 double_insn = false;
397 continue;
398 }
399
400 double_insn = insn[i].code == (BPF_LD | BPF_IMM | BPF_DW);
401
Jakub Kicinskic9c35992017-10-09 10:30:13 -0700402 printf("% 4d: ", i);
403 print_bpf_insn(print_insn, NULL, insn + i, true);
404
405 if (opcodes) {
406 printf(" ");
Quentin Monnet9cbe1f582017-10-19 15:46:19 -0700407 fprint_hex(stdout, insn + i, 8, " ");
Quentin Monnet9e2308c2017-10-19 15:46:24 -0700408 if (double_insn && i < len - 1) {
409 printf(" ");
410 fprint_hex(stdout, insn + i + 1, 8, " ");
411 }
Jakub Kicinskic9c35992017-10-09 10:30:13 -0700412 printf("\n");
413 }
Jakub Kicinskic9c35992017-10-09 10:30:13 -0700414 }
415}
416
Quentin Monnetf05e2c32017-10-23 09:24:10 -0700417static void print_insn_json(struct bpf_verifier_env *env, const char *fmt, ...)
418{
419 unsigned int l = strlen(fmt);
420 char chomped_fmt[l];
421 va_list args;
422
423 va_start(args, fmt);
424 if (l > 0) {
425 strncpy(chomped_fmt, fmt, l - 1);
426 chomped_fmt[l - 1] = '\0';
427 }
428 jsonw_vprintf_enquote(json_wtr, chomped_fmt, args);
429 va_end(args);
430}
431
432static void dump_xlated_json(void *buf, unsigned int len, bool opcodes)
433{
434 struct bpf_insn *insn = buf;
435 bool double_insn = false;
436 unsigned int i;
437
438 jsonw_start_array(json_wtr);
439 for (i = 0; i < len / sizeof(*insn); i++) {
440 if (double_insn) {
441 double_insn = false;
442 continue;
443 }
444 double_insn = insn[i].code == (BPF_LD | BPF_IMM | BPF_DW);
445
446 jsonw_start_object(json_wtr);
447 jsonw_name(json_wtr, "disasm");
448 print_bpf_insn(print_insn_json, NULL, insn + i, true);
449
450 if (opcodes) {
451 jsonw_name(json_wtr, "opcodes");
452 jsonw_start_object(json_wtr);
453
454 jsonw_name(json_wtr, "code");
455 jsonw_printf(json_wtr, "\"0x%02hhx\"", insn[i].code);
456
457 jsonw_name(json_wtr, "src_reg");
458 jsonw_printf(json_wtr, "\"0x%hhx\"", insn[i].src_reg);
459
460 jsonw_name(json_wtr, "dst_reg");
461 jsonw_printf(json_wtr, "\"0x%hhx\"", insn[i].dst_reg);
462
463 jsonw_name(json_wtr, "off");
464 print_hex_data_json((uint8_t *)(&insn[i].off), 2);
465
466 jsonw_name(json_wtr, "imm");
467 if (double_insn && i < len - 1)
468 print_hex_data_json((uint8_t *)(&insn[i].imm),
469 12);
470 else
471 print_hex_data_json((uint8_t *)(&insn[i].imm),
472 4);
473 jsonw_end_object(json_wtr);
474 }
475 jsonw_end_object(json_wtr);
476 }
477 jsonw_end_array(json_wtr);
478}
479
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700480static int do_dump(int argc, char **argv)
481{
482 struct bpf_prog_info info = {};
483 __u32 len = sizeof(info);
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700484 unsigned int buf_size;
485 char *filepath = NULL;
486 bool opcodes = false;
487 unsigned char *buf;
488 __u32 *member_len;
489 __u64 *member_ptr;
490 ssize_t n;
491 int err;
492 int fd;
493
494 if (is_prefix(*argv, "jited")) {
495 member_len = &info.jited_prog_len;
496 member_ptr = &info.jited_prog_insns;
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700497 } else if (is_prefix(*argv, "xlated")) {
498 member_len = &info.xlated_prog_len;
499 member_ptr = &info.xlated_prog_insns;
500 } else {
501 err("expected 'xlated' or 'jited', got: %s\n", *argv);
502 return -1;
503 }
504 NEXT_ARG();
505
506 if (argc < 2)
507 usage();
508
509 fd = prog_parse_fd(&argc, &argv);
510 if (fd < 0)
511 return -1;
512
513 if (is_prefix(*argv, "file")) {
514 NEXT_ARG();
515 if (!argc) {
516 err("expected file path\n");
517 return -1;
518 }
519
520 filepath = *argv;
521 NEXT_ARG();
522 } else if (is_prefix(*argv, "opcodes")) {
523 opcodes = true;
524 NEXT_ARG();
525 }
526
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700527 if (argc) {
528 usage();
529 return -1;
530 }
531
532 err = bpf_obj_get_info_by_fd(fd, &info, &len);
533 if (err) {
534 err("can't get prog info: %s\n", strerror(errno));
535 return -1;
536 }
537
538 if (!*member_len) {
539 info("no instructions returned\n");
540 close(fd);
541 return 0;
542 }
543
544 buf_size = *member_len;
545
546 buf = malloc(buf_size);
547 if (!buf) {
548 err("mem alloc failed\n");
549 close(fd);
550 return -1;
551 }
552
553 memset(&info, 0, sizeof(info));
554
555 *member_ptr = ptr_to_u64(buf);
556 *member_len = buf_size;
557
558 err = bpf_obj_get_info_by_fd(fd, &info, &len);
559 close(fd);
560 if (err) {
561 err("can't get prog info: %s\n", strerror(errno));
562 goto err_free;
563 }
564
565 if (*member_len > buf_size) {
Quentin Monnet1d844872017-10-19 15:46:21 -0700566 err("too many instructions returned\n");
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700567 goto err_free;
568 }
569
570 if (filepath) {
571 fd = open(filepath, O_WRONLY | O_CREAT | O_TRUNC, 0600);
572 if (fd < 0) {
573 err("can't open file %s: %s\n", filepath,
574 strerror(errno));
575 goto err_free;
576 }
577
578 n = write(fd, buf, *member_len);
579 close(fd);
580 if (n != *member_len) {
581 err("error writing output file: %s\n",
582 n < 0 ? strerror(errno) : "short write");
583 goto err_free;
584 }
585 } else {
Jakub Kicinskic9c35992017-10-09 10:30:13 -0700586 if (member_len == &info.jited_prog_len)
587 disasm_print_insn(buf, *member_len, opcodes);
588 else
Quentin Monnetf05e2c32017-10-23 09:24:10 -0700589 if (json_output)
590 dump_xlated_json(buf, *member_len, opcodes);
591 else
592 dump_xlated_plain(buf, *member_len, opcodes);
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700593 }
594
595 free(buf);
596
597 return 0;
598
599err_free:
600 free(buf);
601 return -1;
602}
603
604static int do_pin(int argc, char **argv)
605{
606 return do_pin_any(argc, argv, bpf_prog_get_fd_by_id);
607}
608
609static int do_help(int argc, char **argv)
610{
611 fprintf(stderr,
612 "Usage: %s %s show [PROG]\n"
Quentin Monnet8dfbc6d2017-10-19 15:46:25 -0700613 " %s %s dump xlated PROG [{ file FILE | opcodes }]\n"
614 " %s %s dump jited PROG [{ file FILE | opcodes }]\n"
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700615 " %s %s pin PROG FILE\n"
616 " %s %s help\n"
617 "\n"
618 " " HELP_SPEC_PROGRAM "\n"
619 "",
620 bin_name, argv[-2], bin_name, argv[-2], bin_name, argv[-2],
621 bin_name, argv[-2], bin_name, argv[-2]);
622
623 return 0;
624}
625
626static const struct cmd cmds[] = {
627 { "show", do_show },
Quentin Monnet9f606172017-10-19 15:46:22 -0700628 { "help", do_help },
Jakub Kicinski71bb4282017-10-04 20:10:04 -0700629 { "dump", do_dump },
630 { "pin", do_pin },
631 { 0 }
632};
633
634int do_prog(int argc, char **argv)
635{
636 return cmd_select(cmds, argc, argv, do_help);
637}