Message ID | 20231019204919.4203-5-daniel@iogearbox.net (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | Add bpf programmable net device | expand |
Daniel Borkmann <daniel@iogearbox.net> writes: > 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) > [...] Couldn't we make this show whether the program is attached as primary/peer as well? Seems like that would be useful (like in the cgroup output above)? -Toke
On 10/23/23 4:26 PM, Toke Høiland-Jørgensen wrote: > Daniel Borkmann <daniel@iogearbox.net> writes: > >> 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) >> [...] > > Couldn't we make this show whether the program is attached as > primary/peer as well? Seems like that would be useful (like in the > cgroup output above)? Makes sense, will add it. Thanks, Daniel
diff --git a/tools/bpf/bpftool/link.c b/tools/bpf/bpftool/link.c index 4b1407b05056..79c2d5357570 100644 --- a/tools/bpf/bpftool/link.c +++ b/tools/bpf/bpftool/link.c @@ -451,6 +451,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_NETKIT: + show_link_ifindex_json(info->netkit.ifindex, json_wtr); + break; case BPF_LINK_TYPE_XDP: show_link_ifindex_json(info->xdp.ifindex, json_wtr); break; @@ -791,6 +794,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_NETKIT: + printf("\n\t"); + show_link_ifindex_plain(info->netkit.ifindex); + break; case BPF_LINK_TYPE_XDP: printf("\n\t"); show_link_ifindex_plain(info->xdp.ifindex);