[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <32ab89e1-84e9-75f1-18c1-81db9a40d0bb@meta.com>
Date: Sun, 12 Feb 2023 22:29:11 -0800
From: Yonghong Song <yhs@...a.com>
To: Cong Wang <xiyou.wangcong@...il.com>, netdev@...r.kernel.org
Cc: bpf@...r.kernel.org, Cong Wang <cong.wang@...edance.com>,
John Fastabend <john.fastabend@...il.com>,
Jakub Sitnicki <jakub@...udflare.com>
Subject: Re: [Patch net-next] sock_map: dump socket map id via diag
On 2/11/23 12:19 PM, Cong Wang wrote:
> From: Cong Wang <cong.wang@...edance.com>
>
> Currently there is no way to know which sockmap a socket has been added
> to from outside, especially for that a socket can be added to multiple
> sockmap's. We could dump this via socket diag, as shown below.
>
> Sample output:
>
> # ./iproute2/misc/ss -tnaie --sockmap
> ESTAB 0 344329 127.0.0.1:1234 127.0.0.1:40912 ino:21098 sk:5 cgroup:/user.slice/user-0.slice/session-c1.scope <-> sockmap: 1
>
> # bpftool map
> 1: sockmap flags 0x0
> key 4B value 4B max_entries 2 memlock 4096B
> pids echo-sockmap(549)
> 4: array name pid_iter.rodata flags 0x480
> key 4B value 4B max_entries 1 memlock 4096B
> btf_id 10 frozen
> pids bpftool(624)
>
> In the future, we could dump other sockmap related stats too, hence I
> make it a nested attribute.
Have you considered to implement a sockmap iterator? This will be
similar to existing hash/array/sk_local_storage map iterators. The
link below is the kernel implementation for sk_local_storage map
iterator which iterates through all sockets.
https://lore.kernel.org/bpf/20200723184116.590602-1-yhs@fb.com
This way, in the future, if you want to print out more information
from the socket, no kernel change is needed and you can just adjust
your bpf program.
>
> Cc: John Fastabend <john.fastabend@...il.com>
> Cc: Jakub Sitnicki <jakub@...udflare.com>
> Signed-off-by: Cong Wang <cong.wang@...edance.com>
> ---
> include/linux/bpf.h | 1 +
> include/uapi/linux/inet_diag.h | 1 +
> include/uapi/linux/sock_diag.h | 8 ++++++
> include/uapi/linux/unix_diag.h | 1 +
> net/core/sock_map.c | 49 ++++++++++++++++++++++++++++++++++
> net/ipv4/inet_diag.c | 5 ++++
> net/unix/diag.c | 6 +++++
> 7 files changed, 71 insertions(+)
>
[...]
Powered by blists - more mailing lists