Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

netty: Add option to limit RST_STREAM rate #10675

Merged
merged 4 commits into from
Nov 17, 2023
Merged

Conversation

ejona86
Copy link
Member

@ejona86 ejona86 commented Nov 16, 2023

The behavior purposefully mirrors that of Netty's
AbstractHttp2ConnectionHandlerBuilder.decoderEnforceMaxRstFramesPerWindow(). That API is not available to our code as we extend the Http2ConnectionHandler, but we want our API to be able to delegate to Netty's in the future if that ever becomes possible.

CC @temawi

The behavior purposefully mirrors that of Netty's
AbstractHttp2ConnectionHandlerBuilder.decoderEnforceMaxRstFramesPerWindow().
That API is not available to our code as we extend the
Http2ConnectionHandler, but we want our API to be able to delegate to
Netty's in the future if that ever becomes possible.
@ejona86 ejona86 requested a review from YifeiZhuang November 16, 2023 23:59
@ejona86 ejona86 added the TODO:backport PR needs to be backported. Removed after backport complete label Nov 16, 2023
Comment on lines 547 to 558
if (maxRstCount > 0) {
long now = System.nanoTime();
if (now - lastRstNanoTime > maxRstPeriodNanos) {
lastRstNanoTime = now;
rstCount = 1;
} else {
rstCount++;
if (rstCount > maxRstCount) {
throw Http2Exception.connectionError(Http2Error.ENHANCE_YOUR_CALM, "too_many_rststreams");
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract this logic to a method? Would keep this method more concise and a well named new method would also communicate what this logic is for. Or a comment, as an alternative.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Enforce maxRstCount" as a comment seems a bit repetitive. And the description of how this should work is in the public documentation. Do you have an idea for something in particular that is helpful to communicate?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I was just looking for something to indicate this block of code IS the maxRstCount enforcement. But I don't feel strongly about it.

@ejona86 ejona86 merged commit 0987dc4 into grpc:master Nov 17, 2023
@ejona86 ejona86 deleted the rapid-reset branch November 17, 2023 23:10
@ejona86 ejona86 removed the TODO:backport PR needs to be backported. Removed after backport complete label Nov 20, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants