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

Function syncookie_reseed

freebsd/netinet/tcp_syncache.c:2425–2445  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2423#endif /* INVARIANTS */
2424
2425static void
2426syncookie_reseed(void *arg)
2427{
2428 struct tcp_syncache *sc = arg;
2429 uint8_t *secbits;
2430 int secbit;
2431
2432 /*
2433 * Reseeding the secret doesn't have to be protected by a lock.
2434 * It only must be ensured that the new random values are visible
2435 * to all CPUs in a SMP environment. The atomic with release
2436 * semantics ensures that.
2437 */
2438 secbit = (sc->secret.oddeven & 0x1) ? 0 : 1;
2439 secbits = sc->secret.key[secbit];
2440 arc4rand(secbits, SYNCOOKIE_SECRET_SIZE, 0);
2441 atomic_add_rel_int(&sc->secret.oddeven, 1);
2442
2443 /* Reschedule ourself. */
2444 callout_schedule(&sc->secret.reseed, SYNCOOKIE_LIFETIME * hz);
2445}
2446
2447/*
2448 * We have overflowed a bucket. Let's pause dealing with the syncache.

Callers

nothing calls this directly

Calls 2

arc4randFunction · 0.50
callout_scheduleFunction · 0.50

Tested by

no test coverage detected