From owner-freebsd-hackers Wed Mar 6 17: 8:19 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from harrier.prod.itd.earthlink.net (harrier.mail.pas.earthlink.net [207.217.120.12]) by hub.freebsd.org (Postfix) with ESMTP id 4FD5C37B400; Wed, 6 Mar 2002 17:08:14 -0800 (PST) Received: from pool0533.cvx21-bradley.dialup.earthlink.net ([209.179.194.23] helo=mindspring.com) by harrier.prod.itd.earthlink.net with esmtp (Exim 3.33 #1) id 16imOD-00052s-00; Wed, 06 Mar 2002 17:08:13 -0800 Message-ID: <3C86BD6B.3ADCB4F0@mindspring.com> Date: Wed, 06 Mar 2002 17:07:55 -0800 From: Terry Lambert X-Mailer: Mozilla 4.7 [en]C-CCK-MCD {Sony} (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: net@freebsd.org Cc: hackers@freebsd.org Subject: in_pcblookup_hash() called multiple times Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG There are redundant calls to the in_pcblookup_hash() in the ip_fw_chk() function called via (*ip_fw_chk_ptr)() in the ip_input path. Would it be useful to modify the (*pr_input) function pointer in the struct ipprotosw to take a fourth argument (perhaps it should be cast to a "void *" to keep it generalized?) to pass the pre-looked-up struct inpcb * to TCP, if the lookup has already been done? Profiling indicates that this is one of the most expensive calls in the code path, particularly when there are a lot of sockets open. Increasing the hash table size only works so far; at "a lot", the number of connections makes the lookup expensive anyway (it's a linear traversal of the collision chain for the bucket). Since there are reasons other than firewalling to do the lookup early, it seems that it would be useful to pass a pointer the a pointer that was non-NULL, if the lookup had already taken place. For example, moving the ipflow to use an overlay structure for the inpcb would mean that a single lookup was used for fast forwarding, firewalling, and inpcb identification for tcpcb retrieval for TCP. Note that I'm only talking about the packet input path here, at this time, so the firewall code isn't really generalizable (the inpcb is already known on output, except to the ip_fw code; it probably doesn't make sense to push knwledge of it into the ip_output path, at least without more thought). Right now, I'm just talking about a way ip_input could pass the already looked up input inpcb to tcp_input, udp_input, or udp_ctlinput -- all of which repeat the lookup operation. -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message