Skip to content

Conversation

@SkohTV
Copy link
Contributor

@SkohTV SkohTV commented Oct 8, 2025

Fix #215

I've started getting into adding this features.
So far, I've managed to add the ratelimit [int]/[time_unit] keyword to the cli and put it's value into a bf_map.
However I'm not sure about implementing a "real" rate limiting as it seems to require EMIT (and that look scary).
Added (empty for now) elfstub to handle rate limiting

The idea of the implementation so far is pretty naive (only allow the first X requests to pass through), mostly because it was easier to implement and I hadn't strong feelings on which direction to go.

I'll keep this as a draft for now since it's still in its early stages.

@SkohTV SkohTV changed the title cli: add ratelimit keyword feature: rate limit Oct 10, 2025
Copy link
Contributor

@qdeslandes qdeslandes left a comment

Choose a reason for hiding this comment

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

I went for an early review, mostly for the parsing part. On the BPF side, the map will contain the runtime values for a given rule's rate limit (current burst/allowance, limit, last update time...).

Comment on lines 91 to 95
[0-9]+ {
BEGIN(INITIAL);
yylval.sval = strdup(yytext);
return RATELIMIT_VAL;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should expect any float value (even negative, we'll error out later on). We also need a time window , e.g. 10/second.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we really wanna handle float or do we also error them out later on ?
It feels weird writing 12.1/second (even though it is technically correct), and we could have issues with float precision in some cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

We don't want to handle floats, but it's easier to error out when parsing the matcher payload (e.g. with a clear error message) than in the lexer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support traffic rate limiting

2 participants