Deleted Added
full compact
tcp_input.c (206456) tcp_input.c (207369)
1/*-
2 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 16 unchanged lines hidden (view full) ---

25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)tcp_input.c 8.12 (Berkeley) 5/24/95
30 */
31
32#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 16 unchanged lines hidden (view full) ---

25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)tcp_input.c 8.12 (Berkeley) 5/24/95
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/netinet/tcp_input.c 206456 2010-04-10 12:47:06Z rpaulo $");
33__FBSDID("$FreeBSD: head/sys/netinet/tcp_input.c 207369 2010-04-29 11:52:42Z bz $");
34
35#include "opt_ipfw.h" /* for ipfw_fwd */
36#include "opt_inet.h"
37#include "opt_inet6.h"
38#include "opt_ipsec.h"
39#include "opt_tcpdebug.h"
40
41#include <sys/param.h>

--- 52 unchanged lines hidden (view full) ---

94
95#include <machine/in_cksum.h>
96
97#include <security/mac/mac_framework.h>
98
99static const int tcprexmtthresh = 3;
100
101VNET_DEFINE(struct tcpstat, tcpstat);
34
35#include "opt_ipfw.h" /* for ipfw_fwd */
36#include "opt_inet.h"
37#include "opt_inet6.h"
38#include "opt_ipsec.h"
39#include "opt_tcpdebug.h"
40
41#include <sys/param.h>

--- 52 unchanged lines hidden (view full) ---

