summaryrefslogtreecommitdiff
path: root/tools/bpf
diff options
context:
space:
mode:
authorJakub Kicinski <jakub.kicinski@netronome.com>2017-11-03 13:56:19 -0700
committerDavid S. Miller <davem@davemloft.net>2017-11-05 22:26:19 +0900
commit928631e05495fa1f0e9775f555b94dbcbb4e2fb5 (patch)
tree68e81ea982fa01410347eb397d94646a9f7f2942 /tools/bpf
parentbd601b6ada11fdfb9e277f24ad2eb54bc599156b (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')
-rw-r--r--tools/bpf/bpftool/prog.c31
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 @@
#include <string.h>
#include <time.h>
#include <unistd.h>
+#include <net/if.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -229,6 +230,21 @@ static void print_prog_json(struct bpf_prog_info *info, int fd)
info->tag[0], info->tag[1], info->tag[2], info->tag[3],
info->tag[4], info->tag[5], info->tag[6], info->tag[7]);
+ if (info->status & BPF_PROG_STATUS_DEV_BOUND) {
+ jsonw_name(json_wtr, "dev");
+ if (info->ifindex) {
+ char name[IF_NAMESIZE];
+
+ if (!if_indextoname(info->ifindex, name))
+ jsonw_printf(json_wtr, "\"ifindex:%d\"",
+ info->ifindex);
+ else
+ jsonw_printf(json_wtr, "\"%s\"", name);
+ } else {
+ jsonw_printf(json_wtr, "\"unknown\"");
+ }
+ }
+
if (info->load_time) {
char buf[32];
@@ -274,6 +290,21 @@ static void print_prog_plain(struct bpf_prog_info *info, int fd)
printf("tag ");
fprint_hex(stdout, info->tag, BPF_TAG_SIZE, "");
+ printf(" ");
+
+ if (info->status & BPF_PROG_STATUS_DEV_BOUND) {
+ printf("dev ");
+ if (info->ifindex) {
+ char name[IF_NAMESIZE];
+
+ if (!if_indextoname(info->ifindex, name))
+ printf("ifindex:%d ", info->ifindex);
+ else
+ printf("%s ", name);
+ } else {
+ printf("unknown ");
+ }
+ }
printf("\n");
if (info->load_time) {