Skip to content

Commit bfdb1e5

Browse files
Yonghong Songqmonnet
authored andcommitted
bpftool: Add link dump support for BPF_LINK_TYPE_SOCKMAP
An example output looks like: $ bpftool link 1776: sk_skb prog 49730 map_id 0 attach_type sk_skb_verdict pids test_progs(8424) 1777: sk_skb prog 49755 map_id 0 attach_type sk_skb_stream_verdict pids test_progs(8424) 1778: sk_msg prog 49770 map_id 8208 attach_type sk_msg_verdict pids test_progs(8424) Reviewed-by: John Fastabend <[email protected]> Reviewed-by: Quentin Monnet <[email protected]> Signed-off-by: Yonghong Song <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 33d5079 commit bfdb1e5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/link.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,10 @@ static int show_link_close_json(int fd, struct bpf_link_info *info)
526526
show_link_ifindex_json(info->netkit.ifindex, json_wtr);
527527
show_link_attach_type_json(info->netkit.attach_type, json_wtr);
528528
break;
529+
case BPF_LINK_TYPE_SOCKMAP:
530+
jsonw_uint_field(json_wtr, "map_id", info->sockmap.map_id);
531+
show_link_attach_type_json(info->sockmap.attach_type, json_wtr);
532+
break;
529533
case BPF_LINK_TYPE_XDP:
530534
show_link_ifindex_json(info->xdp.ifindex, json_wtr);
531535
break;
@@ -915,6 +919,11 @@ static int show_link_close_plain(int fd, struct bpf_link_info *info)
915919
show_link_ifindex_plain(info->netkit.ifindex);
916920
show_link_attach_type_plain(info->netkit.attach_type);
917921
break;
922+
case BPF_LINK_TYPE_SOCKMAP:
923+
printf("\n\t");
924+
printf("map_id %u ", info->sockmap.map_id);
925+
show_link_attach_type_plain(info->sockmap.attach_type);
926+
break;
918927
case BPF_LINK_TYPE_XDP:
919928
printf("\n\t");
920929
show_link_ifindex_plain(info->xdp.ifindex);

0 commit comments

Comments
 (0)