All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Eric Dumazet <edumazet@google.com>
Cc: "David S . Miller" <davem@davemloft.net>,
	Paolo Abeni <pabeni@redhat.com>, Jiri Pirko <jiri@nvidia.com>,
	David Ahern <dsahern@kernel.org>,
	netdev@vger.kernel.org, Florian Westphal <fw@strlen.de>,
	eric.dumazet@gmail.com
Subject: Re: [PATCH net-next 6/6] inet: use xa_array iterator to implement inet_dump_ifaddr()
Date: Thu, 29 Feb 2024 08:21:10 -0800	[thread overview]
Message-ID: <20240229082110.796fbb09@kernel.org> (raw)
In-Reply-To: <CANn89iLPo61i8-ycKYVrUtEUVMGg09mw153eB3sPX24jXaD9WA@mail.gmail.com>

On Thu, 29 Feb 2024 16:50:45 +0100 Eric Dumazet wrote:
> > > You basically only want to return skb->len when message has
> > > overflown, so the somewhat idiomatic way to do this is:
> > >
> > >         err = (err == -EMSGSIZE) ? skb->len : err;  
> 
> This would set err to zero if skb is empty at this point.
> 
> I guess a more correct action would be:
> 
> if (err == -EMSGSIZE && likely(skb->len))
>     err = skb->len;

Ugh, fair point.
We should probably move the EMSGSIZE handling to the core, this is
getting too complicated for average humans.. Like this?

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 765921cf1194..ce27003b90a8 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2264,6 +2264,8 @@ static int netlink_dump(struct sock *sk, bool lock_taken)
 		if (extra_mutex)
 			mutex_lock(extra_mutex);
 		nlk->dump_done_errno = cb->dump(skb, cb);
+		if (nlk->dump_done_errno == -EMSGSIZE && skb->len)
+			nlk->dump_done_errno = skb->len;
 		if (extra_mutex)
 			mutex_unlock(extra_mutex);

> > >
> > > Assuming err can't be set to some weird positive value.
> > >
> > > IDK if you want to do this in future patches or it's risky, but I have
> > > the itch to tell you every time I see a conversion which doesn't follow
> > > this pattern :)  
> >
> > This totally makes sense.
> >
> > I will send a followup patch to fix all these in one go, if this is ok
> > with you ?

Definitely not a blocker

  reply	other threads:[~2024-02-29 16:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-29 11:40 [PATCH net-next 0/6] inet: no longer use RTNL to protect inet_dump_ifaddr() Eric Dumazet
2024-02-29 11:40 ` [PATCH net-next 1/6] inet: annotate data-races around ifa->ifa_tstamp and ifa->ifa_cstamp Eric Dumazet
2024-02-29 11:40 ` [PATCH net-next 2/6] inet: annotate data-races around ifa->ifa_valid_lft Eric Dumazet
2024-02-29 11:40 ` [PATCH net-next 3/6] inet: annotate data-races around ifa->ifa_preferred_lft Eric Dumazet
2024-02-29 11:40 ` [PATCH net-next 4/6] inet: annotate data-races around ifa->ifa_flags Eric Dumazet
2024-02-29 11:40 ` [PATCH net-next 5/6] inet: prepare inet_base_seq() to run without RTNL Eric Dumazet
2024-02-29 11:40 ` [PATCH net-next 6/6] inet: use xa_array iterator to implement inet_dump_ifaddr() Eric Dumazet
2024-02-29 15:37   ` Jakub Kicinski
2024-02-29 15:45     ` Eric Dumazet
2024-02-29 15:50       ` Eric Dumazet
2024-02-29 16:21         ` Jakub Kicinski [this message]
2024-02-29 16:26           ` Eric Dumazet
2024-02-29 14:18 ` [PATCH net-next 0/6] inet: no longer use RTNL to protect inet_dump_ifaddr() Jiri Pirko
2024-03-01 11:20 ` 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=20240229082110.796fbb09@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=fw@strlen.de \
    --cc=jiri@nvidia.com \
    --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 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.