aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/bpf/bpftool/netlink_dumper.h
diff options
context:
space:
mode:
authorYonghong Song <yhs@fb.com>2018-09-17 16:13:00 -0700
committerDaniel Borkmann <daniel@iogearbox.net>2018-09-18 17:42:31 +0200
commit7900efc19214e326913dc0f0e8ded24adc0018f2 (patch)
tree9dcb527a1ec501454909874b3c4c410c76f61c54 /tools/bpf/bpftool/netlink_dumper.h
parentselftests/bpf: fix bpf_flow.c build (diff)
downloadwireguard-linux-7900efc19214e326913dc0f0e8ded24adc0018f2.tar.xz
wireguard-linux-7900efc19214e326913dc0f0e8ded24adc0018f2.zip
tools/bpf: bpftool: improve output format for bpftool net
This is a followup patch for Commit f6f3bac08ff9 ("tools/bpf: bpftool: add net support"). Some improvements are made for the bpftool net output. Specially, plain output is more concise such that per attachment should nicely fit in one line. Compared to previous output, the prog tag is removed since it can be easily obtained with program id. Similar to xdp attachments, the device name is added to tc attachments. The bpf program attached through shared block mechanism is supported as well. $ ip link add dev v1 type veth peer name v2 $ tc qdisc add dev v1 ingress_block 10 egress_block 20 clsact $ tc qdisc add dev v2 ingress_block 10 egress_block 20 clsact $ tc filter add block 10 protocol ip prio 25 bpf obj bpf_shared.o sec ingress flowid 1:1 $ tc filter add block 20 protocol ip prio 30 bpf obj bpf_cyclic.o sec classifier flowid 1:1 $ bpftool net xdp: tc: v2(7) clsact/ingress bpf_shared.o:[ingress] id 23 v2(7) clsact/egress bpf_cyclic.o:[classifier] id 24 v1(8) clsact/ingress bpf_shared.o:[ingress] id 23 v1(8) clsact/egress bpf_cyclic.o:[classifier] id 24 The documentation and "bpftool net help" are updated to make it clear that current implementation only supports xdp and tc attachments. For programs attached to cgroups, "bpftool cgroup" can be used to dump attachments. For other programs e.g. sk_{filter,skb,msg,reuseport} and lwt/seg6, iproute2 tools should be used. The new output: $ bpftool net xdp: eth0(2) driver id 198 tc: eth0(2) clsact/ingress fbflow_icmp id 335 act [{icmp_action id 336}] eth0(2) clsact/egress fbflow_egress id 334 $ bpftool -jp net [{ "xdp": [{ "devname": "eth0", "ifindex": 2, "mode": "driver", "id": 198 } ], "tc": [{ "devname": "eth0", "ifindex": 2, "kind": "clsact/ingress", "name": "fbflow_icmp", "id": 335, "act": [{ "name": "icmp_action", "id": 336 } ] },{ "devname": "eth0", "ifindex": 2, "kind": "clsact/egress", "name": "fbflow_egress", "id": 334 } ] } ] Signed-off-by: Yonghong Song <yhs@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/bpf/bpftool/netlink_dumper.h')
-rw-r--r--tools/bpf/bpftool/netlink_dumper.h22
1 files changed, 7 insertions, 15 deletions
diff --git a/tools/bpf/bpftool/netlink_dumper.h b/tools/bpf/bpftool/netlink_dumper.h
index 552d8851ac06..0788cfbbed0e 100644
--- a/tools/bpf/bpftool/netlink_dumper.h
+++ b/tools/bpf/bpftool/netlink_dumper.h
@@ -50,13 +50,13 @@
fprintf(stderr, "\n"); \
}
-#define NET_START_ARRAY(name, newline) \
+#define NET_START_ARRAY(name, fmt_str) \
{ \
if (json_output) { \
jsonw_name(json_wtr, name); \
jsonw_start_array(json_wtr); \
} else { \
- fprintf(stderr, "%s [%s", name, newline);\
+ fprintf(stderr, fmt_str, name); \
} \
}
@@ -65,31 +65,23 @@
if (json_output) \
jsonw_end_array(json_wtr); \
else \
- fprintf(stderr, "]%s", endstr); \
+ fprintf(stderr, "%s", endstr); \
}
-#define NET_DUMP_UINT(name, val) \
+#define NET_DUMP_UINT(name, fmt_str, val) \
{ \
if (json_output) \
jsonw_uint_field(json_wtr, name, val); \
else \
- fprintf(stderr, "%s %d ", name, val); \
+ fprintf(stderr, fmt_str, val); \
}
-#define NET_DUMP_LLUINT(name, val) \
-{ \
- if (json_output) \
- jsonw_lluint_field(json_wtr, name, val);\
- else \
- fprintf(stderr, "%s %lld ", name, val); \
-}
-
-#define NET_DUMP_STR(name, str) \
+#define NET_DUMP_STR(name, fmt_str, str) \
{ \
if (json_output) \
jsonw_string_field(json_wtr, name, str);\
else \
- fprintf(stderr, "%s %s ", name, str); \
+ fprintf(stderr, fmt_str, str); \
}
#define NET_DUMP_STR_ONLY(str) \