Lines Matching refs:sch
137 static void syncache_timeout(struct syncache *sc, struct syncache_head *sch,
150 static int syncookie_cmp(struct in_conninfo *inc, struct syncache_head *sch,
222 #define SCH_LOCK(sch) mtx_lock(&(sch)->sch_mtx) argument
223 #define SCH_UNLOCK(sch) mtx_unlock(&(sch)->sch_mtx) argument
224 #define SCH_LOCK_ASSERT(sch) mtx_assert(&(sch)->sch_mtx, MA_OWNED) argument
310 struct syncache_head *sch; in syncache_destroy() local
323 sch = &V_tcp_syncache.hashbase[i]; in syncache_destroy()
324 callout_drain(&sch->sch_timer); in syncache_destroy()
326 SCH_LOCK(sch); in syncache_destroy()
327 TAILQ_FOREACH_SAFE(sc, &sch->sch_bucket, sc_hash, nsc) in syncache_destroy()
328 syncache_drop(sc, sch); in syncache_destroy()
329 SCH_UNLOCK(sch); in syncache_destroy()
330 KASSERT(TAILQ_EMPTY(&sch->sch_bucket), in syncache_destroy()
332 KASSERT(sch->sch_length == 0, ("%s: sch->sch_length %d not 0", in syncache_destroy()
333 __func__, sch->sch_length)); in syncache_destroy()
334 mtx_destroy(&sch->sch_mtx); in syncache_destroy()
351 syncache_insert(struct syncache *sc, struct syncache_head *sch) in syncache_insert() argument
355 SCH_LOCK(sch); in syncache_insert()
361 if (sch->sch_length >= V_tcp_syncache.bucket_limit) { in syncache_insert()
362 KASSERT(!TAILQ_EMPTY(&sch->sch_bucket), in syncache_insert()
364 sc2 = TAILQ_LAST(&sch->sch_bucket, sch_head); in syncache_insert()
365 sch->sch_last_overflow = time_uptime; in syncache_insert()
366 syncache_drop(sc2, sch); in syncache_insert()
371 TAILQ_INSERT_HEAD(&sch->sch_bucket, sc, sc_hash); in syncache_insert()
372 sch->sch_length++; in syncache_insert()
383 if (sch->sch_length == 1) in syncache_insert()
384 sch->sch_nextc = ticks + INT_MAX; in syncache_insert()
385 syncache_timeout(sc, sch, 1); in syncache_insert()
387 SCH_UNLOCK(sch); in syncache_insert()
398 syncache_drop(struct syncache *sc, struct syncache_head *sch) in syncache_drop() argument
401 SCH_LOCK_ASSERT(sch); in syncache_drop()
404 TAILQ_REMOVE(&sch->sch_bucket, sc, sc_hash); in syncache_drop()
405 sch->sch_length--; in syncache_drop()
422 syncache_timeout(struct syncache *sc, struct syncache_head *sch, int docallout) in syncache_timeout() argument
434 if (TSTMP_LT(sc->sc_rxttime, sch->sch_nextc)) { in syncache_timeout()
435 sch->sch_nextc = sc->sc_rxttime; in syncache_timeout()
437 callout_reset(&sch->sch_timer, sch->sch_nextc - ticks, in syncache_timeout()
438 syncache_timer, (void *)sch); in syncache_timeout()
450 struct syncache_head *sch = (struct syncache_head *)xsch; in syncache_timer() local
455 CURVNET_SET(sch->sch_sc->vnet); in syncache_timer()
458 SCH_LOCK_ASSERT(sch); in syncache_timer()
464 sch->sch_nextc = tick + INT_MAX; in syncache_timer()
466 TAILQ_FOREACH_SAFE(sc, &sch->sch_bucket, sc_hash, nsc) { in syncache_timer()
476 if (TSTMP_LT(sc->sc_rxttime, sch->sch_nextc)) in syncache_timer()
477 sch->sch_nextc = sc->sc_rxttime; in syncache_timer()
487 syncache_drop(sc, sch); in syncache_timer()
498 syncache_respond(sc, sch, NULL, TH_SYN|TH_ACK); in syncache_timer()
500 syncache_timeout(sc, sch, 0); in syncache_timer()
502 if (!TAILQ_EMPTY(&(sch)->sch_bucket)) in syncache_timer()
503 callout_reset(&(sch)->sch_timer, (sch)->sch_nextc - tick, in syncache_timer()
504 syncache_timer, (void *)(sch)); in syncache_timer()
516 struct syncache_head *sch; in syncache_lookup() local
529 sch = &V_tcp_syncache.hashbase[hash]; in syncache_lookup()
530 *schp = sch; in syncache_lookup()
531 SCH_LOCK(sch); in syncache_lookup()
534 TAILQ_FOREACH(sc, &sch->sch_bucket, sc_hash) in syncache_lookup()
552 struct syncache_head *sch; in syncache_chkrst() local
555 sc = syncache_lookup(inc, &sch); /* returns locked sch */ in syncache_chkrst()
556 SCH_LOCK_ASSERT(sch); in syncache_chkrst()
618 syncache_drop(sc, sch); in syncache_chkrst()
635 syncache_respond(sc, sch, m, TH_ACK); in syncache_chkrst()
649 SCH_UNLOCK(sch); in syncache_chkrst()
656 struct syncache_head *sch; in syncache_badack() local
658 sc = syncache_lookup(inc, &sch); /* returns locked sch */ in syncache_badack()
659 SCH_LOCK_ASSERT(sch); in syncache_badack()
661 syncache_drop(sc, sch); in syncache_badack()
664 SCH_UNLOCK(sch); in syncache_badack()
671 struct syncache_head *sch; in syncache_unreach() local
673 sc = syncache_lookup(inc, &sch); /* returns locked sch */ in syncache_unreach()
674 SCH_LOCK_ASSERT(sch); in syncache_unreach()
694 syncache_drop(sc, sch); in syncache_unreach()
697 SCH_UNLOCK(sch); in syncache_unreach()
1027 struct syncache_head *sch; in syncache_expand() local
1039 sc = syncache_lookup(inc, &sch); /* returns locked sch */ in syncache_expand()
1040 SCH_LOCK_ASSERT(sch); in syncache_expand()
1048 syncookie_cmp(inc, sch, sc, th, to, *lsop); in syncache_expand()
1065 SCH_UNLOCK(sch); in syncache_expand()
1073 sch->sch_last_overflow < time_uptime - SYNCOOKIE_LIFETIME) { in syncache_expand()
1074 SCH_UNLOCK(sch); in syncache_expand()
1082 sc = syncookie_lookup(inc, sch, &scs, th, to, *lsop); in syncache_expand()
1083 SCH_UNLOCK(sch); in syncache_expand()
1119 SCH_UNLOCK(sch); in syncache_expand()
1131 SCH_UNLOCK(sch); in syncache_expand()
1153 SCH_UNLOCK(sch); in syncache_expand()
1174 TAILQ_REMOVE(&sch->sch_bucket, sc, sc_hash); in syncache_expand()
1175 sch->sch_length--; in syncache_expand()
1183 SCH_UNLOCK(sch); in syncache_expand()
1314 struct syncache_head *sch; in syncache_add() local
1437 sc = syncache_lookup(inc, &sch); /* returns locked entry */ in syncache_add()
1438 SCH_LOCK_ASSERT(sch); in syncache_add()
1475 if (syncache_respond(sc, sch, m, TH_SYN|TH_ACK) == 0) { in syncache_add()
1477 syncache_timeout(sc, sch, 1); in syncache_add()
1481 SCH_UNLOCK(sch); in syncache_add()
1499 if ((sc = TAILQ_LAST(&sch->sch_bucket, sch_head)) != NULL) { in syncache_add()
1500 sch->sch_last_overflow = time_uptime; in syncache_add()
1501 syncache_drop(sc, sch); in syncache_add()
1509 SCH_UNLOCK(sch); in syncache_add()
1616 sc->sc_iss = syncookie_generate(sch, sc); in syncache_add()
1626 SCH_UNLOCK(sch); in syncache_add()
1639 if (syncache_respond(sc, sch, m, TH_SYN|TH_ACK) == 0) { in syncache_add()
1643 syncache_insert(sc, sch); /* locks and unlocks sch */ in syncache_add()
1684 syncache_respond(struct syncache *sc, struct syncache_head *sch, in syncache_respond() argument
2056 syncookie_generate(struct syncache_head *sch, struct syncache *sc) in syncookie_generate() argument
2063 SCH_LOCK_ASSERT(sch); in syncookie_generate()
2092 secbit = sch->sch_sc->secret.oddeven & 0x1; in syncookie_generate()
2095 secbits = sch->sch_sc->secret.key[secbit]; in syncookie_generate()
2097 (uintptr_t)sch); in syncookie_generate()
2113 syncookie_lookup(struct in_conninfo *inc, struct syncache_head *sch, in syncookie_lookup() argument
2123 SCH_LOCK_ASSERT(sch); in syncookie_lookup()
2139 secbits = sch->sch_sc->secret.key[cookie.flags.odd_even]; in syncookie_lookup()
2141 hash = syncookie_mac(inc, seq, cookie.cookie, secbits, (uintptr_t)sch); in syncookie_lookup()
2208 syncookie_cmp(struct in_conninfo *inc, struct syncache_head *sch, in syncookie_cmp() argument
2216 scx = syncookie_lookup(inc, sch, &scs, th, to, lso); in syncookie_cmp()
2282 struct syncache_head *sch; in syncache_pcblist() local
2286 sch = &V_tcp_syncache.hashbase[i]; in syncache_pcblist()
2287 SCH_LOCK(sch); in syncache_pcblist()
2288 TAILQ_FOREACH(sc, &sch->sch_bucket, sc_hash) { in syncache_pcblist()
2290 SCH_UNLOCK(sch); in syncache_pcblist()
2310 SCH_UNLOCK(sch); in syncache_pcblist()
2315 SCH_UNLOCK(sch); in syncache_pcblist()