tcp_subr.c (168845) | tcp_subr.c (169154) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 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 --- 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 * @(#)tcp_subr.c 8.2 (Berkeley) 5/24/95 | 1/*- 2 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 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 --- 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 * @(#)tcp_subr.c 8.2 (Berkeley) 5/24/95 |
30 * $FreeBSD: head/sys/netinet/tcp_subr.c 168845 2007-04-18 18:14:39Z andre $ | 30 * $FreeBSD: head/sys/netinet/tcp_subr.c 169154 2007-04-30 23:12:05Z rwatson $ |
31 */ 32 33#include "opt_compat.h" 34#include "opt_inet.h" 35#include "opt_inet6.h" 36#include "opt_ipsec.h" 37#include "opt_mac.h" 38#include "opt_tcpdebug.h" --- 271 unchanged lines hidden (view full) --- 310 tcp_msl = TCPTV_MSL; 311 tcp_rexmit_min = TCPTV_MIN; 312 tcp_rexmit_slop = TCPTV_CPU_VAR; 313 tcp_inflight_rttthresh = TCPTV_INFLIGHT_RTTTHRESH; 314 tcp_finwait2_timeout = TCPTV_FINWAIT2_TIMEOUT; 315 316 INP_INFO_LOCK_INIT(&tcbinfo, "tcp"); 317 LIST_INIT(&tcb); | 31 */ 32 33#include "opt_compat.h" 34#include "opt_inet.h" 35#include "opt_inet6.h" 36#include "opt_ipsec.h" 37#include "opt_mac.h" 38#include "opt_tcpdebug.h" --- 271 unchanged lines hidden (view full) --- 310 tcp_msl = TCPTV_MSL; 311 tcp_rexmit_min = TCPTV_MIN; 312 tcp_rexmit_slop = TCPTV_CPU_VAR; 313 tcp_inflight_rttthresh = TCPTV_INFLIGHT_RTTTHRESH; 314 tcp_finwait2_timeout = TCPTV_FINWAIT2_TIMEOUT; 315 316 INP_INFO_LOCK_INIT(&tcbinfo, "tcp"); 317 LIST_INIT(&tcb); |
318 tcbinfo.listhead = &tcb; | 318 tcbinfo.ipi_listhead = &tcb; |
319 TUNABLE_INT_FETCH("net.inet.tcp.tcbhashsize", &hashsize); 320 if (!powerof2(hashsize)) { 321 printf("WARNING: TCB hash size not a power of 2\n"); 322 hashsize = 512; /* safe default */ 323 } 324 tcp_tcbhashsize = hashsize; | 319 TUNABLE_INT_FETCH("net.inet.tcp.tcbhashsize", &hashsize); 320 if (!powerof2(hashsize)) { 321 printf("WARNING: TCB hash size not a power of 2\n"); 322 hashsize = 512; /* safe default */ 323 } 324 tcp_tcbhashsize = hashsize; |
325 tcbinfo.hashbase = hashinit(hashsize, M_PCB, &tcbinfo.hashmask); 326 tcbinfo.porthashbase = hashinit(hashsize, M_PCB, 327 &tcbinfo.porthashmask); | 325 tcbinfo.ipi_hashbase = hashinit(hashsize, M_PCB, 326 &tcbinfo.ipi_hashmask); 327 tcbinfo.ipi_porthashbase = hashinit(hashsize, M_PCB, 328 &tcbinfo.ipi_porthashmask); |
328 tcbinfo.ipi_zone = uma_zcreate("inpcb", sizeof(struct inpcb), 329 NULL, NULL, tcp_inpcb_init, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); 330 uma_zone_set_max(tcbinfo.ipi_zone, maxsockets); 331#ifdef INET6 332#define TCP_MINPROTOHDR (sizeof(struct ip6_hdr) + sizeof(struct tcphdr)) 333#else /* INET6 */ 334#define TCP_MINPROTOHDR (sizeof(struct tcpiphdr)) 335#endif /* INET6 */ --- 515 unchanged lines hidden (view full) --- 851 * Walk the tcpbs, if existing, and flush the reassembly queue, 852 * if there is one... 853 * XXX: The "Net/3" implementation doesn't imply that the TCP 854 * reassembly queue should be flushed, but in a situation 855 * where we're really low on mbufs, this is potentially 856 * usefull. 857 */ 858 INP_INFO_RLOCK(&tcbinfo); | 329 tcbinfo.ipi_zone = uma_zcreate("inpcb", sizeof(struct inpcb), 330 NULL, NULL, tcp_inpcb_init, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); 331 uma_zone_set_max(tcbinfo.ipi_zone, maxsockets); 332#ifdef INET6 333#define TCP_MINPROTOHDR (sizeof(struct ip6_hdr) + sizeof(struct tcphdr)) 334#else /* INET6 */ 335#define TCP_MINPROTOHDR (sizeof(struct tcpiphdr)) 336#endif /* INET6 */ --- 515 unchanged lines hidden (view full) --- 852 * Walk the tcpbs, if existing, and flush the reassembly queue, 853 * if there is one... 854 * XXX: The "Net/3" implementation doesn't imply that the TCP 855 * reassembly queue should be flushed, but in a situation 856 * where we're really low on mbufs, this is potentially 857 * usefull. 858 */ 859 INP_INFO_RLOCK(&tcbinfo); |
859 LIST_FOREACH(inpb, tcbinfo.listhead, inp_list) { | 860 LIST_FOREACH(inpb, tcbinfo.ipi_listhead, inp_list) { |
860 if (inpb->inp_vflag & INP_TIMEWAIT) 861 continue; 862 INP_LOCK(inpb); 863 if ((tcpb = intotcpcb(inpb)) != NULL) { 864 while ((te = LIST_FIRST(&tcpb->t_segq)) 865 != NULL) { 866 LIST_REMOVE(te, tqe_q); 867 m_freem(te->tqe_m); --- 104 unchanged lines hidden (view full) --- 972 if (error) 973 return (error); 974 975 inp_list = malloc(n * sizeof *inp_list, M_TEMP, M_WAITOK); 976 if (inp_list == NULL) 977 return (ENOMEM); 978 979 INP_INFO_RLOCK(&tcbinfo); | 861 if (inpb->inp_vflag & INP_TIMEWAIT) 862 continue; 863 INP_LOCK(inpb); 864 if ((tcpb = intotcpcb(inpb)) != NULL) { 865 while ((te = LIST_FIRST(&tcpb->t_segq)) 866 != NULL) { 867 LIST_REMOVE(te, tqe_q); 868 m_freem(te->tqe_m); --- 104 unchanged lines hidden (view full) --- 973 if (error) 974 return (error); 975 976 inp_list = malloc(n * sizeof *inp_list, M_TEMP, M_WAITOK); 977 if (inp_list == NULL) 978 return (ENOMEM); 979 980 INP_INFO_RLOCK(&tcbinfo); |
980 for (inp = LIST_FIRST(tcbinfo.listhead), i = 0; inp != NULL && i < n; 981 inp = LIST_NEXT(inp, inp_list)) { | 981 for (inp = LIST_FIRST(tcbinfo.ipi_listhead), i = 0; inp != NULL && i 982 < n; inp = LIST_NEXT(inp, inp_list)) { |
982 INP_LOCK(inp); 983 if (inp->inp_gencnt <= gencnt) { 984 /* 985 * XXX: This use of cr_cansee(), introduced with 986 * TCP state changes, is not quite right, but for 987 * now, better than nothing. 988 */ 989 if (inp->inp_vflag & INP_TIMEWAIT) { --- 1417 unchanged lines hidden --- | 983 INP_LOCK(inp); 984 if (inp->inp_gencnt <= gencnt) { 985 /* 986 * XXX: This use of cr_cansee(), introduced with 987 * TCP state changes, is not quite right, but for 988 * now, better than nothing. 989 */ 990 if (inp->inp_vflag & INP_TIMEWAIT) { --- 1417 unchanged lines hidden --- |