From: David Ahern <dsahern@gmail.com>
To: Quentin Deslandes <qde@naccy.de>, netdev@vger.kernel.org
Cc: Martin KaFai Lau <martin.lau@kernel.org>, kernel-team@meta.com
Subject: Re: [PATCH v3 1/2] ss: add support for BPF socket-local storage
Date: Sat, 30 Dec 2023 14:03:41 -0700 [thread overview]
Message-ID: <3f139dae-62cd-4314-81c5-b908d54b7cdc@gmail.com> (raw)
In-Reply-To: <20231220132326.11246-2-qde@naccy.de>
a few nits ...
On 12/20/23 8:23 AM, Quentin Deslandes wrote:
> +static struct rtattr *bpf_map_opts_alloc_rta(void)
> +{
> + size_t total_size = RTA_LENGTH(RTA_LENGTH(sizeof(int)) * bpf_map_opts.nr_maps);
line is too long.
> + struct rtattr *stgs_rta, *fd_rta;
move declaration here and ..
> + unsigned int i;
> + void *buf;
> +
set here.
> + buf = malloc(total_size);
> + if (!buf)
> + return NULL;
> +
> + stgs_rta = buf;
> + stgs_rta->rta_type = INET_DIAG_REQ_SK_BPF_STORAGES | NLA_F_NESTED;
> + stgs_rta->rta_len = total_size;
> +
> + buf = RTA_DATA(stgs_rta);
> + for (i = 0; i < bpf_map_opts.nr_maps; i++) {
> + int *fd;
> +
> + fd_rta = buf;
> + fd_rta->rta_type = SK_DIAG_BPF_STORAGE_REQ_MAP_FD;
> + fd_rta->rta_len = RTA_LENGTH(sizeof(int));
> +
> + fd = RTA_DATA(fd_rta);
> + *fd = bpf_map_opts.maps[i].fd;
> +
> + buf += fd_rta->rta_len;
> + }
> +
> + return stgs_rta;
> +}
> +
> +static void show_sk_bpf_storages(struct rtattr *bpf_stgs)
> +{
> + struct rtattr *tb[SK_DIAG_BPF_STORAGE_MAX + 1], *bpf_stg;
> + unsigned int rem;
> +
> + for (bpf_stg = RTA_DATA(bpf_stgs), rem = RTA_PAYLOAD(bpf_stgs);
> + RTA_OK(bpf_stg, rem); bpf_stg = RTA_NEXT(bpf_stg, rem)) {
> +
> + if ((bpf_stg->rta_type & NLA_TYPE_MASK) != SK_DIAG_BPF_STORAGE)
> + continue;
> +
> + parse_rtattr_nested(tb, SK_DIAG_BPF_STORAGE_MAX,
> + (struct rtattr *)bpf_stg);
> +
> + if (tb[SK_DIAG_BPF_STORAGE_MAP_ID]) {
> + out("map_id:%u",
> + rta_getattr_u32(tb[SK_DIAG_BPF_STORAGE_MAP_ID]));
> + }
> + }
> +}
> +
> +#endif
> +
> static int inet_show_sock(struct nlmsghdr *nlh,
> struct sockstat *s)
> {
> @@ -3381,8 +3620,8 @@ static int inet_show_sock(struct nlmsghdr *nlh,
> struct inet_diag_msg *r = NLMSG_DATA(nlh);
> unsigned char v6only = 0;
>
> - parse_rtattr(tb, INET_DIAG_MAX, (struct rtattr *)(r+1),
> - nlh->nlmsg_len - NLMSG_LENGTH(sizeof(*r)));
> + parse_rtattr_flags(tb, INET_DIAG_MAX, (struct rtattr *)(r+1),
> + nlh->nlmsg_len - NLMSG_LENGTH(sizeof(*r)), NLA_F_NESTED);
column alignment and I think NESTED will need to be on the next line.
>
> if (tb[INET_DIAG_PROTOCOL])
> s->type = rta_getattr_u8(tb[INET_DIAG_PROTOCOL]);
Also, please add a patch that updates the man page for all new options.
next prev parent reply other threads:[~2023-12-30 21:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-20 13:23 [PATCH v3 0/2] ss: pretty-printing BPF socket-local storage Quentin Deslandes
2023-12-20 13:23 ` [PATCH v3 1/2] ss: add support for " Quentin Deslandes
2023-12-30 21:03 ` David Ahern [this message]
2024-01-03 19:21 ` Martin KaFai Lau
2023-12-20 13:23 ` [PATCH v3 2/2] ss: pretty-print " Quentin Deslandes
2024-01-03 19:51 ` Martin KaFai Lau
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=3f139dae-62cd-4314-81c5-b908d54b7cdc@gmail.com \
--to=dsahern@gmail.com \
--cc=kernel-team@meta.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).