Print this page
3660 tcp_slow_start_* tunables should allow increasing the initial congestion window
Reviewed by: Dan McDonald <danmcd@nexenta.com>
Reviewed by: Sebastien Roy <sebastien.roy@delphix.com>
Reviewed by: Brendan Gregg <brendan.gregg@joyent.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/inet/tcp/tcp_opt_data.c
+++ new/usr/src/uts/common/inet/tcp/tcp_opt_data.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
23 23 * Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved.
24 24 */
25 25
26 26 #include <sys/types.h>
27 27 #include <sys/stream.h>
28 28 #define _SUN_TPI_VERSION 2
29 29 #include <sys/tihdr.h>
30 30 #include <sys/socket.h>
31 31 #include <sys/xti_xtiopt.h>
32 32 #include <sys/xti_inet.h>
33 33 #include <sys/policy.h>
34 34
35 35 #include <inet/common.h>
36 36 #include <netinet/ip6.h>
37 37 #include <inet/ip.h>
38 38
39 39 #include <netinet/in.h>
40 40 #include <netinet/tcp.h>
41 41 #include <inet/optcom.h>
42 42 #include <inet/proto_set.h>
43 43 #include <inet/tcp_impl.h>
44 44
45 45 static int tcp_opt_default(queue_t *, int, int, uchar_t *);
46 46
47 47 /*
48 48 * Table of all known options handled on a TCP protocol stack.
49 49 *
50 50 * Note: This table contains options processed by both TCP and IP levels
51 51 * and is the superset of options that can be performed on a TCP over IP
52 52 * stack.
53 53 */
54 54 opdes_t tcp_opt_arr[] = {
55 55
56 56 { SO_LINGER, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0,
57 57 sizeof (struct linger), 0 },
58 58
59 59 { SO_DEBUG, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 },
60 60 { SO_KEEPALIVE, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 },
61 61 { SO_DONTROUTE, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 },
62 62 { SO_USELOOPBACK, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0
63 63 },
64 64 { SO_BROADCAST, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 },
65 65 { SO_REUSEADDR, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 },
66 66 { SO_OOBINLINE, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 },
67 67 { SO_TYPE, SOL_SOCKET, OA_R, OA_R, OP_NP, 0, sizeof (int), 0 },
68 68 { SO_SNDBUF, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 },
69 69 { SO_RCVBUF, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 },
70 70 { SO_SNDTIMEO, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0,
71 71 sizeof (struct timeval), 0 },
72 72 { SO_RCVTIMEO, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0,
73 73 sizeof (struct timeval), 0 },
74 74 { SO_DGRAM_ERRIND, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0
75 75 },
76 76 { SO_SND_COPYAVOID, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 },
77 77 { SO_ANON_MLP, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int),
78 78 0 },
79 79 { SO_MAC_EXEMPT, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int),
80 80 0 },
81 81 { SO_MAC_IMPLICIT, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int),
82 82 0 },
83 83 { SO_ALLZONES, SOL_SOCKET, OA_R, OA_RW, OP_CONFIG, 0, sizeof (int),
84 84 0 },
85 85 { SO_EXCLBIND, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 },
86 86
87 87 { SO_DOMAIN, SOL_SOCKET, OA_R, OA_R, OP_NP, 0, sizeof (int), 0 },
88 88
89 89 { SO_PROTOTYPE, SOL_SOCKET, OA_R, OA_R, OP_NP, 0, sizeof (int), 0 },
90 90
91 91 { TCP_NODELAY, IPPROTO_TCP, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0
92 92 },
93 93 { TCP_MAXSEG, IPPROTO_TCP, OA_R, OA_R, OP_NP, 0, sizeof (uint_t),
94 94 536 },
95 95
96 96 { TCP_NOTIFY_THRESHOLD, IPPROTO_TCP, OA_RW, OA_RW, OP_NP,
97 97 OP_DEF_FN, sizeof (int), -1 /* not initialized */ },
98 98
99 99 { TCP_ABORT_THRESHOLD, IPPROTO_TCP, OA_RW, OA_RW, OP_NP,
100 100 OP_DEF_FN, sizeof (int), -1 /* not initialized */ },
101 101
102 102 { TCP_CONN_NOTIFY_THRESHOLD, IPPROTO_TCP, OA_RW, OA_RW, OP_NP,
103 103 OP_DEF_FN, sizeof (int), -1 /* not initialized */ },
104 104
105 105 { TCP_CONN_ABORT_THRESHOLD, IPPROTO_TCP, OA_RW, OA_RW, OP_NP,
106 106 OP_DEF_FN, sizeof (int), -1 /* not initialized */ },
107 107
108 108 { TCP_RECVDSTADDR, IPPROTO_TCP, OA_RW, OA_RW, OP_NP, 0, sizeof (int),
109 109 0 },
110 110
111 111 { TCP_ANONPRIVBIND, IPPROTO_TCP, OA_R, OA_RW, OP_PRIVPORT, 0,
112 112 sizeof (int), 0 },
113 113
114 114 { TCP_EXCLBIND, IPPROTO_TCP, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0
115 115 },
116 116
117 117 { TCP_INIT_CWND, IPPROTO_TCP, OA_RW, OA_RW, OP_CONFIG, 0,
118 118 sizeof (int), 0 },
119 119
120 120 { TCP_KEEPALIVE_THRESHOLD, IPPROTO_TCP, OA_RW, OA_RW, OP_NP, 0,
121 121 sizeof (int), 0 },
122 122
123 123 { TCP_KEEPIDLE, IPPROTO_TCP, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 },
124 124
125 125 { TCP_KEEPCNT, IPPROTO_TCP, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 },
126 126
127 127 { TCP_KEEPINTVL, IPPROTO_TCP, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 },
128 128
129 129 { TCP_KEEPALIVE_ABORT_THRESHOLD, IPPROTO_TCP, OA_RW, OA_RW, OP_NP, 0,
130 130 sizeof (int), 0 },
131 131
132 132 { TCP_CORK, IPPROTO_TCP, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 },
133 133
134 134 { TCP_RTO_INITIAL, IPPROTO_TCP, OA_RW, OA_RW, OP_NP, 0, sizeof (uint32_t), 0 },
135 135
136 136 { TCP_RTO_MIN, IPPROTO_TCP, OA_RW, OA_RW, OP_NP, 0, sizeof (uint32_t), 0 },
137 137
138 138 { TCP_RTO_MAX, IPPROTO_TCP, OA_RW, OA_RW, OP_NP, 0, sizeof (uint32_t), 0 },
139 139
140 140 { TCP_LINGER2, IPPROTO_TCP, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 },
141 141
142 142 { IP_OPTIONS, IPPROTO_IP, OA_RW, OA_RW, OP_NP,
143 143 (OP_VARLEN|OP_NODEFAULT),
144 144 IP_MAX_OPT_LENGTH + IP_ADDR_LEN, -1 /* not initialized */ },
145 145 { T_IP_OPTIONS, IPPROTO_IP, OA_RW, OA_RW, OP_NP,
146 146 (OP_VARLEN|OP_NODEFAULT),
147 147 IP_MAX_OPT_LENGTH + IP_ADDR_LEN, -1 /* not initialized */ },
148 148
149 149 { IP_TOS, IPPROTO_IP, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 },
150 150 { T_IP_TOS, IPPROTO_IP, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 },
151 151 { IP_TTL, IPPROTO_IP, OA_RW, OA_RW, OP_NP, OP_DEF_FN,
152 152 sizeof (int), -1 /* not initialized */ },
153 153
154 154 { IP_SEC_OPT, IPPROTO_IP, OA_RW, OA_RW, OP_NP, OP_NODEFAULT,
155 155 sizeof (ipsec_req_t), -1 /* not initialized */ },
156 156
157 157 { IP_BOUND_IF, IPPROTO_IP, OA_RW, OA_RW, OP_NP, 0,
158 158 sizeof (int), 0 /* no ifindex */ },
159 159
160 160 { IP_UNSPEC_SRC, IPPROTO_IP, OA_R, OA_RW, OP_RAW, 0,
161 161 sizeof (int), 0 },
162 162
163 163 { IPV6_UNICAST_HOPS, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, OP_DEF_FN,
164 164 sizeof (int), -1 /* not initialized */ },
165 165
166 166 { IPV6_BOUND_IF, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0,
167 167 sizeof (int), 0 /* no ifindex */ },
168 168
169 169 { IP_DONTFRAG, IPPROTO_IP, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 },
170 170
171 171 { IP_NEXTHOP, IPPROTO_IP, OA_R, OA_RW, OP_CONFIG, 0,
172 172 sizeof (in_addr_t), -1 /* not initialized */ },
173 173
174 174 { IPV6_UNSPEC_SRC, IPPROTO_IPV6, OA_R, OA_RW, OP_RAW, 0,
175 175 sizeof (int), 0 },
176 176
177 177 { IPV6_PKTINFO, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP,
178 178 (OP_NODEFAULT|OP_VARLEN),
179 179 sizeof (struct in6_pktinfo), -1 /* not initialized */ },
180 180 { IPV6_NEXTHOP, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP,
181 181 OP_NODEFAULT,
182 182 sizeof (sin6_t), -1 /* not initialized */ },
183 183 { IPV6_HOPOPTS, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP,
184 184 (OP_VARLEN|OP_NODEFAULT), 255*8,
185 185 -1 /* not initialized */ },
186 186 { IPV6_DSTOPTS, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP,
187 187 (OP_VARLEN|OP_NODEFAULT), 255*8,
188 188 -1 /* not initialized */ },
189 189 { IPV6_RTHDRDSTOPTS, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP,
190 190 (OP_VARLEN|OP_NODEFAULT), 255*8,
191 191 -1 /* not initialized */ },
192 192 { IPV6_RTHDR, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP,
193 193 (OP_VARLEN|OP_NODEFAULT), 255*8,
194 194 -1 /* not initialized */ },
195 195 { IPV6_TCLASS, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP,
196 196 OP_NODEFAULT,
197 197 sizeof (int), -1 /* not initialized */ },
198 198 { IPV6_PATHMTU, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP,
199 199 OP_NODEFAULT,
200 200 sizeof (struct ip6_mtuinfo), -1 /* not initialized */ },
201 201 { IPV6_DONTFRAG, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0,
202 202 sizeof (int), 0 },
203 203 { IPV6_USE_MIN_MTU, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0,
204 204 sizeof (int), 0 },
205 205 { IPV6_V6ONLY, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0,
206 206 sizeof (int), 0 },
207 207
208 208 /* Enable receipt of ancillary data */
209 209 { IPV6_RECVPKTINFO, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0,
210 210 sizeof (int), 0 },
211 211 { IPV6_RECVHOPLIMIT, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0,
212 212 sizeof (int), 0 },
213 213 { IPV6_RECVHOPOPTS, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0,
214 214 sizeof (int), 0 },
215 215 { _OLD_IPV6_RECVDSTOPTS, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0,
216 216 sizeof (int), 0 },
217 217 { IPV6_RECVDSTOPTS, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0,
218 218 sizeof (int), 0 },
219 219 { IPV6_RECVRTHDR, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0,
220 220 sizeof (int), 0 },
221 221 { IPV6_RECVRTHDRDSTOPTS, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0,
222 222 sizeof (int), 0 },
223 223 { IPV6_RECVTCLASS, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0,
224 224 sizeof (int), 0 },
225 225
226 226 { IPV6_SEC_OPT, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, OP_NODEFAULT,
227 227 sizeof (ipsec_req_t), -1 /* not initialized */ },
228 228 { IPV6_SRC_PREFERENCES, IPPROTO_IPV6, OA_RW, OA_RW, OP_NP, 0,
229 229 sizeof (uint32_t), IPV6_PREFER_SRC_DEFAULT },
230 230 };
231 231
232 232 /*
233 233 * Table of all supported levels
234 234 * Note: Some levels (e.g. XTI_GENERIC) may be valid but may not have
235 235 * any supported options so we need this info separately.
236 236 *
237 237 * This is needed only for topmost tpi providers and is used only by
238 238 * XTI interfaces.
239 239 */
240 240 optlevel_t tcp_valid_levels_arr[] = {
241 241 XTI_GENERIC,
242 242 SOL_SOCKET,
243 243 IPPROTO_TCP,
244 244 IPPROTO_IP,
245 245 IPPROTO_IPV6
246 246 };
247 247
248 248
249 249 #define TCP_OPT_ARR_CNT A_CNT(tcp_opt_arr)
250 250 #define TCP_VALID_LEVELS_CNT A_CNT(tcp_valid_levels_arr)
251 251
252 252 uint_t tcp_max_optsize; /* initialized when TCP driver is loaded */
253 253
254 254 /*
255 255 * Initialize option database object for TCP
256 256 *
257 257 * This object represents database of options to search passed to
258 258 * {sock,tpi}optcom_req() interface routine to take care of option
259 259 * management and associated methods.
260 260 */
261 261
↓ open down ↓ |
261 lines elided |
↑ open up ↑ |
262 262 optdb_obj_t tcp_opt_obj = {
263 263 tcp_opt_default, /* TCP default value function pointer */
264 264 tcp_tpi_opt_get, /* TCP get function pointer */
265 265 tcp_tpi_opt_set, /* TCP set function pointer */
266 266 TCP_OPT_ARR_CNT, /* TCP option database count of entries */
267 267 tcp_opt_arr, /* TCP option database */
268 268 TCP_VALID_LEVELS_CNT, /* TCP valid level count of entries */
269 269 tcp_valid_levels_arr /* TCP valid level array */
270 270 };
271 271
272 -/* Maximum TCP initial cwin (start/restart). */
273 -#define TCP_MAX_INIT_CWND 16
274 -
275 272 static int tcp_max_init_cwnd = TCP_MAX_INIT_CWND;
276 273
277 274 /*
278 275 * Some TCP options can be "set" by requesting them in the option
279 276 * buffer. This is needed for XTI feature test though we do not
280 277 * allow it in general. We interpret that this mechanism is more
281 278 * applicable to OSI protocols and need not be allowed in general.
282 279 * This routine filters out options for which it is not allowed (most)
283 280 * and lets through those (few) for which it is. [ The XTI interface
284 281 * test suite specifics will imply that any XTI_GENERIC level XTI_* if
285 282 * ever implemented will have to be allowed here ].
286 283 */
287 284 static boolean_t
288 285 tcp_allow_connopt_set(int level, int name)
289 286 {
290 287
291 288 switch (level) {
292 289 case IPPROTO_TCP:
293 290 switch (name) {
294 291 case TCP_NODELAY:
295 292 return (B_TRUE);
296 293 default:
297 294 return (B_FALSE);
298 295 }
299 296 /*NOTREACHED*/
300 297 default:
301 298 return (B_FALSE);
302 299 }
303 300 /*NOTREACHED*/
304 301 }
305 302
306 303 /*
307 304 * This routine gets default values of certain options whose default
308 305 * values are maintained by protocol specific code
309 306 */
310 307 /* ARGSUSED */
311 308 static int
312 309 tcp_opt_default(queue_t *q, int level, int name, uchar_t *ptr)
313 310 {
314 311 int32_t *i1 = (int32_t *)ptr;
315 312 tcp_stack_t *tcps = Q_TO_TCP(q)->tcp_tcps;
316 313
317 314 switch (level) {
318 315 case IPPROTO_TCP:
319 316 switch (name) {
320 317 case TCP_NOTIFY_THRESHOLD:
321 318 *i1 = tcps->tcps_ip_notify_interval;
322 319 break;
323 320 case TCP_ABORT_THRESHOLD:
324 321 *i1 = tcps->tcps_ip_abort_interval;
325 322 break;
326 323 case TCP_CONN_NOTIFY_THRESHOLD:
327 324 *i1 = tcps->tcps_ip_notify_cinterval;
328 325 break;
329 326 case TCP_CONN_ABORT_THRESHOLD:
330 327 *i1 = tcps->tcps_ip_abort_cinterval;
331 328 break;
332 329 default:
333 330 return (-1);
334 331 }
335 332 break;
336 333 case IPPROTO_IP:
337 334 switch (name) {
338 335 case IP_TTL:
339 336 *i1 = tcps->tcps_ipv4_ttl;
340 337 break;
341 338 default:
342 339 return (-1);
343 340 }
344 341 break;
345 342 case IPPROTO_IPV6:
346 343 switch (name) {
347 344 case IPV6_UNICAST_HOPS:
348 345 *i1 = tcps->tcps_ipv6_hoplimit;
349 346 break;
350 347 default:
351 348 return (-1);
352 349 }
353 350 break;
354 351 default:
355 352 return (-1);
356 353 }
357 354 return (sizeof (int));
358 355 }
359 356
360 357 /*
361 358 * TCP routine to get the values of options.
362 359 */
363 360 int
364 361 tcp_opt_get(conn_t *connp, int level, int name, uchar_t *ptr)
365 362 {
366 363 int *i1 = (int *)ptr;
367 364 tcp_t *tcp = connp->conn_tcp;
368 365 conn_opt_arg_t coas;
369 366 int retval;
370 367
371 368 coas.coa_connp = connp;
372 369 coas.coa_ixa = connp->conn_ixa;
373 370 coas.coa_ipp = &connp->conn_xmit_ipp;
374 371 coas.coa_ancillary = B_FALSE;
375 372 coas.coa_changed = 0;
376 373
377 374 switch (level) {
378 375 case SOL_SOCKET:
379 376 switch (name) {
380 377 case SO_SND_COPYAVOID:
381 378 *i1 = tcp->tcp_snd_zcopy_on ?
382 379 SO_SND_COPYAVOID : 0;
383 380 return (sizeof (int));
384 381 case SO_ACCEPTCONN:
385 382 *i1 = (tcp->tcp_state == TCPS_LISTEN);
386 383 return (sizeof (int));
387 384 }
388 385 break;
389 386 case IPPROTO_TCP:
390 387 switch (name) {
391 388 case TCP_NODELAY:
392 389 *i1 = (tcp->tcp_naglim == 1) ? TCP_NODELAY : 0;
393 390 return (sizeof (int));
394 391 case TCP_MAXSEG:
395 392 *i1 = tcp->tcp_mss;
396 393 return (sizeof (int));
397 394 case TCP_NOTIFY_THRESHOLD:
398 395 *i1 = (int)tcp->tcp_first_timer_threshold;
399 396 return (sizeof (int));
400 397 case TCP_ABORT_THRESHOLD:
401 398 *i1 = tcp->tcp_second_timer_threshold;
402 399 return (sizeof (int));
403 400 case TCP_CONN_NOTIFY_THRESHOLD:
404 401 *i1 = tcp->tcp_first_ctimer_threshold;
405 402 return (sizeof (int));
406 403 case TCP_CONN_ABORT_THRESHOLD:
407 404 *i1 = tcp->tcp_second_ctimer_threshold;
408 405 return (sizeof (int));
409 406 case TCP_INIT_CWND:
410 407 *i1 = tcp->tcp_init_cwnd;
411 408 return (sizeof (int));
412 409 case TCP_KEEPALIVE_THRESHOLD:
413 410 *i1 = tcp->tcp_ka_interval;
414 411 return (sizeof (int));
415 412
416 413 /*
417 414 * TCP_KEEPIDLE expects value in seconds, but
418 415 * tcp_ka_interval is in milliseconds.
419 416 */
420 417 case TCP_KEEPIDLE:
421 418 *i1 = tcp->tcp_ka_interval / 1000;
422 419 return (sizeof (int));
423 420 case TCP_KEEPCNT:
424 421 *i1 = tcp->tcp_ka_cnt;
425 422 return (sizeof (int));
426 423
427 424 /*
428 425 * TCP_KEEPINTVL expects value in seconds, but
429 426 * tcp_ka_rinterval is in milliseconds.
430 427 */
431 428 case TCP_KEEPINTVL:
432 429 *i1 = tcp->tcp_ka_rinterval / 1000;
433 430 return (sizeof (int));
434 431 case TCP_KEEPALIVE_ABORT_THRESHOLD:
435 432 *i1 = tcp->tcp_ka_abort_thres;
436 433 return (sizeof (int));
437 434 case TCP_CORK:
438 435 *i1 = tcp->tcp_cork;
439 436 return (sizeof (int));
440 437 case TCP_RTO_INITIAL:
441 438 *i1 = tcp->tcp_rto_initial;
442 439 return (sizeof (uint32_t));
443 440 case TCP_RTO_MIN:
444 441 *i1 = tcp->tcp_rto_min;
445 442 return (sizeof (uint32_t));
446 443 case TCP_RTO_MAX:
447 444 *i1 = tcp->tcp_rto_max;
448 445 return (sizeof (uint32_t));
449 446 case TCP_LINGER2:
450 447 *i1 = tcp->tcp_fin_wait_2_flush_interval / SECONDS;
451 448 return (sizeof (int));
452 449 }
453 450 break;
454 451 case IPPROTO_IP:
455 452 if (connp->conn_family != AF_INET)
456 453 return (-1);
457 454 switch (name) {
458 455 case IP_OPTIONS:
459 456 case T_IP_OPTIONS:
460 457 /* Caller ensures enough space */
461 458 return (ip_opt_get_user(connp, ptr));
462 459 default:
463 460 break;
464 461 }
465 462 break;
466 463
467 464 case IPPROTO_IPV6:
468 465 /*
469 466 * IPPROTO_IPV6 options are only supported for sockets
470 467 * that are using IPv6 on the wire.
471 468 */
472 469 if (connp->conn_ipversion != IPV6_VERSION) {
473 470 return (-1);
474 471 }
475 472 switch (name) {
476 473 case IPV6_PATHMTU:
477 474 if (tcp->tcp_state < TCPS_ESTABLISHED)
478 475 return (-1);
479 476 break;
480 477 }
481 478 break;
482 479 }
483 480 mutex_enter(&connp->conn_lock);
484 481 retval = conn_opt_get(&coas, level, name, ptr);
485 482 mutex_exit(&connp->conn_lock);
486 483 return (retval);
487 484 }
488 485
489 486 /*
490 487 * We declare as 'int' rather than 'void' to satisfy pfi_t arg requirements.
491 488 * Parameters are assumed to be verified by the caller.
492 489 */
493 490 /* ARGSUSED */
494 491 int
495 492 tcp_opt_set(conn_t *connp, uint_t optset_context, int level, int name,
496 493 uint_t inlen, uchar_t *invalp, uint_t *outlenp, uchar_t *outvalp,
497 494 void *thisdg_attrs, cred_t *cr)
498 495 {
499 496 tcp_t *tcp = connp->conn_tcp;
500 497 int *i1 = (int *)invalp;
501 498 boolean_t onoff = (*i1 == 0) ? 0 : 1;
502 499 boolean_t checkonly;
503 500 int reterr;
504 501 tcp_stack_t *tcps = tcp->tcp_tcps;
505 502 conn_opt_arg_t coas;
506 503 uint32_t val = *((uint32_t *)invalp);
507 504
508 505 coas.coa_connp = connp;
509 506 coas.coa_ixa = connp->conn_ixa;
510 507 coas.coa_ipp = &connp->conn_xmit_ipp;
511 508 coas.coa_ancillary = B_FALSE;
512 509 coas.coa_changed = 0;
513 510
514 511 switch (optset_context) {
515 512 case SETFN_OPTCOM_CHECKONLY:
516 513 checkonly = B_TRUE;
517 514 /*
518 515 * Note: Implies T_CHECK semantics for T_OPTCOM_REQ
519 516 * inlen != 0 implies value supplied and
520 517 * we have to "pretend" to set it.
521 518 * inlen == 0 implies that there is no
522 519 * value part in T_CHECK request and just validation
523 520 * done elsewhere should be enough, we just return here.
524 521 */
525 522 if (inlen == 0) {
526 523 *outlenp = 0;
527 524 return (0);
528 525 }
529 526 break;
530 527 case SETFN_OPTCOM_NEGOTIATE:
531 528 checkonly = B_FALSE;
532 529 break;
533 530 case SETFN_UD_NEGOTIATE: /* error on conn-oriented transports ? */
534 531 case SETFN_CONN_NEGOTIATE:
535 532 checkonly = B_FALSE;
536 533 /*
537 534 * Negotiating local and "association-related" options
538 535 * from other (T_CONN_REQ, T_CONN_RES,T_UNITDATA_REQ)
539 536 * primitives is allowed by XTI, but we choose
540 537 * to not implement this style negotiation for Internet
541 538 * protocols (We interpret it is a must for OSI world but
542 539 * optional for Internet protocols) for all options.
543 540 * [ Will do only for the few options that enable test
544 541 * suites that our XTI implementation of this feature
545 542 * works for transports that do allow it ]
546 543 */
547 544 if (!tcp_allow_connopt_set(level, name)) {
548 545 *outlenp = 0;
549 546 return (EINVAL);
550 547 }
551 548 break;
552 549 default:
553 550 /*
554 551 * We should never get here
555 552 */
556 553 *outlenp = 0;
557 554 return (EINVAL);
558 555 }
559 556
560 557 ASSERT((optset_context != SETFN_OPTCOM_CHECKONLY) ||
561 558 (optset_context == SETFN_OPTCOM_CHECKONLY && inlen != 0));
562 559
563 560 /*
564 561 * For TCP, we should have no ancillary data sent down
565 562 * (sendmsg isn't supported for SOCK_STREAM), so thisdg_attrs
566 563 * has to be zero.
567 564 */
568 565 ASSERT(thisdg_attrs == NULL);
569 566
570 567 /*
571 568 * For fixed length options, no sanity check
572 569 * of passed in length is done. It is assumed *_optcom_req()
573 570 * routines do the right thing.
574 571 */
575 572 switch (level) {
576 573 case SOL_SOCKET:
577 574 switch (name) {
578 575 case SO_KEEPALIVE:
579 576 if (checkonly) {
580 577 /* check only case */
581 578 break;
582 579 }
583 580
584 581 if (!onoff) {
585 582 if (connp->conn_keepalive) {
586 583 if (tcp->tcp_ka_tid != 0) {
587 584 (void) TCP_TIMER_CANCEL(tcp,
588 585 tcp->tcp_ka_tid);
589 586 tcp->tcp_ka_tid = 0;
590 587 }
591 588 connp->conn_keepalive = 0;
592 589 }
593 590 break;
594 591 }
595 592 if (!connp->conn_keepalive) {
596 593 /* Crank up the keepalive timer */
597 594 tcp->tcp_ka_last_intrvl = 0;
598 595 tcp->tcp_ka_tid = TCP_TIMER(tcp,
599 596 tcp_keepalive_timer, tcp->tcp_ka_interval);
600 597 connp->conn_keepalive = 1;
601 598 }
602 599 break;
603 600 case SO_SNDBUF: {
604 601 if (*i1 > tcps->tcps_max_buf) {
605 602 *outlenp = 0;
606 603 return (ENOBUFS);
607 604 }
608 605 if (checkonly)
609 606 break;
610 607
611 608 connp->conn_sndbuf = *i1;
612 609 if (tcps->tcps_snd_lowat_fraction != 0) {
613 610 connp->conn_sndlowat = connp->conn_sndbuf /
614 611 tcps->tcps_snd_lowat_fraction;
615 612 }
616 613 (void) tcp_maxpsz_set(tcp, B_TRUE);
617 614 /*
618 615 * If we are flow-controlled, recheck the condition.
619 616 * There are apps that increase SO_SNDBUF size when
620 617 * flow-controlled (EWOULDBLOCK), and expect the flow
621 618 * control condition to be lifted right away.
622 619 */
623 620 mutex_enter(&tcp->tcp_non_sq_lock);
624 621 if (tcp->tcp_flow_stopped &&
625 622 TCP_UNSENT_BYTES(tcp) < connp->conn_sndbuf) {
626 623 tcp_clrqfull(tcp);
627 624 }
628 625 mutex_exit(&tcp->tcp_non_sq_lock);
629 626 *outlenp = inlen;
630 627 return (0);
631 628 }
632 629 case SO_RCVBUF:
633 630 if (*i1 > tcps->tcps_max_buf) {
634 631 *outlenp = 0;
635 632 return (ENOBUFS);
636 633 }
637 634 /* Silently ignore zero */
638 635 if (!checkonly && *i1 != 0) {
639 636 *i1 = MSS_ROUNDUP(*i1, tcp->tcp_mss);
640 637 (void) tcp_rwnd_set(tcp, *i1);
641 638 }
642 639 /*
643 640 * XXX should we return the rwnd here
644 641 * and tcp_opt_get ?
645 642 */
646 643 *outlenp = inlen;
647 644 return (0);
648 645 case SO_SND_COPYAVOID:
649 646 if (!checkonly) {
650 647 if (tcp->tcp_loopback ||
651 648 (onoff != 1) || !tcp_zcopy_check(tcp)) {
652 649 *outlenp = 0;
653 650 return (EOPNOTSUPP);
654 651 }
655 652 tcp->tcp_snd_zcopy_aware = 1;
656 653 }
657 654 *outlenp = inlen;
658 655 return (0);
659 656 }
660 657 break;
661 658 case IPPROTO_TCP:
662 659 switch (name) {
663 660 case TCP_NODELAY:
664 661 if (!checkonly)
665 662 tcp->tcp_naglim = *i1 ? 1 : tcp->tcp_mss;
666 663 break;
667 664 case TCP_NOTIFY_THRESHOLD:
668 665 if (!checkonly)
669 666 tcp->tcp_first_timer_threshold = *i1;
670 667 break;
671 668 case TCP_ABORT_THRESHOLD:
672 669 if (!checkonly)
673 670 tcp->tcp_second_timer_threshold = *i1;
674 671 break;
675 672 case TCP_CONN_NOTIFY_THRESHOLD:
676 673 if (!checkonly)
677 674 tcp->tcp_first_ctimer_threshold = *i1;
678 675 break;
679 676 case TCP_CONN_ABORT_THRESHOLD:
680 677 if (!checkonly)
681 678 tcp->tcp_second_ctimer_threshold = *i1;
682 679 break;
683 680 case TCP_RECVDSTADDR:
684 681 if (tcp->tcp_state > TCPS_LISTEN) {
685 682 *outlenp = 0;
686 683 return (EOPNOTSUPP);
687 684 }
688 685 /* Setting done in conn_opt_set */
689 686 break;
690 687 case TCP_INIT_CWND:
691 688 if (checkonly)
692 689 break;
693 690
694 691 /*
695 692 * Only allow socket with network configuration
696 693 * privilege to set the initial cwnd to be larger
697 694 * than allowed by RFC 3390.
698 695 */
699 696 if (val > MIN(4, MAX(2, 4380 / tcp->tcp_mss))) {
700 697 if ((reterr = secpolicy_ip_config(cr, B_TRUE))
701 698 != 0) {
702 699 *outlenp = 0;
703 700 return (reterr);
704 701 }
705 702 if (val > tcp_max_init_cwnd) {
706 703 *outlenp = 0;
707 704 return (EINVAL);
708 705 }
709 706 }
710 707
711 708 tcp->tcp_init_cwnd = val;
712 709
713 710 /*
714 711 * If the socket is connected, AND no outbound data
715 712 * has been sent, reset the actual cwnd values.
716 713 */
717 714 if (tcp->tcp_state == TCPS_ESTABLISHED &&
718 715 tcp->tcp_iss == tcp->tcp_snxt - 1) {
719 716 tcp->tcp_cwnd =
720 717 MIN(tcp->tcp_rwnd, val * tcp->tcp_mss);
721 718 }
722 719 break;
723 720
724 721 /*
725 722 * TCP_KEEPIDLE is in seconds but TCP_KEEPALIVE_THRESHOLD
726 723 * is in milliseconds. TCP_KEEPIDLE is introduced for
727 724 * compatibility with other Unix flavors.
728 725 * We can fall through TCP_KEEPALIVE_THRESHOLD logic after
729 726 * converting the input to milliseconds.
730 727 */
731 728 case TCP_KEEPIDLE:
732 729 *i1 *= 1000;
733 730 /* FALLTHRU */
734 731
735 732 case TCP_KEEPALIVE_THRESHOLD:
736 733 if (checkonly)
737 734 break;
738 735
739 736 if (*i1 < tcps->tcps_keepalive_interval_low ||
740 737 *i1 > tcps->tcps_keepalive_interval_high) {
741 738 *outlenp = 0;
742 739 return (EINVAL);
743 740 }
744 741 if (*i1 != tcp->tcp_ka_interval) {
745 742 tcp->tcp_ka_interval = *i1;
746 743 /*
747 744 * Check if we need to restart the
748 745 * keepalive timer.
749 746 */
750 747 if (tcp->tcp_ka_tid != 0) {
751 748 ASSERT(connp->conn_keepalive);
752 749 (void) TCP_TIMER_CANCEL(tcp,
753 750 tcp->tcp_ka_tid);
754 751 tcp->tcp_ka_last_intrvl = 0;
755 752 tcp->tcp_ka_tid = TCP_TIMER(tcp,
756 753 tcp_keepalive_timer,
757 754 tcp->tcp_ka_interval);
758 755 }
759 756 }
760 757 break;
761 758
762 759 /*
763 760 * tcp_ka_abort_thres = tcp_ka_rinterval * tcp_ka_cnt.
764 761 * So setting TCP_KEEPCNT or TCP_KEEPINTVL can affect all the
765 762 * three members - tcp_ka_abort_thres, tcp_ka_rinterval and
766 763 * tcp_ka_cnt.
767 764 */
768 765 case TCP_KEEPCNT:
769 766 if (checkonly)
770 767 break;
771 768
772 769 if (*i1 == 0) {
773 770 return (EINVAL);
774 771 } else if (tcp->tcp_ka_rinterval == 0) {
775 772 if ((tcp->tcp_ka_abort_thres / *i1) <
776 773 tcp->tcp_rto_min ||
777 774 (tcp->tcp_ka_abort_thres / *i1) >
778 775 tcp->tcp_rto_max)
779 776 return (EINVAL);
780 777
781 778 tcp->tcp_ka_rinterval =
782 779 tcp->tcp_ka_abort_thres / *i1;
783 780 } else {
784 781 if ((*i1 * tcp->tcp_ka_rinterval) <
785 782 tcps->tcps_keepalive_abort_interval_low ||
786 783 (*i1 * tcp->tcp_ka_rinterval) >
787 784 tcps->tcps_keepalive_abort_interval_high)
788 785 return (EINVAL);
789 786 tcp->tcp_ka_abort_thres =
790 787 (*i1 * tcp->tcp_ka_rinterval);
791 788 }
792 789 tcp->tcp_ka_cnt = *i1;
793 790 break;
794 791 case TCP_KEEPINTVL:
795 792 /*
796 793 * TCP_KEEPINTVL is specified in seconds, but
797 794 * tcp_ka_rinterval is in milliseconds.
798 795 */
799 796
800 797 if (checkonly)
801 798 break;
802 799
803 800 if ((*i1 * 1000) < tcp->tcp_rto_min ||
804 801 (*i1 * 1000) > tcp->tcp_rto_max)
805 802 return (EINVAL);
806 803
807 804 if (tcp->tcp_ka_cnt == 0) {
808 805 tcp->tcp_ka_cnt =
809 806 tcp->tcp_ka_abort_thres / (*i1 * 1000);
810 807 } else {
811 808 if ((*i1 * tcp->tcp_ka_cnt * 1000) <
812 809 tcps->tcps_keepalive_abort_interval_low ||
813 810 (*i1 * tcp->tcp_ka_cnt * 1000) >
814 811 tcps->tcps_keepalive_abort_interval_high)
815 812 return (EINVAL);
816 813 tcp->tcp_ka_abort_thres =
817 814 (*i1 * tcp->tcp_ka_cnt * 1000);
818 815 }
819 816 tcp->tcp_ka_rinterval = *i1 * 1000;
820 817 break;
821 818 case TCP_KEEPALIVE_ABORT_THRESHOLD:
822 819 if (!checkonly) {
823 820 if (*i1 <
824 821 tcps->tcps_keepalive_abort_interval_low ||
825 822 *i1 >
826 823 tcps->tcps_keepalive_abort_interval_high) {
827 824 *outlenp = 0;
828 825 return (EINVAL);
829 826 }
830 827 tcp->tcp_ka_abort_thres = *i1;
831 828 tcp->tcp_ka_cnt = 0;
832 829 tcp->tcp_ka_rinterval = 0;
833 830 }
834 831 break;
835 832 case TCP_CORK:
836 833 if (!checkonly) {
837 834 /*
838 835 * if tcp->tcp_cork was set and is now
839 836 * being unset, we have to make sure that
840 837 * the remaining data gets sent out. Also
841 838 * unset tcp->tcp_cork so that tcp_wput_data()
842 839 * can send data even if it is less than mss
843 840 */
844 841 if (tcp->tcp_cork && onoff == 0 &&
845 842 tcp->tcp_unsent > 0) {
846 843 tcp->tcp_cork = B_FALSE;
847 844 tcp_wput_data(tcp, NULL, B_FALSE);
848 845 }
849 846 tcp->tcp_cork = onoff;
850 847 }
851 848 break;
852 849 case TCP_RTO_INITIAL: {
853 850 clock_t rto;
854 851
855 852 if (checkonly || val == 0)
856 853 break;
857 854
858 855 /*
859 856 * Sanity checks
860 857 *
861 858 * The initial RTO should be bounded by the minimum
862 859 * and maximum RTO. And it should also be smaller
863 860 * than the connect attempt abort timeout. Otherwise,
864 861 * the connection won't be aborted in a period
865 862 * reasonably close to that timeout.
866 863 */
867 864 if (val < tcp->tcp_rto_min || val > tcp->tcp_rto_max ||
868 865 val > tcp->tcp_second_ctimer_threshold ||
869 866 val < tcps->tcps_rexmit_interval_initial_low ||
870 867 val > tcps->tcps_rexmit_interval_initial_high) {
871 868 *outlenp = 0;
872 869 return (EINVAL);
873 870 }
874 871 tcp->tcp_rto_initial = val;
875 872
876 873 /*
877 874 * If TCP has not sent anything, need to re-calculate
878 875 * tcp_rto. Otherwise, this option change does not
879 876 * really affect anything.
880 877 */
881 878 if (tcp->tcp_state >= TCPS_SYN_SENT)
882 879 break;
883 880
884 881 tcp->tcp_rtt_sa = tcp->tcp_rto_initial << 2;
885 882 tcp->tcp_rtt_sd = tcp->tcp_rto_initial >> 1;
886 883 rto = (tcp->tcp_rtt_sa >> 3) + tcp->tcp_rtt_sd +
887 884 tcps->tcps_rexmit_interval_extra +
888 885 (tcp->tcp_rtt_sa >> 5) +
889 886 tcps->tcps_conn_grace_period;
890 887 TCP_SET_RTO(tcp, rto);
891 888 break;
892 889 }
893 890 case TCP_RTO_MIN:
894 891 if (checkonly || val == 0)
895 892 break;
896 893
897 894 if (val < tcps->tcps_rexmit_interval_min_low ||
898 895 val > tcps->tcps_rexmit_interval_min_high ||
899 896 val > tcp->tcp_rto_max) {
900 897 *outlenp = 0;
901 898 return (EINVAL);
902 899 }
903 900 tcp->tcp_rto_min = val;
904 901 if (tcp->tcp_rto < val)
905 902 tcp->tcp_rto = val;
906 903 break;
907 904 case TCP_RTO_MAX:
908 905 if (checkonly || val == 0)
909 906 break;
910 907
911 908 /*
912 909 * Sanity checks
913 910 *
914 911 * The maximum RTO should not be larger than the
915 912 * connection abort timeout. Otherwise, the
916 913 * connection won't be aborted in a period reasonably
917 914 * close to that timeout.
918 915 */
919 916 if (val < tcps->tcps_rexmit_interval_max_low ||
920 917 val > tcps->tcps_rexmit_interval_max_high ||
921 918 val < tcp->tcp_rto_min ||
922 919 val > tcp->tcp_second_timer_threshold) {
923 920 *outlenp = 0;
924 921 return (EINVAL);
925 922 }
926 923 tcp->tcp_rto_max = val;
927 924 if (tcp->tcp_rto > val)
928 925 tcp->tcp_rto = val;
929 926 break;
930 927 case TCP_LINGER2:
931 928 if (checkonly || *i1 == 0)
932 929 break;
933 930
934 931 /*
935 932 * Note that the option value's unit is second. And
936 933 * the value should be bigger than the private
937 934 * parameter tcp_fin_wait_2_flush_interval's lower
938 935 * bound and smaller than the current value of that
939 936 * parameter. It should be smaller than the current
940 937 * value to avoid an app setting TCP_LINGER2 to a big
941 938 * value, causing resource to be held up too long in
942 939 * FIN-WAIT-2 state.
943 940 */
944 941 if (*i1 < 0 ||
945 942 tcps->tcps_fin_wait_2_flush_interval_low/SECONDS >
946 943 *i1 ||
947 944 tcps->tcps_fin_wait_2_flush_interval/SECONDS <
948 945 *i1) {
949 946 *outlenp = 0;
950 947 return (EINVAL);
951 948 }
952 949 tcp->tcp_fin_wait_2_flush_interval = *i1 * SECONDS;
953 950 break;
954 951 default:
955 952 break;
956 953 }
957 954 break;
958 955 case IPPROTO_IP:
959 956 if (connp->conn_family != AF_INET) {
960 957 *outlenp = 0;
961 958 return (EINVAL);
962 959 }
963 960 switch (name) {
964 961 case IP_SEC_OPT:
965 962 /*
966 963 * We should not allow policy setting after
967 964 * we start listening for connections.
968 965 */
969 966 if (tcp->tcp_state == TCPS_LISTEN) {
970 967 return (EINVAL);
971 968 }
972 969 break;
973 970 }
974 971 break;
975 972 case IPPROTO_IPV6:
976 973 /*
977 974 * IPPROTO_IPV6 options are only supported for sockets
978 975 * that are using IPv6 on the wire.
979 976 */
980 977 if (connp->conn_ipversion != IPV6_VERSION) {
981 978 *outlenp = 0;
982 979 return (EINVAL);
983 980 }
984 981
985 982 switch (name) {
986 983 case IPV6_RECVPKTINFO:
987 984 if (!checkonly) {
988 985 /* Force it to be sent up with the next msg */
989 986 tcp->tcp_recvifindex = 0;
990 987 }
991 988 break;
992 989 case IPV6_RECVTCLASS:
993 990 if (!checkonly) {
994 991 /* Force it to be sent up with the next msg */
995 992 tcp->tcp_recvtclass = 0xffffffffU;
996 993 }
997 994 break;
998 995 case IPV6_RECVHOPLIMIT:
999 996 if (!checkonly) {
1000 997 /* Force it to be sent up with the next msg */
1001 998 tcp->tcp_recvhops = 0xffffffffU;
1002 999 }
1003 1000 break;
1004 1001 case IPV6_PKTINFO:
1005 1002 /* This is an extra check for TCP */
1006 1003 if (inlen == sizeof (struct in6_pktinfo)) {
1007 1004 struct in6_pktinfo *pkti;
1008 1005
1009 1006 pkti = (struct in6_pktinfo *)invalp;
1010 1007 /*
1011 1008 * RFC 3542 states that ipi6_addr must be
1012 1009 * the unspecified address when setting the
1013 1010 * IPV6_PKTINFO sticky socket option on a
1014 1011 * TCP socket.
1015 1012 */
1016 1013 if (!IN6_IS_ADDR_UNSPECIFIED(&pkti->ipi6_addr))
1017 1014 return (EINVAL);
1018 1015 }
1019 1016 break;
1020 1017 case IPV6_SEC_OPT:
1021 1018 /*
1022 1019 * We should not allow policy setting after
1023 1020 * we start listening for connections.
1024 1021 */
1025 1022 if (tcp->tcp_state == TCPS_LISTEN) {
1026 1023 return (EINVAL);
1027 1024 }
1028 1025 break;
1029 1026 }
1030 1027 break;
1031 1028 }
1032 1029 reterr = conn_opt_set(&coas, level, name, inlen, invalp,
1033 1030 checkonly, cr);
1034 1031 if (reterr != 0) {
1035 1032 *outlenp = 0;
1036 1033 return (reterr);
1037 1034 }
1038 1035
1039 1036 /*
1040 1037 * Common case of OK return with outval same as inval
1041 1038 */
1042 1039 if (invalp != outvalp) {
1043 1040 /* don't trust bcopy for identical src/dst */
1044 1041 (void) bcopy(invalp, outvalp, inlen);
1045 1042 }
1046 1043 *outlenp = inlen;
1047 1044
1048 1045 if (coas.coa_changed & COA_HEADER_CHANGED) {
1049 1046 /* If we are connected we rebuilt the headers */
1050 1047 if (!IN6_IS_ADDR_UNSPECIFIED(&connp->conn_faddr_v6) &&
1051 1048 !IN6_IS_ADDR_V4MAPPED_ANY(&connp->conn_faddr_v6)) {
1052 1049 reterr = tcp_build_hdrs(tcp);
1053 1050 if (reterr != 0)
1054 1051 return (reterr);
1055 1052 }
1056 1053 }
1057 1054 if (coas.coa_changed & COA_ROUTE_CHANGED) {
1058 1055 in6_addr_t nexthop;
1059 1056
1060 1057 /*
1061 1058 * If we are connected we re-cache the information.
1062 1059 * We ignore errors to preserve BSD behavior.
1063 1060 * Note that we don't redo IPsec policy lookup here
1064 1061 * since the final destination (or source) didn't change.
1065 1062 */
1066 1063 ip_attr_nexthop(&connp->conn_xmit_ipp, connp->conn_ixa,
1067 1064 &connp->conn_faddr_v6, &nexthop);
1068 1065
1069 1066 if (!IN6_IS_ADDR_UNSPECIFIED(&connp->conn_faddr_v6) &&
1070 1067 !IN6_IS_ADDR_V4MAPPED_ANY(&connp->conn_faddr_v6)) {
1071 1068 (void) ip_attr_connect(connp, connp->conn_ixa,
1072 1069 &connp->conn_laddr_v6, &connp->conn_faddr_v6,
1073 1070 &nexthop, connp->conn_fport, NULL, NULL,
1074 1071 IPDF_VERIFY_DST);
1075 1072 }
1076 1073 }
1077 1074 if ((coas.coa_changed & COA_SNDBUF_CHANGED) && !IPCL_IS_NONSTR(connp)) {
1078 1075 connp->conn_wq->q_hiwat = connp->conn_sndbuf;
1079 1076 }
1080 1077 if (coas.coa_changed & COA_WROFF_CHANGED) {
1081 1078 connp->conn_wroff = connp->conn_ht_iphc_allocated +
1082 1079 tcps->tcps_wroff_xtra;
1083 1080 (void) proto_set_tx_wroff(connp->conn_rq, connp,
1084 1081 connp->conn_wroff);
1085 1082 }
1086 1083 if (coas.coa_changed & COA_OOBINLINE_CHANGED) {
1087 1084 if (IPCL_IS_NONSTR(connp))
1088 1085 proto_set_rx_oob_opt(connp, onoff);
1089 1086 }
1090 1087 return (0);
1091 1088 }
↓ open down ↓ |
807 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX