tcp_subr.c (290028) | tcp_subr.c (292309) |
---|---|
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 --- 16 unchanged lines hidden (view full) --- 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 */ 31 32#include <sys/cdefs.h> | 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 --- 16 unchanged lines hidden (view full) --- 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 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/netinet/tcp_subr.c 290028 2015-10-27 00:42:15Z gnn $"); | 33__FBSDID("$FreeBSD: head/sys/netinet/tcp_subr.c 292309 2015-12-16 00:56:45Z rrs $"); |
34 35#include "opt_compat.h" 36#include "opt_inet.h" 37#include "opt_inet6.h" 38#include "opt_ipsec.h" 39#include "opt_tcpdebug.h" 40 41#include <sys/param.h> 42#include <sys/systm.h> 43#include <sys/callout.h> 44#include <sys/hhook.h> 45#include <sys/kernel.h> 46#include <sys/khelp.h> 47#include <sys/sysctl.h> 48#include <sys/jail.h> 49#include <sys/malloc.h> | 34 35#include "opt_compat.h" 36#include "opt_inet.h" 37#include "opt_inet6.h" 38#include "opt_ipsec.h" 39#include "opt_tcpdebug.h" 40 41#include <sys/param.h> 42#include <sys/systm.h> 43#include <sys/callout.h> 44#include <sys/hhook.h> 45#include <sys/kernel.h> 46#include <sys/khelp.h> 47#include <sys/sysctl.h> 48#include <sys/jail.h> 49#include <sys/malloc.h> |
50#include <sys/refcount.h> |
|
50#include <sys/mbuf.h> 51#ifdef INET6 52#include <sys/domain.h> 53#endif 54#include <sys/priv.h> 55#include <sys/proc.h> 56#include <sys/sdt.h> 57#include <sys/socket.h> --- 62 unchanged lines hidden (view full) --- 120 121#include <security/mac/mac_framework.h> 122 123VNET_DEFINE(int, tcp_mssdflt) = TCP_MSS; 124#ifdef INET6 125VNET_DEFINE(int, tcp_v6mssdflt) = TCP6_MSS; 126#endif 127 | 51#include <sys/mbuf.h> 52#ifdef INET6 53#include <sys/domain.h> 54#endif 55#include <sys/priv.h> 56#include <sys/proc.h> 57#include <sys/sdt.h> 58#include <sys/socket.h> --- 62 unchanged lines hidden (view full) --- 121 122#include <security/mac/mac_framework.h> 123 124VNET_DEFINE(int, tcp_mssdflt) = TCP_MSS; 125#ifdef INET6 126VNET_DEFINE(int, tcp_v6mssdflt) = TCP6_MSS; 127#endif 128 |
129struct rwlock tcp_function_lock; 130 |
|
128static int 129sysctl_net_inet_tcp_mss_check(SYSCTL_HANDLER_ARGS) 130{ 131 int error, new; 132 133 new = V_tcp_mssdflt; 134 error = sysctl_handle_int(oidp, &new, 0, req); 135 if (error == 0 && req->newptr) { --- 95 unchanged lines hidden (view full) --- 231 232static struct inpcb *tcp_notify(struct inpcb *, int); 233static struct inpcb *tcp_mtudisc_notify(struct inpcb *, int); 234static void tcp_mtudisc(struct inpcb *, int); 235static char * tcp_log_addr(struct in_conninfo *inc, struct tcphdr *th, 236 void *ip4hdr, const void *ip6hdr); 237static void tcp_timer_discard(struct tcpcb *, uint32_t); 238 | 131static int 132sysctl_net_inet_tcp_mss_check(SYSCTL_HANDLER_ARGS) 133{ 134 int error, new; 135 136 new = V_tcp_mssdflt; 137 error = sysctl_handle_int(oidp, &new, 0, req); 138 if (error == 0 && req->newptr) { --- 95 unchanged lines hidden (view full) --- 234 235static struct inpcb *tcp_notify(struct inpcb *, int); 236static struct inpcb *tcp_mtudisc_notify(struct inpcb *, int); 237static void tcp_mtudisc(struct inpcb *, int); 238static char * tcp_log_addr(struct in_conninfo *inc, struct tcphdr *th, 239 void *ip4hdr, const void *ip6hdr); 240static void tcp_timer_discard(struct tcpcb *, uint32_t); 241 |
242 243static struct tcp_function_block tcp_def_funcblk = { 244 "default", 245 tcp_output, 246 tcp_do_segment, 247 tcp_default_ctloutput, 248 NULL, 249 NULL, 250 NULL, 251 NULL, 252 NULL, 253 NULL, 254 NULL, 255 0, 256 0 257}; 258 259struct tcp_funchead t_functions; 260static struct tcp_function_block *tcp_func_set_ptr = &tcp_def_funcblk; 261 262static struct tcp_function_block * 263find_tcp_functions_locked(struct tcp_function_set *fs) 264{ 265 struct tcp_function *f; 266 struct tcp_function_block *blk=NULL; 267 268 TAILQ_FOREACH(f, &t_functions, tf_next) { 269 if (strcmp(f->tf_fb->tfb_tcp_block_name, fs->function_set_name) == 0) { 270 blk = f->tf_fb; 271 break; 272 } 273 } 274 return(blk); 275} 276 277static struct tcp_function_block * 278find_tcp_fb_locked(struct tcp_function_block *blk, struct tcp_function **s) 279{ 280 struct tcp_function_block *rblk=NULL; 281 struct tcp_function *f; 282 283 TAILQ_FOREACH(f, &t_functions, tf_next) { 284 if (f->tf_fb == blk) { 285 rblk = blk; 286 if (s) { 287 *s = f; 288 } 289 break; 290 } 291 } 292 return (rblk); 293} 294 295struct tcp_function_block * 296find_and_ref_tcp_functions(struct tcp_function_set *fs) 297{ 298 struct tcp_function_block *blk; 299 300 rw_rlock(&tcp_function_lock); 301 blk = find_tcp_functions_locked(fs); 302 if (blk) 303 refcount_acquire(&blk->tfb_refcnt); 304 rw_runlock(&tcp_function_lock); 305 return(blk); 306} 307 308struct tcp_function_block * 309find_and_ref_tcp_fb(struct tcp_function_block *blk) 310{ 311 struct tcp_function_block *rblk; 312 313 rw_rlock(&tcp_function_lock); 314 rblk = find_tcp_fb_locked(blk, NULL); 315 if (rblk) 316 refcount_acquire(&rblk->tfb_refcnt); 317 rw_runlock(&tcp_function_lock); 318 return(rblk); 319} 320 321 322static int 323sysctl_net_inet_default_tcp_functions(SYSCTL_HANDLER_ARGS) 324{ 325 int error=ENOENT; 326 struct tcp_function_set fs; 327 struct tcp_function_block *blk; 328 329 memset(&fs, 0, sizeof(fs)); 330 rw_rlock(&tcp_function_lock); 331 blk = find_tcp_fb_locked(tcp_func_set_ptr, NULL); 332 if (blk) { 333 /* Found him */ 334 strcpy(fs.function_set_name, blk->tfb_tcp_block_name); 335 fs.pcbcnt = blk->tfb_refcnt; 336 } 337 rw_runlock(&tcp_function_lock); 338 error = sysctl_handle_string(oidp, fs.function_set_name, 339 sizeof(fs.function_set_name), req); 340 341 /* Check for error or no change */ 342 if (error != 0 || req->newptr == NULL) 343 return(error); 344 345 rw_wlock(&tcp_function_lock); 346 blk = find_tcp_functions_locked(&fs); 347 if ((blk == NULL) || 348 (blk->tfb_flags & TCP_FUNC_BEING_REMOVED)) { 349 error = ENOENT; 350 goto done; 351 } 352 tcp_func_set_ptr = blk; 353done: 354 rw_wunlock(&tcp_function_lock); 355 return (error); 356} 357 358SYSCTL_PROC(_net_inet_tcp, OID_AUTO, functions_default, 359 CTLTYPE_STRING | CTLFLAG_RW, 360 NULL, 0, sysctl_net_inet_default_tcp_functions, "A", 361 "Set/get the default TCP functions"); 362 363static int 364sysctl_net_inet_list_available(SYSCTL_HANDLER_ARGS) 365{ 366 int error, cnt, linesz; 367 struct tcp_function *f; 368 char *buffer, *cp; 369 size_t bufsz, outsz; 370 371 cnt = 0; 372 rw_rlock(&tcp_function_lock); 373 TAILQ_FOREACH(f, &t_functions, tf_next) { 374 cnt++; 375 } 376 rw_runlock(&tcp_function_lock); 377 378 bufsz = (cnt+2) * (TCP_FUNCTION_NAME_LEN_MAX + 12) + 1; 379 buffer = malloc(bufsz, M_TEMP, M_WAITOK); 380 381 error = 0; 382 cp = buffer; 383 384 linesz = snprintf(cp, bufsz, "\n%-32s%c %s\n", "Stack", 'D', "PCB count"); 385 cp += linesz; 386 bufsz -= linesz; 387 outsz = linesz; 388 389 rw_rlock(&tcp_function_lock); 390 TAILQ_FOREACH(f, &t_functions, tf_next) { 391 linesz = snprintf(cp, bufsz, "%-32s%c %u\n", 392 f->tf_fb->tfb_tcp_block_name, 393 (f->tf_fb == tcp_func_set_ptr) ? '*' : ' ', 394 f->tf_fb->tfb_refcnt); 395 if (linesz >= bufsz) { 396 error = EOVERFLOW; 397 break; 398 } 399 cp += linesz; 400 bufsz -= linesz; 401 outsz += linesz; 402 } 403 rw_runlock(&tcp_function_lock); 404 if (error == 0) 405 error = sysctl_handle_string(oidp, buffer, outsz + 1, req); 406 free(buffer, M_TEMP); 407 return (error); 408} 409 410SYSCTL_PROC(_net_inet_tcp, OID_AUTO, functions_available, 411 CTLTYPE_STRING|CTLFLAG_RD, 412 NULL, 0, sysctl_net_inet_list_available, "A", 413 "list available TCP Function sets"); 414 |
|
239/* 240 * Target size of TCP PCB hash tables. Must be a power of two. 241 * 242 * Note that this can be overridden by the kernel environment 243 * variable net.inet.tcp.tcbhashsize 244 */ 245#ifndef TCBHASHSIZE 246#define TCBHASHSIZE 0 --- 11 unchanged lines hidden (view full) --- 258 struct cc_var ccv; 259 struct osd osd; 260}; 261 262static VNET_DEFINE(uma_zone_t, tcpcb_zone); 263#define V_tcpcb_zone VNET(tcpcb_zone) 264 265MALLOC_DEFINE(M_TCPLOG, "tcplog", "TCP address and flags print buffers"); | 415/* 416 * Target size of TCP PCB hash tables. Must be a power of two. 417 * 418 * Note that this can be overridden by the kernel environment 419 * variable net.inet.tcp.tcbhashsize 420 */ 421#ifndef TCBHASHSIZE 422#define TCBHASHSIZE 0 --- 11 unchanged lines hidden (view full) --- 434 struct cc_var ccv; 435 struct osd osd; 436}; 437 438static VNET_DEFINE(uma_zone_t, tcpcb_zone); 439#define V_tcpcb_zone VNET(tcpcb_zone) 440 441MALLOC_DEFINE(M_TCPLOG, "tcplog", "TCP address and flags print buffers"); |
442MALLOC_DEFINE(M_TCPFUNCTIONS, "tcpfunc", "TCP function set memory"); 443 |
|
266static struct mtx isn_mtx; 267 268#define ISN_LOCK_INIT() mtx_init(&isn_mtx, "isn_mtx", NULL, MTX_DEF) 269#define ISN_LOCK() mtx_lock(&isn_mtx) 270#define ISN_UNLOCK() mtx_unlock(&isn_mtx) 271 272/* 273 * TCP initialization. --- 32 unchanged lines hidden (view full) --- 306 hashsize = 1 << fls(size); 307 /* catch overflow, and just go one power of 2 smaller */ 308 if (hashsize < size) { 309 hashsize = 1 << (fls(size) - 1); 310 } 311 return (hashsize); 312} 313 | 444static struct mtx isn_mtx; 445 446#define ISN_LOCK_INIT() mtx_init(&isn_mtx, "isn_mtx", NULL, MTX_DEF) 447#define ISN_LOCK() mtx_lock(&isn_mtx) 448#define ISN_UNLOCK() mtx_unlock(&isn_mtx) 449 450/* 451 * TCP initialization. --- 32 unchanged lines hidden (view full) --- 484 hashsize = 1 << fls(size); 485 /* catch overflow, and just go one power of 2 smaller */ 486 if (hashsize < size) { 487 hashsize = 1 << (fls(size) - 1); 488 } 489 return (hashsize); 490} 491 |
492int 493register_tcp_functions(struct tcp_function_block *blk, int wait) 494{ 495 struct tcp_function_block *lblk; 496 struct tcp_function *n; 497 struct tcp_function_set fs; 498 499 if ((blk->tfb_tcp_output == NULL) || 500 (blk->tfb_tcp_do_segment == NULL) || 501 (blk->tfb_tcp_ctloutput == NULL) || 502 (strlen(blk->tfb_tcp_block_name) == 0)) { 503 /* 504 * These functions are required and you 505 * need a name. 506 */ 507 return (EINVAL); 508 } 509 if (blk->tfb_tcp_timer_stop_all || 510 blk->tfb_tcp_timers_left || 511 blk->tfb_tcp_timer_activate || 512 blk->tfb_tcp_timer_active || 513 blk->tfb_tcp_timer_stop) { 514 /* 515 * If you define one timer function you 516 * must have them all. 517 */ 518 if ((blk->tfb_tcp_timer_stop_all == NULL) || 519 (blk->tfb_tcp_timers_left == NULL) || 520 (blk->tfb_tcp_timer_activate == NULL) || 521 (blk->tfb_tcp_timer_active == NULL) || 522 (blk->tfb_tcp_timer_stop == NULL)) { 523 return (EINVAL); 524 } 525 } 526 n = malloc(sizeof(struct tcp_function), M_TCPFUNCTIONS, wait); 527 if (n == NULL) { 528 return (ENOMEM); 529 } 530 n->tf_fb = blk; 531 strcpy(fs.function_set_name, blk->tfb_tcp_block_name); 532 rw_wlock(&tcp_function_lock); 533 lblk = find_tcp_functions_locked(&fs); 534 if (lblk) { 535 /* Duplicate name space not allowed */ 536 rw_wunlock(&tcp_function_lock); 537 free(n, M_TCPFUNCTIONS); 538 return (EALREADY); 539 } 540 refcount_init(&blk->tfb_refcnt, 0); 541 blk->tfb_flags = 0; 542 TAILQ_INSERT_TAIL(&t_functions, n, tf_next); 543 rw_wunlock(&tcp_function_lock); 544 return(0); 545} 546 547int 548deregister_tcp_functions(struct tcp_function_block *blk) 549{ 550 struct tcp_function_block *lblk; 551 struct tcp_function *f; 552 int error=ENOENT; 553 554 if (strcmp(blk->tfb_tcp_block_name, "default") == 0) { 555 /* You can't un-register the default */ 556 return (EPERM); 557 } 558 rw_wlock(&tcp_function_lock); 559 if (blk == tcp_func_set_ptr) { 560 /* You can't free the current default */ 561 rw_wunlock(&tcp_function_lock); 562 return (EBUSY); 563 } 564 if (blk->tfb_refcnt) { 565 /* Still tcb attached, mark it. */ 566 blk->tfb_flags |= TCP_FUNC_BEING_REMOVED; 567 rw_wunlock(&tcp_function_lock); 568 return (EBUSY); 569 } 570 lblk = find_tcp_fb_locked(blk, &f); 571 if (lblk) { 572 /* Found */ 573 TAILQ_REMOVE(&t_functions, f, tf_next); 574 f->tf_fb = NULL; 575 free(f, M_TCPFUNCTIONS); 576 error = 0; 577 } 578 rw_wunlock(&tcp_function_lock); 579 return (error); 580} 581 |
|
314void 315tcp_init(void) 316{ 317 const char *tcbhash_tuneable; 318 int hashsize; 319 320 tcbhash_tuneable = "net.inet.tcp.tcbhashsize"; 321 322 if (hhook_head_register(HHOOK_TYPE_TCP, HHOOK_TCP_EST_IN, 323 &V_tcp_hhh[HHOOK_TCP_EST_IN], HHOOK_NOWAIT|HHOOK_HEADISINVNET) != 0) 324 printf("%s: WARNING: unable to register helper hook\n", __func__); 325 if (hhook_head_register(HHOOK_TYPE_TCP, HHOOK_TCP_EST_OUT, 326 &V_tcp_hhh[HHOOK_TCP_EST_OUT], HHOOK_NOWAIT|HHOOK_HEADISINVNET) != 0) 327 printf("%s: WARNING: unable to register helper hook\n", __func__); | 582void 583tcp_init(void) 584{ 585 const char *tcbhash_tuneable; 586 int hashsize; 587 588 tcbhash_tuneable = "net.inet.tcp.tcbhashsize"; 589 590 if (hhook_head_register(HHOOK_TYPE_TCP, HHOOK_TCP_EST_IN, 591 &V_tcp_hhh[HHOOK_TCP_EST_IN], HHOOK_NOWAIT|HHOOK_HEADISINVNET) != 0) 592 printf("%s: WARNING: unable to register helper hook\n", __func__); 593 if (hhook_head_register(HHOOK_TYPE_TCP, HHOOK_TCP_EST_OUT, 594 &V_tcp_hhh[HHOOK_TCP_EST_OUT], HHOOK_NOWAIT|HHOOK_HEADISINVNET) != 0) 595 printf("%s: WARNING: unable to register helper hook\n", __func__); |
328 | 596 /* Setup the tcp function block list */ 597 TAILQ_INIT(&t_functions); 598 rw_init_flags(&tcp_function_lock, "tcp_func_lock" , 0); 599 register_tcp_functions(&tcp_def_funcblk, M_WAITOK); |
329 hashsize = TCBHASHSIZE; 330 TUNABLE_INT_FETCH(tcbhash_tuneable, &hashsize); 331 if (hashsize == 0) { 332 /* 333 * Auto tune the hash size based on maxsockets. 334 * A perfect hash would have a 1:1 mapping 335 * (hashsize = maxsockets) however it's been 336 * suggested that O(2) average is better. --- 426 unchanged lines hidden (view full) --- 763 if (tm == NULL) 764 return (NULL); 765 tp = &tm->tcb; 766 767 /* Initialise cc_var struct for this tcpcb. */ 768 tp->ccv = &tm->ccv; 769 tp->ccv->type = IPPROTO_TCP; 770 tp->ccv->ccvc.tcp = tp; | 600 hashsize = TCBHASHSIZE; 601 TUNABLE_INT_FETCH(tcbhash_tuneable, &hashsize); 602 if (hashsize == 0) { 603 /* 604 * Auto tune the hash size based on maxsockets. 605 * A perfect hash would have a 1:1 mapping 606 * (hashsize = maxsockets) however it's been 607 * suggested that O(2) average is better. --- 426 unchanged lines hidden (view full) --- 1034 if (tm == NULL) 1035 return (NULL); 1036 tp = &tm->tcb; 1037 1038 /* Initialise cc_var struct for this tcpcb. */ 1039 tp->ccv = &tm->ccv; 1040 tp->ccv->type = IPPROTO_TCP; 1041 tp->ccv->ccvc.tcp = tp; |
771 | 1042 rw_rlock(&tcp_function_lock); 1043 tp->t_fb = tcp_func_set_ptr; 1044 refcount_acquire(&tp->t_fb->tfb_refcnt); 1045 rw_runlock(&tcp_function_lock); 1046 if (tp->t_fb->tfb_tcp_fb_init) { 1047 (*tp->t_fb->tfb_tcp_fb_init)(tp); 1048 } |
772 /* 773 * Use the current system default CC algorithm. 774 */ 775 CC_LIST_RLOCK(); 776 KASSERT(!STAILQ_EMPTY(&cc_list), ("cc_list is empty!")); 777 CC_ALGO(tp) = CC_DEFAULT(); 778 CC_LIST_RUNLOCK(); 779 780 if (CC_ALGO(tp)->cb_init != NULL) 781 if (CC_ALGO(tp)->cb_init(tp->ccv) > 0) { | 1049 /* 1050 * Use the current system default CC algorithm. 1051 */ 1052 CC_LIST_RLOCK(); 1053 KASSERT(!STAILQ_EMPTY(&cc_list), ("cc_list is empty!")); 1054 CC_ALGO(tp) = CC_DEFAULT(); 1055 CC_LIST_RUNLOCK(); 1056 1057 if (CC_ALGO(tp)->cb_init != NULL) 1058 if (CC_ALGO(tp)->cb_init(tp->ccv) > 0) { |
1059 if (tp->t_fb->tfb_tcp_fb_fini) 1060 (*tp->t_fb->tfb_tcp_fb_fini)(tp); 1061 refcount_release(&tp->t_fb->tfb_refcnt); |
|
782 uma_zfree(V_tcpcb_zone, tm); 783 return (NULL); 784 } 785 786 tp->osd = &tm->osd; 787 if (khelp_init_osd(HELPER_CLASS_TCP, tp->osd)) { | 1062 uma_zfree(V_tcpcb_zone, tm); 1063 return (NULL); 1064 } 1065 1066 tp->osd = &tm->osd; 1067 if (khelp_init_osd(HELPER_CLASS_TCP, tp->osd)) { |
1068 if (tp->t_fb->tfb_tcp_fb_fini) 1069 (*tp->t_fb->tfb_tcp_fb_fini)(tp); 1070 refcount_release(&tp->t_fb->tfb_refcnt); |
|
788 uma_zfree(V_tcpcb_zone, tm); 789 return (NULL); 790 } 791 792#ifdef VIMAGE 793 tp->t_vnet = inp->inp_vnet; 794#endif 795 tp->t_timers = &tm->tt; --- 124 unchanged lines hidden (view full) --- 920{ 921 struct socket *so = tp->t_inpcb->inp_socket; 922 923 INP_INFO_LOCK_ASSERT(&V_tcbinfo); 924 INP_WLOCK_ASSERT(tp->t_inpcb); 925 926 if (TCPS_HAVERCVDSYN(tp->t_state)) { 927 tcp_state_change(tp, TCPS_CLOSED); | 1071 uma_zfree(V_tcpcb_zone, tm); 1072 return (NULL); 1073 } 1074 1075#ifdef VIMAGE 1076 tp->t_vnet = inp->inp_vnet; 1077#endif 1078 tp->t_timers = &tm->tt; --- 124 unchanged lines hidden (view full) --- 1203{ 1204 struct socket *so = tp->t_inpcb->inp_socket; 1205 1206 INP_INFO_LOCK_ASSERT(&V_tcbinfo); 1207 INP_WLOCK_ASSERT(tp->t_inpcb); 1208 1209 if (TCPS_HAVERCVDSYN(tp->t_state)) { 1210 tcp_state_change(tp, TCPS_CLOSED); |
928 (void) tcp_output(tp); | 1211 (void) tp->t_fb->tfb_tcp_output(tp); |
929 TCPSTAT_INC(tcps_drops); 930 } else 931 TCPSTAT_INC(tcps_conndrops); 932 if (errno == ETIMEDOUT && tp->t_softerror) 933 errno = tp->t_softerror; 934 so->so_error = errno; 935 return (tcp_close(tp)); 936} --- 18 unchanged lines hidden (view full) --- 955 * callout, and the last discard function called will take care of 956 * deleting the tcpcb. 957 */ 958 tcp_timer_stop(tp, TT_REXMT); 959 tcp_timer_stop(tp, TT_PERSIST); 960 tcp_timer_stop(tp, TT_KEEP); 961 tcp_timer_stop(tp, TT_2MSL); 962 tcp_timer_stop(tp, TT_DELACK); | 1212 TCPSTAT_INC(tcps_drops); 1213 } else 1214 TCPSTAT_INC(tcps_conndrops); 1215 if (errno == ETIMEDOUT && tp->t_softerror) 1216 errno = tp->t_softerror; 1217 so->so_error = errno; 1218 return (tcp_close(tp)); 1219} --- 18 unchanged lines hidden (view full) --- 1238 * callout, and the last discard function called will take care of 1239 * deleting the tcpcb. 1240 */ 1241 tcp_timer_stop(tp, TT_REXMT); 1242 tcp_timer_stop(tp, TT_PERSIST); 1243 tcp_timer_stop(tp, TT_KEEP); 1244 tcp_timer_stop(tp, TT_2MSL); 1245 tcp_timer_stop(tp, TT_DELACK); |
1246 if (tp->t_fb->tfb_tcp_timer_stop_all) { 1247 /* Call the stop-all function of the methods */ 1248 tp->t_fb->tfb_tcp_timer_stop_all(tp); 1249 } |
|
963 964 /* 965 * If we got enough samples through the srtt filter, 966 * save the rtt and rttvar in the routing entry. 967 * 'Enough' is arbitrarily defined as 4 rtt samples. 968 * 4 samples is enough for the srtt filter to converge 969 * to within enough % of the correct value; fewer samples 970 * and we could save a bogus rtt. The danger is not high --- 68 unchanged lines hidden (view full) --- 1039 CC_ALGO(tp)->cb_destroy(tp->ccv); 1040 1041 khelp_destroy_osd(tp->osd); 1042 1043 CC_ALGO(tp) = NULL; 1044 inp->inp_ppcb = NULL; 1045 if ((tp->t_timers->tt_flags & TT_MASK) == 0) { 1046 /* We own the last reference on tcpcb, let's free it. */ | 1250 1251 /* 1252 * If we got enough samples through the srtt filter, 1253 * save the rtt and rttvar in the routing entry. 1254 * 'Enough' is arbitrarily defined as 4 rtt samples. 1255 * 4 samples is enough for the srtt filter to converge 1256 * to within enough % of the correct value; fewer samples 1257 * and we could save a bogus rtt. The danger is not high --- 68 unchanged lines hidden (view full) --- 1326 CC_ALGO(tp)->cb_destroy(tp->ccv); 1327 1328 khelp_destroy_osd(tp->osd); 1329 1330 CC_ALGO(tp) = NULL; 1331 inp->inp_ppcb = NULL; 1332 if ((tp->t_timers->tt_flags & TT_MASK) == 0) { 1333 /* We own the last reference on tcpcb, let's free it. */ |
1334 if ((tp->t_fb->tfb_tcp_timers_left) && 1335 (tp->t_fb->tfb_tcp_timers_left(tp))) { 1336 /* Some fb timers left running! */ 1337 return; 1338 } 1339 if (tp->t_fb->tfb_tcp_fb_fini) 1340 (*tp->t_fb->tfb_tcp_fb_fini)(tp); 1341 refcount_release(&tp->t_fb->tfb_refcnt); |
|
1047 tp->t_inpcb = NULL; 1048 uma_zfree(V_tcpcb_zone, tp); 1049 released = in_pcbrele_wlocked(inp); 1050 KASSERT(!released, ("%s: inp %p should not have been released " 1051 "here", __func__, inp)); 1052 } 1053} 1054 --- 45 unchanged lines hidden (view full) --- 1100 INP_WLOCK(inp); 1101 KASSERT((tp->t_timers->tt_flags & TT_STOPPED) != 0, 1102 ("%s: tcpcb has to be stopped here", __func__)); 1103 KASSERT((tp->t_timers->tt_flags & timer_type) != 0, 1104 ("%s: discard callout should be running", __func__)); 1105 tp->t_timers->tt_flags &= ~timer_type; 1106 if ((tp->t_timers->tt_flags & TT_MASK) == 0) { 1107 /* We own the last reference on this tcpcb, let's free it. */ | 1342 tp->t_inpcb = NULL; 1343 uma_zfree(V_tcpcb_zone, tp); 1344 released = in_pcbrele_wlocked(inp); 1345 KASSERT(!released, ("%s: inp %p should not have been released " 1346 "here", __func__, inp)); 1347 } 1348} 1349 --- 45 unchanged lines hidden (view full) --- 1395 INP_WLOCK(inp); 1396 KASSERT((tp->t_timers->tt_flags & TT_STOPPED) != 0, 1397 ("%s: tcpcb has to be stopped here", __func__)); 1398 KASSERT((tp->t_timers->tt_flags & timer_type) != 0, 1399 ("%s: discard callout should be running", __func__)); 1400 tp->t_timers->tt_flags &= ~timer_type; 1401 if ((tp->t_timers->tt_flags & TT_MASK) == 0) { 1402 /* We own the last reference on this tcpcb, let's free it. */ |
1403 if ((tp->t_fb->tfb_tcp_timers_left) && 1404 (tp->t_fb->tfb_tcp_timers_left(tp))) { 1405 /* Some fb timers left running! */ 1406 goto leave; 1407 } 1408 if (tp->t_fb->tfb_tcp_fb_fini) 1409 (*tp->t_fb->tfb_tcp_fb_fini)(tp); 1410 refcount_release(&tp->t_fb->tfb_refcnt); |
|
1108 tp->t_inpcb = NULL; 1109 uma_zfree(V_tcpcb_zone, tp); 1110 if (in_pcbrele_wlocked(inp)) { 1111 INP_INFO_RUNLOCK(&V_tcbinfo); 1112 CURVNET_RESTORE(); 1113 return; 1114 } 1115 } | 1411 tp->t_inpcb = NULL; 1412 uma_zfree(V_tcpcb_zone, tp); 1413 if (in_pcbrele_wlocked(inp)) { 1414 INP_INFO_RUNLOCK(&V_tcbinfo); 1415 CURVNET_RESTORE(); 1416 return; 1417 } 1418 } |
1419leave: |
|
1116 INP_WUNLOCK(inp); 1117 INP_INFO_RUNLOCK(&V_tcbinfo); 1118 CURVNET_RESTORE(); 1119} 1120 1121/* 1122 * Attempt to close a TCP control block, marking it as dropped, and freeing 1123 * the socket if we hold the only reference. --- 736 unchanged lines hidden (view full) --- 1860 1861 TCPSTAT_INC(tcps_mturesent); 1862 tp->t_rtttime = 0; 1863 tp->snd_nxt = tp->snd_una; 1864 tcp_free_sackholes(tp); 1865 tp->snd_recover = tp->snd_max; 1866 if (tp->t_flags & TF_SACK_PERMIT) 1867 EXIT_FASTRECOVERY(tp->t_flags); | 1420 INP_WUNLOCK(inp); 1421 INP_INFO_RUNLOCK(&V_tcbinfo); 1422 CURVNET_RESTORE(); 1423} 1424 1425/* 1426 * Attempt to close a TCP control block, marking it as dropped, and freeing 1427 * the socket if we hold the only reference. --- 736 unchanged lines hidden (view full) --- 2164 2165 TCPSTAT_INC(tcps_mturesent); 2166 tp->t_rtttime = 0; 2167 tp->snd_nxt = tp->snd_una; 2168 tcp_free_sackholes(tp); 2169 tp->snd_recover = tp->snd_max; 2170 if (tp->t_flags & TF_SACK_PERMIT) 2171 EXIT_FASTRECOVERY(tp->t_flags); |
1868 tcp_output(tp); | 2172 tp->t_fb->tfb_tcp_output(tp); |
1869} 1870 1871#ifdef INET 1872/* 1873 * Look-up the routing entry to the peer of this inpcb. If no route 1874 * is found and it cannot be allocated, then return 0. This routine 1875 * is called by TCP routines that access the rmx structure and by 1876 * tcp_mss_update to get the peer/interface MTU. --- 666 unchanged lines hidden --- | 2173} 2174 2175#ifdef INET 2176/* 2177 * Look-up the routing entry to the peer of this inpcb. If no route 2178 * is found and it cannot be allocated, then return 0. This routine 2179 * is called by TCP routines that access the rmx structure and by 2180 * tcp_mss_update to get the peer/interface MTU. --- 666 unchanged lines hidden --- |