4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright (c) 2011, Joyent Inc. All rights reserved.
25 * Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved.
26 * Copyright (c) 2013,2014 by Delphix. All rights reserved.
27 * Copyright 2014, OmniTI Computer Consulting, Inc. All rights reserved.
28 */
29 /* Copyright (c) 1990 Mentat Inc. */
30
31 #include <sys/types.h>
32 #include <sys/stream.h>
33 #include <sys/strsun.h>
34 #include <sys/strsubr.h>
35 #include <sys/stropts.h>
36 #include <sys/strlog.h>
37 #define _SUN_TPI_VERSION 2
38 #include <sys/tihdr.h>
39 #include <sys/timod.h>
40 #include <sys/ddi.h>
41 #include <sys/sunddi.h>
42 #include <sys/suntpi.h>
43 #include <sys/xti_inet.h>
44 #include <sys/cmn_err.h>
1406 mi_free(tcp->tcp_rthdrdstopts);
1407 tcp->tcp_rthdrdstopts = NULL;
1408 tcp->tcp_rthdrdstoptslen = 0;
1409 }
1410 ASSERT(tcp->tcp_rthdrdstoptslen == 0);
1411 if (tcp->tcp_rthdr != NULL) {
1412 mi_free(tcp->tcp_rthdr);
1413 tcp->tcp_rthdr = NULL;
1414 tcp->tcp_rthdrlen = 0;
1415 }
1416 ASSERT(tcp->tcp_rthdrlen == 0);
1417
1418 /*
1419 * Following is really a blowing away a union.
1420 * It happens to have exactly two members of identical size
1421 * the following code is enough.
1422 */
1423 tcp_close_mpp(&tcp->tcp_conn.tcp_eager_conn_ind);
1424
1425 /*
1426 * If this is a non-STREAM socket still holding on to an upper
1427 * handle, release it. As a result of fallback we might also see
1428 * STREAMS based conns with upper handles, in which case there is
1429 * nothing to do other than clearing the field.
1430 */
1431 if (connp->conn_upper_handle != NULL) {
1432 if (IPCL_IS_NONSTR(connp)) {
1433 (*connp->conn_upcalls->su_closed)(
1434 connp->conn_upper_handle);
1435 tcp->tcp_detached = B_TRUE;
1436 }
1437 connp->conn_upper_handle = NULL;
1438 connp->conn_upcalls = NULL;
1439 }
1440 }
1441
1442 /*
1443 * tcp_get_conn/tcp_free_conn
1444 *
1445 * tcp_get_conn is used to get a clean tcp connection structure.
2037 tcp_init_values(tcp, NULL);
2038
2039 DTRACE_TCP6(state__change, void, NULL, ip_xmit_attr_t *,
2040 connp->conn_ixa, void, NULL, tcp_t *, tcp, void, NULL,
2041 int32_t, oldstate);
2042
2043 ASSERT(tcp->tcp_ptpbhn != NULL);
2044 tcp->tcp_rwnd = connp->conn_rcvbuf;
2045 tcp->tcp_mss = connp->conn_ipversion != IPV4_VERSION ?
2046 tcps->tcps_mss_def_ipv6 : tcps->tcps_mss_def_ipv4;
2047 }
2048
2049 /*
2050 * Force values to zero that need be zero.
2051 * Do not touch values asociated with the BOUND or LISTEN state
2052 * since the connection will end up in that state after the reinit.
2053 * NOTE: tcp_reinit_values MUST have a line for each field in the tcp_t
2054 * structure!
2055 */
2056 static void
2057 tcp_reinit_values(tcp)
2058 tcp_t *tcp;
2059 {
2060 tcp_stack_t *tcps = tcp->tcp_tcps;
2061 conn_t *connp = tcp->tcp_connp;
2062
2063 #ifndef lint
2064 #define DONTCARE(x)
2065 #define PRESERVE(x)
2066 #else
2067 #define DONTCARE(x) ((x) = (x))
2068 #define PRESERVE(x) ((x) = (x))
2069 #endif /* lint */
2070
2071 PRESERVE(tcp->tcp_bind_hash_port);
2072 PRESERVE(tcp->tcp_bind_hash);
2073 PRESERVE(tcp->tcp_ptpbhn);
2074 PRESERVE(tcp->tcp_acceptor_hash);
2075 PRESERVE(tcp->tcp_ptpahn);
2076
2077 /* Should be ASSERT NULL on these with new code! */
2078 ASSERT(tcp->tcp_time_wait_next == NULL);
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2015 Joyent, Inc.
25 * Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved.
26 * Copyright (c) 2013,2014 by Delphix. All rights reserved.
27 * Copyright 2014, OmniTI Computer Consulting, Inc. All rights reserved.
28 */
29 /* Copyright (c) 1990 Mentat Inc. */
30
31 #include <sys/types.h>
32 #include <sys/stream.h>
33 #include <sys/strsun.h>
34 #include <sys/strsubr.h>
35 #include <sys/stropts.h>
36 #include <sys/strlog.h>
37 #define _SUN_TPI_VERSION 2
38 #include <sys/tihdr.h>
39 #include <sys/timod.h>
40 #include <sys/ddi.h>
41 #include <sys/sunddi.h>
42 #include <sys/suntpi.h>
43 #include <sys/xti_inet.h>
44 #include <sys/cmn_err.h>
1406 mi_free(tcp->tcp_rthdrdstopts);
1407 tcp->tcp_rthdrdstopts = NULL;
1408 tcp->tcp_rthdrdstoptslen = 0;
1409 }
1410 ASSERT(tcp->tcp_rthdrdstoptslen == 0);
1411 if (tcp->tcp_rthdr != NULL) {
1412 mi_free(tcp->tcp_rthdr);
1413 tcp->tcp_rthdr = NULL;
1414 tcp->tcp_rthdrlen = 0;
1415 }
1416 ASSERT(tcp->tcp_rthdrlen == 0);
1417
1418 /*
1419 * Following is really a blowing away a union.
1420 * It happens to have exactly two members of identical size
1421 * the following code is enough.
1422 */
1423 tcp_close_mpp(&tcp->tcp_conn.tcp_eager_conn_ind);
1424
1425 /*
1426 * Destroy any association with SO_REUSEPORT group.
1427 */
1428 if (tcp->tcp_rg_bind != NULL) {
1429 /*
1430 * This is only necessary for connections which enabled
1431 * SO_REUSEPORT but were never bound. Such connections should
1432 * be the one and only member of the tcp_rg_tp to which they
1433 * have been associated.
1434 */
1435 VERIFY(tcp_rg_remove(tcp->tcp_rg_bind, tcp));
1436 tcp_rg_destroy(tcp->tcp_rg_bind);
1437 tcp->tcp_rg_bind = NULL;
1438 }
1439
1440 /*
1441 * If this is a non-STREAM socket still holding on to an upper
1442 * handle, release it. As a result of fallback we might also see
1443 * STREAMS based conns with upper handles, in which case there is
1444 * nothing to do other than clearing the field.
1445 */
1446 if (connp->conn_upper_handle != NULL) {
1447 if (IPCL_IS_NONSTR(connp)) {
1448 (*connp->conn_upcalls->su_closed)(
1449 connp->conn_upper_handle);
1450 tcp->tcp_detached = B_TRUE;
1451 }
1452 connp->conn_upper_handle = NULL;
1453 connp->conn_upcalls = NULL;
1454 }
1455 }
1456
1457 /*
1458 * tcp_get_conn/tcp_free_conn
1459 *
1460 * tcp_get_conn is used to get a clean tcp connection structure.
2052 tcp_init_values(tcp, NULL);
2053
2054 DTRACE_TCP6(state__change, void, NULL, ip_xmit_attr_t *,
2055 connp->conn_ixa, void, NULL, tcp_t *, tcp, void, NULL,
2056 int32_t, oldstate);
2057
2058 ASSERT(tcp->tcp_ptpbhn != NULL);
2059 tcp->tcp_rwnd = connp->conn_rcvbuf;
2060 tcp->tcp_mss = connp->conn_ipversion != IPV4_VERSION ?
2061 tcps->tcps_mss_def_ipv6 : tcps->tcps_mss_def_ipv4;
2062 }
2063
2064 /*
2065 * Force values to zero that need be zero.
2066 * Do not touch values asociated with the BOUND or LISTEN state
2067 * since the connection will end up in that state after the reinit.
2068 * NOTE: tcp_reinit_values MUST have a line for each field in the tcp_t
2069 * structure!
2070 */
2071 static void
2072 tcp_reinit_values(tcp_t *tcp)
2073 {
2074 tcp_stack_t *tcps = tcp->tcp_tcps;
2075 conn_t *connp = tcp->tcp_connp;
2076
2077 #ifndef lint
2078 #define DONTCARE(x)
2079 #define PRESERVE(x)
2080 #else
2081 #define DONTCARE(x) ((x) = (x))
2082 #define PRESERVE(x) ((x) = (x))
2083 #endif /* lint */
2084
2085 PRESERVE(tcp->tcp_bind_hash_port);
2086 PRESERVE(tcp->tcp_bind_hash);
2087 PRESERVE(tcp->tcp_ptpbhn);
2088 PRESERVE(tcp->tcp_acceptor_hash);
2089 PRESERVE(tcp->tcp_ptpahn);
2090
2091 /* Should be ASSERT NULL on these with new code! */
2092 ASSERT(tcp->tcp_time_wait_next == NULL);
|