Skip to content

Commit 4042759

Browse files
borkmannKernel Patches Daemon
authored andcommitted
bpftool: Implement link show support for netkit
Add support to dump netkit link information to bpftool in similar way as we have for XDP. The netkit 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 [...] 8: netkit prog 35 ifindex nk1(18) attach_type netkit_primary [...] Equivalent json output: # bpftool link --json [...] { "id": 10, "type": "cgroup", "prog_id": 2466, "cgroup_id": 1, "attach_type": "cgroup_inet6_post_bind" }, [...] { "id": 12, "type": "netkit", "prog_id": 61, "devname": "nk1", "ifindex": 21, "attach_type": "netkit_primary" } [...] Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Reviewed-by: Quentin Monnet <quentin@isovalent.com>
1 parent a3ce278 commit 4042759

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tools/bpf/bpftool/link.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,10 @@ static int show_link_close_json(int fd, struct bpf_link_info *info)
451451
show_link_ifindex_json(info->tcx.ifindex, json_wtr);
452452
show_link_attach_type_json(info->tcx.attach_type, json_wtr);
453453
break;
454+
case BPF_LINK_TYPE_NETKIT:
455+
show_link_ifindex_json(info->netkit.ifindex, json_wtr);
456+
show_link_attach_type_json(info->netkit.attach_type, json_wtr);
457+
break;
454458
case BPF_LINK_TYPE_XDP:
455459
show_link_ifindex_json(info->xdp.ifindex, json_wtr);
456460
break;
@@ -791,6 +795,11 @@ static int show_link_close_plain(int fd, struct bpf_link_info *info)
791795
show_link_ifindex_plain(info->tcx.ifindex);
792796
show_link_attach_type_plain(info->tcx.attach_type);
793797
break;
798+
case BPF_LINK_TYPE_NETKIT:
799+
printf("\n\t");
800+
show_link_ifindex_plain(info->netkit.ifindex);
801+
show_link_attach_type_plain(info->netkit.attach_type);
802+
break;
794803
case BPF_LINK_TYPE_XDP:
795804
printf("\n\t");
796805
show_link_ifindex_plain(info->xdp.ifindex);

0 commit comments

Comments
 (0)