Re: [PATCH 1/1] net: Add SO_REUSEPORT_LISTEN_OFF socket option as drain mode
From: Willy Tarreau <w@1wt.eu>
Date: 2015-12-18 18:58:24
From: Willy Tarreau <w@1wt.eu>
Date: 2015-12-18 18:58:24
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. Thanks, Willy