From owner-freebsd-net@FreeBSD.ORG Mon Dec 3 16:15:34 2012 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7290B399 for ; Mon, 3 Dec 2012 16:15:34 +0000 (UTC) (envelope-from keith.arner@gmail.com) Received: from mail-ee0-f54.google.com (mail-ee0-f54.google.com [74.125.83.54]) by mx1.freebsd.org (Postfix) with ESMTP id 0429E8FC14 for ; Mon, 3 Dec 2012 16:15:33 +0000 (UTC) Received: by mail-ee0-f54.google.com with SMTP id c13so2065218eek.13 for ; Mon, 03 Dec 2012 08:15:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; bh=EmVW8Why0F+/C0Bq8S3HSCIg+0ECaNUG15YxnZ28rxM=; b=YNEheMW7L8z//47eHhKytnH+aj0J+8XtIJ72PA2BsYC2DEd3L7tfoTtl4pe2Vz9ZnF qIe9ZGP+eHeOmWENkqGmBzookx/LNiG4SDG+ne+qyjrDfoyTquWnjGux9RLiB3gxDZ/8 wLbyYDgurmj/bLgqQFfrPuQt39G0DxNPMzHsliLigPok7l+jRTTy/XD9gE9Ti+dyxgH7 rUIpHT+PbhURvH+uQ6Pag25iGY6zgynnCWrej0rRQ2TjXl4C1Cdf+W5hpgvVKb+7k3k4 DFYpOQ2q2qTOx1vNJtadnqcjavoVd56NutsloKSjScSP5pJROi+W0F5y67tlHT/G22W5 cOsA== MIME-Version: 1.0 Received: by 10.14.218.69 with SMTP id j45mr37814254eep.35.1354551332826; Mon, 03 Dec 2012 08:15:32 -0800 (PST) Sender: keith.arner@gmail.com Received: by 10.14.48.1 with HTTP; Mon, 3 Dec 2012 08:15:32 -0800 (PST) Date: Mon, 3 Dec 2012 11:15:32 -0500 X-Google-Sender-Auth: 86FYCYWSKuVss6tQFoQnOPMLK7Q Message-ID: Subject: Re: Problems with ephemeral port selection From: Keith Arner To: freebsd-net@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Dec 2012 16:15:34 -0000 > Date: Sat, 01 Dec 2012 09:28:05 +0100 > From: Andre Oppermann > > On 30.11.2012 15:09, Keith Arner wrote: >> I've noticed some issues with ephemeral port number selection from >> tcp_connect(), > > this is an excellent analysis. Could you please file it as a problem > report too and post the PR-number here so we can better track it? Done. PR-number is: kern/174087 > From: Fernando Gont > Subject: Re: Problems with ephemeral port selection > > Please take a look at the discussion on how to "steal" incomming > connections in Section 3.1 of RFC 6056. Fair point. I added your comment to kern/174087 when I filed it. The points made in RFC 6056 actually answer a few outstanding questions I had about why in_pcbbind_setup() behaves the way it does. In particular, I previously couldn't figure out why it was taking special consideration for unconnected sockets. With that in mind, I believe the criteria for check_suitable_port() (as described bt RFC 6056) should be*: A candidate ephemeral port is suitable if and only if: 1) There is no other existing local socket with the same 5-tuple. 2) There is no local socket using the same local port number, and with either a wildcard fport or wildcard faddr. I had previously suggested using in_pcblookup_hash() as a check_suitable_port() function. That would suffice for criterion #1, but would fall short for criterion #2. Looks like we need yet another pcb lookup function. Keith * Yes, I realize that my terminology freely mixes the abstract concepts in the RFC with the concrete language of the FreeBSD implementation. -- "A problem well put is half solved."