From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: Re: [PATCH 1/1] net: Add SO_REUSEPORT_LISTEN_OFF socket option as drain mode Date: Fri, 18 Dec 2015 18:38:03 -0800 Message-ID: <1450492683.8474.123.camel@edumazet-glaptop2.roam.corp.google.com> References: <1447290541.22599.11.camel@edumazet-glaptop2.roam.corp.google.com> <20151215161456.GA3182@1wt.eu> <1450199424.8474.30.camel@edumazet-glaptop2.roam.corp.google.com> <20151215174346.GA3187@1wt.eu> <1450203712.8474.46.camel@edumazet-glaptop2.roam.corp.google.com> <20151215194410.GB3187@1wt.eu> <1450214475.8474.50.camel@edumazet-glaptop2.roam.corp.google.com> <20151216073814.GA3373@1wt.eu> <20151216161514.GA3476@1wt.eu> <20151218185812.GD4448@1wt.eu> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: Josh Snyder , Tom Herbert , Tolga Ceylan , Aaron Conole , "David S. Miller" , Linux Kernel Network Developers To: Willy Tarreau , cgallek@google.com Return-path: Received: from mail-qg0-f54.google.com ([209.85.192.54]:35878 "EHLO mail-qg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752626AbbLSCiH (ORCPT ); Fri, 18 Dec 2015 21:38:07 -0500 Received: by mail-qg0-f54.google.com with SMTP id c96so47806491qgd.3 for ; Fri, 18 Dec 2015 18:38:06 -0800 (PST) In-Reply-To: <20151218185812.GD4448@1wt.eu> Sender: netdev-owner@vger.kernel.org List-ID: On Fri, 2015-12-18 at 19:58 +0100, Willy Tarreau wrote: > Hi Josh, > > On Fri, Dec 18, 2015 at 08:33:45AM -0800, Josh Snyder wrote: > > I was also puzzled that binding succeeded. Looking into the code paths > > involved, in inet_csk_get_port, we quickly goto have_snum. From there, we end > > up dropping into tb_found. Since !hlist_empty(&tb->owners), we end up checking > > that (tb->fastreuseport > 0 && sk->sk_reuseport && uid_eq(tb->fastuid, uid)). > > This test passes, so we goto success and bind. > > > > Crucially, we are checking the fastreuseport field on the inet_bind_bucket, and > > not the sk_reuseport variable on the other sockets in the bucket. Since this > > bit is set based on sk_reuseport at the time the first socket binds (see > > tb_not_found), I can see no reason why sockets need to keep SO_REUSEPORT set > > beyond initial binding. > > > > Given this, I believe Willy's patch elegantly solves the problem at hand. > > Great, thanks for your in-depth explanation. > > Eric, do you think that this patch may be acceptable material for next > merge window (given that it's not a fix per-se) ? If so I'll resubmit > later. I need to check with Craig Gallek, because he was about to upstream a change to make SO_REUSEPORT more scalable & sexy (like having an [e]BPF filter to perform the selection in an array of sockets)