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

Function tcp_input_data

freebsd/netinet/tcp_hpts.c:1252–1365  ·  view source on GitHub ↗

* Do NOT try to optimize the processing of inp's * by first pulling off all the inp's into a temporary * list (e.g. TAILQ_CONCAT). If you do that the subtle * interactions of switching CPU's will kill because of * problems in the linked list manipulation. Basically * you would switch cpu's with the hpts mutex locked * but then while you were processing one of the inp's * some other one that

Source from the content-addressed store, hash-verified

1250 * list.
1251 */
1252static void
1253tcp_input_data(struct tcp_hpts_entry *hpts, struct timeval *tv)
1254{
1255 struct tcpcb *tp;
1256 struct inpcb *inp;
1257 uint16_t drop_reason;
1258 int16_t set_cpu;
1259 uint32_t did_prefetch = 0;
1260 int dropped;
1261
1262 HPTS_MTX_ASSERT(hpts);
1263 NET_EPOCH_ASSERT();
1264
1265 while ((inp = TAILQ_FIRST(&hpts->p_input)) != NULL) {
1266 HPTS_MTX_ASSERT(hpts);
1267 hpts_sane_input_remove(hpts, inp, 0);
1268 if (inp->inp_input_cpu_set == 0) {
1269 set_cpu = 1;
1270 } else {
1271 set_cpu = 0;
1272 }
1273 hpts->p_inp = inp;
1274 drop_reason = inp->inp_hpts_drop_reas;
1275 inp->inp_in_input = 0;
1276 mtx_unlock(&hpts->p_mtx);
1277 INP_WLOCK(inp);
1278#ifdef VIMAGE
1279 CURVNET_SET(inp->inp_vnet);
1280#endif
1281 if ((inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) ||
1282 (inp->inp_flags2 & INP_FREED)) {
1283out:
1284 hpts->p_inp = NULL;
1285 if (in_pcbrele_wlocked(inp) == 0) {
1286 INP_WUNLOCK(inp);
1287 }
1288#ifdef VIMAGE
1289 CURVNET_RESTORE();
1290#endif
1291 mtx_lock(&hpts->p_mtx);
1292 continue;
1293 }
1294 tp = intotcpcb(inp);
1295 if ((tp == NULL) || (tp->t_inpcb == NULL)) {
1296 goto out;
1297 }
1298 if (drop_reason) {
1299 /* This tcb is being destroyed for drop_reason */
1300 tcp_drop_in_pkts(tp);
1301 tp = tcp_drop(tp, drop_reason);
1302 if (tp == NULL) {
1303 INP_WLOCK(inp);
1304 }
1305 if (in_pcbrele_wlocked(inp) == 0)
1306 INP_WUNLOCK(inp);
1307#ifdef VIMAGE
1308 CURVNET_RESTORE();
1309#endif

Callers 1

tcp_hptsiFunction · 0.85

Calls 7

hpts_sane_input_removeFunction · 0.85
in_pcbrele_wlockedFunction · 0.85
tcp_drop_in_pktsFunction · 0.85
tcp_dropFunction · 0.85
kern_prefetchFunction · 0.85
mtx_unlockFunction · 0.50
mtx_lockFunction · 0.50

Tested by

no test coverage detected