tcp_usrreq.c (133720) | tcp_usrreq.c (133874) |
---|---|
1/* 2 * Copyright (c) 1982, 1986, 1988, 1993 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 --- 13 unchanged lines hidden (view full) --- 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 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 * From: @(#)tcp_usrreq.c 8.2 (Berkeley) 1/3/94 | 1/* 2 * Copyright (c) 1982, 1986, 1988, 1993 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 --- 13 unchanged lines hidden (view full) --- 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 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 * From: @(#)tcp_usrreq.c 8.2 (Berkeley) 1/3/94 |
30 * $FreeBSD: head/sys/netinet/tcp_usrreq.c 133720 2004-08-14 15:32:40Z dwmalone $ | 30 * $FreeBSD: head/sys/netinet/tcp_usrreq.c 133874 2004-08-16 18:32:07Z rwatson $ |
31 */ 32 33#include "opt_ipsec.h" 34#include "opt_inet.h" 35#include "opt_inet6.h" 36#include "opt_tcpdebug.h" 37 38#include <sys/param.h> --- 423 unchanged lines hidden (view full) --- 462 INP_INFO_RUNLOCK(&tcbinfo); 463 return (EINVAL); 464 } 465 INP_LOCK(inp); 466 INP_INFO_RUNLOCK(&tcbinfo); 467 tp = intotcpcb(inp); 468 TCPDEBUG1(); 469 | 31 */ 32 33#include "opt_ipsec.h" 34#include "opt_inet.h" 35#include "opt_inet6.h" 36#include "opt_tcpdebug.h" 37 38#include <sys/param.h> --- 423 unchanged lines hidden (view full) --- 462 INP_INFO_RUNLOCK(&tcbinfo); 463 return (EINVAL); 464 } 465 INP_LOCK(inp); 466 INP_INFO_RUNLOCK(&tcbinfo); 467 tp = intotcpcb(inp); 468 TCPDEBUG1(); 469 |
470 /* | 470 /* |
471 * We inline in_setpeeraddr and COMMON_END here, so that we can 472 * copy the data of interest and defer the malloc until after we 473 * release the lock. 474 */ 475 port = inp->inp_fport; 476 addr = inp->inp_faddr; 477 478out: TCPDEBUG2(PRU_ACCEPT); --- 27 unchanged lines hidden (view full) --- 506 if (inp == 0) { 507 INP_INFO_RUNLOCK(&tcbinfo); 508 return (EINVAL); 509 } 510 INP_LOCK(inp); 511 INP_INFO_RUNLOCK(&tcbinfo); 512 tp = intotcpcb(inp); 513 TCPDEBUG1(); | 471 * We inline in_setpeeraddr and COMMON_END here, so that we can 472 * copy the data of interest and defer the malloc until after we 473 * release the lock. 474 */ 475 port = inp->inp_fport; 476 addr = inp->inp_faddr; 477 478out: TCPDEBUG2(PRU_ACCEPT); --- 27 unchanged lines hidden (view full) --- 506 if (inp == 0) { 507 INP_INFO_RUNLOCK(&tcbinfo); 508 return (EINVAL); 509 } 510 INP_LOCK(inp); 511 INP_INFO_RUNLOCK(&tcbinfo); 512 tp = intotcpcb(inp); 513 TCPDEBUG1(); |
514 /* | 514 /* |
515 * We inline in6_mapped_peeraddr and COMMON_END here, so that we can 516 * copy the data of interest and defer the malloc until after we 517 * release the lock. 518 */ 519 if (inp->inp_vflag & INP_IPV4) { 520 v4 = 1; 521 port = inp->inp_fport; 522 addr = inp->inp_faddr; --- 11 unchanged lines hidden (view full) --- 534 else 535 *nam = in6_sockaddr(port, &addr6); 536 } 537 return error; 538} 539#endif /* INET6 */ 540 541/* | 515 * We inline in6_mapped_peeraddr and COMMON_END here, so that we can 516 * copy the data of interest and defer the malloc until after we 517 * release the lock. 518 */ 519 if (inp->inp_vflag & INP_IPV4) { 520 v4 = 1; 521 port = inp->inp_fport; 522 addr = inp->inp_faddr; --- 11 unchanged lines hidden (view full) --- 534 else 535 *nam = in6_sockaddr(port, &addr6); 536 } 537 return error; 538} 539#endif /* INET6 */ 540 541/* |
542 * This is the wrapper function for in_setsockaddr. We just pass down 543 * the pcbinfo for in_setsockaddr to lock. We don't want to do the locking | 542 * This is the wrapper function for in_setsockaddr. We just pass down 543 * the pcbinfo for in_setsockaddr to lock. We don't want to do the locking |
544 * here because in_setsockaddr will call malloc and can block. 545 */ 546static int 547tcp_sockaddr(struct socket *so, struct sockaddr **nam) 548{ 549 return (in_setsockaddr(so, nam, &tcbinfo)); 550} 551 --- 45 unchanged lines hidden (view full) --- 597/* 598 * Do a send by putting data in output queue and updating urgent 599 * marker if URG set. Possibly send more data. Unlike the other 600 * pru_*() routines, the mbuf chains are our responsibility. We 601 * must either enqueue them or free them. The other pru_* routines 602 * generally are caller-frees. 603 */ 604static int | 544 * here because in_setsockaddr will call malloc and can block. 545 */ 546static int 547tcp_sockaddr(struct socket *so, struct sockaddr **nam) 548{ 549 return (in_setsockaddr(so, nam, &tcbinfo)); 550} 551 --- 45 unchanged lines hidden (view full) --- 597/* 598 * Do a send by putting data in output queue and updating urgent 599 * marker if URG set. Possibly send more data. Unlike the other 600 * pru_*() routines, the mbuf chains are our responsibility. We 601 * must either enqueue them or free them. The other pru_* routines 602 * generally are caller-frees. 603 */ 604static int |
605tcp_usr_send(struct socket *so, int flags, struct mbuf *m, | 605tcp_usr_send(struct socket *so, int flags, struct mbuf *m, |
606 struct sockaddr *nam, struct mbuf *control, struct thread *td) 607{ 608 int error = 0; 609 struct inpcb *inp; 610 struct tcpcb *tp; 611 const int inirw = INI_WRITE; 612#ifdef INET6 613 int isipv6; --- 109 unchanged lines hidden (view full) --- 723 tp->snd_wnd = TTCP_CLIENT_SND_WND; 724 tcp_mss(tp, -1); 725 } 726 tp->snd_up = tp->snd_una + so->so_snd.sb_cc; 727 tp->t_force = 1; 728 error = tcp_output(tp); 729 tp->t_force = 0; 730 } | 606 struct sockaddr *nam, struct mbuf *control, struct thread *td) 607{ 608 int error = 0; 609 struct inpcb *inp; 610 struct tcpcb *tp; 611 const int inirw = INI_WRITE; 612#ifdef INET6 613 int isipv6; --- 109 unchanged lines hidden (view full) --- 723 tp->snd_wnd = TTCP_CLIENT_SND_WND; 724 tcp_mss(tp, -1); 725 } 726 tp->snd_up = tp->snd_una + so->so_snd.sb_cc; 727 tp->t_force = 1; 728 error = tcp_output(tp); 729 tp->t_force = 0; 730 } |
731 COMMON_END((flags & PRUS_OOB) ? PRU_SENDOOB : | 731 COMMON_END((flags & PRUS_OOB) ? PRU_SENDOOB : |
732 ((flags & PRUS_EOF) ? PRU_SEND_EOF : PRU_SEND)); 733} 734 735/* 736 * Abort the TCP. 737 */ 738static int 739tcp_usr_abort(struct socket *so) --- 200 unchanged lines hidden (view full) --- 940 } 941 if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) 942 inp->in6p_laddr = *addr6; 943 inp->in6p_faddr = sin6->sin6_addr; 944 inp->inp_fport = sin6->sin6_port; 945 /* update flowinfo - draft-itojun-ipv6-flowlabel-api-00 */ 946 inp->in6p_flowinfo &= ~IPV6_FLOWLABEL_MASK; 947 if (inp->in6p_flags & IN6P_AUTOFLOWLABEL) | 732 ((flags & PRUS_EOF) ? PRU_SEND_EOF : PRU_SEND)); 733} 734 735/* 736 * Abort the TCP. 737 */ 738static int 739tcp_usr_abort(struct socket *so) --- 200 unchanged lines hidden (view full) --- 940 } 941 if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) 942 inp->in6p_laddr = *addr6; 943 inp->in6p_faddr = sin6->sin6_addr; 944 inp->inp_fport = sin6->sin6_port; 945 /* update flowinfo - draft-itojun-ipv6-flowlabel-api-00 */ 946 inp->in6p_flowinfo &= ~IPV6_FLOWLABEL_MASK; 947 if (inp->in6p_flags & IN6P_AUTOFLOWLABEL) |
948 inp->in6p_flowinfo |= | 948 inp->in6p_flowinfo |= |
949 (htonl(ip6_randomflowlabel()) & IPV6_FLOWLABEL_MASK); 950 in_pcbrehash(inp); 951 952 /* Compute window scaling to request. */ 953 while (tp->request_r_scale < TCP_MAX_WINSHIFT && 954 (TCP_MAXWIN << tp->request_r_scale) < so->so_rcv.sb_hiwat) 955 tp->request_r_scale++; 956 --- 171 unchanged lines hidden (view full) --- 1128} 1129 1130/* 1131 * tcp_sendspace and tcp_recvspace are the default send and receive window 1132 * sizes, respectively. These are obsolescent (this information should 1133 * be set by the route). 1134 */ 1135u_long tcp_sendspace = 1024*32; | 949 (htonl(ip6_randomflowlabel()) & IPV6_FLOWLABEL_MASK); 950 in_pcbrehash(inp); 951 952 /* Compute window scaling to request. */ 953 while (tp->request_r_scale < TCP_MAX_WINSHIFT && 954 (TCP_MAXWIN << tp->request_r_scale) < so->so_rcv.sb_hiwat) 955 tp->request_r_scale++; 956 --- 171 unchanged lines hidden (view full) --- 1128} 1129 1130/* 1131 * tcp_sendspace and tcp_recvspace are the default send and receive window 1132 * sizes, respectively. These are obsolescent (this information should 1133 * be set by the route). 1134 */ 1135u_long tcp_sendspace = 1024*32; |
1136SYSCTL_INT(_net_inet_tcp, TCPCTL_SENDSPACE, sendspace, CTLFLAG_RW, | 1136SYSCTL_INT(_net_inet_tcp, TCPCTL_SENDSPACE, sendspace, CTLFLAG_RW, |
1137 &tcp_sendspace , 0, "Maximum outgoing TCP datagram size"); 1138u_long tcp_recvspace = 1024*64; | 1137 &tcp_sendspace , 0, "Maximum outgoing TCP datagram size"); 1138u_long tcp_recvspace = 1024*64; |
1139SYSCTL_INT(_net_inet_tcp, TCPCTL_RECVSPACE, recvspace, CTLFLAG_RW, | 1139SYSCTL_INT(_net_inet_tcp, TCPCTL_RECVSPACE, recvspace, CTLFLAG_RW, |
1140 &tcp_recvspace , 0, "Maximum incoming TCP datagram size"); 1141 1142/* 1143 * Attach TCP protocol to socket, allocating 1144 * internet protocol control block, tcp control block, 1145 * bufer space, and entering LISTEN state if to accept connections. 1146 */ 1147static int --- 119 unchanged lines hidden --- | 1140 &tcp_recvspace , 0, "Maximum incoming TCP datagram size"); 1141 1142/* 1143 * Attach TCP protocol to socket, allocating 1144 * internet protocol control block, tcp control block, 1145 * bufer space, and entering LISTEN state if to accept connections. 1146 */ 1147static int --- 119 unchanged lines hidden --- |