From: Ido Schimmel <idosch@idosch.org>
To: Jakub Kicinski <kuba@kernel.org>
Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
pabeni@redhat.com, jiri@resnulli.us, johannes@sipsolutions.net,
fw@strlen.de, pablo@netfilter.org, kuniyu@amazon.com
Subject: Re: [PATCH net-next v2 1/3] netlink: handle EMSGSIZE errors in the core
Date: Sun, 3 Mar 2024 17:01:13 +0200 [thread overview]
Message-ID: <ZeSQuYVI3PTX0nha@shredder> (raw)
In-Reply-To: <20240303052408.310064-2-kuba@kernel.org>
On Sat, Mar 02, 2024 at 09:24:06PM -0800, Jakub Kicinski wrote:
> Eric points out that our current suggested way of handling
> EMSGSIZE errors ((err == -EMSGSIZE) ? skb->len : err) will
> break if we didn't fit even a single object into the buffer
> provided by the user. This should not happen for well behaved
> applications, but we can fix that, and free netlink families
> from dealing with that completely by moving error handling
> into the core.
>
> Let's assume from now on that all EMSGSIZE errors in dumps are
> because we run out of skb space. Families can now propagate
> the error nla_put_*() etc generated and not worry about any
> return value magic. If some family really wants to send EMSGSIZE
> to user space, assuming it generates the same error on the next
> dump iteration the skb->len should be 0, and user space should
> still see the EMSGSIZE.
>
> This should simplify families and prevent mistakes in return
> values which lead to DONE being forced into a separate recv()
> call as discovered by Ido some time ago.
>
> Reviewed-by: Eric Dumazet <edumazet@google.com>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
I read your comment here [1] and I believe this patch [2] is needed to
avoid another pass in case of an error code other than EMSGSIZE. I can
submit it after your series is accepted.
[1] https://lore.kernel.org/netdev/20240229073750.6e59155e@kernel.org/
[2]
diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
index 70509da4f080..b3a24b61f76b 100644
--- a/net/ipv4/nexthop.c
+++ b/net/ipv4/nexthop.c
@@ -3241,10 +3241,6 @@ static int rtm_dump_nexthop(struct sk_buff *skb, struct netlink_callback *cb)
err = rtm_dump_walk_nexthops(skb, cb, root, ctx,
&rtm_dump_nexthop_cb, &filter);
- if (err < 0) {
- if (likely(skb->len))
- err = skb->len;
- }
cb->seq = net->nexthop.seq;
nl_dump_check_consistent(cb, nlmsg_hdr(skb));
@@ -3439,11 +3435,6 @@ static int rtm_dump_nexthop_bucket(struct sk_buff *skb,
&rtm_dump_nexthop_bucket_cb, &dd);
}
- if (err < 0) {
- if (likely(skb->len))
- err = skb->len;
- }
-
cb->seq = net->nexthop.seq;
nl_dump_check_consistent(cb, nlmsg_hdr(skb));
return err;
next prev parent reply other threads:[~2024-03-03 15:01 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-03 5:24 [PATCH net-next v2 0/3] netlink: handle EMSGSIZE errors in the core Jakub Kicinski
2024-03-03 5:24 ` [PATCH net-next v2 1/3] " Jakub Kicinski
2024-03-03 15:01 ` Ido Schimmel [this message]
2024-03-03 5:24 ` [PATCH net-next v2 2/3] netdev: let netlink core handle -EMSGSIZE errors Jakub Kicinski
2024-03-03 15:08 ` Ido Schimmel
2024-03-03 5:24 ` [PATCH net-next v2 3/3] genetlink: fit NLMSG_DONE into same read() as families Jakub Kicinski
2024-03-03 15:10 ` Ido Schimmel
2024-03-15 11:48 ` Stefano Brivio
2024-03-19 15:55 ` Jakub Kicinski
2024-03-19 17:17 ` Eric Dumazet
2024-03-19 17:40 ` Jakub Kicinski
2024-03-21 12:56 ` Gal Pressman
2024-03-21 13:51 ` Ido Schimmel
2024-03-21 15:03 ` Gal Pressman
2024-03-21 17:26 ` Eric Dumazet
2024-03-21 17:41 ` Ido Schimmel
2024-04-03 22:52 ` Ilya Maximets
2024-04-11 15:16 ` Jakub Kicinski
2024-04-11 15:39 ` Ilya Maximets
2024-04-11 15:52 ` Jakub Kicinski
2024-04-11 16:38 ` Ilya Maximets
2024-04-11 18:03 ` Jakub Kicinski
2024-04-11 18:04 ` Jakub Kicinski
2024-03-19 23:36 ` David Gibson
2024-03-06 8:10 ` [PATCH net-next v2 0/3] netlink: handle EMSGSIZE errors in the core patchwork-bot+netdevbpf
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=ZeSQuYVI3PTX0nha@shredder \
--to=idosch@idosch.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=jiri@resnulli.us \
--cc=johannes@sipsolutions.net \
--cc=kuba@kernel.org \
--cc=kuniyu@amazon.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.