[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89iL5sb8Q1ZiPtGBWGd+ZFSVD71hPG7eoxacmDe7kenBmrA@mail.gmail.com>
Date: Thu, 29 Feb 2024 17:26:05 +0100
From: Eric Dumazet <edumazet@...gle.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: "David S . Miller" <davem@...emloft.net>, Paolo Abeni <pabeni@...hat.com>, Jiri Pirko <jiri@...dia.com>,
David Ahern <dsahern@...nel.org>, netdev@...r.kernel.org,
Florian Westphal <fw@...len.de>, eric.dumazet@...il.com
Subject: Re: [PATCH net-next 6/6] inet: use xa_array iterator to implement inet_dump_ifaddr()
On Thu, Feb 29, 2024 at 5:21 PM Jakub Kicinski <kuba@...nel.org> wrote:
>
> 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?
>
Now you are talking ! Yep, definitely nicer.
> 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
Powered by blists - more mailing lists