xds_listener.cc
Go to the documentation of this file.
1 //
2 // Copyright 2018 gRPC authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
18 
20 
21 #include <stdint.h>
22 
23 #include <set>
24 #include <type_traits>
25 #include <utility>
26 
27 #include "absl/memory/memory.h"
28 #include "absl/status/status.h"
29 #include "absl/strings/str_cat.h"
30 #include "absl/strings/str_format.h"
31 #include "absl/strings/str_join.h"
47 #include "upb/text_encode.h"
48 #include "upb/upb.h"
49 
50 #include <grpc/support/log.h>
51 
61 #include "src/core/lib/json/json.h"
63 
64 namespace grpc_core {
65 
66 //
67 // XdsListenerResource::DownstreamTlsContext
68 //
69 
71  return absl::StrFormat("common_tls_context=%s, require_client_certificate=%s",
73  require_client_certificate ? "true" : "false");
74 }
75 
77  return common_tls_context.Empty();
78 }
79 
80 //
81 // XdsListenerResource::HttpConnectionManager
82 //
83 
85  std::vector<std::string> contents;
86  contents.push_back(absl::StrFormat(
87  "route_config_name=%s",
88  !route_config_name.empty() ? route_config_name.c_str() : "<inlined>"));
89  contents.push_back(absl::StrFormat("http_max_stream_duration=%s",
90  http_max_stream_duration.ToString()));
91  if (rds_update.has_value()) {
92  contents.push_back(
93  absl::StrFormat("rds_update=%s", rds_update->ToString()));
94  }
95  if (!http_filters.empty()) {
96  std::vector<std::string> filter_strings;
97  for (const auto& http_filter : http_filters) {
98  filter_strings.push_back(http_filter.ToString());
99  }
100  contents.push_back(absl::StrCat("http_filters=[",
101  absl::StrJoin(filter_strings, ", "), "]"));
102  }
103  return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
104 }
105 
106 //
107 // XdsListenerResource::HttpFilter
108 //
109 
111  const {
112  return absl::StrCat("{name=", name, ", config=", config.ToString(), "}");
113 }
114 
115 //
116 // XdsListenerResource::FilterChainData
117 //
118 
120  return absl::StrCat(
121  "{downstream_tls_context=", downstream_tls_context.ToString(),
122  " http_connection_manager=", http_connection_manager.ToString(), "}");
123 }
124 
125 //
126 // XdsListenerResource::FilterChainMap::CidrRange
127 //
128 
130  auto addr_str = grpc_sockaddr_to_string(&address, false);
131  return absl::StrCat(
132  "{address_prefix=",
133  addr_str.ok() ? addr_str.value() : addr_str.status().ToString(),
134  ", prefix_len=", prefix_len, "}");
135 }
136 
137 //
138 // FilterChain
139 //
140 
141 struct FilterChain {
143  uint32_t destination_port = 0;
144  std::vector<XdsListenerResource::FilterChainMap::CidrRange> prefix_ranges;
147  std::vector<XdsListenerResource::FilterChainMap::CidrRange>
149  std::vector<uint32_t> source_ports;
150  std::vector<std::string> server_names;
152  std::vector<std::string> application_protocols;
153 
154  std::string ToString() const;
155  } filter_chain_match;
156 
157  std::shared_ptr<XdsListenerResource::FilterChainData> filter_chain_data;
158 };
159 
161  std::vector<std::string> contents;
162  if (destination_port != 0) {
163  contents.push_back(absl::StrCat("destination_port=", destination_port));
164  }
165  if (!prefix_ranges.empty()) {
166  std::vector<std::string> prefix_ranges_content;
167  for (const auto& range : prefix_ranges) {
168  prefix_ranges_content.push_back(range.ToString());
169  }
170  contents.push_back(absl::StrCat(
171  "prefix_ranges={", absl::StrJoin(prefix_ranges_content, ", "), "}"));
172  }
174  kSameIpOrLoopback) {
175  contents.push_back("source_type=SAME_IP_OR_LOOPBACK");
176  } else if (source_type == XdsListenerResource::FilterChainMap::
177  ConnectionSourceType::kExternal) {
178  contents.push_back("source_type=EXTERNAL");
179  }
180  if (!source_prefix_ranges.empty()) {
181  std::vector<std::string> source_prefix_ranges_content;
182  for (const auto& range : source_prefix_ranges) {
183  source_prefix_ranges_content.push_back(range.ToString());
184  }
185  contents.push_back(
186  absl::StrCat("source_prefix_ranges={",
187  absl::StrJoin(source_prefix_ranges_content, ", "), "}"));
188  }
189  if (!source_ports.empty()) {
190  contents.push_back(
191  absl::StrCat("source_ports={", absl::StrJoin(source_ports, ", "), "}"));
192  }
193  if (!server_names.empty()) {
194  contents.push_back(
195  absl::StrCat("server_names={", absl::StrJoin(server_names, ", "), "}"));
196  }
197  if (!transport_protocol.empty()) {
198  contents.push_back(absl::StrCat("transport_protocol=", transport_protocol));
199  }
200  if (!application_protocols.empty()) {
201  contents.push_back(absl::StrCat("application_protocols={",
202  absl::StrJoin(application_protocols, ", "),
203  "}"));
204  }
205  return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
206 }
207 
208 //
209 // XdsListenerResource::FilterChainMap
210 //
211 
213  std::vector<std::string> contents;
214  for (const auto& destination_ip : destination_ip_vector) {
215  for (int source_type = 0; source_type < 3; ++source_type) {
216  for (const auto& source_ip :
217  destination_ip.source_types_array[source_type]) {
218  for (const auto& source_port_pair : source_ip.ports_map) {
219  FilterChain::FilterChainMatch filter_chain_match;
220  if (destination_ip.prefix_range.has_value()) {
221  filter_chain_match.prefix_ranges.push_back(
222  *destination_ip.prefix_range);
223  }
224  filter_chain_match.source_type = static_cast<
226  source_type);
227  if (source_ip.prefix_range.has_value()) {
228  filter_chain_match.source_prefix_ranges.push_back(
229  *source_ip.prefix_range);
230  }
231  if (source_port_pair.first != 0) {
232  filter_chain_match.source_ports.push_back(source_port_pair.first);
233  }
234  contents.push_back(absl::StrCat(
235  "{filter_chain_match=", filter_chain_match.ToString(),
236  ", filter_chain=", source_port_pair.second.data->ToString(),
237  "}"));
238  }
239  }
240  }
241  }
242  return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
243 }
244 
245 //
246 // XdsListenerResource
247 //
248 
250  std::vector<std::string> contents;
252  contents.push_back(absl::StrCat("address=", address));
253  contents.push_back(
254  absl::StrCat("filter_chain_map=", filter_chain_map.ToString()));
255  if (default_filter_chain.has_value()) {
256  contents.push_back(absl::StrCat("default_filter_chain=",
257  default_filter_chain->ToString()));
258  }
259  } else if (type == ListenerType::kHttpApiListener) {
260  contents.push_back(absl::StrFormat("http_connection_manager=%s",
262  }
263  return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
264 }
265 
266 //
267 // XdsListenerResourceType
268 //
269 
270 namespace {
271 
272 void MaybeLogHttpConnectionManager(
275  http_connection_manager_config) {
276  if (GRPC_TRACE_FLAG_ENABLED(*context.tracer) &&
278  const upb_MessageDef* msg_type =
280  context.symtab);
281  char buf[10240];
282  upb_TextEncode(http_connection_manager_config, msg_type, nullptr, 0, buf,
283  sizeof(buf));
284  gpr_log(GPR_DEBUG, "[xds_client %p] HttpConnectionManager: %s",
285  context.client, buf);
286  }
287 }
288 
289 grpc_error_handle HttpConnectionManagerParse(
290  bool is_client, const XdsEncodingContext& context,
292  http_connection_manager_proto,
293  bool is_v2,
294  XdsListenerResource::HttpConnectionManager* http_connection_manager) {
295  MaybeLogHttpConnectionManager(context, http_connection_manager_proto);
296  // NACK a non-zero `xff_num_trusted_hops` and a `non-empty
297  // original_ip_detection_extensions` as mentioned in
298  // https://github.com/grpc/proposal/blob/master/A41-xds-rbac.md
300  http_connection_manager_proto) != 0) {
302  "'xff_num_trusted_hops' must be zero");
303  }
305  http_connection_manager_proto)) {
307  "'original_ip_detection_extensions' must be empty");
308  }
309  // Obtain max_stream_duration from Http Protocol Options.
312  http_connection_manager_proto);
313  if (options != nullptr) {
314  const google_protobuf_Duration* duration =
316  if (duration != nullptr) {
318  ParseDuration(duration);
319  }
320  }
321  // Parse filters.
322  if (!is_v2) {
323  size_t num_filters = 0;
324  const auto* http_filters =
326  http_connection_manager_proto, &num_filters);
327  std::set<absl::string_view> names_seen;
328  for (size_t i = 0; i < num_filters; ++i) {
329  const auto* http_filter = http_filters[i];
332  http_filter));
333  if (name.empty()) {
335  absl::StrCat("empty filter name at index ", i));
336  }
337  if (names_seen.find(name) != names_seen.end()) {
339  absl::StrCat("duplicate HTTP filter name: ", name));
340  }
341  names_seen.insert(name);
342  const bool is_optional =
344  http_filter);
345  const google_protobuf_Any* any =
347  http_filter);
348  if (any == nullptr) {
349  if (is_optional) continue;
351  absl::StrCat("no filter config specified for filter name ", name));
352  }
353  auto filter_type = ExtractExtensionTypeName(context, any);
354  if (!filter_type.ok()) {
355  return absl_status_to_grpc_error(filter_type.status());
356  }
357  const XdsHttpFilterImpl* filter_impl =
358  XdsHttpFilterRegistry::GetFilterForType(filter_type->type);
359  if (filter_impl == nullptr) {
360  if (is_optional) continue;
362  "no filter registered for config type ", filter_type->type));
363  }
364  if ((is_client && !filter_impl->IsSupportedOnClients()) ||
365  (!is_client && !filter_impl->IsSupportedOnServers())) {
366  if (is_optional) continue;
368  "Filter %s is not supported on %s", filter_type->type,
369  is_client ? "clients" : "servers"));
370  }
372  filter_impl->GenerateFilterConfig(google_protobuf_Any_value(any),
373  context.arena);
374  if (!filter_config.ok()) {
376  "filter config for type ", filter_type->type,
377  " failed to parse: ", StatusToString(filter_config.status())));
378  }
380  XdsListenerResource::HttpConnectionManager::HttpFilter{
381  std::string(name), std::move(*filter_config)});
382  }
383  if (http_connection_manager->http_filters.empty()) {
385  "Expected at least one HTTP filter");
386  }
387  // Make sure that the last filter is terminal and non-last filters are
388  // non-terminal. Note that this check is being performed in a separate loop
389  // to take care of the case where there are two terminal filters in the list
390  // out of which only one gets added in the final list.
391  for (const auto& http_filter : http_connection_manager->http_filters) {
392  const XdsHttpFilterImpl* filter_impl =
394  http_filter.config.config_proto_type_name);
395  if (&http_filter != &http_connection_manager->http_filters.back()) {
396  // Filters before the last filter must not be terminal.
397  if (filter_impl->IsTerminalFilter()) {
399  absl::StrCat("terminal filter for config type ",
400  http_filter.config.config_proto_type_name,
401  " must be the last filter in the chain"));
402  }
403  } else {
404  // The last filter must be terminal.
405  if (!filter_impl->IsTerminalFilter()) {
407  absl::StrCat("non-terminal filter for config type ",
408  http_filter.config.config_proto_type_name,
409  " is the last filter in the chain"));
410  }
411  }
412  }
413  } else {
414  // If using a v2 config, we just hard-code a list containing only the
415  // router filter without actually looking at the config. This ensures
416  // that the right thing happens in the xds resolver without having
417  // to expose whether the resource we received was v2 or v3.
419  XdsListenerResource::HttpConnectionManager::HttpFilter{
420  "router", {kXdsHttpRouterFilterConfigName, Json()}});
421  }
422  // Guarding parsing of RouteConfig on the server side with the environmental
423  // variable since that's the first feature on the server side that will be
424  // using this.
425  if (is_client || XdsRbacEnabled()) {
426  // Found inlined route_config. Parse it to find the cluster_name.
428  http_connection_manager_proto)) {
429  const envoy_config_route_v3_RouteConfiguration* route_config =
431  http_connection_manager_proto);
432  XdsRouteConfigResource rds_update;
435  if (!GRPC_ERROR_IS_NONE(error)) return error;
437  return GRPC_ERROR_NONE;
438  }
439  // Validate that RDS must be used to get the route_config dynamically.
442  http_connection_manager_proto);
443  if (rds == nullptr) {
445  "HttpConnectionManager neither has inlined route_config nor RDS.");
446  }
447  // Check that the ConfigSource specifies ADS.
448  const envoy_config_core_v3_ConfigSource* config_source =
450  rds);
451  if (config_source == nullptr) {
453  "HttpConnectionManager missing config_source for RDS.");
454  }
455  if (!envoy_config_core_v3_ConfigSource_has_ads(config_source) &&
458  "HttpConnectionManager ConfigSource for RDS does not specify ADS "
459  "or SELF.");
460  }
461  // Get the route_config_name.
464  rds));
465  }
466  return GRPC_ERROR_NONE;
467 }
468 
469 grpc_error_handle LdsResourceParseClient(
470  const XdsEncodingContext& context,
471  const envoy_config_listener_v3_ApiListener* api_listener, bool is_v2,
472  XdsListenerResource* lds_update) {
474  const upb_StringView encoded_api_listener = google_protobuf_Any_value(
476  const auto* http_connection_manager =
478  encoded_api_listener.data, encoded_api_listener.size, context.arena);
479  if (http_connection_manager == nullptr) {
481  "Could not parse HttpConnectionManager config from ApiListener");
482  }
483  return HttpConnectionManagerParse(true /* is_client */, context,
485  &lds_update->http_connection_manager);
486 }
487 
488 grpc_error_handle DownstreamTlsContextParse(
489  const XdsEncodingContext& context,
490  const envoy_config_core_v3_TransportSocket* transport_socket,
491  XdsListenerResource::DownstreamTlsContext* downstream_tls_context) {
494  if (name != "envoy.transport_sockets.tls") {
496  absl::StrCat("Unrecognized transport socket: ", name));
497  }
498  auto* typed_config =
500  std::vector<grpc_error_handle> errors;
501  if (typed_config != nullptr) {
502  const upb_StringView encoded_downstream_tls_context =
503  google_protobuf_Any_value(typed_config);
504  auto* downstream_tls_context_proto =
506  encoded_downstream_tls_context.data,
507  encoded_downstream_tls_context.size, context.arena);
508  if (downstream_tls_context_proto == nullptr) {
510  "Can't decode downstream tls context.");
511  }
512  auto* common_tls_context =
514  downstream_tls_context_proto);
515  if (common_tls_context != nullptr) {
517  CommonTlsContext::Parse(context, common_tls_context,
518  &downstream_tls_context->common_tls_context);
519  if (!GRPC_ERROR_IS_NONE(error)) errors.push_back(error);
520  }
521  auto* require_client_certificate =
523  downstream_tls_context_proto);
524  if (require_client_certificate != nullptr) {
525  downstream_tls_context->require_client_certificate =
526  google_protobuf_BoolValue_value(require_client_certificate);
527  }
528  auto* require_sni =
530  downstream_tls_context_proto);
531  if (require_sni != nullptr &&
532  google_protobuf_BoolValue_value(require_sni)) {
533  errors.push_back(
534  GRPC_ERROR_CREATE_FROM_STATIC_STRING("require_sni: unsupported"));
535  }
537  downstream_tls_context_proto) !=
540  "ocsp_staple_policy: Only LENIENT_STAPLING supported"));
541  }
542  }
543  if (downstream_tls_context->common_tls_context
544  .tls_certificate_provider_instance.instance_name.empty()) {
546  "TLS configuration provided but no "
547  "tls_certificate_provider_instance found."));
548  }
549  if (downstream_tls_context->require_client_certificate &&
550  downstream_tls_context->common_tls_context.certificate_validation_context
551  .ca_certificate_provider_instance.instance_name.empty()) {
553  "TLS configuration requires client certificates but no certificate "
554  "provider instance specified for validation."));
555  }
556  if (!downstream_tls_context->common_tls_context.certificate_validation_context
557  .match_subject_alt_names.empty()) {
559  "match_subject_alt_names not supported on servers"));
560  }
561  return GRPC_ERROR_CREATE_FROM_VECTOR("Error parsing DownstreamTlsContext",
562  &errors);
563 }
564 
565 grpc_error_handle CidrRangeParse(
566  const envoy_config_core_v3_CidrRange* cidr_range_proto,
567  XdsListenerResource::FilterChainMap::CidrRange* cidr_range) {
568  std::string address_prefix = UpbStringToStdString(
571  grpc_string_to_sockaddr(&cidr_range->address, address_prefix.c_str(), 0);
572  if (!GRPC_ERROR_IS_NONE(error)) return error;
573  cidr_range->prefix_len = 0;
574  auto* prefix_len_proto =
576  if (prefix_len_proto != nullptr) {
577  cidr_range->prefix_len = std::min(
578  google_protobuf_UInt32Value_value(prefix_len_proto),
579  (reinterpret_cast<const grpc_sockaddr*>(cidr_range->address.addr))
580  ->sa_family == GRPC_AF_INET
581  ? uint32_t(32)
582  : uint32_t(128));
583  }
584  // Normalize the network address by masking it with prefix_len
585  grpc_sockaddr_mask_bits(&cidr_range->address, cidr_range->prefix_len);
586  return GRPC_ERROR_NONE;
587 }
588 
589 grpc_error_handle FilterChainMatchParse(
590  const envoy_config_listener_v3_FilterChainMatch* filter_chain_match_proto,
591  FilterChain::FilterChainMatch* filter_chain_match) {
592  auto* destination_port =
594  filter_chain_match_proto);
595  if (destination_port != nullptr) {
596  filter_chain_match->destination_port =
597  google_protobuf_UInt32Value_value(destination_port);
598  }
599  size_t size = 0;
601  filter_chain_match_proto, &size);
602  filter_chain_match->prefix_ranges.reserve(size);
603  for (size_t i = 0; i < size; i++) {
604  XdsListenerResource::FilterChainMap::CidrRange cidr_range;
605  grpc_error_handle error = CidrRangeParse(prefix_ranges[i], &cidr_range);
606  if (!GRPC_ERROR_IS_NONE(error)) return error;
607  filter_chain_match->prefix_ranges.push_back(cidr_range);
608  }
609  filter_chain_match->source_type =
612  filter_chain_match_proto));
613  auto* source_prefix_ranges =
615  filter_chain_match_proto, &size);
616  filter_chain_match->source_prefix_ranges.reserve(size);
617  for (size_t i = 0; i < size; i++) {
618  XdsListenerResource::FilterChainMap::CidrRange cidr_range;
620  CidrRangeParse(source_prefix_ranges[i], &cidr_range);
621  if (!GRPC_ERROR_IS_NONE(error)) return error;
622  filter_chain_match->source_prefix_ranges.push_back(cidr_range);
623  }
625  filter_chain_match_proto, &size);
626  filter_chain_match->source_ports.reserve(size);
627  for (size_t i = 0; i < size; i++) {
628  filter_chain_match->source_ports.push_back(source_ports[i]);
629  }
631  filter_chain_match_proto, &size);
632  for (size_t i = 0; i < size; i++) {
633  filter_chain_match->server_names.push_back(
634  UpbStringToStdString(server_names[i]));
635  }
636  filter_chain_match->transport_protocol = UpbStringToStdString(
638  filter_chain_match_proto));
639  auto* application_protocols =
641  filter_chain_match_proto, &size);
642  for (size_t i = 0; i < size; i++) {
643  filter_chain_match->application_protocols.push_back(
644  UpbStringToStdString(application_protocols[i]));
645  }
646  return GRPC_ERROR_NONE;
647 }
648 
649 grpc_error_handle FilterChainParse(
650  const XdsEncodingContext& context,
651  const envoy_config_listener_v3_FilterChain* filter_chain_proto, bool is_v2,
652  FilterChain* filter_chain) {
653  std::vector<grpc_error_handle> errors;
654  auto* filter_chain_match =
656  filter_chain_proto);
657  if (filter_chain_match != nullptr) {
658  grpc_error_handle error = FilterChainMatchParse(
659  filter_chain_match, &filter_chain->filter_chain_match);
660  if (!GRPC_ERROR_IS_NONE(error)) errors.push_back(error);
661  }
662  filter_chain->filter_chain_data =
663  std::make_shared<XdsListenerResource::FilterChainData>();
664  // Parse the filters list. Currently we only support HttpConnectionManager.
665  size_t size = 0;
666  auto* filters =
668  if (size != 1) {
670  "FilterChain should have exactly one filter: HttpConnectionManager; no "
671  "other filter is supported at the moment"));
672  } else {
673  auto* typed_config =
675  if (typed_config == nullptr) {
677  "No typed_config found in filter."));
678  } else {
681  if (type_url !=
682  "type.googleapis.com/"
683  "envoy.extensions.filters.network.http_connection_manager.v3."
684  "HttpConnectionManager") {
686  absl::StrCat("Unsupported filter type ", type_url)));
687  } else {
688  const upb_StringView encoded_http_connection_manager =
689  google_protobuf_Any_value(typed_config);
690  const auto* http_connection_manager =
692  encoded_http_connection_manager.data,
693  encoded_http_connection_manager.size, context.arena);
694  if (http_connection_manager == nullptr) {
696  "Could not parse HttpConnectionManager config from filter "
697  "typed_config"));
698  } else {
699  grpc_error_handle error = HttpConnectionManagerParse(
700  false /* is_client */, context, http_connection_manager, is_v2,
701  &filter_chain->filter_chain_data->http_connection_manager);
702  if (!GRPC_ERROR_IS_NONE(error)) errors.push_back(error);
703  }
704  }
705  }
706  }
707  auto* transport_socket =
709  if (transport_socket != nullptr) {
710  grpc_error_handle error = DownstreamTlsContextParse(
711  context, transport_socket,
712  &filter_chain->filter_chain_data->downstream_tls_context);
713  if (!GRPC_ERROR_IS_NONE(error)) errors.push_back(error);
714  }
715  return GRPC_ERROR_CREATE_FROM_VECTOR("Error parsing FilterChain", &errors);
716 }
717 
718 grpc_error_handle AddressParse(
719  const envoy_config_core_v3_Address* address_proto, std::string* address) {
720  const auto* socket_address =
722  if (socket_address == nullptr) {
724  "Address does not have socket_address");
725  }
726  if (envoy_config_core_v3_SocketAddress_protocol(socket_address) !=
729  "SocketAddress protocol is not TCP");
730  }
732  if (port > 65535) {
733  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Invalid port");
734  }
738  port);
739  return GRPC_ERROR_NONE;
740 }
741 
742 // An intermediate map for filter chains that we create to validate the list of
743 // filter chains received from the control plane and to finally create
744 // XdsListenerResource::FilterChainMap
745 struct InternalFilterChainMap {
746  using SourceIpMap =
747  std::map<std::string, XdsListenerResource::FilterChainMap::SourceIp>;
748  using ConnectionSourceTypesArray = std::array<SourceIpMap, 3>;
749  struct DestinationIp {
752  ConnectionSourceTypesArray source_types_array;
753  };
754  using DestinationIpMap = std::map<std::string, DestinationIp>;
755  DestinationIpMap destination_ip_map;
756 };
757 
758 grpc_error_handle AddFilterChainDataForSourcePort(
759  const FilterChain& filter_chain,
761  uint32_t port) {
762  auto insert_result = ports_map->emplace(
763  port, XdsListenerResource::FilterChainMap::FilterChainDataSharedPtr{
764  filter_chain.filter_chain_data});
765  if (!insert_result.second) {
767  "Duplicate matching rules detected when adding filter chain: ",
768  filter_chain.filter_chain_match.ToString()));
769  }
770  return GRPC_ERROR_NONE;
771 }
772 
773 grpc_error_handle AddFilterChainDataForSourcePorts(
774  const FilterChain& filter_chain,
776  if (filter_chain.filter_chain_match.source_ports.empty()) {
777  return AddFilterChainDataForSourcePort(filter_chain, ports_map, 0);
778  } else {
779  for (uint32_t port : filter_chain.filter_chain_match.source_ports) {
781  AddFilterChainDataForSourcePort(filter_chain, ports_map, port);
782  if (!GRPC_ERROR_IS_NONE(error)) return error;
783  }
784  }
785  return GRPC_ERROR_NONE;
786 }
787 
788 grpc_error_handle AddFilterChainDataForSourceIpRange(
789  const FilterChain& filter_chain,
790  InternalFilterChainMap::SourceIpMap* source_ip_map) {
791  if (filter_chain.filter_chain_match.source_prefix_ranges.empty()) {
792  auto insert_result = source_ip_map->emplace(
793  "", XdsListenerResource::FilterChainMap::SourceIp());
794  return AddFilterChainDataForSourcePorts(
795  filter_chain, &insert_result.first->second.ports_map);
796  } else {
797  for (const auto& prefix_range :
798  filter_chain.filter_chain_match.source_prefix_ranges) {
799  auto addr_str = grpc_sockaddr_to_string(&prefix_range.address, false);
800  if (!addr_str.ok()) {
801  return GRPC_ERROR_CREATE_FROM_CPP_STRING(addr_str.status().ToString());
802  }
803  auto insert_result = source_ip_map->emplace(
804  absl::StrCat(*addr_str, "/", prefix_range.prefix_len),
805  XdsListenerResource::FilterChainMap::SourceIp());
806  if (insert_result.second) {
807  insert_result.first->second.prefix_range.emplace(prefix_range);
808  }
809  grpc_error_handle error = AddFilterChainDataForSourcePorts(
810  filter_chain, &insert_result.first->second.ports_map);
811  if (!GRPC_ERROR_IS_NONE(error)) return error;
812  }
813  }
814  return GRPC_ERROR_NONE;
815 }
816 
817 grpc_error_handle AddFilterChainDataForSourceType(
818  const FilterChain& filter_chain,
819  InternalFilterChainMap::DestinationIp* destination_ip) {
820  GPR_ASSERT(static_cast<unsigned int>(
821  filter_chain.filter_chain_match.source_type) < 3);
822  return AddFilterChainDataForSourceIpRange(
823  filter_chain, &destination_ip->source_types_array[static_cast<int>(
824  filter_chain.filter_chain_match.source_type)]);
825 }
826 
827 grpc_error_handle AddFilterChainDataForApplicationProtocols(
828  const FilterChain& filter_chain,
829  InternalFilterChainMap::DestinationIp* destination_ip) {
830  // Only allow filter chains that do not mention application protocols
831  if (!filter_chain.filter_chain_match.application_protocols.empty()) {
832  return GRPC_ERROR_NONE;
833  }
834  return AddFilterChainDataForSourceType(filter_chain, destination_ip);
835 }
836 
837 grpc_error_handle AddFilterChainDataForTransportProtocol(
838  const FilterChain& filter_chain,
839  InternalFilterChainMap::DestinationIp* destination_ip) {
840  const std::string& transport_protocol =
841  filter_chain.filter_chain_match.transport_protocol;
842  // Only allow filter chains with no transport protocol or "raw_buffer"
843  if (!transport_protocol.empty() && transport_protocol != "raw_buffer") {
844  return GRPC_ERROR_NONE;
845  }
846  // If for this configuration, we've already seen filter chains that mention
847  // the transport protocol as "raw_buffer", we will never match filter chains
848  // that do not mention it.
849  if (destination_ip->transport_protocol_raw_buffer_provided &&
850  transport_protocol.empty()) {
851  return GRPC_ERROR_NONE;
852  }
853  if (!transport_protocol.empty() &&
854  !destination_ip->transport_protocol_raw_buffer_provided) {
855  destination_ip->transport_protocol_raw_buffer_provided = true;
856  // Clear out the previous entries if any since those entries did not mention
857  // "raw_buffer"
858  destination_ip->source_types_array =
859  InternalFilterChainMap::ConnectionSourceTypesArray();
860  }
861  return AddFilterChainDataForApplicationProtocols(filter_chain,
862  destination_ip);
863 }
864 
865 grpc_error_handle AddFilterChainDataForServerNames(
866  const FilterChain& filter_chain,
867  InternalFilterChainMap::DestinationIp* destination_ip) {
868  // Don't continue adding filter chains with server names mentioned
869  if (!filter_chain.filter_chain_match.server_names.empty()) {
870  return GRPC_ERROR_NONE;
871  }
872  return AddFilterChainDataForTransportProtocol(filter_chain, destination_ip);
873 }
874 
875 grpc_error_handle AddFilterChainDataForDestinationIpRange(
876  const FilterChain& filter_chain,
877  InternalFilterChainMap::DestinationIpMap* destination_ip_map) {
878  if (filter_chain.filter_chain_match.prefix_ranges.empty()) {
879  auto insert_result = destination_ip_map->emplace(
880  "", InternalFilterChainMap::DestinationIp());
881  return AddFilterChainDataForServerNames(filter_chain,
882  &insert_result.first->second);
883  } else {
884  for (const auto& prefix_range :
885  filter_chain.filter_chain_match.prefix_ranges) {
886  auto addr_str = grpc_sockaddr_to_string(&prefix_range.address, false);
887  if (!addr_str.ok()) {
888  return GRPC_ERROR_CREATE_FROM_CPP_STRING(addr_str.status().ToString());
889  }
890  auto insert_result = destination_ip_map->emplace(
891  absl::StrCat(*addr_str, "/", prefix_range.prefix_len),
892  InternalFilterChainMap::DestinationIp());
893  if (insert_result.second) {
894  insert_result.first->second.prefix_range.emplace(prefix_range);
895  }
896  grpc_error_handle error = AddFilterChainDataForServerNames(
897  filter_chain, &insert_result.first->second);
898  if (!GRPC_ERROR_IS_NONE(error)) return error;
899  }
900  }
901  return GRPC_ERROR_NONE;
902 }
903 
904 XdsListenerResource::FilterChainMap BuildFromInternalFilterChainMap(
905  InternalFilterChainMap* internal_filter_chain_map) {
906  XdsListenerResource::FilterChainMap filter_chain_map;
907  for (auto& destination_ip_pair :
908  internal_filter_chain_map->destination_ip_map) {
909  XdsListenerResource::FilterChainMap::DestinationIp destination_ip;
910  destination_ip.prefix_range = destination_ip_pair.second.prefix_range;
911  for (int i = 0; i < 3; i++) {
912  auto& source_ip_map = destination_ip_pair.second.source_types_array[i];
913  for (auto& source_ip_pair : source_ip_map) {
914  destination_ip.source_types_array[i].push_back(
915  std::move(source_ip_pair.second));
916  }
917  }
918  filter_chain_map.destination_ip_vector.push_back(std::move(destination_ip));
919  }
920  return filter_chain_map;
921 }
922 
923 grpc_error_handle BuildFilterChainMap(
924  const std::vector<FilterChain>& filter_chains,
925  XdsListenerResource::FilterChainMap* filter_chain_map) {
926  InternalFilterChainMap internal_filter_chain_map;
927  for (const auto& filter_chain : filter_chains) {
928  // Discard filter chain entries that specify destination port
929  if (filter_chain.filter_chain_match.destination_port != 0) continue;
930  grpc_error_handle error = AddFilterChainDataForDestinationIpRange(
931  filter_chain, &internal_filter_chain_map.destination_ip_map);
932  if (!GRPC_ERROR_IS_NONE(error)) return error;
933  }
935  BuildFromInternalFilterChainMap(&internal_filter_chain_map);
936  return GRPC_ERROR_NONE;
937 }
938 
939 grpc_error_handle LdsResourceParseServer(
940  const XdsEncodingContext& context,
941  const envoy_config_listener_v3_Listener* listener, bool is_v2,
942  XdsListenerResource* lds_update) {
945  AddressParse(envoy_config_listener_v3_Listener_address(listener),
946  &lds_update->address);
947  if (!GRPC_ERROR_IS_NONE(error)) return error;
948  const auto* use_original_dst =
950  if (use_original_dst != nullptr) {
951  if (google_protobuf_BoolValue_value(use_original_dst)) {
953  "Field \'use_original_dst\' is not supported.");
954  }
955  }
956  size_t size = 0;
957  auto* filter_chains =
959  std::vector<FilterChain> parsed_filter_chains;
960  parsed_filter_chains.reserve(size);
961  for (size_t i = 0; i < size; i++) {
962  FilterChain filter_chain;
963  error = FilterChainParse(context, filter_chains[i], is_v2, &filter_chain);
964  if (!GRPC_ERROR_IS_NONE(error)) return error;
965  parsed_filter_chains.push_back(std::move(filter_chain));
966  }
967  error =
968  BuildFilterChainMap(parsed_filter_chains, &lds_update->filter_chain_map);
969  if (!GRPC_ERROR_IS_NONE(error)) return error;
970  auto* default_filter_chain =
972  if (default_filter_chain != nullptr) {
973  FilterChain filter_chain;
974  error =
975  FilterChainParse(context, default_filter_chain, is_v2, &filter_chain);
976  if (!GRPC_ERROR_IS_NONE(error)) return error;
977  if (filter_chain.filter_chain_data != nullptr) {
978  lds_update->default_filter_chain =
979  std::move(*filter_chain.filter_chain_data);
980  }
981  }
982  if (size == 0 && default_filter_chain == nullptr) {
983  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("No filter chain provided.");
984  }
985  return GRPC_ERROR_NONE;
986 }
987 
988 grpc_error_handle LdsResourceParse(
989  const XdsEncodingContext& context,
990  const envoy_config_listener_v3_Listener* listener, bool is_v2,
991  XdsListenerResource* lds_update) {
992  // Check whether it's a client or server listener.
993  const envoy_config_listener_v3_ApiListener* api_listener =
997  // TODO(roth): Re-enable the following check once
998  // github.com/istio/istio/issues/38914 is resolved.
999  // if (api_listener != nullptr && address != nullptr) {
1000  // return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1001  // "Listener has both address and ApiListener");
1002  // }
1003  if (api_listener == nullptr && address == nullptr) {
1005  "Listener has neither address nor ApiListener");
1006  }
1007  // Validate Listener fields.
1009  if (api_listener != nullptr) {
1010  error = LdsResourceParseClient(context, api_listener, is_v2, lds_update);
1011  } else {
1012  error = LdsResourceParseServer(context, listener, is_v2, lds_update);
1013  }
1014  return error;
1015 }
1016 
1017 void MaybeLogListener(const XdsEncodingContext& context,
1018  const envoy_config_listener_v3_Listener* listener) {
1019  if (GRPC_TRACE_FLAG_ENABLED(*context.tracer) &&
1021  const upb_MessageDef* msg_type =
1023  char buf[10240];
1024  upb_TextEncode(listener, msg_type, nullptr, 0, buf, sizeof(buf));
1025  gpr_log(GPR_DEBUG, "[xds_client %p] Listener: %s", context.client, buf);
1026  }
1027 }
1028 
1029 } // namespace
1030 
1032  const XdsEncodingContext& context, absl::string_view serialized_resource,
1033  bool is_v2) const {
1034  // Parse serialized proto.
1035  auto* resource = envoy_config_listener_v3_Listener_parse(
1036  serialized_resource.data(), serialized_resource.size(), context.arena);
1037  if (resource == nullptr) {
1038  return absl::InvalidArgumentError("Can't parse Listener resource.");
1039  }
1040  MaybeLogListener(context, resource);
1041  // Validate resource.
1043  result.name =
1045  auto listener_data = absl::make_unique<ResourceDataSubclass>();
1047  LdsResourceParse(context, resource, is_v2, &listener_data->resource);
1048  if (!GRPC_ERROR_IS_NONE(error)) {
1051  if (GRPC_TRACE_FLAG_ENABLED(*context.tracer)) {
1052  gpr_log(GPR_ERROR, "[xds_client %p] invalid Listener %s: %s",
1053  context.client, result.name.c_str(), error_str.c_str());
1054  }
1055  result.resource = absl::InvalidArgumentError(error_str);
1056  } else {
1057  if (GRPC_TRACE_FLAG_ENABLED(*context.tracer)) {
1058  gpr_log(GPR_INFO, "[xds_client %p] parsed Listener %s: %s",
1059  context.client, result.name.c_str(),
1060  listener_data->resource.ToString().c_str());
1061  }
1062  result.resource = std::move(listener_data);
1063  }
1064  return std::move(result);
1065 }
1066 
1067 } // namespace grpc_core
grpc_core::XdsListenerResource::FilterChainData::ToString
std::string ToString() const
Definition: xds_listener.cc:119
prefix_range
absl::optional< XdsListenerResource::FilterChainMap::CidrRange > prefix_range
Definition: xds_listener.cc:750
envoy_config_core_v3_SocketAddress_protocol
UPB_INLINE int32_t envoy_config_core_v3_SocketAddress_protocol(const envoy_config_core_v3_SocketAddress *msg)
Definition: address.upb.h:203
envoy_extensions_filters_network_http_connection_manager_v3_Rds_route_config_name
UPB_INLINE upb_StringView envoy_extensions_filters_network_http_connection_manager_v3_Rds_route_config_name(const envoy_extensions_filters_network_http_connection_manager_v3_Rds *msg)
Definition: http_connection_manager.upb.h:1854
trace.h
absl::InvalidArgumentError
Status InvalidArgumentError(absl::string_view message)
Definition: third_party/abseil-cpp/absl/status/status.cc:351
envoy_config_listener_v3_FilterChainMatch_source_ports
UPB_INLINE uint32_t const * envoy_config_listener_v3_FilterChainMatch_source_ports(const envoy_config_listener_v3_FilterChainMatch *msg, size_t *len)
Definition: listener_components.upb.h:230
envoy_config_listener_v3_Listener_name
UPB_INLINE upb_StringView envoy_config_listener_v3_Listener_name(const envoy_config_listener_v3_Listener *msg)
Definition: listener.upb.h:168
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
GPR_INFO
#define GPR_INFO
Definition: include/grpc/impl/codegen/log.h:56
cleanup.Json
Json
Definition: cleanup.py:49
grpc_core::XdsListenerResource::ToString
std::string ToString() const
Definition: xds_listener.cc:249
route.upb.h
grpc_core::XdsRbacEnabled
bool XdsRbacEnabled()
Definition: xds_route_config.cc:82
grpc_core::FilterChain::FilterChainMatch::source_ports
std::vector< uint32_t > source_ports
Definition: xds_listener.cc:149
envoy_config_listener_v3_FilterChainMatch
struct envoy_config_listener_v3_FilterChainMatch envoy_config_listener_v3_FilterChainMatch
Definition: listener_components.upb.h:31
GRPC_ERROR_NONE
#define GRPC_ERROR_NONE
Definition: error.h:234
log.h
sockaddr_utils.h
envoy_config_listener_v3_ApiListener
struct envoy_config_listener_v3_ApiListener envoy_config_listener_v3_ApiListener
Definition: api_listener.upb.h:24
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_LENIENT_STAPLING
@ envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_LENIENT_STAPLING
Definition: tls.upb.h:68
absl::StrCat
std::string StrCat(const AlphaNum &a, const AlphaNum &b)
Definition: abseil-cpp/absl/strings/str_cat.cc:98
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_getmsgdef
const UPB_INLINE upb_MessageDef * envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_getmsgdef(upb_DefPool *s)
Definition: http_connection_manager.upbdefs.h:24
envoy_extensions_filters_network_http_connection_manager_v3_HttpFilter_typed_config
UPB_INLINE const struct google_protobuf_Any * envoy_extensions_filters_network_http_connection_manager_v3_HttpFilter_typed_config(const envoy_extensions_filters_network_http_connection_manager_v3_HttpFilter *msg)
Definition: http_connection_manager.upb.h:2438
rds_update
absl::optional< absl::StatusOr< XdsRouteConfigResource > > rds_update
Definition: xds_server_config_fetcher.cc:231
absl::StrFormat
ABSL_MUST_USE_RESULT std::string StrFormat(const FormatSpec< Args... > &format, const Args &... args)
Definition: abseil-cpp/absl/strings/str_format.h:338
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_has_original_ip_detection_extensions
UPB_INLINE bool envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_has_original_ip_detection_extensions(const envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager *msg)
Definition: http_connection_manager.upb.h:555
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_rds
const UPB_INLINE envoy_extensions_filters_network_http_connection_manager_v3_Rds * envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_rds(const envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager *msg)
Definition: http_connection_manager.upb.h:231
gpr_should_log
GPRAPI void GPRAPI int gpr_should_log(gpr_log_severity severity)
Definition: log.cc:67
grpc_core::FilterChain
Definition: xds_listener.cc:141
grpc_core::FilterChain::FilterChainMatch::server_names
std::vector< std::string > server_names
Definition: xds_listener.cc:150
capstone.range
range
Definition: third_party/bloaty/third_party/capstone/bindings/python/capstone/__init__.py:6
grpc_core::XdsEncodingContext
Definition: upb_utils.h:39
grpc_core
Definition: call_metric_recorder.h:31
xds_resource_type.h
upb_StringView::data
const char * data
Definition: upb/upb/upb.h:73
upb_MessageDef
Definition: upb/upb/def.c:100
options
double_dict options[]
Definition: capstone_test.c:55
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
absl::string_view
Definition: abseil-cpp/absl/strings/string_view.h:167
envoy_config_core_v3_TransportSocket_typed_config
UPB_INLINE const struct google_protobuf_Any * envoy_config_core_v3_TransportSocket_typed_config(const envoy_config_core_v3_TransportSocket *msg)
Definition: base.upb.h:1649
envoy_config_core_v3_HttpProtocolOptions
struct envoy_config_core_v3_HttpProtocolOptions envoy_config_core_v3_HttpProtocolOptions
Definition: protocol.upb.h:45
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
error
grpc_error_handle error
Definition: retry_filter.cc:499
grpc_core::FilterChain::FilterChainMatch::source_prefix_ranges
std::vector< XdsListenerResource::FilterChainMap::CidrRange > source_prefix_ranges
Definition: xds_listener.cc:148
envoy_config_listener_v3_FilterChainMatch_transport_protocol
UPB_INLINE upb_StringView envoy_config_listener_v3_FilterChainMatch_transport_protocol(const envoy_config_listener_v3_FilterChainMatch *msg)
Definition: listener_components.upb.h:245
envoy_config_listener_v3_Listener_filter_chains
UPB_INLINE const struct envoy_config_listener_v3_FilterChain *const * envoy_config_listener_v3_Listener_filter_chains(const envoy_config_listener_v3_Listener *msg, size_t *len)
Definition: listener.upb.h:186
envoy_config_listener_v3_FilterChainMatch_source_prefix_ranges
UPB_INLINE const struct envoy_config_core_v3_CidrRange *const * envoy_config_listener_v3_FilterChainMatch_source_prefix_ranges(const envoy_config_listener_v3_FilterChainMatch *msg, size_t *len)
Definition: listener_components.upb.h:224
envoy_config_listener_v3_FilterChainMatch_server_names
UPB_INLINE upb_StringView const * envoy_config_listener_v3_FilterChainMatch_server_names(const envoy_config_listener_v3_FilterChainMatch *msg, size_t *len)
Definition: listener_components.upb.h:257
envoy_extensions_filters_network_http_connection_manager_v3_Rds_config_source
UPB_INLINE const struct envoy_config_core_v3_ConfigSource * envoy_extensions_filters_network_http_connection_manager_v3_Rds_config_source(const envoy_extensions_filters_network_http_connection_manager_v3_Rds *msg)
Definition: http_connection_manager.upb.h:1848
setup.name
name
Definition: setup.py:542
grpc_core::FilterChain::FilterChainMatch::prefix_ranges
std::vector< XdsListenerResource::FilterChainMap::CidrRange > prefix_ranges
Definition: xds_listener.cc:144
envoy_config_core_v3_SocketAddress_port_value
UPB_INLINE uint32_t envoy_config_core_v3_SocketAddress_port_value(const envoy_config_core_v3_SocketAddress *msg)
Definition: address.upb.h:218
grpc_core::XdsListenerResource::HttpConnectionManager::route_config_name
std::string route_config_name
Definition: xds_listener.h:73
GPR_LOG_SEVERITY_DEBUG
@ GPR_LOG_SEVERITY_DEBUG
Definition: include/grpc/impl/codegen/log.h:46
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_xff_num_trusted_hops
UPB_INLINE uint32_t envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_xff_num_trusted_hops(const envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager *msg)
Definition: http_connection_manager.upb.h:354
grpc_sockaddr_to_string
absl::StatusOr< std::string > grpc_sockaddr_to_string(const grpc_resolved_address *resolved_addr, bool normalize)
Definition: sockaddr_utils.cc:194
sockaddr.h
grpc_core::XdsListenerResource::filter_chain_map
struct grpc_core::XdsListenerResource::FilterChainMap filter_chain_map
grpc_core::XdsListenerResource::type
enum grpc_core::XdsListenerResource::ListenerType type
status_helper.h
grpc_core::XdsHttpFilterRegistry::GetFilterForType
static const XdsHttpFilterImpl * GetFilterForType(absl::string_view proto_type_name)
Definition: xds_http_filters.cc:98
GRPC_TRACE_FLAG_ENABLED
#define GRPC_TRACE_FLAG_ENABLED(f)
Definition: debug/trace.h:114
envoy_config_listener_v3_FilterChain
struct envoy_config_listener_v3_FilterChain envoy_config_listener_v3_FilterChain
Definition: listener_components.upb.h:32
tls.upb.h
grpc_core::XdsListenerResource::DownstreamTlsContext::ToString
std::string ToString() const
Definition: xds_listener.cc:70
GRPC_ERROR_CREATE_FROM_VECTOR
#define GRPC_ERROR_CREATE_FROM_VECTOR(desc, error_list)
Definition: error.h:314
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_common_http_protocol_options
UPB_INLINE const struct envoy_config_core_v3_HttpProtocolOptions * envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_common_http_protocol_options(const envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager *msg)
Definition: http_connection_manager.upb.h:471
config_source.upb.h
base.upb.h
grpc_core::XdsListenerResource::DownstreamTlsContext::Empty
bool Empty() const
Definition: xds_listener.cc:76
http_connection_manager.upbdefs.h
grpc_core::UpbStringToStdString
std::string UpbStringToStdString(const upb_StringView &str)
Definition: upb_utils.h:60
google_protobuf_Any
struct google_protobuf_Any google_protobuf_Any
Definition: any.upb.h:24
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
grpc_core::XdsListenerResource::FilterChainMap
Definition: xds_listener.h:138
envoy_config_listener_v3_FilterChain_transport_socket
UPB_INLINE const struct envoy_config_core_v3_TransportSocket * envoy_config_listener_v3_FilterChain_transport_socket(const envoy_config_listener_v3_FilterChain *msg)
Definition: listener_components.upb.h:448
envoy_config_listener_v3_FilterChainMatch_prefix_ranges
UPB_INLINE const struct envoy_config_core_v3_CidrRange *const * envoy_config_listener_v3_FilterChainMatch_prefix_ranges(const envoy_config_listener_v3_FilterChainMatch *msg, size_t *len)
Definition: listener_components.upb.h:200
destination_ip_map
DestinationIpMap destination_ip_map
Definition: xds_listener.cc:755
listener.upb.h
envoy_config_core_v3_TransportSocket_name
UPB_INLINE upb_StringView envoy_config_core_v3_TransportSocket_name(const envoy_config_core_v3_TransportSocket *msg)
Definition: base.upb.h:1640
listener_components.upb.h
grpc_core::XdsListenerResource::FilterChainMap::ToString
std::string ToString() const
Definition: xds_listener.cc:212
grpc_core::ParseDuration
Duration ParseDuration(const google_protobuf_Duration *proto_duration)
Definition: xds_common_types.h:39
parse_address.h
grpc_core::FilterChain::FilterChainMatch::application_protocols
std::vector< std::string > application_protocols
Definition: xds_listener.cc:152
errors
const char * errors
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/tokenizer_unittest.cc:841
envoy_config_listener_v3_Listener_getmsgdef
const UPB_INLINE upb_MessageDef * envoy_config_listener_v3_Listener_getmsgdef(upb_DefPool *s)
Definition: listener.upbdefs.h:29
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
envoy_config_listener_v3_ApiListener_api_listener
UPB_INLINE const struct google_protobuf_Any * envoy_config_listener_v3_ApiListener_api_listener(const envoy_config_listener_v3_ApiListener *msg)
Definition: api_listener.upb.h:68
absl::StrJoin
std::string StrJoin(Iterator start, Iterator end, absl::string_view sep, Formatter &&fmt)
Definition: abseil-cpp/absl/strings/str_join.h:239
envoy_config_listener_v3_Listener_use_original_dst
UPB_INLINE const struct google_protobuf_BoolValue * envoy_config_listener_v3_Listener_use_original_dst(const envoy_config_listener_v3_Listener *msg)
Definition: listener.upb.h:195
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_parse
UPB_INLINE envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext * envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_parse(const char *buf, size_t size, upb_Arena *arena)
Definition: tls.upb.h:175
absl::string_view::size
constexpr size_type size() const noexcept
Definition: abseil-cpp/absl/strings/string_view.h:277
envoy_config_listener_v3_FilterChain_filters
const UPB_INLINE envoy_config_listener_v3_Filter *const * envoy_config_listener_v3_FilterChain_filters(const envoy_config_listener_v3_FilterChain *msg, size_t *len)
Definition: listener_components.upb.h:421
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_require_client_certificate
UPB_INLINE const struct google_protobuf_BoolValue * envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_require_client_certificate(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext *msg)
Definition: tls.upb.h:225
grpc_core::XdsListenerResource::FilterChainMap::ConnectionSourceType::kAny
@ kAny
upb_StringView::size
size_t size
Definition: upb/upb/upb.h:74
envoy_config_listener_v3_FilterChainMatch_application_protocols
UPB_INLINE upb_StringView const * envoy_config_listener_v3_FilterChainMatch_application_protocols(const envoy_config_listener_v3_FilterChainMatch *msg, size_t *len)
Definition: listener_components.upb.h:251
xds_common_types.h
grpc_core::StatusToString
std::string StatusToString(const absl::Status &status)
Definition: status_helper.cc:282
grpc_core::XdsListenerResource::ListenerType::kHttpApiListener
@ kHttpApiListener
grpc_string_to_sockaddr
grpc_error_handle grpc_string_to_sockaddr(grpc_resolved_address *out, const char *addr, int port)
Definition: parse_address.cc:320
envoy_config_route_v3_RouteConfiguration
struct envoy_config_route_v3_RouteConfiguration envoy_config_route_v3_RouteConfiguration
Definition: route.upb.h:26
source_types_array
ConnectionSourceTypesArray source_types_array
Definition: xds_listener.cc:752
upb.h
gpr_log
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
envoy_config_listener_v3_FilterChainMatch_source_type
UPB_INLINE int32_t envoy_config_listener_v3_FilterChainMatch_source_type(const envoy_config_listener_v3_FilterChainMatch *msg)
Definition: listener_components.upb.h:263
envoy_config_listener_v3_Filter_typed_config
UPB_INLINE const struct google_protobuf_Any * envoy_config_listener_v3_Filter_typed_config(const envoy_config_listener_v3_Filter *msg)
Definition: listener_components.upb.h:122
grpc_core::FilterChain::FilterChainMatch::source_type
XdsListenerResource::FilterChainMap::ConnectionSourceType source_type
Definition: xds_listener.cc:145
grpc_core::XdsListenerResource::HttpConnectionManager::rds_update
absl::optional< XdsRouteConfigResource > rds_update
Definition: xds_listener.h:79
envoy_config_core_v3_ConfigSource_has_self
UPB_INLINE bool envoy_config_core_v3_ConfigSource_has_self(const envoy_config_core_v3_ConfigSource *msg)
Definition: config_source.upb.h:555
api_listener.upb.h
grpc_core::JoinHostPort
std::string JoinHostPort(absl::string_view host, int port)
Definition: host_port.cc:32
wrappers.upb.h
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_parse
UPB_INLINE envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager * envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_parse(const char *buf, size_t size, upb_Arena *arena)
Definition: http_connection_manager.upb.h:171
absl::optional
Definition: abseil-cpp/absl/types/internal/optional.h:61
envoy_config_listener_v3_Listener_parse
UPB_INLINE envoy_config_listener_v3_Listener * envoy_config_listener_v3_Listener_parse(const char *buf, size_t size, upb_Arena *arena)
Definition: listener.upb.h:132
envoy_config_core_v3_Address_socket_address
const UPB_INLINE envoy_config_core_v3_SocketAddress * envoy_config_core_v3_Address_socket_address(const envoy_config_core_v3_Address *msg)
Definition: address.upb.h:505
grpc_core::XdsListenerResourceType::Decode
absl::StatusOr< DecodeResult > Decode(const XdsEncodingContext &context, absl::string_view serialized_resource, bool is_v2) const override
Definition: xds_listener.cc:1031
envoy_config_core_v3_SocketAddress_address
UPB_INLINE upb_StringView envoy_config_core_v3_SocketAddress_address(const envoy_config_core_v3_SocketAddress *msg)
Definition: address.upb.h:209
grpc_core::XdsListenerResource::http_connection_manager
HttpConnectionManager http_connection_manager
Definition: xds_listener.h:104
xds_listener.h
error.h
host_port.h
grpc_core::kXdsHttpRouterFilterConfigName
const char * kXdsHttpRouterFilterConfigName
Definition: xds_http_filters.cc:36
json.h
GPR_ERROR
#define GPR_ERROR
Definition: include/grpc/impl/codegen/log.h:57
min
#define min(a, b)
Definition: qsort.h:83
grpc_core::FilterChain::FilterChainMatch
Definition: xds_listener.cc:142
grpc_core::XdsListenerResource::HttpConnectionManager::HttpFilter::ToString
std::string ToString() const
Definition: xds_listener.cc:110
grpc_core::XdsListenerResource::FilterChainMap::ConnectionSourceType
ConnectionSourceType
Definition: xds_listener.h:167
envoy_extensions_filters_network_http_connection_manager_v3_HttpFilter_is_optional
UPB_INLINE bool envoy_extensions_filters_network_http_connection_manager_v3_HttpFilter_is_optional(const envoy_extensions_filters_network_http_connection_manager_v3_HttpFilter *msg)
Definition: http_connection_manager.upb.h:2453
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_http_filters
const UPB_INLINE envoy_extensions_filters_network_http_connection_manager_v3_HttpFilter *const * envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_http_filters(const envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager *msg, size_t *len)
Definition: http_connection_manager.upb.h:249
stdint.h
envoy_config_core_v3_HttpProtocolOptions_max_stream_duration
UPB_INLINE const struct google_protobuf_Duration * envoy_config_core_v3_HttpProtocolOptions_max_stream_duration(const envoy_config_core_v3_HttpProtocolOptions *msg)
Definition: protocol.upb.h:625
grpc_core::XdsListenerResource::default_filter_chain
absl::optional< FilterChainData > default_filter_chain
Definition: xds_listener.h:191
http_connection_manager.upb.h
envoy_config_core_v3_CidrRange
struct envoy_config_core_v3_CidrRange envoy_config_core_v3_CidrRange
Definition: address.upb.h:36
GRPC_ERROR_CREATE_FROM_STATIC_STRING
#define GRPC_ERROR_CREATE_FROM_STATIC_STRING(desc)
Definition: error.h:291
envoy_extensions_filters_network_http_connection_manager_v3_HttpFilter_name
UPB_INLINE upb_StringView envoy_extensions_filters_network_http_connection_manager_v3_HttpFilter_name(const envoy_extensions_filters_network_http_connection_manager_v3_HttpFilter *msg)
Definition: http_connection_manager.upb.h:2429
grpc_core::XdsListenerResource::FilterChainMap::SourcePortsMap
std::map< uint16_t, FilterChainDataSharedPtr > SourcePortsMap
Definition: xds_listener.h:156
google_protobuf_UInt32Value_value
UPB_INLINE uint32_t google_protobuf_UInt32Value_value(const google_protobuf_UInt32Value *msg)
Definition: wrappers.upb.h:297
tests.unit._exit_scenarios.port
port
Definition: _exit_scenarios.py:179
grpc_core::XdsListenerResource::address
std::string address
Definition: xds_listener.h:108
envoy_config_listener_v3_Listener_address
UPB_INLINE const struct envoy_config_core_v3_Address * envoy_config_listener_v3_Listener_address(const envoy_config_listener_v3_Listener *msg)
Definition: listener.upb.h:177
grpc_core::FilterChain::FilterChainMatch::ToString
std::string ToString() const
Definition: xds_listener.cc:160
upb_TextEncode
size_t upb_TextEncode(const upb_Message *msg, const upb_MessageDef *m, const upb_DefPool *ext_pool, int options, char *buf, size_t size)
Definition: text_encode.c:455
envoy_config_listener_v3_FilterChainMatch_destination_port
UPB_INLINE const struct google_protobuf_UInt32Value * envoy_config_listener_v3_FilterChainMatch_destination_port(const envoy_config_listener_v3_FilterChainMatch *msg)
Definition: listener_components.upb.h:239
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_ocsp_staple_policy
UPB_INLINE int32_t envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_ocsp_staple_policy(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext *msg)
Definition: tls.upb.h:276
contents
string_view contents
Definition: elf.cc:597
envoy_config_listener_v3_Listener_default_filter_chain
UPB_INLINE const struct envoy_config_listener_v3_FilterChain * envoy_config_listener_v3_Listener_default_filter_chain(const envoy_config_listener_v3_Listener *msg)
Definition: listener.upb.h:354
absl::StatusOr::ok
ABSL_MUST_USE_RESULT bool ok() const
Definition: abseil-cpp/absl/status/statusor.h:491
grpc_core::CommonTlsContext::ToString
std::string ToString() const
Definition: xds_common_types.cc:87
absl_status_to_grpc_error
grpc_error_handle absl_status_to_grpc_error(absl::Status status)
Definition: error_utils.cc:167
upb_StringView
Definition: upb/upb/upb.h:72
grpc_core::XdsListenerResource::FilterChainMap::CidrRange::ToString
std::string ToString() const
Definition: xds_listener.cc:129
grpc_core::XdsListenerResource::ListenerType::kTcpListener
@ kTcpListener
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_has_route_config
UPB_INLINE bool envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_has_route_config(const envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager *msg)
Definition: http_connection_manager.upb.h:234
listener.upbdefs.h
grpc_error_std_string
std::string grpc_error_std_string(grpc_error_handle error)
Definition: error.cc:944
grpc_core::FilterChain::FilterChainMatch::transport_protocol
std::string transport_protocol
Definition: xds_listener.cc:151
envoy_config_core_v3_CidrRange_prefix_len
UPB_INLINE const struct google_protobuf_UInt32Value * envoy_config_core_v3_CidrRange_prefix_len(const envoy_config_core_v3_CidrRange *msg)
Definition: address.upb.h:607
GRPC_ERROR_CREATE_FROM_CPP_STRING
#define GRPC_ERROR_CREATE_FROM_CPP_STRING(desc)
Definition: error.h:297
protocol.upb.h
google_protobuf_Any_type_url
UPB_INLINE upb_StringView google_protobuf_Any_type_url(const google_protobuf_Any *msg)
Definition: any.upb.h:63
grpc_core::XdsListenerResource::FilterChainMap::destination_ip_vector
DestinationIpVector destination_ip_vector
Definition: xds_listener.h:182
type_url
string * type_url
Definition: bloaty/third_party/protobuf/conformance/conformance_cpp.cc:72
grpc_core::XdsResourceType::DecodeResult
Definition: xds_resource_type.h:44
google_protobuf_Duration
struct google_protobuf_Duration google_protobuf_Duration
Definition: duration.upb.h:24
envoy_config_core_v3_TransportSocket
struct envoy_config_core_v3_TransportSocket envoy_config_core_v3_TransportSocket
Definition: base.upb.h:68
GRPC_ERROR_UNREF
#define GRPC_ERROR_UNREF(err)
Definition: error.h:262
grpc_core::ExtractExtensionTypeName
absl::StatusOr< ExtractExtensionTypeNameResult > ExtractExtensionTypeName(const XdsEncodingContext &context, const google_protobuf_Any *any)
Definition: xds_common_types.cc:377
config_s
Definition: bloaty/third_party/zlib/deflate.c:120
grpc_core::XdsListenerResource::HttpConnectionManager::http_filters
std::vector< HttpFilter > http_filters
Definition: xds_listener.h:91
envoy_config_core_v3_CidrRange_address_prefix
UPB_INLINE upb_StringView envoy_config_core_v3_CidrRange_address_prefix(const envoy_config_core_v3_CidrRange *msg)
Definition: address.upb.h:598
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager
struct envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager
Definition: http_connection_manager.upb.h:43
grpc_core::XdsRouteConfigResource::Parse
static grpc_error_handle Parse(const XdsEncodingContext &context, const envoy_config_route_v3_RouteConfiguration *route_config, XdsRouteConfigResource *rds_update)
Definition: xds_route_config.cc:945
grpc_core::CommonTlsContext::Parse
static grpc_error_handle Parse(const XdsEncodingContext &context, const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext *common_tls_context_proto, CommonTlsContext *common_tls_context)
Definition: xds_common_types.cc:272
envoy_config_core_v3_ConfigSource_has_ads
UPB_INLINE bool envoy_config_core_v3_ConfigSource_has_ads(const envoy_config_core_v3_ConfigSource *msg)
Definition: config_source.upb.h:537
GPR_DEBUG
#define GPR_DEBUG
Definition: include/grpc/impl/codegen/log.h:55
context
grpc::ClientContext context
Definition: istio_echo_server_lib.cc:61
envoy_config_core_v3_SocketAddress_TCP
@ envoy_config_core_v3_SocketAddress_TCP
Definition: address.upb.h:52
envoy_config_core_v3_ConfigSource
struct envoy_config_core_v3_ConfigSource envoy_config_core_v3_ConfigSource
Definition: config_source.upb.h:35
envoy_extensions_filters_network_http_connection_manager_v3_Rds
struct envoy_extensions_filters_network_http_connection_manager_v3_Rds envoy_extensions_filters_network_http_connection_manager_v3_Rds
Definition: http_connection_manager.upb.h:52
duration.upb.h
any.upb.h
envoy_config_listener_v3_FilterChain_filter_chain_match
const UPB_INLINE envoy_config_listener_v3_FilterChainMatch * envoy_config_listener_v3_FilterChain_filter_chain_match(const envoy_config_listener_v3_FilterChain *msg)
Definition: listener_components.upb.h:412
absl::StatusOr
Definition: abseil-cpp/absl/status/statusor.h:187
grpc_error
Definition: error_internal.h:42
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_require_sni
UPB_INLINE const struct google_protobuf_BoolValue * envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_require_sni(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext *msg)
Definition: tls.upb.h:234
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
envoy_config_core_v3_Address
struct envoy_config_core_v3_Address envoy_config_core_v3_Address
Definition: address.upb.h:35
grpc_core::XdsListenerResource::HttpConnectionManager::ToString
std::string ToString() const
Definition: xds_listener.cc:84
absl::string_view::data
constexpr const_pointer data() const noexcept
Definition: abseil-cpp/absl/strings/string_view.h:336
grpc_core::XdsListenerResource::DownstreamTlsContext::require_client_certificate
bool require_client_certificate
Definition: xds_listener.h:55
address.upb.h
text_encode.h
grpc_core::UpbStringToAbsl
absl::string_view UpbStringToAbsl(const upb_StringView &str)
Definition: upb_utils.h:56
envoy_config_listener_v3_Listener_api_listener
UPB_INLINE const struct envoy_config_listener_v3_ApiListener * envoy_config_listener_v3_Listener_api_listener(const envoy_config_listener_v3_Listener *msg)
Definition: listener.upb.h:312
google_protobuf_BoolValue_value
UPB_INLINE bool google_protobuf_BoolValue_value(const google_protobuf_BoolValue *msg)
Definition: wrappers.upb.h:339
transport_protocol_raw_buffer_provided
bool transport_protocol_raw_buffer_provided
Definition: xds_listener.cc:751
grpc_core::FilterChain::filter_chain_data
std::shared_ptr< XdsListenerResource::FilterChainData > filter_chain_data
Definition: xds_listener.cc:157
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
envoy_config_listener_v3_Listener
struct envoy_config_listener_v3_Listener envoy_config_listener_v3_Listener
Definition: listener.upb.h:30
google_protobuf_Any_value
UPB_INLINE upb_StringView google_protobuf_Any_value(const google_protobuf_Any *msg)
Definition: any.upb.h:69
grpc_core::XdsListenerResource::DownstreamTlsContext::common_tls_context
CommonTlsContext common_tls_context
Definition: xds_listener.h:54
absl::StatusOr::status
const Status & status() const &
Definition: abseil-cpp/absl/status/statusor.h:678
grpc_sockaddr_mask_bits
void grpc_sockaddr_mask_bits(grpc_resolved_address *address, uint32_t mask_bits)
Definition: sockaddr_utils.cc:363
error_utils.h
grpc_core::XdsListenerResource::HttpConnectionManager::http_max_stream_duration
Duration http_max_stream_duration
Definition: xds_listener.h:76
GRPC_ERROR_IS_NONE
#define GRPC_ERROR_IS_NONE(err)
Definition: error.h:241
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_common_tls_context
const UPB_INLINE envoy_extensions_transport_sockets_tls_v3_CommonTlsContext * envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_common_tls_context(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext *msg)
Definition: tls.upb.h:216
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_route_config
UPB_INLINE const struct envoy_config_route_v3_RouteConfiguration * envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_route_config(const envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager *msg)
Definition: http_connection_manager.upb.h:240
port_platform.h


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:59