94
95#include <machine/in_cksum.h>
96
97#include <security/mac/mac_framework.h>
98
99static const int tcprexmtthresh = 3;
100
101VNET_DEFINE(struct tcpstat, tcpstat);
102VNET_DEFINE(int, blackhole);
103VNET_DEFINE(int, tcp_delack_enabled);
104VNET_DEFINE(int, drop_synfin);
105VNET_DEFINE(int, tcp_do_rfc3042);
106VNET_DEFINE(int, tcp_do_rfc3390);
107VNET_DEFINE(int, tcp_do_ecn);
108VNET_DEFINE(int, tcp_ecn_maxretries);
109VNET_DEFINE(int, tcp_insecure_rst);
110VNET_DEFINE(int, tcp_do_autorcvbuf);
111VNET_DEFINE(int, tcp_autorcvbuf_inc);
112VNET_DEFINE(int, tcp_autorcvbuf_max);
113VNET_DEFINE(int, tcp_do_rfc3465);
114VNET_DEFINE(int, tcp_abc_l_var);
115
116SYSCTL_VNET_STRUCT(_net_inet_tcp, TCPCTL_STATS, stats, CTLFLAG_RW,
117 &VNET_NAME(tcpstat), tcpstat,
118 "TCP statistics (struct tcpstat, netinet/tcp_var.h)");
119
120int tcp_log_in_vain = 0;
121SYSCTL_INT(_net_inet_tcp, OID_AUTO, log_in_vain, CTLFLAG_RW,
122 &tcp_log_in_vain, 0,
123 "Log all incoming TCP segments to closed ports");
124
102SYSCTL_VNET_STRUCT(_net_inet_tcp, TCPCTL_STATS, stats, CTLFLAG_RW,
103 &VNET_NAME(tcpstat), tcpstat,
104 "TCP statistics (struct tcpstat, netinet/tcp_var.h)");
105
106int tcp_log_in_vain = 0;
107SYSCTL_INT(_net_inet_tcp, OID_AUTO, log_in_vain, CTLFLAG_RW,
108 &tcp_log_in_vain, 0,
109 "Log all incoming TCP segments to closed ports");
110
111VNET_DEFINE(int, blackhole) = 0;
112#define V_blackhole VNET(blackhole)
125SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, blackhole, CTLFLAG_RW,
126 &VNET_NAME(blackhole), 0,
127 "Do not send RST on segments to closed ports");
128
113SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, blackhole, CTLFLAG_RW,
114 &VNET_NAME(blackhole), 0,
115 "Do not send RST on segments to closed ports");
116
117VNET_DEFINE(int, tcp_delack_enabled) = 1;
129SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, delayed_ack, CTLFLAG_RW,
130 &VNET_NAME(tcp_delack_enabled), 0,
131 "Delay ACK to try and piggyback it onto a data packet");
132
118SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, delayed_ack, CTLFLAG_RW,
119 &VNET_NAME(tcp_delack_enabled), 0,
120 "Delay ACK to try and piggyback it onto a data packet");
121
122VNET_DEFINE(int, drop_synfin) = 0;
123#define V_drop_synfin VNET(drop_synfin)
133SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, drop_synfin, CTLFLAG_RW,
134 &VNET_NAME(drop_synfin), 0,
135 "Drop TCP packets with SYN+FIN set");
136
124SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, drop_synfin, CTLFLAG_RW,
125 &VNET_NAME(drop_synfin), 0,
126 "Drop TCP packets with SYN+FIN set");
127
128VNET_DEFINE(int, tcp_do_rfc3042) = 1;
129#define V_tcp_do_rfc3042 VNET(tcp_do_rfc3042)
137SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, rfc3042, CTLFLAG_RW,
138 &VNET_NAME(tcp_do_rfc3042), 0,
139 "Enable RFC 3042 (Limited Transmit)");
140
130SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, rfc3042, CTLFLAG_RW,
131 &VNET_NAME(tcp_do_rfc3042), 0,
132 "Enable RFC 3042 (Limited Transmit)");
133
134VNET_DEFINE(int, tcp_do_rfc3390) = 1;
135#define V_tcp_do_rfc3390 VNET(tcp_do_rfc3390)
141SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, rfc3390, CTLFLAG_RW,
142 &VNET_NAME(tcp_do_rfc3390), 0,
143 "Enable RFC 3390 (Increasing TCP's Initial Congestion Window)");
144
136SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, rfc3390, CTLFLAG_RW,
137 &VNET_NAME(tcp_do_rfc3390), 0,
138 "Enable RFC 3390 (Increasing TCP's Initial Congestion Window)");
139
140VNET_DEFINE(int, tcp_do_rfc3465) = 1;
141#define V_tcp_do_rfc3465 VNET(tcp_do_rfc3465)
145SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, rfc3465, CTLFLAG_RW,
146 &VNET_NAME(tcp_do_rfc3465), 0,
147 "Enable RFC 3465 (Appropriate Byte Counting)");
148
142SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, rfc3465, CTLFLAG_RW,
143 &VNET_NAME(tcp_do_rfc3465), 0,
144 "Enable RFC 3465 (Appropriate Byte Counting)");
145
146VNET_DEFINE(int, tcp_abc_l_var) = 2;
147#define V_tcp_abc_l_var VNET(tcp_abc_l_var)
149SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, abc_l_var, CTLFLAG_RW,
150 &VNET_NAME(tcp_abc_l_var), 2,
151 "Cap the max cwnd increment during slow-start to this number of segments");
152
153SYSCTL_NODE(_net_inet_tcp, OID_AUTO, ecn, CTLFLAG_RW, 0, "TCP ECN");
154
148SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, abc_l_var, CTLFLAG_RW,
149 &VNET_NAME(tcp_abc_l_var), 2,
150 "Cap the max cwnd increment during slow-start to this number of segments");
151
152SYSCTL_NODE(_net_inet_tcp, OID_AUTO, ecn, CTLFLAG_RW, 0, "TCP ECN");
153
154VNET_DEFINE(int, tcp_do_ecn) = 0;
155SYSCTL_VNET_INT(_net_inet_tcp_ecn, OID_AUTO, enable, CTLFLAG_RW,
156 &VNET_NAME(tcp_do_ecn), 0,
157 "TCP ECN support");
158
155SYSCTL_VNET_INT(_net_inet_tcp_ecn, OID_AUTO, enable, CTLFLAG_RW,
156 &VNET_NAME(tcp_do_ecn), 0,
157 "TCP ECN support");
158
159VNET_DEFINE(int, tcp_ecn_maxretries) = 1;
159SYSCTL_VNET_INT(_net_inet_tcp_ecn, OID_AUTO, maxretries, CTLFLAG_RW,
160 &VNET_NAME(tcp_ecn_maxretries), 0,
161 "Max retries before giving up on ECN");
162
160SYSCTL_VNET_INT(_net_inet_tcp_ecn, OID_AUTO, maxretries, CTLFLAG_RW,
161 &VNET_NAME(tcp_ecn_maxretries), 0,
162 "Max retries before giving up on ECN");
163
164VNET_DEFINE(int, tcp_insecure_rst) = 0;
165#define V_tcp_insecure_rst VNET(tcp_insecure_rst)
163SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, insecure_rst, CTLFLAG_RW,
164 &VNET_NAME(tcp_insecure_rst), 0,
165 "Follow the old (insecure) criteria for accepting RST packets");
166
166SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, insecure_rst, CTLFLAG_RW,
167 &VNET_NAME(tcp_insecure_rst), 0,
168 "Follow the old (insecure) criteria for accepting RST packets");
169
170VNET_DEFINE(int, tcp_do_autorcvbuf) = 1;
171#define V_tcp_do_autorcvbuf VNET(tcp_do_autorcvbuf)
167SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, recvbuf_auto, CTLFLAG_RW,
168 &VNET_NAME(tcp_do_autorcvbuf), 0,
169 "Enable automatic receive buffer sizing");
170
172SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, recvbuf_auto, CTLFLAG_RW,
173 &VNET_NAME(tcp_do_autorcvbuf), 0,
174 "Enable automatic receive buffer sizing");
175
176VNET_DEFINE(int, tcp_autorcvbuf_inc) = 16*1024;
177#define V_tcp_autorcvbuf_inc VNET(tcp_autorcvbuf_inc)
171SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, recvbuf_inc, CTLFLAG_RW,
172 &VNET_NAME(tcp_autorcvbuf_inc), 0,
173 "Incrementor step size of automatic receive buffer");
174
178SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, recvbuf_inc, CTLFLAG_RW,
179 &VNET_NAME(tcp_autorcvbuf_inc), 0,
180 "Incrementor step size of automatic receive buffer");
181
182VNET_DEFINE(int, tcp_autorcvbuf_max) = 256*1024;
183#define V_tcp_autorcvbuf_max VNET(tcp_autorcvbuf_max)
175SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, recvbuf_max, CTLFLAG_RW,
176 &VNET_NAME(tcp_autorcvbuf_max), 0,
177 "Max size of automatic receive buffer");
178
179int tcp_read_locking = 1;
180SYSCTL_INT(_net_inet_tcp, OID_AUTO, read_locking, CTLFLAG_RW,
181 &tcp_read_locking, 0, "Enable read locking strategy");
182
183VNET_DEFINE(struct inpcbhead, tcb);
184SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, recvbuf_max, CTLFLAG_RW,
185 &VNET_NAME(tcp_autorcvbuf_max), 0,
186 "Max size of automatic receive buffer");
187
188int tcp_read_locking = 1;
189SYSCTL_INT(_net_inet_tcp, OID_AUTO, read_locking, CTLFLAG_RW,
190 &tcp_read_locking, 0, "Enable read locking strategy");
191
192VNET_DEFINE(struct inpcbhead, tcb);
184VNET_DEFINE(struct inpcbinfo, tcbinfo);
185#define tcb6 tcb /* for KAME src sync over BSD*'s */
193#define tcb6 tcb /* for KAME src sync over BSD*'s */
194VNET_DEFINE(struct inpcbinfo, tcbinfo);
186
187static void tcp_dooptions(struct tcpopt *, u_char *, int, int);
188static void tcp_do_segment(struct mbuf *, struct tcphdr *,
189 struct socket *, struct tcpcb *, int, int, uint8_t,
190 int);
191static void tcp_dropwithreset(struct mbuf *, struct tcphdr *,
192 struct tcpcb *, int, int);
193static void tcp_pulloutofband(struct socket *,

--- 3245 unchanged lines hidden ---
195
196static void tcp_dooptions(struct tcpopt *, u_char *, int, int);
197static void tcp_do_segment(struct mbuf *, struct tcphdr *,
198 struct socket *, struct tcpcb *, int, int, uint8_t,
199 int);
200static void tcp_dropwithreset(struct mbuf *, struct tcphdr *,
201 struct tcpcb *, int, int);
202static void tcp_pulloutofband(struct socket *,

--- 3245 unchanged lines hidden ---