Subject: NetBSD master CVS tree commits
To: None <source-changes@NetBSD.ORG>
From: None <source@NetBSD.ORG>
List: source-changes
Date: 05/14/1997 17:50:02
mellon
Wed May 14 10:42:30 PDT 1997
Update of /cvsroot/src/sys/netinet
In directory netbsd1:/var/slash-tmp/cvs-serv24005

Modified Files:
      Tag: SYN_cache_branch
	tcp_input.c 
Log Message:
Incorporate David Borman of BSDI's tcp SYN caching patches for
4.4BSD-lite2:

	- define non-global syn cache variables
	- define syn cache hashing algorithm

	in tcp_input():

	- package ts_val, ts_ecr and ts_present in a tcp_opt_info
	  structure so that they can be passed en masse to the
	  syn_cache code. 

	if the packet matched a socket that's in the ACCEPTING state:

	- if an incoming connection does not yet have a tcpcb, but
	  it's not a SYN packet, check in the syn cache to see if we
	  cached the initial SYN.   If not, send an RST packet.   If
	  so, and if it's an RST packet, though, just blow away the
	  cache entry.   If there was a cache entry and we aren't
	  processing an RST packet, create the full-blown connection
	  now and jump into the part of tcp_input() that deals with
	  connected sockets.

	- if it is a SYN, and sonewconn() wouldn't queue it because
	  the limit for incoming half-up connections has been
	  exceeded, but the limit for established connections hasn't
	  yet been exceeded, then put this connection into the syn
	  cache.

	after we've handled the accepting state:

	- call tcp_dooptions with tcp_opt_info structure rather than
	  discrete option state variables.

	- If the connection is half-up, and we get an ACK packet, but
	  it's not for the SYN we sent, drop the connection and send
	  an RST, per rfc793, p. 36.

	in tcp_dooptions:

	- combine all the option state passed as arguments into one
	  tcp_opt_info structure.

	add syn cache management functions, verbatim from David's
	patch:

	syn_cache_insert: insert a connection into the SYN cache.   If
	  we reach the per-bucket or cache size limit, toss the oldest
	  entry in the bucket, or if there are no entries in this
	  bucket yet, go looking for an entry to toss.

	syn_cache_timer: blow away aging cache entries.

	syn_cache_lookup: find the syn cache entry matching a
	  particular tcp packet, if any.

	syn_cache_get: take an entry out of the cache and make a
	  socket for it.

	syn_cache_reset: zap a connection in the syn cache based on
	  receipt of an RST packet.

	syn_cache_unreach: zap a connection in the syn cache based on
	  an ICMP unreachable message.

	syn_cache_add: given a LISTEN socket and an inbound SYN
	  request, add an entry to the syn cache and send a SYN,ACK to
	  the source.

	syn_cache_respond: actually sends the SYN,ACK.