1/*- 2 * Copyright (c) 1982, 1986, 1988, 1993 3 * The Regents of the University of California. 4 * Copyright (c) 2006-2007 Robert N. M. Watson 5 * Copyright (c) 2010-2011 Juniper Networks, Inc. 6 * All rights reserved. 7 * 8 * Portions of this software were developed by Robert N. M. Watson under --- 22 unchanged lines hidden (view full) --- 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 * From: @(#)tcp_usrreq.c 8.2 (Berkeley) 1/3/94 36 */ 37 38#include <sys/cdefs.h> |
39__FBSDID("$FreeBSD: head/sys/netinet/tcp_usrreq.c 254889 2013-08-25 21:54:41Z markj $"); |
40 41#include "opt_ddb.h" 42#include "opt_inet.h" 43#include "opt_inet6.h" 44#include "opt_tcpdebug.h" 45 46#include <sys/param.h> 47#include <sys/systm.h> --- 314 unchanged lines hidden (view full) --- 362 TCPDEBUG1(); 363 SOCK_LOCK(so); 364 error = solisten_proto_check(so); 365 INP_HASH_WLOCK(&V_tcbinfo); 366 if (error == 0 && inp->inp_lport == 0) 367 error = in_pcbbind(inp, (struct sockaddr *)0, td->td_ucred); 368 INP_HASH_WUNLOCK(&V_tcbinfo); 369 if (error == 0) { |
370 tcp_state_change(tp, TCPS_LISTEN); |
371 solisten_proto(so, backlog); 372#ifdef TCP_OFFLOAD 373 if ((so->so_options & SO_NO_OFFLOAD) == 0) 374 tcp_offload_listen_start(tp); 375#endif 376 } 377 SOCK_UNLOCK(so); 378 --- 28 unchanged lines hidden (view full) --- 407 if (error == 0 && inp->inp_lport == 0) { 408 inp->inp_vflag &= ~INP_IPV4; 409 if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0) 410 inp->inp_vflag |= INP_IPV4; 411 error = in6_pcbbind(inp, (struct sockaddr *)0, td->td_ucred); 412 } 413 INP_HASH_WUNLOCK(&V_tcbinfo); 414 if (error == 0) { |
415 tcp_state_change(tp, TCPS_LISTEN); |
416 solisten_proto(so, backlog); 417#ifdef TCP_OFFLOAD 418 if ((so->so_options & SO_NO_OFFLOAD) == 0) 419 tcp_offload_listen_start(tp); 420#endif 421 } 422 SOCK_UNLOCK(so); 423 --- 723 unchanged lines hidden (view full) --- 1147 * XXX: This should move to tcp_output(). 1148 */ 1149 while (tp->request_r_scale < TCP_MAX_WINSHIFT && 1150 (TCP_MAXWIN << tp->request_r_scale) < sb_max) 1151 tp->request_r_scale++; 1152 1153 soisconnecting(so); 1154 TCPSTAT_INC(tcps_connattempt); |
1155 tcp_state_change(tp, TCPS_SYN_SENT); |
1156 tp->iss = tcp_new_isn(tp); 1157 tcp_sendseqinit(tp); 1158 1159 return 0; 1160 1161out: 1162 INP_HASH_WUNLOCK(&V_tcbinfo); 1163 return (error); --- 55 unchanged lines hidden (view full) --- 1219 1220 /* Compute window scaling to request. */ 1221 while (tp->request_r_scale < TCP_MAX_WINSHIFT && 1222 (TCP_MAXWIN << tp->request_r_scale) < sb_max) 1223 tp->request_r_scale++; 1224 1225 soisconnecting(so); 1226 TCPSTAT_INC(tcps_connattempt); |
1227 tcp_state_change(tp, TCPS_SYN_SENT); |
1228 tp->iss = tcp_new_isn(tp); 1229 tcp_sendseqinit(tp); 1230 1231 return 0; 1232 1233out: 1234 INP_HASH_WUNLOCK(&V_tcbinfo); 1235 return error; --- 463 unchanged lines hidden (view full) --- 1699 1700 switch (tp->t_state) { 1701 case TCPS_LISTEN: 1702#ifdef TCP_OFFLOAD 1703 tcp_offload_listen_stop(tp); 1704#endif 1705 /* FALLTHROUGH */ 1706 case TCPS_CLOSED: |
1707 tcp_state_change(tp, TCPS_CLOSED); |
1708 tp = tcp_close(tp); 1709 /* 1710 * tcp_close() should never return NULL here as the socket is 1711 * still open. 1712 */ 1713 KASSERT(tp != NULL, 1714 ("tcp_usrclosed: tcp_close() returned NULL")); 1715 break; 1716 1717 case TCPS_SYN_SENT: 1718 case TCPS_SYN_RECEIVED: 1719 tp->t_flags |= TF_NEEDFIN; 1720 break; 1721 1722 case TCPS_ESTABLISHED: |
1723 tcp_state_change(tp, TCPS_FIN_WAIT_1); |
1724 break; 1725 1726 case TCPS_CLOSE_WAIT: |
1727 tcp_state_change(tp, TCPS_LAST_ACK); |
1728 break; 1729 } 1730 if (tp->t_state >= TCPS_FIN_WAIT_2) { 1731 soisdisconnected(tp->t_inpcb->inp_socket); 1732 /* Prevent the connection hanging in FIN_WAIT_2 forever. */ 1733 if (tp->t_state == TCPS_FIN_WAIT_2) { 1734 int timeout; 1735 --- 318 unchanged lines hidden --- |