From: Martin KaFai Lau <martin.lau@linux.dev>
To: Quentin Deslandes <qde@naccy.de>
Cc: David Ahern <dsahern@gmail.com>,
Martin KaFai Lau <martin.lau@kernel.org>,
netdev@vger.kernel.org
Subject: Re: [PATCH 3/3] ss: pretty-print BPF socket-local storage
Date: Tue, 28 Nov 2023 15:42:15 -0800 [thread overview]
Message-ID: <d1cb4093-f20a-45c7-bfe3-5be6fd93c844@linux.dev> (raw)
In-Reply-To: <20231128023058.53546-4-qde@naccy.de>
On 11/27/23 6:30 PM, Quentin Deslandes wrote:
> +static int bpf_maps_opts_load_btf(struct bpf_map_info *info, struct btf **btf)
> +{
> + if (info->btf_vmlinux_value_type_id) {
> + if (!bpf_map_opts.kernel_btf) {
> + bpf_map_opts.kernel_btf = libbpf_find_kernel_btf();
> + if (!bpf_map_opts.kernel_btf) {
> + fprintf(stderr, "ss: failed to load kernel BTF\n");
> + return -1;
> + }
> + }
> +
> + *btf = bpf_map_opts.kernel_btf;
> + } else if (info->btf_value_type_id) {
> + *btf = btf__load_from_kernel_by_id(info->btf_id);
> + if (!*btf) {
> + fprintf(stderr, "ss: failed to load BTF for map ID %u\n",
> + info->id);
> + return -1;
> + }
> + } else {
> + *btf = NULL;
> + }
> +
> + return 0;
> +}
[ ... ]
> +static void out_bpf_sk_storage(int map_id, const void *data, size_t len,
> + out_prefix_t *prefix)
> +{
> + uint32_t type_id;
> + struct bpf_sk_storage_map_info *map_info;
> +
> + map_info = bpf_map_opts_get_info(map_id);
> + if (!map_info) {
> + OUT_P(prefix, "map_id: %d: missing map info", map_id);
> + return;
> + }
> +
> + if (map_info->info.value_size != len) {
> + OUT_P(prefix, "map_id: %d: invalid value size, expecting %u, got %lu\n",
> + map_id, map_info->info.value_size, len);
> + return;
> + }
> +
> + type_id = map_info->info.btf_vmlinux_value_type_id ?: map_info->info.btf_value_type_id;
sk_storage does not use info.btf_vmlinux_value_type_id, so no need to handle
this case. Only info.btf_value_type_id is used.
> +
> + OUT_P(prefix, "map_id: %d [\n", map_id);
> + out_prefix_push(prefix);
> +
> + out_btf_dump_type(map_info->btf, 0, type_id, data, len, prefix);
> +
> + out_prefix_pop(prefix);
> + OUT_P(prefix, "]");
> +}
> +
next prev parent reply other threads:[~2023-11-28 23:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-28 2:30 [PATCH 0/3] ss: pretty-printing BPF socket-local storage Quentin Deslandes
2023-11-28 2:30 ` [PATCH 1/3] ss: prevent "Process" column from being printed unless requested Quentin Deslandes
2023-11-29 0:20 ` David Ahern
2023-11-28 2:30 ` [PATCH 2/3] ss: add support for BPF socket-local storage Quentin Deslandes
2023-11-28 23:35 ` Martin KaFai Lau
2023-11-28 2:30 ` [PATCH 3/3] ss: pretty-print " Quentin Deslandes
2023-11-28 23:42 ` Martin KaFai Lau [this message]
2023-11-28 22:43 ` [PATCH 0/3] ss: pretty-printing " Stephen Hemminger
2023-12-08 15:01 ` Quentin Deslandes
2023-12-08 17:27 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d1cb4093-f20a-45c7-bfe3-5be6fd93c844@linux.dev \
--to=martin.lau@linux.dev \
--cc=dsahern@gmail.com \
--cc=martin.lau@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=qde@naccy.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).