diff options
author | Jakub Kicinski <jakub.kicinski@netronome.com> | 2017-11-03 16:56:19 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-11-05 08:26:19 -0500 |
commit | 928631e05495fa1f0e9775f555b94dbcbb4e2fb5 (patch) | |
tree | 68e81ea982fa01410347eb397d94646a9f7f2942 /tools/bpf/bpftool/prog.c | |
parent | bd601b6ada11fdfb9e277f24ad2eb54bc599156b (diff) |
bpftool: print program device bound info
If program is bound to a device, print the name of the relevant
interface or unknown if the netdev has since been removed.
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/bpf/bpftool/prog.c')
-rw-r--r-- | tools/bpf/bpftool/prog.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c index 250f80fd46aa..d3ab808dc882 100644 --- a/tools/bpf/bpftool/prog.c +++ b/tools/bpf/bpftool/prog.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <string.h> | 41 | #include <string.h> |
42 | #include <time.h> | 42 | #include <time.h> |
43 | #include <unistd.h> | 43 | #include <unistd.h> |
44 | #include <net/if.h> | ||
44 | #include <sys/types.h> | 45 | #include <sys/types.h> |
45 | #include <sys/stat.h> | 46 | #include <sys/stat.h> |
46 | 47 | ||
@@ -229,6 +230,21 @@ static void print_prog_json(struct bpf_prog_info *info, int fd) | |||
229 | info->tag[0], info->tag[1], info->tag[2], info->tag[3], | 230 | 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]); | 231 | info->tag[4], info->tag[5], info->tag[6], info->tag[7]); |
231 | 232 | ||
233 | if (info->status & BPF_PROG_STATUS_DEV_BOUND) { | ||
234 | jsonw_name(json_wtr, "dev"); | ||
235 | if (info->ifindex) { | ||
236 | char name[IF_NAMESIZE]; | ||
237 | |||
238 | if (!if_indextoname(info->ifindex, name)) | ||
239 | jsonw_printf(json_wtr, "\"ifindex:%d\"", | ||
240 | info->ifindex); | ||
241 | else | ||
242 | jsonw_printf(json_wtr, "\"%s\"", name); | ||
243 | } else { | ||
244 | jsonw_printf(json_wtr, "\"unknown\""); | ||
245 | } | ||
246 | } | ||
247 | |||
232 | if (info->load_time) { | 248 | if (info->load_time) { |
233 | char buf[32]; | 249 | char buf[32]; |
234 | 250 | ||
@@ -274,6 +290,21 @@ static void print_prog_plain(struct bpf_prog_info *info, int fd) | |||
274 | 290 | ||
275 | printf("tag "); | 291 | printf("tag "); |
276 | fprint_hex(stdout, info->tag, BPF_TAG_SIZE, ""); | 292 | fprint_hex(stdout, info->tag, BPF_TAG_SIZE, ""); |
293 | printf(" "); | ||
294 | |||
295 | if (info->status & BPF_PROG_STATUS_DEV_BOUND) { | ||
296 | printf("dev "); | ||
297 | if (info->ifindex) { | ||
298 | char name[IF_NAMESIZE]; | ||
299 | |||
300 | if (!if_indextoname(info->ifindex, name)) | ||
301 | printf("ifindex:%d ", info->ifindex); | ||
302 | else | ||
303 | printf("%s ", name); | ||
304 | } else { | ||
305 | printf("unknown "); | ||
306 | } | ||
307 | } | ||
277 | printf("\n"); | 308 | printf("\n"); |
278 | 309 | ||
279 | if (info->load_time) { | 310 | if (info->load_time) { |