MCPcopy Create free account
hub / github.com/F-Stack/f-stack / tcp_init

Function tcp_init

freebsd/netinet/tcp_subr.c:1091–1242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1089}
1090
1091void
1092tcp_init(void)
1093{
1094 const char *tcbhash_tuneable;
1095 int hashsize;
1096
1097 tcbhash_tuneable = "net.inet.tcp.tcbhashsize";
1098
1099#ifdef TCP_HHOOK
1100 if (hhook_head_register(HHOOK_TYPE_TCP, HHOOK_TCP_EST_IN,
1101 &V_tcp_hhh[HHOOK_TCP_EST_IN], HHOOK_NOWAIT|HHOOK_HEADISINVNET) != 0)
1102 printf("%s: WARNING: unable to register helper hook\n", __func__);
1103 if (hhook_head_register(HHOOK_TYPE_TCP, HHOOK_TCP_EST_OUT,
1104 &V_tcp_hhh[HHOOK_TCP_EST_OUT], HHOOK_NOWAIT|HHOOK_HEADISINVNET) != 0)
1105 printf("%s: WARNING: unable to register helper hook\n", __func__);
1106#endif
1107#ifdef STATS
1108 if (tcp_stats_init())
1109 printf("%s: WARNING: unable to initialise TCP stats\n",
1110 __func__);
1111#endif
1112 hashsize = TCBHASHSIZE;
1113 TUNABLE_INT_FETCH(tcbhash_tuneable, &hashsize);
1114 if (hashsize == 0) {
1115 /*
1116 * Auto tune the hash size based on maxsockets.
1117 * A perfect hash would have a 1:1 mapping
1118 * (hashsize = maxsockets) however it's been
1119 * suggested that O(2) average is better.
1120 */
1121 hashsize = maketcp_hashsize(maxsockets / 4);
1122 /*
1123 * Our historical default is 512,
1124 * do not autotune lower than this.
1125 */
1126 if (hashsize < 512)
1127 hashsize = 512;
1128 if (bootverbose && IS_DEFAULT_VNET(curvnet))
1129 printf("%s: %s auto tuned to %d\n", __func__,
1130 tcbhash_tuneable, hashsize);
1131 }
1132 /*
1133 * We require a hashsize to be a power of two.
1134 * Previously if it was not a power of two we would just reset it
1135 * back to 512, which could be a nasty surprise if you did not notice
1136 * the error message.
1137 * Instead what we do is clip it to the closest power of two lower
1138 * than the specified hash value.
1139 */
1140 if (!powerof2(hashsize)) {
1141 int oldhashsize = hashsize;
1142
1143 hashsize = maketcp_hashsize(hashsize);
1144 /* prevent absurdly low value */
1145 if (hashsize < 16)
1146 hashsize = 16;
1147 printf("%s: WARNING: TCB hash size not a power of 2, "
1148 "clipped from %d to %d.\n", __func__, oldhashsize,

Callers

nothing calls this directly

Calls 15

hhook_head_registerFunction · 0.85
tcp_stats_initFunction · 0.85
maketcp_hashsizeFunction · 0.85
in_pcbinfo_initFunction · 0.85
uma_zcreateFunction · 0.85
uma_zone_set_maxFunction · 0.85
uma_zone_set_warningFunction · 0.85
tcp_tw_initFunction · 0.85
syncache_initFunction · 0.85
tcp_hc_initFunction · 0.85
tcp_fastopen_initFunction · 0.85
tcp_reass_global_initFunction · 0.85

Tested by

no test coverage detected