envoyproxy / envoyproxy/envoy

Matcher-based Listener filters

Open
#35,958 28 comments 0 reactions 1 assignee Assigned to @krinkinmu View on GitHub
area/matching area/tls_inspector enhancement no stalebot
Dominant language
C++
Stars
28.9k
Forks
5.6k
Avg merge
1d 20h
Merged PRs (30d)
428

Description

*Title*: Matcher-based Listener filters

*Description*:
Currently, we use tls_inspector and http_inspector in a variety of places to inspect traffic. The problem with these is its not safe to unconditionally enable them, as some protocols are "server first" protocols where the server sends the first bytes of traffic.

In the past, we worked around this by using the `FilterDisabled` field on the listener filter. For our simple use case we had at the time, this was sufficient because we only needed to classify based on port. We used many bind_to_port=false listeners, rather than 1 large listener with a match on IP, effectively giving us an IP-match implicitly

We are moving towards a more complex matching model, reliant on a single listener with lots of chains and using the filter_chain_matcher API. This breaks our ability to disable the filter appropriately.

## Option 1: integrated into the matcher
In the ideal scenario, the listener filters could be enable in the matching tree itself:
```yaml
filterChainMatcher:
matcherTree:
input:
name: ip
rangeMatchers:
- ranges:
- addressPrefix: 240.240.0.2
onMatch:
listenerFilters: ["http_inspector"] # THIS WOULD BE NEW
exactMatchMap:
input:
name: port
map:
"465":
action: cluster-465
"587":
action: cluster-587
```

Basically we do some preliminary matching, then run the listener filter, then can do more matching. Obviously the user will need to ensure they run the filter before matching the output of it.

## Option 2: a new dedicated match

Rather than the `FilterDisabled` approach which just handles ports, we could have a `FilterDisabledMatcher` or equivalent which uses the new matcher framework.

The downside of this approach is that it requires generating a mirror matcher tree. This may be expensive and complex to maintain

cc @keithmattix

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.