Home | History | Annotate | Download | only in netinet

Lines Matching defs:vtw

32  * methods called Vestigial Time-Wait (VTW) and Maximum Segment Lifetime
35 * MSLT and VTW were contributed by Coyote Point Systems, Inc.
54 * Vestigial Time-Wait (VTW) replaces a TIME_WAIT session's PCB/socket
56 * "vestigial PCB". VTW data structures are designed to be very fast and
64 * runs out, VTW makes room by discarding old vestigial PCBs, oldest first.
65 * VTW cooperates with MSLT.
67 * It may help to think of VTW as a "FIN cache" by analogy to the SYN
71 * sessions as fast as it can is approximately 17% idle when VTW is active
72 * versus 0% idle when VTW is inactive. It has 103 megabytes more free RAM
73 * when VTW is active (approximately 64k vestigial PCBs are created) than
377 vtw_age(fat->vtw, 0);
401 fp->tag[i] = tag ^ idx_encode(fat->vtw, idx) ^ fatp_xtra[i];
412 vtw_alive(const vtw_t *vtw)
414 return vtw->hashed && vtw->expire.tv_sec;
423 KASSERT(0 && "vtw out of bounds");
434 KASSERT(0 && "vtw out of bounds");
440 vtw_index(vtw_ctl_t *ctl, vtw_t *vtw)
446 return vtw_index_v4(ctl, (vtw_v4_t *)vtw);
449 return vtw_index_v6(ctl, (vtw_v6_t *)vtw);
470 vtw_v4_t *vtw = ctl->base.v4 + idx;
472 return (ctl->base.v4 <= vtw && vtw <= ctl->lim.v4)
473 ? &vtw->common : 0;
475 vtw_v6_t *vtw = ctl->base.v6 + idx;
477 return (ctl->base.v6 <= vtw && vtw <= ctl->lim.v6)
478 ? &vtw->common : 0;
485 /*!\brief return the next vtw after this one.
493 vtw_next(vtw_ctl_t *ctl, vtw_t *vtw)
496 vtw_v4_t *v4 = (void*)vtw;
498 vtw = &(++v4)->common;
500 vtw_v6_t *v6 = (void*)vtw;
502 vtw = &(++v6)->common;
505 if (vtw > ctl->lim.v)
506 vtw = ctl->base.v;
508 return vtw;
514 vtw_unhash(vtw_ctl_t *ctl, vtw_t *vtw)
518 uint32_t key = vtw->key;
520 vtw_v4_t *v4 = (void*)vtw;
521 vtw_v6_t *v6 = (void*)vtw;
523 if (!vtw->hashed) {
528 if (fat->vtw->is_v4) {
530 } else if (fat->vtw->is_v6) {
541 idx = vtw_index(ctl, vtw);
606 vtw->key ^= ~0;
609 if (fat->vtw->is_v4) {
611 } else if (fat->vtw->is_v6) {
617 key = vtw->port_key;
620 idx = vtw_index(ctl, vtw);
667 vtw->port_key ^= ~0;
670 vtw->hashed = 0;
676 vtw_del(vtw_ctl_t *ctl, vtw_t *vtw)
680 if (vtw->hashed) {
682 vtw_unhash(ctl, vtw);
687 if (vtw != ctl->oldest.v)
693 vtw->expire.tv_sec = 0;
694 vtw->expire.tv_usec = ~0;
699 ctl->oldest.v = vtw_next(ctl, vtw);
705 vtw_inshash_v4(vtw_ctl_t *ctl, vtw_t *vtw)
707 uint32_t idx = vtw_index(ctl, vtw);
709 vtw_v4_t *v4 = (void*)vtw;
712 KASSERT(!vtw->hashed);
713 KASSERT(ctl->clidx == vtw->msl_class);
720 vtw->key = fatp_vtw_inshash(ctl->fat, idx, tag, 0, vtw);
723 , "vtw: ins %8.8x:%4.4x %8.8x:%4.4x"
728 , vtw->key));
731 vtw->port_key = fatp_vtw_inshash(ctl->fat, idx, tag, 1, vtw);
733 db_trace(KTR_VTW, (ctl, "vtw: ins %P - %4.4x tag %8.8x key %8.8x"
736 , vtw->key));
738 vtw->hashed = 1;
744 vtw_inshash_v6(vtw_ctl_t *ctl, vtw_t *vtw)
746 uint32_t idx = vtw_index(ctl, vtw);
748 vtw_v6_t *v6 = (void*)vtw;
751 KASSERT(!vtw->hashed);
752 KASSERT(ctl->clidx == vtw->msl_class);
759 vtw->key = fatp_vtw_inshash(ctl->fat, idx, tag, 0, vtw);
762 vtw->port_key = fatp_vtw_inshash(ctl->fat, idx, tag, 1, vtw);
764 db_trace(KTR_VTW, (ctl, "vtw: ins %P - %4.4x tag %8.8x key %8.8x"
767 , vtw->key));
769 vtw->hashed = 1;
778 vtw_t *vtw;
814 vtw = vtw_from_index(ctl, idx);
816 if (!vtw) {
820 , (fp, "vtw: fast %A:%P %A:%P"
828 v4 = (void*)vtw;
830 /* The de-referencing of vtw is what we want to avoid.
833 if (vtw_alive(vtw)
834 && ((which ? vtw->port_key : vtw->key)
843 , (fp, "vtw: hit %8.8x:%4.4x"
847 , idx_decode(ctl, idx), vtw->key));
849 KASSERT(vtw->hashed);
856 if (vtw_alive(vtw)) {
858 , (fp, "vtw:!mis %8.8x:%4.4x"
866 , (vtw, "vtw:!mis %8.8x:%4.4x"
870 , vtw->key
874 if (vtw->key == fatp_key(ctl->fat, fp, i)) {
876 , (vtw, "vtw:!mis %8.8x:%4.4x"
881 , vtw->key
886 , (vtw
887 , "vtw:!mis"
890 , vtw->key
899 , "vtw:!mis free entry"
900 " idx %x vtw %p which %x"
902 , vtw, which));
913 vtw = 0;
922 return vtw;
931 vtw_t *vtw;
967 vtw = vtw_from_index(ctl, idx);
976 if (!vtw) {
982 v6 = (void*)vtw;
984 if (vtw_alive(vtw)
985 && ((which ? vtw->port_key : vtw->key)
995 KASSERT(vtw->hashed);
1010 vtw = 0;
1019 return vtw;
1029 vtw_t *vtw;
1063 vtw = vtw_from_index(ctl, idx);
1065 if (!vtw) {
1071 v4 = (void*)vtw;
1073 if (vtw_alive(vtw)
1074 && vtw->port_key == fatp_key(ctl->fat, fp, i)
1081 } else if (vtw_alive(vtw)) {
1086 , (vtw, "vtw:!mis"
1091 , vtw->key
1106 , (fp, "vtw:!mis port %x"
1107 " - free entry idx %x vtw %p"
1110 , vtw));
1124 vtw = 0;
1133 return vtw;
1143 vtw_t *vtw;
1177 vtw = vtw_from_index(ctl, idx);
1179 if (!vtw) {
1185 v6 = (void*)vtw;
1188 , (vtw, "vtw: i %x idx %x fp->tag %x"
1193 if (vtw_alive(vtw)
1194 && vtw->port_key == fatp_key(ctl->fat, fp, i)
1199 , (fp, "vtw: nxt port %P - %4.4x"
1202 , idx_decode(ctl, idx), vtw->key));
1206 } else if (vtw_alive(vtw)) {
1210 , (vtw, "vtw:!mis port %6A:%4.4x"
1218 , vtw->key
1235 , "vtw:!mis port %x"
1236 " - free entry idx %x vtw %p"
1238 , vtw));
1252 vtw = 0;
1261 return vtw;
1264 /*!\brief initialise the VTW allocation arena
1309 fat->vtw = ctl;
1373 /*!\brief allocate a vtw entry
1378 vtw_t *vtw = 0;
1408 , (ctl, "vtw:!none free in class %x %x/%x"
1416 vtw = ctl->alloc.v;
1418 if (vtw->msl_class != ctl->clidx) {
1422 KASSERT(!vtw->msl_class || !ctl->clidx);
1424 if (vtw->hashed || vtw->expire.tv_sec) {
1432 , (ctl, "vtw:!%p class %x!=%x %x:%x%s"
1433 , vtw, vtw->msl_class, ctl->clidx
1434 , vtw->expire.tv_sec
1435 , vtw->expire.tv_usec
1436 , vtw->hashed ? " hashed" : ""));
1442 , (ctl, "vtw:!%p usurped from %x to %x"
1443 , vtw, vtw->msl_class, ctl->clidx));
1445 vtw->msl_class = ctl->clidx;
1448 if (vtw_alive(vtw)) {
1455 ctl->alloc.v = vtw_next(ctl, vtw);
1464 getmicrouptime(&vtw->expire);
1468 vtw->expire.tv_sec += msl / 1000;
1469 vtw->expire.tv_usec += 1000 * (msl % 1000);
1471 while (vtw->expire.tv_usec >= 1000*1000) {
1472 vtw->expire.tv_usec -= 1000*1000;
1473 vtw->expire.tv_sec += 1;
1477 ctl->oldest.v = vtw;
1479 return vtw;
1487 vtw_t *vtw;
1496 for (vtw = ctl->oldest.v; vtw && ctl->nalloc; ) {
1500 if (vtw->msl_class != ctl->clidx) {
1502 , (vtw, "vtw:!age class mismatch %x != %x"
1503 , vtw->msl_class, ctl->clidx));
1508 ctl->oldest.v = vtw = vtw_next(ctl, vtw);
1514 then = vtw->expire;
1518 if (!timercmp(&vtw->expire, when, <=))
1522 , (vtw, "vtw: expire %x %8.8x:%8.8x %x/%x"
1524 , vtw->expire.tv_sec
1525 , vtw->expire.tv_usec
1532 vtw_del(ctl, vtw);
1533 vtw = ctl->oldest.v;
1599 /*!\brief export an IPv4 vtw.
1602 vtw_export_v4(vtw_ctl_t *ctl, vtw_t *vtw, vestigial_inpcb_t *res)
1604 vtw_v4_t *v4 = (void*)vtw;
1608 if (ctl && vtw) {
1609 if (!ctl->clidx && vtw->msl_class)
1610 ctl += vtw->msl_class;
1612 KASSERT(ctl->clidx == vtw->msl_class);
1621 res->vtw = vtw; // netlock held over call(s)
1623 res->reuse_addr = vtw->reuse_addr;
1624 res->reuse_port = vtw->reuse_port;
1625 res->snd_nxt = vtw->snd_nxt;
1626 res->rcv_nxt = vtw->rcv_nxt;
1627 res->rcv_wnd = vtw->rcv_wnd;
1628 res->uid = vtw->uid;
1640 vtw_t *vtw = 0;
1643 vtw = vtw_next_port_v4(it);
1645 if (!vtw)
1648 return vtw_export_v4(it->ctl, vtw, res);
1656 vtw_t *vtw;
1661 , (res, "vtw: lookup %A:%P %A:%P"
1665 vtw = vtw_lookup_hash_v4((ctl = &vtw_tcpv4[0])
1669 return vtw_export_v4(ctl, vtw, res);
1698 /*!\brief export an IPv6 vtw.
1701 vtw_export_v6(vtw_ctl_t *ctl, vtw_t *vtw, vestigial_inpcb_t *res)
1703 vtw_v6_t *v6 = (void*)vtw;
1707 if (ctl && vtw) {
1708 if (!ctl->clidx && vtw->msl_class)
1709 ctl += vtw->msl_class;
1711 KASSERT(ctl->clidx == vtw->msl_class);
1720 res->vtw = vtw; // netlock held over call(s)
1723 res->v6only = vtw->v6only;
1724 res->reuse_addr = vtw->reuse_addr;
1725 res->reuse_port = vtw->reuse_port;
1727 res->snd_nxt = vtw->snd_nxt;
1728 res->rcv_nxt = vtw->rcv_nxt;
1729 res->rcv_wnd = vtw->rcv_wnd;
1730 res->uid = vtw->uid;
1740 vtw_t *vtw = 0;
1743 vtw = vtw_next_port_v6(it);
1745 if (!vtw)
1748 return vtw_export_v6(it->ctl, vtw, res);
1757 vtw_t *vtw;
1760 , (res, "vtw: lookup %6A:%P %6A:%P"
1764 vtw = vtw_lookup_hash_v6((ctl = &vtw_tcpv6[0])
1768 return vtw_export_v6(ctl, vtw, res);
1883 vtw_t *vtw;
1895 vtw = vtw_alloc(ctl);
1897 if (vtw) {
1898 vtw->snd_nxt = tp->snd_nxt;
1899 vtw->rcv_nxt = tp->rcv_nxt;
1904 vtw_v4_t *v4 = (void*)vtw;
1911 vtw->reuse_port = !!(inp->inp_socket->so_options
1913 vtw->reuse_addr = !!(inp->inp_socket->so_options
1915 vtw->v6only = 0;
1916 vtw->uid = inp->inp_socket->so_uidinfo->ui_uid;
1918 vtw_inshash_v4(ctl, vtw);
1931 == vtw);
1976 vtw_v6_t *v6 = (void*)vtw;
1983 vtw->reuse_port = !!(inp->inp_socket->so_options
1985 vtw->reuse_addr = !!(inp->inp_socket->so_options
1987 vtw->v6only = !!(inp->inp_flags
1989 vtw->uid = inp->inp_socket->so_uidinfo->ui_uid;
1991 vtw_inshash_v6(ctl, vtw);
2001 == vtw);
2059 vtw_v4_t copy = *(vtw_v4_t*)vp->vtw;
2060 vtw_t *vtw;
2067 , (vp->vtw, "vtw: restart %A:%P %A:%P"
2074 vtw = vtw_alloc(ctl);
2076 if (vtw) {
2077 vtw_v4_t *v4 = (void*)vtw;
2081 vtw_del(vp->ctl, vp->vtw);
2083 vtw->snd_nxt = cp->snd_nxt;
2084 vtw->rcv_nxt = cp->rcv_nxt;
2091 vtw->reuse_port = cp->reuse_port;
2092 vtw->reuse_addr = cp->reuse_addr;
2093 vtw->v6only = 0;
2094 vtw->uid = cp->uid;
2096 vtw_inshash_v4(ctl, vtw);
2107 vtw_v6_t copy = *(vtw_v6_t*)vp->vtw;
2108 vtw_t *vtw;
2115 , (vp->vtw, "vtw: restart %6A:%P %6A:%P"
2124 vtw = vtw_alloc(ctl);
2126 if (vtw) {
2127 vtw_v6_t *v6 = (void*)vtw;
2131 vtw_del(vp->ctl, vp->vtw);
2133 vtw->snd_nxt = cp->snd_nxt;
2134 vtw->rcv_nxt = cp->rcv_nxt;
2141 vtw->reuse_port = cp->reuse_port;
2142 vtw->reuse_addr = cp->reuse_addr;
2143 vtw->v6only = cp->v6only;
2144 vtw->uid = cp->uid;
2146 vtw_inshash_v6(ctl, vtw);
2230 vtw_t *vtw;
2236 vtw = vtw_alloc(ctl);
2238 if (vtw) {
2239 vtw->snd_nxt = 0;
2240 vtw->rcv_nxt = 0;
2244 vtw_v4_t *v4 = (void*)vtw;
2251 vtw->reuse_port = 1;
2252 vtw->reuse_addr = 1;
2253 vtw->v6only = 0;
2254 vtw->uid = 0;
2256 vtw_inshash_v4(ctl, vtw);
2261 vtw_v6_t *v6 = (void*)vtw;
2269 vtw->reuse_port = 1;
2270 vtw->reuse_addr = 1;
2271 vtw->v6only = 0;
2272 vtw->uid = 0;
2274 vtw_inshash_v6(ctl, vtw);
2376 vtw_t *vtw;
2386 for (n = 0, vtw = ctl->base.v; ; ) {
2388 vtw = vtw_next(ctl, vtw);
2389 if (vtw == ctl->base.v)
2405 for (n = 0, vtw = ctl->base.v; ; ) {
2407 vtw = vtw_next(ctl, vtw);
2408 if (vtw == ctl->base.v)
2468 SYSCTL_DESCR("vtw debug"