From owner-freebsd-net@FreeBSD.ORG Fri Nov 29 17:18:37 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5EDA2B77 for ; Fri, 29 Nov 2013 17:18:37 +0000 (UTC) Received: from mail-pd0-x230.google.com (mail-pd0-x230.google.com [IPv6:2607:f8b0:400e:c02::230]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 32A3512A2 for ; Fri, 29 Nov 2013 17:18:37 +0000 (UTC) Received: by mail-pd0-f176.google.com with SMTP id w10so14134058pde.35 for ; Fri, 29 Nov 2013 09:18:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=1Ka6ifvySYjEuUyGR7ROx44fNG14SfurkPH6NAisZE8=; b=iyXwCznWUW76dPHjKiPjhT6mnzuMFvLzUP5o2SQtLXAz9ZeBnm36iwQO9el+Kh0SYf fySYoHNwFXI5+y5nCSQ/v+tsxsCXd2tpGEMwIFheW2z+qGoHeFqggm59kGH5xbLFEK4Y d+iKHxEBdE6OTpDcOTmyUlowe7Xp9a14APz3v3UvKGrG6ghHKn9Ig7rnJjajAGidvVnW xpjJF/WChFaocQ3WQB6eFylfNz1krc7cNWglUBZ6JNxwz9EGfxWrWPbuV48hfmQ3QnP6 e6nJ2gO+Qn9OYsCHNJvZXSdFRUPqfp+jer/21jtwlbJokX5PT96OJX5TEnezVADEptcd ElqQ== MIME-Version: 1.0 X-Received: by 10.68.196.227 with SMTP id ip3mr17143467pbc.163.1385745516791; Fri, 29 Nov 2013 09:18:36 -0800 (PST) Received: by 10.68.147.131 with HTTP; Fri, 29 Nov 2013 09:18:36 -0800 (PST) In-Reply-To: <5298C152.4030209@rewt.org.uk> References: <5298BD83.2090601@freebsd.org> <5298C152.4030209@rewt.org.uk> Date: Fri, 29 Nov 2013 09:18:36 -0800 Message-ID: Subject: Re: [PATCH] SO_REUSEADDR and SO_REUSEPORT behaviour From: Oleg Moskalenko To: Joe Holden Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.16 Cc: FreeBSD Net X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Nov 2013 17:18:37 -0000 Joe is right. I've been watching this feature. It is very important for high-performance media gateways - they use mostly UDP protocol. Linux now has it. I hope FreeBSD will include it, too. One thing that makes it especially useful is that the kernel remembers the networks path (from which remote address to which listening UDP socket) the packets are being delivered. That allows very efficient and simple UDP servers. Currently several sockets can listen on the same local address, but the packets are delivered only to one socket of them. Oleg On Fri, Nov 29, 2013 at 8:31 AM, Joe Holden wrote: > On 29/11/2013 16:14, Julian Elischer wrote: > >> On 11/29/13, 8:04 PM, Ermal Lu=E7i wrote: >> >>> Hello, >>> >>> since SO_REUSEADDR and SO_REUSEPORT are supposed to allow two daemons t= o >>> share the same port and possibly listening ip, you would expect if you >>> bind >>> two daemon with such options to same port to see the same traffic on >>> both! >>> >> this is not how I interpret it.. I presume it is is to allow two >> OUTGOING sessions from the same source. >> >>> >>> No, it is to allow multiple listeners bound to the same ip:port. This > already works in FreeBSD but the kernel does not distribute incoming > connections to the different threads, rather just the last one that calle= d > listen(). > > See the article in my previous post for how it should be implemented... > > > > This is not the case today. >>> Only multicast sockets seem to have the behaviour of broadcasting the >>> data >>> to all sockets sharing the same properties through these options! >>> >>> The patch at [1] implements/corrects the behaviour for UDP sockets. >>> Is there anything to be corrected in that patch? >>> Why it has not been provided there before? >>> Can it be committed to the tree? >>> Any extra security checks for jails needed there? >>> >>> >>> [1] >>> https://github.com/pfsense/pfsense-tools/blob/master/ >>> patches/RELENG_10_0/udp_SO_REUSEADDR%2BPORT.diff >>> >>> >>> >> _______________________________________________ >> freebsd-net@freebsd.org mailing list >> http://lists.freebsd.org/mailman/listinfo/freebsd-net >> To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org" >> > > _______________________________________________ > freebsd-net@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org" >