Skip to content

Commit a0bed72

Browse files
authored
xds: add http filters to FilterChain matching (#4595)
* Add HTTP Filters to FilterChain
1 parent 0a8c637 commit a0bed72

File tree

6 files changed

+538
-117
lines changed

6 files changed

+538
-117
lines changed

xds/internal/server/listener_wrapper_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030

3131
v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
3232
v3listenerpb "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3"
33+
v3httppb "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3"
3334
v3tlspb "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/tls/v3"
3435
wrapperspb "github.com/golang/protobuf/ptypes/wrappers"
3536
"google.golang.org/grpc/internal/grpctest"
@@ -82,6 +83,14 @@ var listenerWithFilterChains = &v3listenerpb.Listener{
8283
}),
8384
},
8485
},
86+
Filters: []*v3listenerpb.Filter{
87+
{
88+
Name: "filter-1",
89+
ConfigType: &v3listenerpb.Filter_TypedConfig{
90+
TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{}),
91+
},
92+
},
93+
},
8594
},
8695
},
8796
}

xds/internal/xdsclient/filter_chain.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
v3listenerpb "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3"
2727
v3tlspb "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/tls/v3"
2828
"github.com/golang/protobuf/proto"
29-
3029
"google.golang.org/grpc/xds/internal/version"
3130
)
3231

@@ -50,14 +49,11 @@ const (
5049

5150
// FilterChain captures information from within a FilterChain message in a
5251
// Listener resource.
53-
//
54-
// Currently, this simply contains the security configuration found in the
55-
// 'transport_socket' field of the filter chain. The actual set of filters
56-
// associated with this filter chain are not captured here, since we do not
57-
// support these filters on the server-side yet.
5852
type FilterChain struct {
5953
// SecurityCfg contains transport socket security configuration.
6054
SecurityCfg *SecurityConfig
55+
// HTTPFilters represent the HTTP Filters that comprise this FilterChain.
56+
HTTPFilters []HTTPFilter
6157
}
6258

6359
// SourceType specifies the connection source IP match type.
@@ -395,16 +391,20 @@ func (fci *FilterChainManager) addFilterChainsForSourcePorts(srcEntry *sourcePre
395391
}
396392

397393
// filterChainFromProto extracts the relevant information from the FilterChain
398-
// proto and stores it in our internal representation. Currently, we only
399-
// process the security configuration stored in the transport_socket field.
394+
// proto and stores it in our internal representation.
400395
func filterChainFromProto(fc *v3listenerpb.FilterChain) (*FilterChain, error) {
396+
httpFilters, err := processNetworkFilters(fc.GetFilters())
397+
if err != nil {
398+
return nil, err
399+
}
400+
filterChain := &FilterChain{HTTPFilters: httpFilters}
401401
// If the transport_socket field is not specified, it means that the control
402402
// plane has not sent us any security config. This is fine and the server
403403
// will use the fallback credentials configured as part of the
404404
// xdsCredentials.
405405
ts := fc.GetTransportSocket()
406406
if ts == nil {
407-
return &FilterChain{}, nil
407+
return filterChain, nil
408408
}
409409
if name := ts.GetName(); name != transportSocketName {
410410
return nil, fmt.Errorf("transport_socket field has unexpected name: %s", name)
@@ -431,7 +431,8 @@ func filterChainFromProto(fc *v3listenerpb.FilterChain) (*FilterChain, error) {
431431
if sc.RequireClientCert && sc.RootInstanceName == "" {
432432
return nil, errors.New("security configuration on the server-side does not contain root certificate provider instance name, but require_client_cert field is set")
433433
}
434-
return &FilterChain{SecurityCfg: sc}, nil
434+
filterChain.SecurityCfg = sc
435+
return filterChain, nil
435436
}
436437

437438
// FilterChainLookupParams wraps parameters to be passed to Lookup.

0 commit comments

Comments
 (0)