Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A732C5ACC4 for ; Thu, 20 Feb 2020 00:34:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F1E9A208C4 for ; Thu, 20 Feb 2020 00:34:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727078AbgBTAe5 (ORCPT ); Wed, 19 Feb 2020 19:34:57 -0500 Received: from shards.monkeyblade.net ([23.128.96.9]:49570 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726736AbgBTAe5 (ORCPT ); Wed, 19 Feb 2020 19:34:57 -0500 Received: from localhost (unknown [IPv6:2601:601:9f00:477::3d5]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 671C915BD9502; Wed, 19 Feb 2020 16:34:56 -0800 (PST) Date: Wed, 19 Feb 2020 16:34:55 -0800 (PST) Message-Id: <20200219.163455.2118359448089082650.davem@davemloft.net> To: willemdebruijn.kernel@gmail.com Cc: netdev@vger.kernel.org, plroskin@gmail.com, edumazet@google.com, willemb@google.com Subject: Re: [PATCH net] udp: rehash on disconnect From: David Miller In-Reply-To: <20200219191632.253526-1-willemdebruijn.kernel@gmail.com> References: <20200219191632.253526-1-willemdebruijn.kernel@gmail.com> X-Mailer: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Wed, 19 Feb 2020 16:34:56 -0800 (PST) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Willem de Bruijn Date: Wed, 19 Feb 2020 14:16:32 -0500 > From: Willem de Bruijn > > As of the below commit, udp sockets bound to a specific address can > coexist with one bound to the any addr for the same port. > > The commit also phased out the use of socket hashing based only on > port (hslot), in favor of always hashing on {addr, port} (hslot2). > > The change broke the following behavior with disconnect (AF_UNSPEC): > > server binds to 0.0.0.0:1337 > server connects to 127.0.0.1:80 > server disconnects > client connects to 127.0.0.1:1337 > client sends "hello" > server reads "hello" // times out, packet did not find sk > > On connect the server acquires a specific source addr suitable for > routing to its destination. On disconnect it reverts to the any addr. > > The connect call triggers a rehash to a different hslot2. On > disconnect, add the same to return to the original hslot2. > > Skip this step if the socket is going to be unhashed completely. > > Fixes: 4cdeeee9252a ("net: udp: prefer listeners bound to an address") > Reported-by: Pavel Roskin > Signed-off-by: Willem de Bruijn Applied and queued up for -stable, thanks Willem.