Skip to content

api: support rate limit action based on cidr match#42845

Merged
wbpcode merged 1 commit intoenvoyproxy:mainfrom
rudrakhp:api_cidr_matcher
Feb 4, 2026
Merged

api: support rate limit action based on cidr match#42845
wbpcode merged 1 commit intoenvoyproxy:mainfrom
rudrakhp:api_cidr_matcher

Conversation

@rudrakhp
Copy link
Copy Markdown
Member

@rudrakhp rudrakhp commented Jan 4, 2026

Commit Message: [api] support rate limit action based on cidr match
Additional Description: Proposed API changes to support rate limit actions on remote address match. This includes additions of a new rate limit action RemoteAddressMatch as well as inclusion of a CIDR matcher in the MaskedRemoteAddress action.
Risk Level: Low (doesn't break/affect existing usecases)
Testing: N/A (API changes only)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A
[Optional Runtime guard:]
Related #36442
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
Optional API Considerations:

  • RemoteAddressMatch rate limit action will cater to usecases that need to match on remote address.
  • Need to enhance substitution formatter to support %MASKED_REMOTE_ADDRESS(prefix_len)%.
  • Reusing existing type.matcher.v3.AddressMatcher. Need to implement invert_match in existing usage at FilterStateIpRangeMatcher::match.

@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @adisuissa
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #42845 was opened by rudrakhp.

see: more, trace.

Copy link
Copy Markdown
Member

@agrawroh agrawroh left a comment

Choose a reason for hiding this comment

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

Just curios, why can't we use the existing Dynamic Metadata for this? It should be trivial to write Dynamic Metadata for Remote Address and use that instead right?

@rudrakhp
Copy link
Copy Markdown
Member Author

rudrakhp commented Jan 5, 2026

@agrawroh the challenge here is not to apply rate limits to remote address ,in fact we already have the RemoteAddress rate limit action for this and can also use GenericKey with CEL without any dynamic metadata. But the usecase here is to apply different rate limits to remote addresses matching on some CIDRs. See the referred issue #36442 and also the related envoyproxy/gateway#4385 issue.

@rudrakhp rudrakhp requested a review from agrawroh January 5, 2026 04:05
Copy link
Copy Markdown
Member

@wbpcode wbpcode left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution and some comments are added.

Comment thread api/envoy/config/route/v3/route_components.proto Outdated
Comment thread api/envoy/config/route/v3/route_components.proto
@rudrakhp rudrakhp requested a review from wbpcode January 6, 2026 04:45
@rudrakhp
Copy link
Copy Markdown
Member Author

/retest

Copy link
Copy Markdown
Contributor

@adisuissa adisuissa left a comment

Choose a reason for hiding this comment

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

Thanks!
I think that matching is a good feature to have, I just wonder whether it could be more generic.


// [#not-implemented-hide:]
// Rate limit on remote address match.
RemoteAddressMatch remote_address_match = 13;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this new field is confusing because there are already remote_address and remote_address_match. I think calrifying the reasoning behind this feature is the first step. I'm not an expert in this domain, but I would suggest one of the following:

  1. consider adding options to RemoteAddress and MaskedRemoteAddress that enables the matching (the reasoning behind this is that I think that matching is more generic and orthogonal to whether the matched object is a remote address, a request header, etc).
  2. See if this should be a typed-extension (using the extension field).

cc @wbpcode due to the comment in #36442

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@adisuissa thanks for the comment. This is supposed to handle all the remote address matching usecases in a generic way by leveraging CEL and substitution formatting in descriptor_value. For example:

  • Using %DOWNSTREAM_REMOTE_ADDRESS% here will handle the existing RemoteAddress usecase with CIDR matching.
  • We might need to introduce formatter like %MASKED_DOWNSTREAM_REMOTE_ADDRESS(len)% to handle MaskedRemoteAddress usecase with CIDR matching. See feat: add formatters for masked IP addresses #42969 .

@wbpcode is aligned with the RemoteAddressMatch approach (see comments above), if the name is confusing I will think of some alternatives.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

^ bump @adisuissa @wbpcode
How does remote_address_range_match / remote_address_value_match sound instead of remote_address_match?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@wbpcode is the expert on substitution formatters. I'm just presenting my thoughts on design and combination of features.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sure, thanks for your inputs!

Copy link
Copy Markdown
Member

@wbpcode wbpcode Jan 28, 2026

Choose a reason for hiding this comment

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

There are some similar patterns:

request_headers vs header_value_match, query_parameters vs query_parameter_value_match, the former will use the content of header/query as the descriptor value, the latter use a matcher to match the header/query's content and use some other unrelated values as descriptor value.

This is the same pattern for RemoteAddress and RemoteAddressMatch

It's hard to add match option in the RemoteAddress and get similar result.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hello, @adisuissa , is this a block point for you?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Whatever you decide.
My 2cents is that if there are repeated sub-configurations that will be needed in different places, then it suggests a design smell, but I'm not against the current suggestion.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

IMO we must mark the RemoteAddress and MaskedRemoteAddress as deprecated options after this implementation goes in. CEL should be the way forward instead of having dedicated rate limit actions for each usecase. That should also help address @adisuissa's comment regarding repeated sub-configurations.

wbpcode pushed a commit that referenced this pull request Jan 20, 2026
<!--
!!!ATTENTION!!!

If you are fixing *any* crash or *any* potential security issue, *do
not*
open a pull request in this repo. Please report the issue via emailing
envoy-security@googlegroups.com where the issue will be triaged
appropriately.
Thank you in advance for helping to keep Envoy secure.

!!!ATTENTION!!!

For an explanation of how to fill out the fields, please see the
relevant section
in
[PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md)

!!!ATTENTION!!!

Please check the [use of generative AI
policy](https://github.com/envoyproxy/envoy/blob/main/CONTRIBUTING.md?plain=1#L41).

You may use generative AI only if you fully understand the code. You
need to disclose
this usage in the PR description to ensure transparency.
-->

Commit Message: Add formatters for masked IP addresses
Additional Description: Added masked alternatives for supported
substitution formatters that return IP addresses today
Risk Level: Low
Testing: Unit testing
Docs Changes: Added the new substitution formatters to docs
Release Notes: Yes
Platform Specific Features: N/A
Related:
#42845 (comment)

Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
wbpcode
wbpcode previously approved these changes Feb 3, 2026
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
@rudrakhp rudrakhp requested a review from wbpcode February 4, 2026 06:38
@rudrakhp
Copy link
Copy Markdown
Member Author

rudrakhp commented Feb 4, 2026

/retest

@repokitteh-read-only repokitteh-read-only Bot removed the api label Feb 4, 2026
@wbpcode wbpcode merged commit 7dc9d36 into envoyproxy:main Feb 4, 2026
26 checks passed
wbpcode pushed a commit that referenced this pull request Feb 11, 2026
<!--
!!!ATTENTION!!!

If you are fixing *any* crash or *any* potential security issue, *do
not*
open a pull request in this repo. Please report the issue via emailing
envoy-security@googlegroups.com where the issue will be triaged
appropriately.
Thank you in advance for helping to keep Envoy secure.

!!!ATTENTION!!!

For an explanation of how to fill out the fields, please see the
relevant section
in
[PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md)

!!!ATTENTION!!!

Please check the [use of generative AI
policy](https://github.com/envoyproxy/envoy/blob/main/CONTRIBUTING.md?plain=1#L41).

You may use generative AI only if you fully understand the code. You
need to disclose
this usage in the PR description to ensure transparency.
-->

Commit Message:
Additional Description: Support rate limit actions on remote address
match. Includes implementation `invert_match` for address matcher.
Risk Level: Low
Testing: Unit testing
Docs Changes: n/a
Release Notes: Yes
Platform Specific Features:
[Optional Runtime guard:]
Fixes #36442 
Implements API introduced in #42845

Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
shane-yuan pushed a commit to shane-yuan/envoy that referenced this pull request Feb 11, 2026
<!--
!!!ATTENTION!!!

If you are fixing *any* crash or *any* potential security issue, *do
not*
open a pull request in this repo. Please report the issue via emailing
envoy-security@googlegroups.com where the issue will be triaged
appropriately.
Thank you in advance for helping to keep Envoy secure.

!!!ATTENTION!!!

For an explanation of how to fill out the fields, please see the
relevant section
in
[PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md)

!!!ATTENTION!!!

Please check the [use of generative AI
policy](https://github.com/envoyproxy/envoy/blob/main/CONTRIBUTING.md?plain=1#L41).

You may use generative AI only if you fully understand the code. You
need to disclose
this usage in the PR description to ensure transparency.
-->

Commit Message: Add formatters for masked IP addresses
Additional Description: Added masked alternatives for supported
substitution formatters that return IP addresses today
Risk Level: Low
Testing: Unit testing
Docs Changes: Added the new substitution formatters to docs
Release Notes: Yes
Platform Specific Features: N/A
Related:
envoyproxy#42845 (comment)

Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
shane-yuan pushed a commit to shane-yuan/envoy that referenced this pull request Feb 11, 2026
Commit Message: [api] support rate limit action based on cidr match
Additional Description: Proposed API changes to support rate limit
actions on remote address match. This includes additions of a new rate
limit action `RemoteAddressMatch` as well as inclusion of a CIDR matcher
in the `MaskedRemoteAddress` action.
Risk Level: Low (doesn't break/affect existing usecases)
Testing: N/A (API changes only)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A
[Optional Runtime guard:]
Related envoyproxy#36442
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
Optional [API
Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):
* `RemoteAddressMatch` rate limit action will cater to usecases that
need to match on remote address.
* Need to enhance substitution formatter to support
`%MASKED_REMOTE_ADDRESS(prefix_len)%`.
* Reusing existing `type.matcher.v3.AddressMatcher`. Need to implement
`invert_match` in existing usage at `FilterStateIpRangeMatcher::match`.

Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
shane-yuan pushed a commit to shane-yuan/envoy that referenced this pull request Feb 11, 2026
<!--
!!!ATTENTION!!!

If you are fixing *any* crash or *any* potential security issue, *do
not*
open a pull request in this repo. Please report the issue via emailing
envoy-security@googlegroups.com where the issue will be triaged
appropriately.
Thank you in advance for helping to keep Envoy secure.

!!!ATTENTION!!!

For an explanation of how to fill out the fields, please see the
relevant section
in
[PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md)

!!!ATTENTION!!!

Please check the [use of generative AI
policy](https://github.com/envoyproxy/envoy/blob/main/CONTRIBUTING.md?plain=1#L41).

You may use generative AI only if you fully understand the code. You
need to disclose
this usage in the PR description to ensure transparency.
-->

Commit Message:
Additional Description: Support rate limit actions on remote address
match. Includes implementation `invert_match` for address matcher.
Risk Level: Low
Testing: Unit testing
Docs Changes: n/a
Release Notes: Yes
Platform Specific Features:
[Optional Runtime guard:]
Fixes envoyproxy#36442 
Implements API introduced in envoyproxy#42845

Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
nickshokri pushed a commit to nickshokri/envoy that referenced this pull request Mar 17, 2026
Commit Message: [api] support rate limit action based on cidr match
Additional Description: Proposed API changes to support rate limit
actions on remote address match. This includes additions of a new rate
limit action `RemoteAddressMatch` as well as inclusion of a CIDR matcher
in the `MaskedRemoteAddress` action.
Risk Level: Low (doesn't break/affect existing usecases)
Testing: N/A (API changes only)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A
[Optional Runtime guard:]
Related envoyproxy#36442
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
Optional [API
Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):
* `RemoteAddressMatch` rate limit action will cater to usecases that
need to match on remote address.
* Need to enhance substitution formatter to support
`%MASKED_REMOTE_ADDRESS(prefix_len)%`.
* Reusing existing `type.matcher.v3.AddressMatcher`. Need to implement
`invert_match` in existing usage at `FilterStateIpRangeMatcher::match`.

Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
Signed-off-by: nick <nickshokri@google.com>
nickshokri pushed a commit to nickshokri/envoy that referenced this pull request Mar 17, 2026
<!--
!!!ATTENTION!!!

If you are fixing *any* crash or *any* potential security issue, *do
not*
open a pull request in this repo. Please report the issue via emailing
envoy-security@googlegroups.com where the issue will be triaged
appropriately.
Thank you in advance for helping to keep Envoy secure.

!!!ATTENTION!!!

For an explanation of how to fill out the fields, please see the
relevant section
in
[PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md)

!!!ATTENTION!!!

Please check the [use of generative AI
policy](https://github.com/envoyproxy/envoy/blob/main/CONTRIBUTING.md?plain=1#L41).

You may use generative AI only if you fully understand the code. You
need to disclose
this usage in the PR description to ensure transparency.
-->

Commit Message:
Additional Description: Support rate limit actions on remote address
match. Includes implementation `invert_match` for address matcher.
Risk Level: Low
Testing: Unit testing
Docs Changes: n/a
Release Notes: Yes
Platform Specific Features:
[Optional Runtime guard:]
Fixes envoyproxy#36442
Implements API introduced in envoyproxy#42845

Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
Signed-off-by: nick <nickshokri@google.com>
nickshokri pushed a commit to nickshokri/envoy that referenced this pull request Mar 17, 2026
Commit Message: [api] support rate limit action based on cidr match
Additional Description: Proposed API changes to support rate limit
actions on remote address match. This includes additions of a new rate
limit action `RemoteAddressMatch` as well as inclusion of a CIDR matcher
in the `MaskedRemoteAddress` action.
Risk Level: Low (doesn't break/affect existing usecases)
Testing: N/A (API changes only)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A
[Optional Runtime guard:]
Related envoyproxy#36442
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
Optional [API
Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):
* `RemoteAddressMatch` rate limit action will cater to usecases that
need to match on remote address.
* Need to enhance substitution formatter to support
`%MASKED_REMOTE_ADDRESS(prefix_len)%`.
* Reusing existing `type.matcher.v3.AddressMatcher`. Need to implement
`invert_match` in existing usage at `FilterStateIpRangeMatcher::match`.

Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
Signed-off-by: nick <nickshokri@google.com>
nickshokri pushed a commit to nickshokri/envoy that referenced this pull request Mar 17, 2026
<!--
!!!ATTENTION!!!

If you are fixing *any* crash or *any* potential security issue, *do
not*
open a pull request in this repo. Please report the issue via emailing
envoy-security@googlegroups.com where the issue will be triaged
appropriately.
Thank you in advance for helping to keep Envoy secure.

!!!ATTENTION!!!

For an explanation of how to fill out the fields, please see the
relevant section
in
[PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md)

!!!ATTENTION!!!

Please check the [use of generative AI
policy](https://github.com/envoyproxy/envoy/blob/main/CONTRIBUTING.md?plain=1#L41).

You may use generative AI only if you fully understand the code. You
need to disclose
this usage in the PR description to ensure transparency.
-->

Commit Message:
Additional Description: Support rate limit actions on remote address
match. Includes implementation `invert_match` for address matcher.
Risk Level: Low
Testing: Unit testing
Docs Changes: n/a
Release Notes: Yes
Platform Specific Features:
[Optional Runtime guard:]
Fixes envoyproxy#36442
Implements API introduced in envoyproxy#42845

Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
Signed-off-by: nick <nickshokri@google.com>
grnmeira pushed a commit to grnmeira/envoy that referenced this pull request Mar 20, 2026
<!--
!!!ATTENTION!!!

If you are fixing *any* crash or *any* potential security issue, *do
not*
open a pull request in this repo. Please report the issue via emailing
envoy-security@googlegroups.com where the issue will be triaged
appropriately.
Thank you in advance for helping to keep Envoy secure.

!!!ATTENTION!!!

For an explanation of how to fill out the fields, please see the
relevant section
in
[PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md)

!!!ATTENTION!!!

Please check the [use of generative AI
policy](https://github.com/envoyproxy/envoy/blob/main/CONTRIBUTING.md?plain=1#L41).

You may use generative AI only if you fully understand the code. You
need to disclose
this usage in the PR description to ensure transparency.
-->

Commit Message: Add formatters for masked IP addresses
Additional Description: Added masked alternatives for supported
substitution formatters that return IP addresses today
Risk Level: Low
Testing: Unit testing
Docs Changes: Added the new substitution formatters to docs
Release Notes: Yes
Platform Specific Features: N/A
Related:
envoyproxy#42845 (comment)

Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
Signed-off-by: Gustavo <grnmeira@gmail.com>
grnmeira pushed a commit to grnmeira/envoy that referenced this pull request Mar 20, 2026
Commit Message: [api] support rate limit action based on cidr match
Additional Description: Proposed API changes to support rate limit
actions on remote address match. This includes additions of a new rate
limit action `RemoteAddressMatch` as well as inclusion of a CIDR matcher
in the `MaskedRemoteAddress` action.
Risk Level: Low (doesn't break/affect existing usecases)
Testing: N/A (API changes only)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A
[Optional Runtime guard:]
Related envoyproxy#36442
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
Optional [API
Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):
* `RemoteAddressMatch` rate limit action will cater to usecases that
need to match on remote address.
* Need to enhance substitution formatter to support
`%MASKED_REMOTE_ADDRESS(prefix_len)%`.
* Reusing existing `type.matcher.v3.AddressMatcher`. Need to implement
`invert_match` in existing usage at `FilterStateIpRangeMatcher::match`.

Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
Signed-off-by: Gustavo <grnmeira@gmail.com>
fishcakez pushed a commit to fishcakez/envoy that referenced this pull request Mar 25, 2026
<!--
!!!ATTENTION!!!

If you are fixing *any* crash or *any* potential security issue, *do
not*
open a pull request in this repo. Please report the issue via emailing
envoy-security@googlegroups.com where the issue will be triaged
appropriately.
Thank you in advance for helping to keep Envoy secure.

!!!ATTENTION!!!

For an explanation of how to fill out the fields, please see the
relevant section
in
[PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md)

!!!ATTENTION!!!

Please check the [use of generative AI
policy](https://github.com/envoyproxy/envoy/blob/main/CONTRIBUTING.md?plain=1#L41).

You may use generative AI only if you fully understand the code. You
need to disclose
this usage in the PR description to ensure transparency.
-->

Commit Message:
Additional Description: Support rate limit actions on remote address
match. Includes implementation `invert_match` for address matcher.
Risk Level: Low
Testing: Unit testing
Docs Changes: n/a
Release Notes: Yes
Platform Specific Features:
[Optional Runtime guard:]
Fixes envoyproxy#36442 
Implements API introduced in envoyproxy#42845

Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
krinkinmu pushed a commit to grnmeira/envoy that referenced this pull request Apr 20, 2026
<!--
!!!ATTENTION!!!

If you are fixing *any* crash or *any* potential security issue, *do
not*
open a pull request in this repo. Please report the issue via emailing
envoy-security@googlegroups.com where the issue will be triaged
appropriately.
Thank you in advance for helping to keep Envoy secure.

!!!ATTENTION!!!

For an explanation of how to fill out the fields, please see the
relevant section
in
[PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md)

!!!ATTENTION!!!

Please check the [use of generative AI
policy](https://github.com/envoyproxy/envoy/blob/main/CONTRIBUTING.md?plain=1#L41).

You may use generative AI only if you fully understand the code. You
need to disclose
this usage in the PR description to ensure transparency.
-->

Commit Message:
Additional Description: Support rate limit actions on remote address
match. Includes implementation `invert_match` for address matcher.
Risk Level: Low
Testing: Unit testing
Docs Changes: n/a
Release Notes: Yes
Platform Specific Features:
[Optional Runtime guard:]
Fixes envoyproxy#36442 
Implements API introduced in envoyproxy#42845

Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants