Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The first version of the retry processing was limiting CPU and memory consumption in an indirect way: if there were too many connection in progress, picoquic would send a "stateless retry" packet to the peer, and the connection would not progress until an initial packet was received with the correct token. The CPU consumption was limited, because the expensive asymmetrical key operations would only happen after the retry/token handshake, but the memory consumption would still grow quickly, because each "initial" packet caused creation of a connection context (about 5KB). These contexts would only be freed after a timer, and thus the memory consumption could be large.
This PR ensures that no context is created if the initial packet is not "accepted". The picoquic server will simply queue a "stateless packet" containing either the "retry" packet or an initial packet with a connection close frame stating "server busy".
The "cnx_ddos" test has been updated to verify that not to many contexts are created.