mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-27 12:21:22 -05:00
bpftool: Implement link show support for xdp
Add support to dump XDP link information to bpftool. This reuses the
recently added show_link_ifindex_{plain,json}(). The XDP link info only
exposes the ifindex.
Below shows an example link dump output, and a cgroup link is included
for comparison, too:
# bpftool link
[...]
10: cgroup prog 2466
cgroup_id 1 attach_type cgroup_inet6_post_bind
[...]
16: xdp prog 2477
ifindex enp5s0(3)
[...]
Equivalent json output:
# bpftool link --json
[...]
{
"id": 10,
"type": "cgroup",
"prog_id": 2466,
"cgroup_id": 1,
"attach_type": "cgroup_inet6_post_bind"
},
[...]
{
"id": 16,
"type": "xdp",
"prog_id": 2477,
"devname": "enp5s0",
"ifindex": 3
}
[...]
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Quentin Monnet <quentin@isovalent.com>
Link: https://lore.kernel.org/r/20230816095651.10014-2-daniel@iogearbox.net
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
This commit is contained in:
committed by
Martin KaFai Lau
parent
e16e6c6df4
commit
053bbf9bff
@@ -449,6 +449,9 @@ static int show_link_close_json(int fd, struct bpf_link_info *info)
|
||||
show_link_ifindex_json(info->tcx.ifindex, json_wtr);
|
||||
show_link_attach_type_json(info->tcx.attach_type, json_wtr);
|
||||
break;
|
||||
case BPF_LINK_TYPE_XDP:
|
||||
show_link_ifindex_json(info->xdp.ifindex, json_wtr);
|
||||
break;
|
||||
case BPF_LINK_TYPE_STRUCT_OPS:
|
||||
jsonw_uint_field(json_wtr, "map_id",
|
||||
info->struct_ops.map_id);
|
||||
@@ -782,6 +785,10 @@ static int show_link_close_plain(int fd, struct bpf_link_info *info)
|
||||
show_link_ifindex_plain(info->tcx.ifindex);
|
||||
show_link_attach_type_plain(info->tcx.attach_type);
|
||||
break;
|
||||
case BPF_LINK_TYPE_XDP:
|
||||
printf("\n\t");
|
||||
show_link_ifindex_plain(info->xdp.ifindex);
|
||||
break;
|
||||
case BPF_LINK_TYPE_KPROBE_MULTI:
|
||||
show_kprobe_multi_plain(info);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user