Page MenuHomeFreeBSD

avoid unneeded call to arc4random() in syncache_add()
ClosedPublic

Authored by gallatin on Sep 10 2019, 7:47 PM.
Tags
None
Referenced Files
F151397964: D21591.id61908.diff
Wed, Apr 8, 4:04 AM
Unknown Object (File)
Fri, Apr 3, 3:02 PM
Unknown Object (File)
Fri, Apr 3, 1:01 AM
Unknown Object (File)
Feb 21 2026, 8:08 AM
Unknown Object (File)
Feb 18 2026, 3:11 AM
Unknown Object (File)
Feb 8 2026, 9:46 AM
Unknown Object (File)
Feb 8 2026, 7:32 AM
Unknown Object (File)
Jan 31 2026, 1:21 AM
Subscribers

Details

Summary

We currently call arc4random() unconditionally to initialize sc_iss, but then when syncookies are enabled, we overwrite it with the return value from from syncookie_generate(). It would seem to make more sense to only call arc4random() 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).

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable