From owner-freebsd-net@FreeBSD.ORG Tue Dec 31 03:38:59 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 0F95E526 for ; Tue, 31 Dec 2013 03:38:59 +0000 (UTC) Received: from mail-lb0-x22b.google.com (mail-lb0-x22b.google.com [IPv6:2a00:1450:4010:c04::22b]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 8DB251B1C for ; Tue, 31 Dec 2013 03:38:58 +0000 (UTC) Received: by mail-lb0-f171.google.com with SMTP id w7so6086417lbi.30 for ; Mon, 30 Dec 2013 19:38:56 -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=Q1c4/frshThABSqm4FchDlKswk51skkiL3/7fn+K5PE=; b=I4beU6haw3vkksZ83RxjV3nkNpcJsIRxEwo3TnEOEH7vFomN+kCiYEp1HvoHscmP1T Lg/2kVCbtWnqUkyVg/86zK9dw2K1qD0betClfzs0aYVCaT+OeXOQdd9YE9HbUjgdhIU3 myBxOicGqeC5Omo+cdJGB7vacASjJ/EznNfW/v0FwpyEoXEx8H9Rzoa/3c5k7j2C0/Lv e393tndtbyWPnFnTUxyvLCYiasjYpu6abwLrtH54E4dgwFgcwpAmZnxeqaI8ZHFwmtbf QqowDaIZW5u2iZqV7Fo5rY/NIyQFytatTff/n+cy3R9OX2FMjrG0MZhTIVg8xQLZet8E XbHw== MIME-Version: 1.0 X-Received: by 10.112.130.35 with SMTP id ob3mr27490004lbb.2.1388461136478; Mon, 30 Dec 2013 19:38:56 -0800 (PST) Received: by 10.114.199.102 with HTTP; Mon, 30 Dec 2013 19:38:56 -0800 (PST) In-Reply-To: References: Date: Tue, 31 Dec 2013 11:38:56 +0800 Message-ID: Subject: Re: Question about the "connected" UDP sockets From: Sepherosa Ziehau To: Oleg Moskalenko Content-Type: text/plain; charset=ISO-8859-1 Cc: FreeBSD Net X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Dec 2013 03:38:59 -0000 On Fri, Dec 27, 2013 at 1:49 AM, Oleg Moskalenko wrote: > Hi > > I cannot find the information about the implementation details of the > "connected" UDP sockets in FreeBSD. I know that in older Linux kernels all You could start from sys/netinet/udp_usrreq.c:udp_connect(). > UDP sockets are stored in a hash table - and the remote IP:port are not > used for the hash calculation, so the performance is awful when you have > thousands "connected" UDP sockets on the same local IP:port address. So a > UDP packet incoming to the local address has to go through the long list of > sockets to find the proper destination. > > How it is done in the FreeBSD ? Are the UDP "connected" sockets using a > hash table with key based upon 5-tuple (protocol, remote-ip, remote-port, > local-ip, local-port} ? UDP uses its own hash table for "connected" sockets (inpcb actually). The "connected" inpcbs are hashed using lport/fport/laddr/faddr (4-tuple). Best Regards, sephe