Skip to content

ip tagging: filter skeleton#998

Merged
htuch merged 22 commits intomasterfrom
ip-tagging-filter
Jun 2, 2017
Merged

ip tagging: filter skeleton#998
htuch merged 22 commits intomasterfrom
ip-tagging-filter

Conversation

@junr03
Copy link
Copy Markdown
Member

@junr03 junr03 commented May 19, 2017

@ccaraman

Here is the skeleton for the ip tagging filter. Will write tests, and actual filter code once we have the trie.

#include "common/http/filter/ip_tagging_filter.h"
#include "common/json/config_schemas.h"

namespace Envoy {
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.

@ccaraman
Copy link
Copy Markdown
Contributor

@junr03 I'll take a look later today.

static IpTaggingFilterStats generateStats(const std::string& prefix, Stats::Store& store);

//Trie ip_tags_;
Runtime::Loader& runtime_;
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.

Runtime isn't needed for this filter at the moment.

"type" : "string",
"enum" : ["internal", "external", "both"]
},
"ip_tags" : {
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.

ip_tags is supposed to be an array of ip_tag_name and ip_lists.

Comment thread source/common/json/config_schemas.cc Outdated
"items" : {
"type": "string",
"oneOf": [
{ "format": "host-name" },
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.

We don't have plans to support host-name for ip tagging.

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.

In fact I think we need to change this to a regex match, because as far as I can tell there is no pre determined format for a CIDR range. And what this is is actually an array of cidr ranges, isn't it?

/**
* All stats for the ip tagging filter. @see stats_macros.h
*/
// clang-format off
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.

At the moment, there are no specific IP Tag stats. This can be removed for now.

Comment thread source/common/json/config_schemas.cc Outdated
"items" : {
"type": "string",
"oneOf": [
{ "pattern" : "^([0-9]{1,3}\.){3}[0-9]{1,3}(\/([0-9]|[1-2][0-9]|3[0-2]))?$" },
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.

Why use these patterns instead of ipv6 and ipv4 like you had before?

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.

from the comment above: In fact I think we need to change this to a regex match, because as far as I can tell there is no pre determined format for a CIDR range. And what this is is actually an array of cidr ranges, isn't it?

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.

I stand corrected. The json schema format rule includes the range.

extra data. This is useful to prevent against DDoS.

**Note**: this filter is under active development, and currently does not perform any tagging on requests. In other
words, installing this filter is a nop in the filter chain.
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.

nit: no-op or no op

}

request_type:
(optional, string) The type of requests the filter should apply to. ``external``, ``internal``, or ``both``.
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.

Can you expand the about what is deemed internal/external? ie take it from the rl filter.

Defaults to ``both``.

ip_tags:
(optional, array) Specifies the list of ip tags to set for a request.
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.

(optional, array) + in other places.


ip_list:
(required, list of strings) A list of IP address and subnet masks that will be tagged with the ``ip_tag_name``. Both
IPv4, and IPv6 CIDR addresses are allowed here. No newline at end of file
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.

no need for comma

}

ip_tag_name:
(required, string) Specifies the ip tag name to apply. The names will be added to the request's ``x-envoy-ip-tag``
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.

put some docs in place for the HTTP header "x-envoy-ip-tag"


ip_tag_name:
(required, string) Specifies the ip tag name to apply. The names will be added to the request's ``x-envoy-ip-tag``
header if the request's XFF address belongs to a range present in the ``ip_list``
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.

XFF can contain multiple addresses, can you put more details around if we look at the last hop address or not.

Comment thread source/server/config/http/ip_tagging.cc Outdated
namespace Server {
namespace Configuration {

HttpFilterFactoryCb IpTaggingFilterConfig::tryCreateFilterFactory(HttpFilterType type,
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.

can you refactor this to use a new method for filter registration, see 3a466c3#diff-12a4439b6c76df424840b91ab1cf3789R14

Comment thread source/server/config/http/ip_tagging.cc Outdated
std::string IpTaggingFilterConfig::name() { return "ip_tagging"; }

/**
* Static registration for the ip tagging filter. @see RegisterHttpFilterConfigFactory.
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.

RegisterHttpFilterConfigFactory is not correct ;)

Jose Nino added 2 commits May 30, 2017 13:49
Comment thread source/common/json/config_schemas.cc Outdated
"items" : {
"type": "string",
"anyOf": [
{ "format" : "ipv4" },
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.

can you add a test when format does not conform ipv4/ipv6?

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.

on adding this test it looks like we are not actually enforcing this format. I verified with tests that exercise this https://github.com/lyft/envoy/blob/master/source/common/json/config_schemas.cc#L79. The schema validator lets the wrong string through, and it is envoy code that catches it. Specifically: https://github.com/lyft/envoy/blob/master/source/common/network/utility.cc#L28

Comment thread test/server/config/http/config_test.cc Outdated
Json::ObjectSharedPtr json_config = Json::Factory::loadFromString(json_string);
NiceMock<MockInstance> server;
IpTaggingFilterConfig factory;
EXPECT_THROW(factory.tryCreateFilterFactory(HttpFilterType::Decoder, "ip_tagging", *json_config,
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.

createFilterFactory ?

Ip tagging filter
====================

This is a filter which enables Envoy to tag requests with extra information such as location, cloud source and any
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.

is a HTTP filter

Ip tagging filter
====================

This is a filter which enables Envoy to tag requests with extra information such as location, cloud source and any
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.

oxford comma?

ccaraman
ccaraman previously approved these changes Jun 1, 2017
Copy link
Copy Markdown
Contributor

@ccaraman ccaraman left a comment

Choose a reason for hiding this comment

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

LGTM

@junr03
Copy link
Copy Markdown
Member Author

junr03 commented Jun 1, 2017

@htuch this is just the skeleton for the forthcoming IP Tagging Filter described in #1001. We are going to add the Trie and functionality in subsequent PRs

@htuch
Copy link
Copy Markdown
Member

htuch commented Jun 2, 2017

@junr03 Sure. Can you keep in mind my request in #1001 that we make the trie generic enough to be useful in the Listener prefix range matching when we do LDS? Thanks.

@htuch htuch merged commit a75dced into master Jun 2, 2017
@htuch htuch deleted the ip-tagging-filter branch June 2, 2017 13:54
@mattklein123
Copy link
Copy Markdown
Member

@junr03 @ccaraman even though this is not used yet and we are going to pause work for a little bit, can one of you please get coverage on the IP tagging filter files up to 100%. Thanks. :)

@junr03
Copy link
Copy Markdown
Member Author

junr03 commented Jun 13, 2017

@mattklein123 @ccaraman I can take care of that.

jpsim pushed a commit that referenced this pull request Nov 28, 2022
Description: This job seems to get cancelled frequently at the 45-minute mark, which just means another 45-minute cycle to run it again. Increase to 60 to hopefully get it to complete consistently.

Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: JP Simard <jp@jpsim.com>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
Description: This job seems to get cancelled frequently at the 45-minute mark, which just means another 45-minute cycle to run it again. Increase to 60 to hopefully get it to complete consistently.

Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: JP Simard <jp@jpsim.com>
mathetake added a commit that referenced this pull request Mar 3, 2026
**Description**

This removes the input api schema field in the filter config as it
shouldn't be a config and currently it is not really used. The input
schema is already determined by the specific API endpoint being used by
the Envoy AI Gateway, such as the unified OpenAI API at
`v1/chat/completions` or later the Anthropic Messages API we are
supporting at `anthropic/v1/messages`. This removes the confusion when
we are going to support other vendor pass through APIs like Anthropic.
We may need to consider deprecating the input `APISchema` defined on
`AIGatewayRoute` which is also not really used.

Related Issue: #847

---------

Signed-off-by: Dan Sun <dsun20@bloomberg.net>
Co-authored-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
mathetake added a commit that referenced this pull request Mar 3, 2026
**Description**
This removes the unused "schema" API from AIGatewayRoute as a
preparation for transparent passthrough etc support for non-OpenAI SDK
support as well as the prefix configuration #1002

**Related Issues/PRs (if applicable)**
Follow up on #998 
Necessary for #1002

---------

Signed-off-by: Takeshi Yoneda <t.y.mathetake@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.

5 participants