From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Miller Subject: Re: [PATCH] net: do not allow changing SO_REUSEADDR/SO_REUSEPORT on bound sockets Date: Mon, 04 Jun 2018 17:14:55 -0400 (EDT) Message-ID: <20180604.171455.1155660680592072439.davem@davemloft.net> References: <20180603174705.51802-1-zenczykowski@gmail.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=iso-8859-2 Content-Transfer-Encoding: 8BIT Cc: maze@google.com, edumazet@google.com, netdev@vger.kernel.org To: zenczykowski@gmail.com Return-path: Received: from shards.monkeyblade.net ([184.105.139.130]:52666 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751187AbeFDVO5 (ORCPT ); Mon, 4 Jun 2018 17:14:57 -0400 In-Reply-To: <20180603174705.51802-1-zenczykowski@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: From: "Maciej Żenczykowski" Date: Sun, 3 Jun 2018 10:47:05 -0700 > From: Maciej Żenczykowski > > It is not safe to do so because such sockets are already in the > hash tables and changing these options can result in invalidating > the tb->fastreuse(port) caching. > > This can have later far reaching consequences wrt. bind conflict checks > which rely on these caches (for optimization purposes). > > Not to mention that you can currently end up with two identical > non-reuseport listening sockets bound to the same local ip:port > by clearing reuseport on them after they've already both been bound. > > There is unfortunately no EISBOUND error or anything similar, > and EISCONN seems to be misleading for a bound-but-not-connected > socket, so use EUCLEAN 'Structure needs cleaning' which AFAICT > is the closest you can get to meaning 'socket in bad state'. > (although perhaps EINVAL wouldn't be a bad choice either?) > > This does unfortunately run the risk of breaking buggy > userspace programs... > > Signed-off-by: Maciej Żenczykowski > Change-Id: I77c2b3429b2fdf42671eee0fa7a8ba721c94963b Applied and queued up for -stable.