]> git.ipfire.org Git - thirdparty/iproute2.git/commit
ss: add support for BPF socket-local storage
authorQuentin Deslandes <qde@naccy.de>
Wed, 21 Feb 2024 15:16:19 +0000 (16:16 +0100)
committerDavid Ahern <dsahern@kernel.org>
Mon, 26 Feb 2024 16:05:47 +0000 (16:05 +0000)
commit8740ca9dcd3ccf1c75c362900cb3218ae3204cf5
tree46e9f422606b9140b320801b33f6e5553d756634
parentd2f1c3c9a8a38493cdec9fb93534ccec76c48fe2
ss: add support for BPF socket-local storage

While sock_diag is able to return BPF socket-local storage in response
to INET_DIAG_REQ_SK_BPF_STORAGES requests, ss doesn't request it.

This change introduces the --bpf-maps and --bpf-map-id= options to request
BPF socket-local storage for all SK_STORAGE maps, or only specific ones.

The bigger part of this change will check the requested map IDs and
ensure they are valid. The column COL_EXT is used to print the
socket-local data into.

When --bpf-maps is used, ss will send an empty
INET_DIAG_REQ_SK_BPF_STORAGES request, in return the kernel will send
all the BPF socket-local storage entries for a given socket. The BTF
data for each map is loaded on demand, as ss can't predict which map ID
are used.

When --bpf-map-id=ID is used, a file descriptor to the requested maps is
open to 1) ensure the map doesn't disappear before the data is printed,
and 2) ensure the map type is BPF_MAP_TYPE_SK_STORAGE. The BTF data for
each requested map is loaded before the request is sent to the kernel.

Co-developed-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: Quentin Deslandes <qde@naccy.de>
Signed-off-by: David Ahern <dsahern@kernel.org>
misc/ss.c