summaryrefslogtreecommitdiffstats
path: root/sys/netinet/tcp_input.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix indentation (whitespace changes only).bz2008-03-011-4/+4
| | | | MFC after: 6 days
* Merge first in a series of TrustedBSD MAC Framework KPI changesrwatson2007-10-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | | from Mac OS X Leopard--rationalize naming for entry points to the following general forms: mac_<object>_<method/action> mac_<object>_check_<method/action> The previous naming scheme was inconsistent and mostly reversed from the new scheme. Also, make object types more consistent and remove spaces from object types that contain multiple parts ("posix_sem" -> "posixsem") to make mechanical parsing easier. Introduce a new "netinet" object type for certain IPv4/IPv6-related methods. Also simplify, slightly, some entry point names. All MAC policy modules will need to be recompiled, and modules not updates as part of this commit will need to be modified to conform to the new KPI. Sponsored by: SPARTA (original patches against Mac OS X) Obtained from: TrustedBSD Project, Apple Computer
* Add FBSDID to all files in netinet so that people can moresilby2007-10-071-1/+3
| | | | | | easily include file version information in bug reports. Approved by: re (kensmith)
* Improve the debugging message:silby2007-10-071-2/+2
| | | | | | | | | | | TCP: [X.X.X.X]:X to [X.X.X.X]:X tcpflags 0x18<PUSH,ACK>; tcp_do_segment: FIN_WAIT_2: Received data after socket was closed, sending RST and removing tcpcb So that it also includes how many bytes of data were received. It now looks like this: TCP: [X.X.X.X]:X to [X.X.X.X]:X tcpflags 0x18<PUSH,ACK>; tcp_do_segment: FIN_WAIT_2: Received X bytes of data after socket was closed, sending RST and removing tcpcb Approved by: re (gnn)
* Make sure that either inp is NULL or we have obtained a lock on it beforekensmith2007-09-101-13/+13
| | | | | | | | | | jumping to dropunlock to avoid a panic. While here move the calls to ipsec4_in_reject() and ipsec6_in_reject() so they are after we obtain the lock on inp. Original patch to avoid panic: pjd Review of locking adjustments: gnn, sam Approved by: re (rwatson)
* Make tcpstates[] static, and make sure TCPSTATES is defined beforedes2007-07-301-6/+0
| | | | | | | | | <netinet/tcp_fsm.h> is included into any compilation unit that needs tcpstates[]. Also remove incorrect extern declarations and TCPDEBUG conditionals. This allows kernels both with and without TCPDEBUG to build, and unbreaks the tinderbox. Approved by: re (rwatson)
* Fix compilation problems- tcpstates is only available if TCPDEBUGmjacob2007-07-291-0/+6
| | | | | | is set. Approved by: re (in spirit)
* Provide a sysctl to toggle reporting of TCP debug logging:andre2007-07-281-8/+18
| | | | | | | | | | | | | | | | | | | | | sys.net.inet.tcp.log_debug = 1 It defaults to enabled for the moment and is to be turned off for the next release like other diagnostics from development branches. It is important to note that sysctl sys.net.inet.tcp.log_in_vain uses the same logging function as log_debug. Enabling of the former also causes the latter to engage, but not vice versa. Use consistent terminology in tcp log messages: "ignored" means a segment contains invalid flags/information and is dropped without changing state or issuing a reply. "rejected" means a segments contains invalid flags/information but is causing a reply (usually RST) and may cause a state change. Approved by: re (rwatson)
* o Move all detailed checks for RST in LISTEN state from tcp_input() toandre2007-07-281-16/+4
| | | | | | | | | syncache_rst(). o Fix tests for flag combinations of RST and SYN, ACK, FIN. Before a RST for a connection in syncache did not properly free the entry. o Add more detailed logging. Approved by: re (rwatson)
* Export the contents of the syncache to netstat.silby2007-07-271-0/+1
| | | | | Approved by: re (kensmith) MFC after: 2 weeks
* Fix comments in tcp_do_segment().andre2007-07-251-5/+3
| | | | Approved by: re (kensmith)
* Fix cast-qualifiers warning when INET6 is not presentpeter2007-07-051-2/+1
| | | | Approved by: re (rwatson)
* Commit the change from FAST_IPSEC to IPSEC. The FAST_IPSECgnn2007-07-031-4/+4
| | | | | | | | option is now deprecated, as well as the KAME IPsec code. What was FAST_IPSEC is now IPSEC. Approved by: re Sponsored by: Secure Computing
* Commit IPv6 support for FAST_IPSEC to the tree.gnn2007-07-011-13/+3
| | | | | | | | | This commit includes only the kernel files, the rest of the files will follow in a second commit. Reviewed by: bz Approved by: re Supported by: Secure Computing
* Fix a case in tcp_do_segment() where tcp_update_sack_list() wouldandre2007-06-101-2/+1
| | | | | | | | | | | | | be called with an incorrect segment end value. tcp_reass() may trim segments when they overlap with already existing ones in the reassembly queue. Instead of saving the segment end value before the call to tcp_reass() compute it on the fly based on the effective segment length afterwards. This bug was not really problematic as no information got lost and the eventual SACK information computation was correct nontheless. MFC after: 1 week
* Fix style for comments, be more verbose and add some more.andre2007-06-101-23/+34
|
* Remove some bogosity from the SYN_SENT case in tcp_do_segmentandre2007-06-091-6/+8
| | | | | | | | | | and simplify handling of the send/receive window scaling. No change in effective behavour. RFC1323 requires the window field in a SYN (i.e., a <SYN> or <SYN,ACK>) segment itself never be scaled. Noticed by: yar
* Make log messages more verbose and simpler to understand for non-experts.andre2007-05-281-46/+71
| | | | Update comments to be more conscious, verbose and fully reflect reality.
* Fix indentation of the syncache_expand() section in tcp_input().andre2007-05-281-52/+52
|
* Refactor and rewrite in parts the SYN handling code on listen socketsandre2007-05-281-44/+119
| | | | | | | | | | | | | | | | | | | | | in tcp_input(): o tighten the checks on allowed TCP flags to be RFC793 and tcp-secure conform o log check failures to syslog at LOG_DEBUG level o rearrange the code flow to be easier to follow o add KASSERTs to validate assumptions of the code flow Add sysctl net.inet.tcp.syncache.rst_on_sock_fail defaulting to enable that controls the behavior on socket creation failure for a otherwise successful 3-way handshake. The socket creation can fail due to global memory shortage, listen queue limits and file descriptor limits. The sysctl allows to chose between two options to deal with this. One is to send a reset to the other endpoint to notify it about the failure (default). The other one is to ignore and treat the failure as a transient error and have the other endpoint retransmit for another try. Reviewed by: rwatson (in general)
* Add tcp_log_addrs() function to generate and standardized TCP log lineandre2007-05-181-22/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | for use thoughout the tcp subsystem. It is IPv4 and IPv6 aware creates a line in the following format: "TCP: [1.2.3.4]:50332 to [1.2.3.4]:80 tcpflags <RST>" A "\n" is not included at the end. The caller is supposed to add further information after the standard tcp log header. The function returns a NUL terminated string which the caller has to free(s, M_TCPLOG) after use. All memory allocation is done with M_NOWAIT and the return value may be NULL in memory shortage situations. Either struct in_conninfo || (struct tcphdr && (struct ip || struct ip6_hdr) have to be supplied. Due to ip[6].h header inclusion limitations and ordering issues the struct ip and struct ip6_hdr parameters have to be casted and passed as void * pointers. tcp_log_addrs(struct in_conninfo *inc, struct tcphdr *th, void *ip4hdr, void *ip6hdr) Usage example: struct ip *ip; char *tcplog; if (tcplog = tcp_log_addrs(NULL, th, (void *)ip, NULL)) { log(LOG_DEBUG, "%s; %s: Connection attempt to closed port\n", tcplog, __func__); free(s, M_TCPLOG); }
* Move TIME_WAIT related functions and timer handling from filesandre2007-05-161-143/+2
| | | | | | | | | | | | | | | | other than repo copied tcp_subr.c into tcp_timewait.c#1.284: tcp_input.c#1.350 tcp_timewait() -> tcp_twcheck() tcp_timer.c#1.92 tcp_timer_2msl_reset() -> tcp_tw_2msl_reset() tcp_timer.c#1.92 tcp_timer_2msl_stop() -> tcp_tw_2msl_stop() tcp_timer.c#1.92 tcp_timer_2msl_tw() -> tcp_tw_2msl_scan() This is a mechanical move with appropriate renames and making them static if used only locally. The tcp_tw_2msl_scan() cleanup function is still run from the tcp_slowtimo() in tcp_timer.c.
* Complete the (mechanical) move of the TCP reassembly and timewaitandre2007-05-131-211/+0
| | | | | | | functions from their origininal place to their own files. TCP Reassembly from tcp_input.c -> tcp_reass.c TCP Timewait from tcp_subr.c -> tcp_timewait.c
* Move universally to ANSI C function declarations, with relativelyrwatson2007-05-101-1/+2
| | | | consistent style(9)-ish layout.
* o Fix style(9) bugs introduced in the last commit.maxim2007-05-091-3/+3
| | | | Pointed out by: bde
* o Unbreak "options TCPDEBUG" && "nooptions INET6" kernel build.maxim2007-05-091-0/+2
| | | | | PR: kern/112517 Submitted by: vd
* Use existing TF_SACK_PERMIT flag in struct tcpcb t_flags field instead ofandre2007-05-061-22/+22
| | | | a decdicated sack_enable int for this bool. Change all users accordingly.
* o Remove redundant tcp reassembly check in header prediction codeandre2007-05-061-19/+9
| | | | | | o Rearrange code to make intent in TCPS_SYN_SENT case more clear o Assorted style cleanup o Comment clarification for tcp_dropwithreset()
* Reorder the TCP header prediction test to check for the most volatileandre2007-05-061-4/+6
| | | | values first to spend less time on a fallback to normal processing.
* Remove the defunct remains of the TCPS_TIME_WAIT cases from tcp_do_segmentandre2007-05-061-65/+17
| | | | | | | | and change it to a void function. We use a compressed structure for TCPS_TIME_WAIT to save memory. Any late late segments arriving for such a connection is handled directly in the TW code.
* Tweak comment at end of tcp_input() when calling into tcp_do_segment(): therwatson2007-05-041-3/+3
| | | | pcbinfo lock will be released as well, not just the pcb lock.
* o Fix INP lock leak in the minttl caseandre2007-04-231-5/+6
| | | | | o Remove indirection in the decision of unlocking inp o Further annotation of locking in tcp_input()
* o Remove unncessary TOF_SIGLEN flag from struct tcpoptandre2007-04-201-1/+2
| | | | | o Correctly set to->to_signature in tcp_dooptions() o Update comments
* Add more KASSERT's.andre2007-04-201-0/+4
|
* Remove bogus check for accept queue length and associated failure handlingandre2007-04-201-16/+10
| | | | | | | | | | | | | | from the incoming SYN handling section of tcp_input(). Enforcement of the accept queue limits is done by sonewconn() after the 3WHS is completed. It is not necessary to have an earlier check before a connection request enters the SYN cache awaiting the full handshake. It rather limits the effectiveness of the syncache by preventing legit and illegit connections from entering it and having them shaken out before we hit the real limit which may have vanished by then. Change return value of syncache_add() to void. No status communication is required.
* Simplifly syncache_expand() and clarify its semantics. Zero is returnedandre2007-04-201-8/+8
| | | | | | | | | | | | | | | when the ACK is invalid and doesn't belong to any registered connection, either in syncache or through SYN cookies. True but a NULL struct socket is returned when the 3WHS completed but the socket could not be created due to insufficient resources or limits reached. For both cases an RST is sent back in tcp_input(). A logic error leading to a panic is fixed where syncache_expand() would free the mbuf on socket allocation failure but tcp_input() later supplies it to tcp_dropwithreset() to issue a RST to the peer. Reported by: kris (the panic)
* Remove unused variable tcbinfo_mtx.rwatson2007-04-151-1/+0
|
* Change the TCP timer system from using the callout system five timesandre2007-04-111-30/+22
| | | | | | | | | | | | | | | | directly to a merged model where only one callout, the next to fire, is registered. Instead of callout_reset(9) and callout_stop(9) the new function tcp_timer_activate() is used which then internally manages the callout. The single new callout is a mutex callout on inpcb simplifying the locking a bit. tcp_timer() is the called function which handles all race conditions in one place and then dispatches the individual timer functions. Reviewed by: rwatson (earlier version)
* Add INP_INFO_UNLOCK_ASSERT() and use it in tcp_input(). Also add someandre2007-04-041-0/+3
| | | | further INP_INFO_WLOCK_ASSERT() while there.
* Move last tcpcb initialization for the inbound connection case fromandre2007-04-041-10/+2
| | | | | | | | tcp_input() to syncache_socket() where it belongs and the majority of it already happens. The "tp->snd_up = tp->snd_una" is removed as it is done with the tcp_sendseqinit() macro a few lines earlier.
* Retire unused TCP_SACK_DEBUG.andre2007-04-041-1/+0
|
* In tcp_dooptions() skip over SACK options if it is a SYN segment.andre2007-04-041-0/+2
|
* When blackholing do a 'dropunlock' in the new world order to prevent theandre2007-03-281-1/+1
| | | | | | | INP_INFO_LOCK from leaking. Reported by: ache Found by: rwatson
* o Use a define for a buffer size.maxim2007-03-241-1/+10
| | | | | | | | Prodded by: db o Add missed vars for TCPDEBUG in tcp_do_segment(). Prodded by: tinderbox
* Split tcp_input() into its two functional parts:andre2007-03-231-132/+208
| | | | | | | | | | | | | | o tcp_input() now handles TCP segment sanity checks and preparations including the INPCB lookup and syncache. o tcp_do_segment() handles all data and ACK processing and is IPv4/v6 agnostic. Change all KASSERT() messages to ("%s: ", __func__). The changes in this commit are primarily of mechanical nature and no functional changes besides the function split are made. Discussed with: rwatson
* Tidy up some code to conform better to surroundings and style(9), 0 = NULLandre2007-03-231-17/+16
| | | | and space/tab.
* Bring SACK option handling in tcp_dooptions() in line with all otherandre2007-03-231-4/+7
| | | | options and ajust users accordingly.
* ANSIfy function declarations and remove register keywords for variables.andre2007-03-211-50/+24
| | | | Consistently apply style to all function declarations.
* Tidy up IPFIREWALL_FORWARD sections and comments.andre2007-03-211-4/+3
|
* Update and clarify comments in first section of tcp_input().andre2007-03-211-15/+13
|
OpenPOWER on IntegriCloud