* 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
| 1250 | * list. |
| 1251 | */ |
| 1252 | static void |
| 1253 | tcp_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)) { |
| 1283 | out: |
| 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 |
no test coverage detected