mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Avoid unneeded call to arc4random() in syncache_add()
Don't call arc4random() unconditionally to initialize sc_iss, and then when syncookies are enabled, just overwrite it with the return value from from syncookie_generate(). Instead, only call arc4random() to initialize sc_iss when syncookies are not enabled. Note that on a system under a syn flood attack, arc4random() becomes quite expensive, and the chacha_poly crypto that it calls is one of the more expensive things happening on the system. Removing this unneeded arc4random() call reduces CPU from about 40% to about 35% in my test scenario (Broadwell Xeon, 6Mpps syn flood attack). Reviewed by: rrs, tuxen, bz Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D21591
This commit is contained in:
parent
dfcf2d87dd
commit
d2e6258258
1 changed files with 2 additions and 1 deletions
|
|
@ -1543,7 +1543,6 @@ skip_alloc:
|
|||
sc->sc_todctx = todctx;
|
||||
#endif
|
||||
sc->sc_irs = th->th_seq;
|
||||
sc->sc_iss = arc4random();
|
||||
sc->sc_flags = 0;
|
||||
sc->sc_flowlabel = 0;
|
||||
|
||||
|
|
@ -1617,6 +1616,8 @@ skip_alloc:
|
|||
|
||||
if (V_tcp_syncookies)
|
||||
sc->sc_iss = syncookie_generate(sch, sc);
|
||||
else
|
||||
sc->sc_iss = arc4random();
|
||||
#ifdef INET6
|
||||
if (autoflowlabel) {
|
||||
if (V_tcp_syncookies)
|
||||
|
|
|
|||
Loading…
Reference in a new issue