Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 06 Mar 2002 17:07:55 -0800
From:      Terry Lambert <tlambert2@mindspring.com>
To:        net@freebsd.org
Cc:        hackers@freebsd.org
Subject:   in_pcblookup_hash() called multiple times
Message-ID:  <3C86BD6B.3ADCB4F0@mindspring.com>

next in thread | raw e-mail | index | archive | help
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-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3C86BD6B.3ADCB4F0>