From c105005da2bc5faa27ece6a2ba48c6ba0d62f53d Mon Sep 17 00:00:00 2001 From: Zach Reyes <39203661+zasweq@users.noreply.github.com> Date: Wed, 3 Nov 2021 13:25:05 -0400 Subject: [PATCH] xds: NACK missing route specifier server side (#4925) * xds: NACK missing route specifier server side --- xds/internal/xdsclient/client.go | 4 +-- xds/internal/xdsclient/filter_chain.go | 3 +- xds/internal/xdsclient/filter_chain_test.go | 34 +++++++++++++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/xds/internal/xdsclient/client.go b/xds/internal/xdsclient/client.go index 8b7d4bad0..39f1df215 100644 --- a/xds/internal/xdsclient/client.go +++ b/xds/internal/xdsclient/client.go @@ -206,12 +206,12 @@ type ListenerUpdate struct { // RouteConfigName is the route configuration name corresponding to the // target which is being watched through LDS. // - // Only one of RouteConfigName and InlineRouteConfig is set. + // Exactly one of RouteConfigName and InlineRouteConfig is set. RouteConfigName string // InlineRouteConfig is the inline route configuration (RDS response) // returned inside LDS. // - // Only one of RouteConfigName and InlineRouteConfig is set. + // Exactly one of RouteConfigName and InlineRouteConfig is set. InlineRouteConfig *RouteConfigUpdate // MaxStreamDuration contains the HTTP connection manager's diff --git a/xds/internal/xdsclient/filter_chain.go b/xds/internal/xdsclient/filter_chain.go index f2b29f52a..7503e0e48 100644 --- a/xds/internal/xdsclient/filter_chain.go +++ b/xds/internal/xdsclient/filter_chain.go @@ -637,8 +637,7 @@ func processNetworkFilters(filters []*v3listenerpb.Filter) (*FilterChain, error) } filterChain.InlineRouteConfig = &routeU case nil: - // No-op, as no route specifier is a valid configuration on - // the server side. + return nil, fmt.Errorf("no RouteSpecifier: %+v", hcm) default: return nil, fmt.Errorf("unsupported type %T for RouteSpecifier", hcm.RouteSpecifier) } diff --git a/xds/internal/xdsclient/filter_chain_test.go b/xds/internal/xdsclient/filter_chain_test.go index 2cc73b0a5..ae1035e76 100644 --- a/xds/internal/xdsclient/filter_chain_test.go +++ b/xds/internal/xdsclient/filter_chain_test.go @@ -770,6 +770,40 @@ func TestNewFilterChainImpl_Failure_BadRouteUpdate(t *testing.T) { lis *v3listenerpb.Listener wantErr string }{ + { + name: "missing-route-specifier", + lis: &v3listenerpb.Listener{ + FilterChains: []*v3listenerpb.FilterChain{ + { + Name: "filter-chain-1", + Filters: []*v3listenerpb.Filter{ + { + Name: "hcm", + ConfigType: &v3listenerpb.Filter_TypedConfig{ + + TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + HttpFilters: []*v3httppb.HttpFilter{emptyRouterFilter}, + }), + }, + }, + }, + }, + }, + DefaultFilterChain: &v3listenerpb.FilterChain{ + Filters: []*v3listenerpb.Filter{ + { + Name: "hcm", + ConfigType: &v3listenerpb.Filter_TypedConfig{ + TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + HttpFilters: []*v3httppb.HttpFilter{emptyRouterFilter}, + }), + }, + }, + }, + }, + }, + wantErr: "no RouteSpecifier", + }, { name: "not-ads", lis: &v3listenerpb.Listener{