From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B689B7A121 for ; Thu, 29 Feb 2024 16:21:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709223672; cv=none; b=mEbZnqU+EGH6p7DzO8qbvGtJiZg9wMkfK8eslrMDUrM4lziELlGO2vcJiUkkS+LvrPW4ksqE3S3Wzo6+aJuCdEwbNlZAWtwRiVKSZZaouRENJECFvyQg02rsyAXxq5TxjkXHhHSsxnJ0P5d7Tyko7lDMBUXtYT8djP2JAAi+rIg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709223672; c=relaxed/simple; bh=NY52okGZOciVTC1jYblcmJbsxmdnPZXLvi0Nt1mpcuM=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lh6+67kZ0Uztsnk6NB358GYVkDOId6eFbzZYf+sJ31KkNCs6pdIMQa7PvchZ9D620SSN+xvWBzQEFyapotJzcTdxso6B5P8xjvKg3JlPqQ9+aiY9eBEfmIwwlINQl01OKIbEDwUkP+UfhErOzEtsgFHPwkhmHs6jZHBkoSoj4xA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=suiMkyj0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="suiMkyj0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3694C433C7; Thu, 29 Feb 2024 16:21:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709223672; bh=NY52okGZOciVTC1jYblcmJbsxmdnPZXLvi0Nt1mpcuM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=suiMkyj0a9j/d7DaM3ptJ4JYLGZPA2mqFBoUa56S0nFXr68p0gpLo9n/VK+K5aM9B ERBP0FzFhYjeU1jsUwjVST6oKvDtA2R23KnzaBLg1SkxFH9b8gerqdm1vE9v7LKuS7 ne+okkUi+SLEFIN69N40XYjOs+a/AMKnShsn7JktjZ25wY3ZI27E33iFMGAftBM8MU A1eUjsqwyMaizjbUSzoq4TXp02WXorFOFytnbZ/6DT/pF8VRJv/kOiaqqPQvdSuYlS hLX6fkNDhNmti3X9HtakmOxWjz1/CRRF/Uf7Rfz44Ee6z3tW4DLt0NiWpEhqotTBam exaS1LzjEQBhw== Date: Thu, 29 Feb 2024 08:21:10 -0800 From: Jakub Kicinski To: Eric Dumazet Cc: "David S . Miller" , Paolo Abeni , Jiri Pirko , David Ahern , netdev@vger.kernel.org, Florian Westphal , eric.dumazet@gmail.com Subject: Re: [PATCH net-next 6/6] inet: use xa_array iterator to implement inet_dump_ifaddr() Message-ID: <20240229082110.796fbb09@kernel.org> In-Reply-To: References: <20240229114016.2995906-1-edumazet@google.com> <20240229114016.2995906-7-edumazet@google.com> <20240229073750.6e59155e@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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