From: Johannes Berg <johannes@sipsolutions.net>
To: Dmitry Safonov <0x7f454c46@gmail.com>
Cc: Jakub Kicinski <kuba@kernel.org>,
Dmitry Safonov via B4 Relay
<devnull+0x7f454c46.gmail.com@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
David Ahern <dsahern@kernel.org>,
Ivan Delalande <colona@arista.com>,
Matthieu Baerts <matttbe@kernel.org>,
Mat Martineau <martineau@kernel.org>,
Geliang Tang <geliang@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
Davide Caratti <dcaratti@redhat.com>,
Kuniyuki Iwashima <kuniyu@amazon.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
mptcp@lists.linux.dev
Subject: Re: [PATCH net v2 0/5] Make TCP-MD5-diag slightly less broken
Date: Wed, 20 Nov 2024 20:36:19 +0100 [thread overview]
Message-ID: <cf62d3121e50919dafc94d1b89f194799bc4fbcd.camel@sipsolutions.net> (raw)
In-Reply-To: <CAJwJo6ZTT28XZ1HFhC77KrPeFmwVWDkFzYsg7YU1MD0PESAWrw@mail.gmail.com>
On Wed, 2024-11-20 at 16:13 +0000, Dmitry Safonov wrote:
> > We have min_dump_alloc, which a number of places are setting much higher
> > than the default, partially at least because there were similar issues,
> > e.g. in nl80211. See e.g. nl80211_dump_wiphy() doing it dynamically.
>
> Yeah, your example seems alike what netlink_dump() does with
> min_dump_alloc and max_recvmsg_len. You have there
> .doit = nl80211_get_wiphy,
> .dumpit = nl80211_dump_wiphy,
>
> So at this initial patch set, I'm trying to fix
> inet_diag_handler::dump_one() callback, which is to my understanding
> same as .doit() for generic netlink [should we just rename struct
> inet_diag_handler callbacks to match the generics?].
dump_one() doesn't sound like doit(), it sounds more like dump one
object? In generic netlink dumpit has to handle that internally, and
doit() is for commands, without F_DUMP.
But also generic netlink is just one netlink family, so I wouldn't
really rename anything to match it anyway.
> See
> inet_diag_handler_cmd() and NLM_F_DUMP in
> Documentation/userspace-api/netlink/intro.rst
> For TCP-MD5-diag even the single message reply may have a variable
> number of keys on a socket's dump.
Right.
> For multi-messages dump, my plan is
> to use netlink_callback::ctx[] and add an iterator type that will
> allow to stop on N-th key between recvmsg() calls.
Right, so userspace has to understand that format. In nl80211 we've made
an input flag attribute (inputs are often unused with dump, but are
present) to request that split format.
> > Kind of ugly? Sure! And we shouldn't use it now with newer userspace
> > that knows to request a more finely split dump. For older userspace it's
> > the only way though.
>
> Heh, the comment in nl80211_dump_wiphy() on sending an empty message
> and retrying is ouch!
Yeah ... Luckily we basically converted all userspace to request split
dumps, so we shouldn't ever get there now.
> > For auto-grow you'd also have to have information about the userspace
> > buffer, I think? It still has to fit there, might as well fail anyway if
> > that buffer is too small? I'm not sure we have that link back? But I'm
> > not really sure right now, just remember this as an additional wrinkle
> > from the above-mentioned nl80211 problem.
>
> Yeah, netlink_recvmsg() attempts to track what the userspace is asking:
>
> : /* Record the max length of recvmsg() calls for future allocations */
> : max_recvmsg_len = max(READ_ONCE(nlk->max_recvmsg_len), len);
> : max_recvmsg_len = min_t(size_t, max_recvmsg_len,
> : SKB_WITH_OVERHEAD(32768));
> : WRITE_ONCE(nlk->max_recvmsg_len, max_recvmsg_len);
Right, OK, so that's sorted then :)
johannes
next prev parent reply other threads:[~2024-11-20 19:36 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-13 18:46 Dmitry Safonov via B4 Relay
2024-11-13 18:46 ` [PATCH net v2 1/5] net/diag: Do not race on dumping MD5 keys with adding new MD5 keys Dmitry Safonov via B4 Relay
2024-11-13 18:46 ` [PATCH net v2 2/5] net/diag: Warn only once on EMSGSIZE Dmitry Safonov via B4 Relay
2024-11-13 18:46 ` [PATCH net v2 3/5] net/diag: Pre-allocate optional info only if requested Dmitry Safonov via B4 Relay
2024-11-13 18:46 ` [PATCH net v2 4/5] net/diag: Always pre-allocate tcp_ulp info Dmitry Safonov via B4 Relay
2024-11-13 18:46 ` [PATCH net v2 5/5] net/netlink: Correct the comment on netlink message max cap Dmitry Safonov via B4 Relay
2024-11-16 0:13 ` Jakub Kicinski
2024-11-16 0:08 ` [PATCH net v2 0/5] Make TCP-MD5-diag slightly less broken Jakub Kicinski
2024-11-16 0:48 ` Dmitry Safonov
2024-11-16 1:58 ` Jakub Kicinski
2024-11-16 3:52 ` Dmitry Safonov
2024-11-19 0:12 ` Jakub Kicinski
2024-11-20 0:19 ` Dmitry Safonov
2024-11-20 8:44 ` Johannes Berg
2024-11-20 16:13 ` Dmitry Safonov
2024-11-20 19:36 ` Johannes Berg [this message]
2024-11-16 0:20 ` patchwork-bot+netdevbpf
2024-12-05 1:13 ` Jakub Kicinski
2024-12-05 9:09 ` Eric Dumazet
2024-12-06 0:31 ` Jakub Kicinski
2024-12-06 2:49 ` Dmitry Safonov
2024-12-06 15:14 ` Eric Dumazet
2024-12-06 20:35 ` Dmitry Safonov
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=cf62d3121e50919dafc94d1b89f194799bc4fbcd.camel@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=0x7f454c46@gmail.com \
--cc=colona@arista.com \
--cc=davem@davemloft.net \
--cc=dcaratti@redhat.com \
--cc=devnull+0x7f454c46.gmail.com@kernel.org \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=geliang@kernel.org \
--cc=horms@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=kuniyu@amazon.com \
--cc=linux-kernel@vger.kernel.org \
--cc=martineau@kernel.org \
--cc=matttbe@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/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
all inboxes | Powered by JetHome®