grpc 1.41.1 → 1.44.0.pre2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +185 -102
- data/include/grpc/event_engine/event_engine.h +118 -54
- data/include/grpc/event_engine/internal/memory_allocator_impl.h +68 -0
- data/include/grpc/event_engine/memory_allocator.h +226 -0
- data/include/grpc/event_engine/memory_request.h +57 -0
- data/include/grpc/grpc.h +4 -0
- data/include/grpc/grpc_security.h +304 -145
- data/include/grpc/grpc_security_constants.h +2 -14
- data/include/grpc/impl/codegen/compression_types.h +0 -2
- data/include/grpc/impl/codegen/grpc_types.h +6 -0
- data/include/grpc/impl/codegen/port_platform.h +14 -3
- data/src/core/ext/filters/client_channel/backend_metric.cc +21 -23
- data/src/core/ext/filters/client_channel/backend_metric.h +4 -3
- data/src/core/ext/filters/client_channel/backup_poller.cc +2 -1
- data/src/core/ext/filters/client_channel/channel_connectivity.cc +71 -89
- data/src/core/ext/filters/client_channel/client_channel.cc +305 -335
- data/src/core/ext/filters/client_channel/client_channel.h +84 -36
- data/src/core/ext/filters/client_channel/client_channel_factory.cc +1 -1
- data/src/core/ext/filters/client_channel/client_channel_factory.h +17 -19
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +8 -15
- data/src/core/ext/filters/client_channel/config_selector.cc +1 -1
- data/src/core/ext/filters/client_channel/config_selector.h +5 -6
- data/src/core/ext/filters/client_channel/connector.h +18 -18
- data/src/core/ext/filters/client_channel/dynamic_filters.cc +5 -5
- data/src/core/ext/filters/client_channel/dynamic_filters.h +1 -1
- data/src/core/ext/filters/client_channel/global_subchannel_pool.h +0 -1
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +25 -22
- data/src/core/ext/filters/client_channel/health/health_check_client.h +4 -4
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +13 -15
- data/src/core/ext/filters/client_channel/http_connect_handshaker.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +4 -3
- data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +6 -5
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +4 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +5 -18
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +198 -116
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +3 -6
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +1 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +2 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +2 -4
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +66 -36
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +21 -12
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +124 -74
- data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +2514 -0
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +68 -62
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +16 -11
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +18 -6
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +51 -96
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_args.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +101 -46
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +11 -3
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +101 -209
- data/src/core/ext/filters/client_channel/lb_policy.cc +15 -14
- data/src/core/ext/filters/client_channel/lb_policy.h +105 -63
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +1 -0
- data/src/core/ext/filters/client_channel/resolver/binder/binder_resolver.cc +139 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +220 -88
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +22 -12
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +19 -15
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +31 -50
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +124 -240
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +38 -25
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +90 -77
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +13 -11
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +2 -1
- data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +7 -16
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +5 -5
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +423 -396
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +2 -2
- data/src/core/ext/filters/client_channel/retry_filter.cc +66 -131
- data/src/core/ext/filters/client_channel/retry_service_config.cc +1 -1
- data/src/core/ext/filters/client_channel/retry_service_config.h +1 -1
- data/src/core/ext/filters/client_channel/retry_throttle.cc +17 -48
- data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +49 -36
- data/src/core/ext/filters/client_channel/subchannel.cc +99 -161
- data/src/core/ext/filters/client_channel/subchannel.h +31 -52
- data/src/core/ext/filters/client_channel/subchannel_pool_interface.cc +22 -7
- data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +11 -2
- data/src/core/ext/filters/client_idle/client_idle_filter.cc +27 -210
- data/src/core/ext/filters/client_idle/idle_filter_state.cc +96 -0
- data/src/core/ext/filters/client_idle/idle_filter_state.h +66 -0
- data/src/core/ext/filters/deadline/deadline_filter.cc +23 -26
- data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +42 -53
- data/src/core/ext/filters/fault_injection/service_config_parser.cc +6 -9
- data/src/core/ext/filters/fault_injection/service_config_parser.h +1 -1
- data/src/core/ext/filters/http/client/http_client_filter.cc +70 -160
- data/src/core/ext/filters/http/client_authority_filter.cc +19 -36
- data/src/core/ext/filters/http/http_filters_plugin.cc +51 -71
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +46 -139
- data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +5 -25
- data/src/core/ext/filters/http/server/http_server_filter.cc +84 -183
- data/src/core/ext/filters/max_age/max_age_filter.cc +24 -26
- data/src/core/ext/filters/message_size/message_size_filter.cc +19 -16
- data/src/core/ext/filters/message_size/message_size_filter.h +1 -1
- data/src/core/ext/filters/rbac/rbac_filter.cc +157 -0
- data/src/core/ext/filters/rbac/rbac_filter.h +74 -0
- data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +605 -0
- data/src/core/ext/filters/rbac/rbac_service_config_parser.h +70 -0
- data/src/core/ext/filters/server_config_selector/server_config_selector.cc +67 -0
- data/src/core/ext/filters/server_config_selector/server_config_selector.h +71 -0
- data/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc +270 -0
- data/src/core/ext/{transport/chttp2/transport/hpack_utils.h → filters/server_config_selector/server_config_selector_filter.h} +9 -7
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +4 -23
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +0 -2
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +26 -28
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +11 -14
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +33 -53
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +146 -113
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +2 -3
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +9 -13
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +6 -6
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +0 -1
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +129 -278
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +1 -2
- data/src/core/ext/transport/chttp2/transport/context_list.cc +2 -3
- data/src/core/ext/transport/chttp2/transport/context_list.h +2 -3
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +26 -23
- data/src/core/ext/transport/chttp2/transport/flow_control.h +6 -6
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +4 -5
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +2 -3
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/hpack_constants.h +1 -1
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +384 -218
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +89 -143
- data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.h +2 -0
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +201 -202
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +27 -9
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +106 -26
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +29 -44
- data/src/core/ext/transport/chttp2/transport/internal.h +10 -38
- data/src/core/ext/transport/chttp2/transport/parsing.cc +30 -179
- data/src/core/ext/transport/chttp2/transport/writing.cc +65 -127
- data/src/core/ext/transport/inproc/inproc_plugin.cc +0 -4
- data/src/core/ext/transport/inproc/inproc_transport.cc +114 -161
- data/src/core/ext/transport/inproc/inproc_transport.h +1 -4
- data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.c +197 -165
- data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.c +41 -0
- data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.h +18 -0
- data/src/core/ext/upb-generated/envoy/annotations/resource.upb.c +26 -2
- data/src/core/ext/upb-generated/envoy/annotations/resource.upb.h +7 -0
- data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.c +107 -82
- data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c +188 -160
- data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.c +35 -22
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +277 -208
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +141 -1
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.c +16 -5
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.c +36 -25
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.c +56 -39
- data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.c +16 -5
- data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +171 -125
- data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +55 -4
- data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.c +51 -36
- data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.c +15 -4
- data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.c +25 -13
- data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.c +114 -90
- data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c +90 -71
- data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.h +17 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.c +17 -6
- data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +121 -92
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +25 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.c +13 -2
- data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.c +21 -9
- data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.c +18 -7
- data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +22 -11
- data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.c +17 -6
- data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.c +41 -27
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.c +59 -44
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.c +58 -43
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.c +15 -4
- data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +73 -57
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +81 -64
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.c +25 -14
- data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +19 -7
- data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.c +63 -45
- data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.c +66 -47
- data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +99 -78
- data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.h +19 -0
- data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +41 -28
- data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +508 -442
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +51 -19
- data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.c +26 -13
- data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.c +21 -9
- data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/extensions/clusters/aggregate/v3/cluster.upb.c +13 -2
- data/src/core/ext/upb-generated/envoy/extensions/clusters/aggregate/v3/cluster.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.c +35 -20
- data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c +44 -31
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/rbac/v3/rbac.upb.c +61 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/rbac/v3/rbac.upb.h +146 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +22 -11
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +210 -181
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.c +7 -0
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.h +5 -3
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +64 -48
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.c +33 -20
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.c +81 -65
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/service/cluster/v3/cds.upb.c +12 -1
- data/src/core/ext/upb-generated/envoy/service/cluster/v3/cds.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.c +12 -1
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.c +75 -58
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/service/endpoint/v3/eds.upb.c +12 -1
- data/src/core/ext/upb-generated/envoy/service/endpoint/v3/eds.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/service/listener/v3/lds.upb.c +12 -1
- data/src/core/ext/upb-generated/envoy/service/listener/v3/lds.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.c +25 -13
- data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/service/route/v3/rds.upb.c +12 -1
- data/src/core/ext/upb-generated/envoy/service/route/v3/rds.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/service/route/v3/srds.upb.c +12 -1
- data/src/core/ext/upb-generated/envoy/service/route/v3/srds.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.c +61 -46
- data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.c +26 -12
- data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.c +22 -10
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.c +17 -6
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.c +16 -5
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.c +15 -4
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c +27 -14
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.c +25 -13
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.c +20 -8
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.c +30 -17
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.c +38 -21
- data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.c +41 -26
- data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/type/v3/http.upb.c +7 -0
- data/src/core/ext/upb-generated/envoy/type/v3/http.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.c +17 -5
- data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/type/v3/range.upb.c +22 -9
- data/src/core/ext/upb-generated/envoy/type/v3/range.upb.h +2 -0
- data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.c +15 -4
- data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.h +2 -0
- data/src/core/ext/upb-generated/google/api/annotations.upb.c +20 -0
- data/src/core/ext/upb-generated/google/api/annotations.upb.h +7 -0
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c +116 -93
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.h +2 -0
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/eval.upb.c +102 -0
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/eval.upb.h +306 -0
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/explain.upb.c +56 -0
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/explain.upb.h +135 -0
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c +122 -98
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.h +2 -0
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/value.upb.c +115 -0
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/value.upb.h +371 -0
- data/src/core/ext/upb-generated/google/api/http.upb.c +35 -22
- data/src/core/ext/upb-generated/google/api/http.upb.h +2 -0
- data/src/core/ext/upb-generated/google/protobuf/any.upb.c +14 -3
- data/src/core/ext/upb-generated/google/protobuf/any.upb.h +2 -0
- data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +247 -210
- data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h +2 -0
- data/src/core/ext/upb-generated/google/protobuf/duration.upb.c +14 -3
- data/src/core/ext/upb-generated/google/protobuf/duration.upb.h +2 -0
- data/src/core/ext/upb-generated/google/protobuf/empty.upb.c +12 -1
- data/src/core/ext/upb-generated/google/protobuf/empty.upb.h +2 -0
- data/src/core/ext/upb-generated/google/protobuf/struct.upb.c +37 -23
- data/src/core/ext/upb-generated/google/protobuf/struct.upb.h +2 -0
- data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.c +14 -3
- data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.h +2 -0
- data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.c +37 -18
- data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.h +2 -0
- data/src/core/ext/upb-generated/google/rpc/status.upb.c +17 -6
- data/src/core/ext/upb-generated/google/rpc/status.upb.h +2 -0
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c +26 -14
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h +2 -0
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c +105 -83
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h +2 -0
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c +20 -8
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h +2 -0
- data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c +16 -4
- data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h +2 -0
- data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c +65 -47
- data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h +34 -36
- data/src/core/ext/upb-generated/src/proto/grpc/lookup/v1/rls.upb.c +68 -0
- data/src/core/ext/upb-generated/src/proto/grpc/lookup/v1/rls.upb.h +156 -0
- data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.c +67 -7
- data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.h +27 -0
- data/src/core/ext/upb-generated/udpa/annotations/security.upb.c +27 -5
- data/src/core/ext/upb-generated/udpa/annotations/security.upb.h +7 -0
- data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.c +19 -0
- data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.h +7 -0
- data/src/core/ext/upb-generated/udpa/annotations/status.upb.c +27 -3
- data/src/core/ext/upb-generated/udpa/annotations/status.upb.h +7 -0
- data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.c +26 -2
- data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.h +7 -0
- data/src/core/ext/upb-generated/validate/validate.upb.c +320 -251
- data/src/core/ext/upb-generated/validate/validate.upb.h +20 -0
- data/src/core/ext/upb-generated/xds/annotations/v3/status.upb.c +103 -0
- data/src/core/ext/upb-generated/xds/annotations/v3/status.upb.h +199 -0
- data/src/core/ext/upb-generated/xds/core/v3/authority.upb.c +14 -3
- data/src/core/ext/upb-generated/xds/core/v3/authority.upb.h +2 -0
- data/src/core/ext/upb-generated/xds/core/v3/collection_entry.upb.c +25 -13
- data/src/core/ext/upb-generated/xds/core/v3/collection_entry.upb.h +2 -0
- data/src/core/ext/upb-generated/xds/core/v3/context_params.upb.c +20 -8
- data/src/core/ext/upb-generated/xds/core/v3/context_params.upb.h +2 -0
- data/src/core/ext/upb-generated/xds/core/v3/resource.upb.c +19 -8
- data/src/core/ext/upb-generated/xds/core/v3/resource.upb.h +2 -0
- data/src/core/ext/upb-generated/xds/core/v3/resource_locator.upb.c +28 -16
- data/src/core/ext/upb-generated/xds/core/v3/resource_locator.upb.h +2 -0
- data/src/core/ext/upb-generated/xds/core/v3/resource_name.upb.c +19 -8
- data/src/core/ext/upb-generated/xds/core/v3/resource_name.upb.h +2 -0
- data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.c +71 -0
- data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.h +132 -0
- data/src/core/ext/upb-generated/xds/type/v3/typed_struct.upb.c +44 -0
- data/src/core/ext/upb-generated/xds/type/v3/typed_struct.upb.h +85 -0
- data/src/core/ext/upbdefs-generated/envoy/admin/v3/config_dump.upbdefs.c +2 -49
- data/src/core/ext/upbdefs-generated/envoy/annotations/deprecation.upbdefs.c +2 -2
- data/src/core/ext/upbdefs-generated/envoy/annotations/resource.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.c +2 -35
- data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.c +2 -41
- data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/circuit_breaker.upbdefs.c +2 -11
- data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.c +307 -336
- data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.h +10 -0
- data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/filter.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/outlier_detection.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/address.upbdefs.c +2 -19
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/backoff.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.c +100 -138
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.c +2 -15
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/event_service_config.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/extension.upbdefs.c +2 -9
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/grpc_service.upbdefs.c +2 -33
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.c +61 -77
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/http_uri.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +61 -79
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/proxy_protocol.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/resolver.upbdefs.c +2 -9
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/socket_option.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/substitution_format_string.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/udp_socket_config.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint.upbdefs.c +2 -13
- data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint_components.upbdefs.c +80 -99
- data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/load_report.upbdefs.c +2 -15
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/api_listener.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.c +2 -17
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener_components.upbdefs.c +2 -19
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/quic_config.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/udp_listener_config.upbdefs.c +2 -9
- data/src/core/ext/upbdefs-generated/envoy/config/metrics/v3/stats.upbdefs.c +2 -21
- data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.c +2 -23
- data/src/core/ext/upbdefs-generated/envoy/config/rbac/v3/rbac.upbdefs.c +188 -0
- data/src/core/ext/upbdefs-generated/envoy/config/rbac/v3/rbac.upbdefs.h +70 -0
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.c +2 -11
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +325 -427
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/scoped_route.upbdefs.c +2 -11
- data/src/core/ext/upbdefs-generated/envoy/config/trace/v3/http_tracer.upbdefs.c +2 -9
- data/src/core/ext/upbdefs-generated/envoy/extensions/clusters/aggregate/v3/cluster.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/common/fault/v3/fault.upbdefs.c +2 -15
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.c +2 -11
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/rbac/v3/rbac.upbdefs.c +56 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/rbac/v3/rbac.upbdefs.h +40 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +2 -43
- data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/cert.upbdefs.c +2 -2
- data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.c +2 -17
- data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/secret.upbdefs.c +2 -11
- data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +2 -17
- data/src/core/ext/upbdefs-generated/envoy/service/cluster/v3/cds.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/ads.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/discovery.upbdefs.c +2 -19
- data/src/core/ext/upbdefs-generated/envoy/service/endpoint/v3/eds.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/envoy/service/listener/v3/lds.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/envoy/service/load_stats/v3/lrs.upbdefs.c +2 -9
- data/src/core/ext/upbdefs-generated/envoy/service/route/v3/rds.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/envoy/service/route/v3/srds.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.c +2 -15
- data/src/core/ext/upbdefs-generated/envoy/type/http/v3/path_transformation.upbdefs.c +2 -13
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/metadata.upbdefs.c +2 -9
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/node.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/number.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/path.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.c +2 -11
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/string.upbdefs.c +2 -9
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/struct.upbdefs.c +2 -9
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/value.upbdefs.c +2 -11
- data/src/core/ext/upbdefs-generated/envoy/type/metadata/v3/metadata.upbdefs.c +2 -19
- data/src/core/ext/upbdefs-generated/envoy/type/tracing/v3/custom_tag.upbdefs.c +2 -15
- data/src/core/ext/upbdefs-generated/envoy/type/v3/http.upbdefs.c +2 -2
- data/src/core/ext/upbdefs-generated/envoy/type/v3/percent.upbdefs.c +2 -9
- data/src/core/ext/upbdefs-generated/envoy/type/v3/range.upbdefs.c +2 -11
- data/src/core/ext/upbdefs-generated/envoy/type/v3/semantic_version.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/google/api/annotations.upbdefs.c +2 -2
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/checked.upbdefs.c +154 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/checked.upbdefs.h +95 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/eval.upbdefs.c +58 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/eval.upbdefs.h +55 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/explain.upbdefs.c +44 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/explain.upbdefs.h +40 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/syntax.upbdefs.c +153 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/syntax.upbdefs.h +100 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/value.upbdefs.c +75 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/value.upbdefs.h +55 -0
- data/src/core/ext/upbdefs-generated/google/api/http.upbdefs.c +2 -11
- data/src/core/ext/upbdefs-generated/google/protobuf/any.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/google/protobuf/descriptor.upbdefs.c +2 -59
- data/src/core/ext/upbdefs-generated/google/protobuf/duration.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/google/protobuf/empty.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/google/protobuf/struct.upbdefs.c +2 -13
- data/src/core/ext/upbdefs-generated/google/protobuf/timestamp.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/google/protobuf/wrappers.upbdefs.c +2 -23
- data/src/core/ext/upbdefs-generated/google/rpc/status.upbdefs.c +2 -7
- data/src/core/ext/upbdefs-generated/udpa/annotations/migrate.upbdefs.c +7 -15
- data/src/core/ext/upbdefs-generated/udpa/annotations/security.upbdefs.c +21 -30
- data/src/core/ext/upbdefs-generated/udpa/annotations/sensitive.upbdefs.c +6 -5
- data/src/core/ext/upbdefs-generated/udpa/annotations/status.upbdefs.c +7 -10
- data/src/core/ext/upbdefs-generated/udpa/annotations/versioning.upbdefs.c +7 -11
- data/src/core/ext/upbdefs-generated/validate/validate.upbdefs.c +2 -51
- data/src/core/ext/upbdefs-generated/xds/annotations/v3/status.upbdefs.c +64 -0
- data/src/core/ext/upbdefs-generated/xds/annotations/v3/status.upbdefs.h +50 -0
- data/src/core/ext/upbdefs-generated/xds/core/v3/authority.upbdefs.c +15 -19
- data/src/core/ext/upbdefs-generated/xds/core/v3/collection_entry.upbdefs.c +27 -33
- data/src/core/ext/upbdefs-generated/xds/core/v3/context_params.upbdefs.c +18 -24
- data/src/core/ext/upbdefs-generated/xds/core/v3/resource.upbdefs.c +19 -23
- data/src/core/ext/upbdefs-generated/xds/core/v3/resource_locator.upbdefs.c +35 -41
- data/src/core/ext/upbdefs-generated/xds/core/v3/resource_name.upbdefs.c +21 -25
- data/src/core/ext/upbdefs-generated/xds/type/v3/typed_struct.upbdefs.c +40 -0
- data/src/core/ext/upbdefs-generated/xds/type/v3/typed_struct.upbdefs.h +35 -0
- data/src/core/ext/xds/certificate_provider_registry.cc +1 -1
- data/src/core/ext/xds/certificate_provider_store.h +1 -1
- data/src/core/ext/xds/upb_utils.h +65 -0
- data/src/core/ext/xds/xds_api.cc +159 -3468
- data/src/core/ext/xds/xds_api.h +57 -558
- data/src/core/ext/xds/xds_bootstrap.cc +189 -122
- data/src/core/ext/xds/xds_bootstrap.h +30 -15
- data/src/core/ext/xds/xds_certificate_provider.cc +3 -3
- data/src/core/ext/xds/xds_certificate_provider.h +2 -2
- data/src/core/ext/xds/xds_channel_creds.cc +108 -0
- data/src/core/ext/xds/xds_channel_creds.h +50 -0
- data/src/core/ext/xds/xds_channel_stack_modifier.cc +112 -0
- data/src/core/ext/xds/xds_channel_stack_modifier.h +52 -0
- data/src/core/ext/xds/xds_client.cc +751 -844
- data/src/core/ext/xds/xds_client.h +100 -143
- data/src/core/ext/xds/xds_client_stats.h +1 -1
- data/src/core/ext/xds/xds_cluster.cc +451 -0
- data/src/core/ext/xds/xds_cluster.h +111 -0
- data/src/core/ext/xds/xds_common_types.cc +388 -0
- data/src/core/ext/xds/xds_common_types.h +110 -0
- data/src/core/ext/xds/xds_endpoint.cc +364 -0
- data/src/core/ext/xds/xds_endpoint.h +135 -0
- data/src/core/ext/xds/xds_http_filters.cc +5 -0
- data/src/core/ext/xds/xds_http_rbac_filter.cc +563 -0
- data/src/core/ext/xds/xds_http_rbac_filter.h +54 -0
- data/src/core/ext/xds/xds_listener.cc +1036 -0
- data/src/core/ext/xds/xds_listener.h +220 -0
- data/src/core/ext/{filters/workarounds/workaround_cronet_compression_filter.h → xds/xds_resource_type.cc} +14 -8
- data/src/core/ext/xds/xds_resource_type.h +98 -0
- data/src/core/ext/xds/xds_resource_type_impl.h +87 -0
- data/src/core/ext/xds/xds_route_config.cc +993 -0
- data/src/core/ext/xds/xds_route_config.h +215 -0
- data/src/core/ext/xds/xds_routing.cc +250 -0
- data/src/core/ext/xds/xds_routing.h +101 -0
- data/src/core/ext/xds/xds_server_config_fetcher.cc +1061 -289
- data/src/core/lib/address_utils/parse_address.cc +22 -0
- data/src/core/lib/address_utils/parse_address.h +5 -0
- data/src/core/lib/address_utils/sockaddr_utils.cc +33 -36
- data/src/core/lib/address_utils/sockaddr_utils.h +1 -16
- data/src/core/lib/avl/avl.h +389 -88
- data/src/core/lib/backoff/backoff.cc +6 -32
- data/src/core/lib/backoff/backoff.h +3 -3
- data/src/core/lib/channel/channel_args.cc +25 -8
- data/src/core/lib/channel/channel_args.h +11 -1
- data/src/core/lib/channel/channel_args_preconditioning.cc +47 -0
- data/src/core/lib/channel/channel_args_preconditioning.h +62 -0
- data/src/core/lib/channel/channel_stack.cc +8 -0
- data/src/core/lib/channel/channel_stack.h +1 -1
- data/src/core/lib/channel/channel_stack_builder.cc +8 -14
- data/src/core/lib/channel/channel_stack_builder.h +4 -7
- data/src/core/lib/channel/channel_trace.cc +7 -7
- data/src/core/lib/channel/channel_trace.h +1 -1
- data/src/core/lib/channel/channelz.cc +4 -3
- data/src/core/lib/channel/channelz.h +2 -2
- data/src/core/lib/channel/channelz_registry.cc +1 -1
- data/src/core/lib/channel/channelz_registry.h +1 -1
- data/src/core/lib/channel/connected_channel.cc +1 -3
- data/src/core/lib/channel/connected_channel.h +1 -2
- data/src/core/lib/compression/compression.cc +21 -113
- data/src/core/lib/compression/compression_internal.cc +142 -202
- data/src/core/lib/compression/compression_internal.h +64 -69
- data/src/core/lib/compression/message_compress.cc +11 -11
- data/src/core/lib/compression/message_compress.h +2 -2
- data/src/core/lib/config/core_configuration.cc +46 -2
- data/src/core/lib/config/core_configuration.h +50 -1
- data/src/core/lib/debug/stats.cc +1 -1
- data/src/core/lib/debug/stats_data.cc +13 -13
- data/src/core/lib/debug/trace.h +2 -2
- data/src/core/lib/event_engine/{endpoint_config.cc → channel_args_endpoint_config.cc} +2 -1
- data/src/core/lib/event_engine/{endpoint_config_internal.h → channel_args_endpoint_config.h} +3 -3
- data/src/core/lib/event_engine/event_engine.cc +0 -13
- data/src/core/lib/event_engine/event_engine_factory.cc +49 -0
- data/src/core/lib/event_engine/event_engine_factory.h +33 -0
- data/src/core/lib/event_engine/memory_allocator.cc +70 -0
- data/src/core/lib/gpr/atm.cc +1 -1
- data/src/core/lib/gpr/cpu_posix.cc +1 -1
- data/src/core/lib/gpr/string.cc +2 -2
- data/src/core/lib/gpr/tls.h +7 -1
- data/src/core/lib/gpr/useful.h +83 -32
- data/src/core/lib/gprpp/bitset.h +45 -16
- data/src/core/lib/gprpp/chunked_vector.h +253 -0
- data/src/core/lib/gprpp/construct_destruct.h +1 -1
- data/src/core/lib/gprpp/cpp_impl_of.h +45 -0
- data/src/core/lib/gprpp/global_config_env.cc +7 -7
- data/src/core/lib/gprpp/global_config_env.h +2 -2
- data/src/core/lib/gprpp/manual_constructor.h +2 -3
- data/src/core/lib/gprpp/memory.h +6 -0
- data/src/core/lib/gprpp/orphanable.h +1 -1
- data/src/core/lib/gprpp/ref_counted.h +1 -1
- data/src/core/lib/gprpp/ref_counted_ptr.h +2 -4
- data/src/core/lib/gprpp/status_helper.cc +35 -23
- data/src/core/lib/gprpp/status_helper.h +14 -16
- data/src/core/lib/gprpp/table.h +434 -0
- data/src/core/lib/http/httpcli.cc +215 -202
- data/src/core/lib/http/httpcli.h +17 -27
- data/src/core/lib/http/parser.cc +2 -2
- data/src/core/lib/iomgr/buffer_list.cc +9 -9
- data/src/core/lib/iomgr/buffer_list.h +13 -13
- data/src/core/lib/iomgr/call_combiner.cc +44 -16
- data/src/core/lib/iomgr/closure.h +29 -9
- data/src/core/lib/iomgr/combiner.cc +31 -24
- data/src/core/lib/iomgr/endpoint.h +0 -1
- data/src/core/lib/iomgr/endpoint_cfstream.cc +14 -30
- data/src/core/lib/iomgr/endpoint_cfstream.h +4 -4
- data/src/core/lib/iomgr/endpoint_pair_posix.cc +9 -11
- data/src/core/lib/iomgr/endpoint_pair_windows.cc +5 -14
- data/src/core/lib/iomgr/error.cc +115 -52
- data/src/core/lib/iomgr/error.h +53 -9
- data/src/core/lib/iomgr/error_cfstream.cc +5 -0
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +3 -2
- data/src/core/lib/iomgr/ev_epollex_linux.cc +7 -7
- data/src/core/lib/iomgr/ev_poll_posix.cc +29 -20
- data/src/core/lib/iomgr/event_engine/closure.cc +41 -18
- data/src/core/lib/iomgr/event_engine/closure.h +10 -1
- data/src/core/lib/iomgr/event_engine/endpoint.cc +5 -6
- data/src/core/lib/iomgr/event_engine/iomgr.cc +9 -28
- data/src/core/lib/iomgr/event_engine/pollset.cc +5 -4
- data/src/core/lib/iomgr/event_engine/resolved_address_internal.cc +6 -0
- data/src/core/lib/iomgr/event_engine/resolved_address_internal.h +2 -0
- data/src/core/lib/iomgr/event_engine/resolver.cc +68 -46
- data/src/core/lib/iomgr/event_engine/resolver.h +56 -0
- data/src/core/lib/iomgr/event_engine/tcp.cc +16 -13
- data/src/core/lib/iomgr/event_engine/timer.cc +10 -4
- data/src/core/lib/iomgr/exec_ctx.cc +23 -18
- data/src/core/lib/iomgr/exec_ctx.h +11 -11
- data/src/core/lib/iomgr/executor/mpmcqueue.cc +5 -7
- data/src/core/lib/iomgr/executor/mpmcqueue.h +3 -8
- data/src/core/lib/iomgr/executor.cc +26 -34
- data/src/core/lib/iomgr/executor.h +1 -1
- data/src/core/lib/iomgr/fork_posix.cc +3 -2
- data/src/core/lib/iomgr/iomgr.cc +3 -1
- data/src/core/lib/iomgr/iomgr_custom.cc +4 -1
- data/src/core/lib/iomgr/iomgr_internal.cc +4 -9
- data/src/core/lib/iomgr/iomgr_internal.h +3 -2
- data/src/core/lib/iomgr/iomgr_posix.cc +2 -2
- data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +2 -2
- data/src/core/lib/iomgr/iomgr_windows.cc +2 -2
- data/src/core/lib/iomgr/load_file.cc +2 -2
- data/src/core/lib/iomgr/lockfree_event.cc +18 -0
- data/src/core/lib/iomgr/pollset_custom.cc +1 -1
- data/src/core/lib/iomgr/pollset_custom.h +1 -1
- data/src/core/lib/iomgr/port.h +2 -2
- data/src/core/lib/iomgr/resolve_address.cc +5 -24
- data/src/core/lib/iomgr/resolve_address.h +47 -44
- data/src/core/lib/iomgr/resolve_address_custom.cc +131 -109
- data/src/core/lib/iomgr/resolve_address_custom.h +101 -19
- data/src/core/lib/iomgr/resolve_address_impl.h +59 -0
- data/src/core/lib/iomgr/resolve_address_posix.cc +87 -73
- data/src/core/lib/iomgr/resolve_address_posix.h +47 -0
- data/src/core/lib/iomgr/resolve_address_windows.cc +93 -74
- data/src/core/lib/iomgr/resolve_address_windows.h +47 -0
- data/src/core/lib/iomgr/resolved_address.h +39 -0
- data/src/core/lib/iomgr/socket_factory_posix.cc +2 -2
- data/src/core/lib/iomgr/socket_mutator.cc +2 -2
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +1 -2
- data/src/core/lib/iomgr/tcp_client.cc +2 -4
- data/src/core/lib/iomgr/tcp_client.h +1 -3
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +6 -12
- data/src/core/lib/iomgr/tcp_client_custom.cc +5 -11
- data/src/core/lib/iomgr/tcp_client_posix.cc +16 -41
- data/src/core/lib/iomgr/tcp_client_posix.h +3 -4
- data/src/core/lib/iomgr/tcp_client_windows.cc +3 -13
- data/src/core/lib/iomgr/tcp_custom.cc +9 -36
- data/src/core/lib/iomgr/tcp_custom.h +0 -1
- data/src/core/lib/iomgr/tcp_posix.cc +32 -38
- data/src/core/lib/iomgr/tcp_posix.h +1 -3
- data/src/core/lib/iomgr/tcp_server.cc +4 -6
- data/src/core/lib/iomgr/tcp_server.h +6 -8
- data/src/core/lib/iomgr/tcp_server_custom.cc +7 -16
- data/src/core/lib/iomgr/tcp_server_posix.cc +20 -25
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +19 -18
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +1 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +1 -0
- data/src/core/lib/iomgr/tcp_server_windows.cc +9 -17
- data/src/core/lib/iomgr/tcp_windows.cc +4 -9
- data/src/core/lib/iomgr/tcp_windows.h +1 -2
- data/src/core/lib/iomgr/timer_generic.cc +13 -13
- data/src/core/lib/iomgr/timer_heap.cc +1 -1
- data/src/core/lib/iomgr/unix_sockets_posix.cc +22 -34
- data/src/core/lib/iomgr/unix_sockets_posix.h +4 -7
- data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +6 -15
- data/src/core/lib/iomgr/work_serializer.cc +115 -44
- data/src/core/lib/iomgr/work_serializer.h +16 -4
- data/src/core/lib/json/json_reader.cc +83 -35
- data/src/core/lib/json/json_util.cc +69 -1
- data/src/core/lib/json/json_util.h +57 -99
- data/src/core/lib/json/json_writer.cc +0 -3
- data/src/core/lib/matchers/matchers.cc +1 -1
- data/src/core/lib/promise/activity.cc +115 -0
- data/src/core/lib/promise/activity.h +528 -0
- data/src/core/lib/promise/context.h +86 -0
- data/src/core/lib/promise/detail/basic_seq.h +407 -0
- data/src/core/lib/promise/detail/promise_factory.h +189 -0
- data/src/core/lib/promise/detail/promise_like.h +85 -0
- data/src/core/lib/promise/detail/status.h +49 -0
- data/src/core/lib/promise/detail/switch.h +1455 -0
- data/src/core/lib/promise/exec_ctx_wakeup_scheduler.h +48 -0
- data/src/core/lib/promise/loop.h +108 -0
- data/src/core/lib/promise/map.h +88 -0
- data/src/core/lib/promise/poll.h +60 -0
- data/src/core/lib/promise/race.h +84 -0
- data/src/core/lib/promise/seq.h +71 -0
- data/src/core/{ext/filters/client_channel → lib/resolver}/resolver.cc +17 -25
- data/src/core/{ext/filters/client_channel → lib/resolver}/resolver.h +43 -44
- data/src/core/{ext/filters/client_channel → lib/resolver}/resolver_factory.h +12 -5
- data/src/core/{ext/filters/client_channel → lib/resolver}/resolver_registry.cc +15 -17
- data/src/core/{ext/filters/client_channel → lib/resolver}/resolver_registry.h +5 -7
- data/src/core/{ext/filters/client_channel → lib/resolver}/server_address.cc +1 -1
- data/src/core/{ext/filters/client_channel → lib/resolver}/server_address.h +5 -5
- data/src/core/lib/resource_quota/api.cc +108 -0
- data/src/core/lib/resource_quota/api.h +40 -0
- data/src/core/lib/{gprpp → resource_quota}/arena.cc +16 -13
- data/src/core/lib/{gprpp → resource_quota}/arena.h +32 -11
- data/src/core/lib/resource_quota/memory_quota.cc +454 -0
- data/src/core/lib/resource_quota/memory_quota.h +421 -0
- data/src/core/lib/resource_quota/resource_quota.cc +33 -0
- data/src/core/lib/resource_quota/resource_quota.h +58 -0
- data/src/core/lib/{transport/authority_override.h → resource_quota/thread_quota.cc} +22 -16
- data/src/core/lib/resource_quota/thread_quota.h +57 -0
- data/src/core/lib/resource_quota/trace.cc +19 -0
- data/src/core/lib/resource_quota/trace.h +24 -0
- data/src/core/lib/security/authorization/authorization_policy_provider.h +1 -1
- data/src/core/lib/security/authorization/authorization_policy_provider_vtable.cc +1 -1
- data/src/core/lib/security/authorization/evaluate_args.cc +41 -30
- data/src/core/lib/security/authorization/evaluate_args.h +3 -1
- data/src/core/lib/security/authorization/grpc_authorization_engine.cc +60 -0
- data/src/core/lib/security/authorization/grpc_authorization_engine.h +62 -0
- data/src/core/lib/security/authorization/matchers.cc +227 -0
- data/src/core/lib/security/authorization/matchers.h +211 -0
- data/src/core/lib/security/authorization/rbac_policy.cc +442 -0
- data/src/core/lib/security/authorization/rbac_policy.h +170 -0
- data/src/core/lib/security/authorization/sdk_server_authz_filter.cc +15 -1
- data/src/core/lib/security/context/security_context.cc +8 -4
- data/src/core/lib/security/context/security_context.h +1 -1
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +6 -6
- data/src/core/lib/security/credentials/composite/composite_credentials.h +4 -3
- data/src/core/lib/security/credentials/credentials.cc +4 -2
- data/src/core/lib/security/credentials/credentials.h +16 -21
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +8 -12
- data/src/core/lib/security/credentials/external/external_account_credentials.cc +57 -24
- data/src/core/lib/security/credentials/external/external_account_credentials.h +3 -7
- data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +2 -4
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +5 -4
- data/src/core/lib/security/credentials/fake/fake_credentials.h +8 -7
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +4 -9
- data/src/core/lib/security/credentials/iam/iam_credentials.cc +16 -19
- data/src/core/lib/security/credentials/iam/iam_credentials.h +6 -5
- data/src/core/lib/security/credentials/jwt/json_token.cc +4 -6
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +17 -29
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +8 -8
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +11 -24
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +53 -70
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +13 -15
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +8 -9
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +5 -4
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +1 -10
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +11 -12
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +7 -8
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.cc +201 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.h +106 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +15 -88
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +26 -82
- data/src/core/lib/security/credentials/tls/tls_credentials.cc +21 -10
- data/src/core/lib/security/credentials/xds/xds_credentials.cc +28 -33
- data/src/core/lib/security/credentials/xds/xds_credentials.h +1 -1
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +3 -3
- data/src/core/lib/security/security_connector/alts/alts_security_connector.h +2 -2
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +5 -6
- data/src/core/lib/security/security_connector/insecure/insecure_security_connector.cc +2 -2
- data/src/core/lib/security/security_connector/insecure/insecure_security_connector.h +7 -7
- data/src/core/lib/security/security_connector/load_system_roots_linux.cc +1 -2
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +4 -1
- data/src/core/lib/security/security_connector/security_connector.cc +9 -8
- data/src/core/lib/security/security_connector/security_connector.h +6 -2
- data/src/core/lib/security/security_connector/ssl_utils.cc +25 -27
- data/src/core/lib/security/security_connector/ssl_utils.h +6 -15
- data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +347 -198
- data/src/core/lib/security/security_connector/tls/tls_security_connector.h +64 -43
- data/src/core/lib/security/transport/auth_filters.h +7 -0
- data/src/core/lib/security/transport/client_auth_filter.cc +53 -33
- data/src/core/lib/security/transport/security_handshaker.cc +75 -45
- data/src/core/lib/security/transport/server_auth_filter.cc +40 -37
- data/src/core/lib/security/transport/tsi_error.cc +3 -5
- data/src/core/{ext/filters/client_channel → lib/service_config}/service_config.cc +2 -2
- data/src/core/{ext/filters/client_channel → lib/service_config}/service_config.h +4 -4
- data/src/core/lib/service_config/service_config_call_data.h +72 -0
- data/src/core/{ext/filters/client_channel → lib/service_config}/service_config_parser.cc +3 -3
- data/src/core/{ext/filters/client_channel → lib/service_config}/service_config_parser.h +8 -6
- data/src/core/lib/slice/percent_encoding.cc +30 -86
- data/src/core/lib/slice/percent_encoding.h +5 -11
- data/src/core/lib/slice/slice.cc +10 -24
- data/src/core/lib/slice/slice.h +371 -0
- data/src/core/lib/{compression/stream_compression_gzip.h → slice/slice_api.cc} +18 -7
- data/src/core/lib/slice/slice_buffer.cc +9 -5
- data/src/core/lib/slice/slice_intern.cc +4 -107
- data/src/core/lib/slice/slice_internal.h +2 -246
- data/src/core/lib/slice/slice_refcount.cc +17 -0
- data/src/core/lib/slice/slice_refcount.h +116 -0
- data/src/core/lib/slice/slice_refcount_base.h +165 -0
- data/src/core/lib/slice/slice_split.cc +100 -0
- data/src/core/lib/slice/slice_split.h +40 -0
- data/src/core/lib/slice/slice_string_helpers.cc +0 -83
- data/src/core/lib/slice/slice_string_helpers.h +0 -11
- data/src/core/lib/surface/builtins.cc +49 -0
- data/src/core/lib/surface/builtins.h +26 -0
- data/src/core/lib/surface/call.cc +249 -482
- data/src/core/lib/surface/call.h +4 -10
- data/src/core/lib/surface/channel.cc +53 -93
- data/src/core/lib/surface/channel.h +6 -25
- data/src/core/lib/surface/channel_init.cc +23 -76
- data/src/core/lib/surface/channel_init.h +52 -44
- data/src/core/lib/surface/completion_queue.cc +8 -7
- data/src/core/lib/surface/init.cc +0 -42
- data/src/core/lib/surface/init_secure.cc +17 -14
- data/src/core/lib/surface/lame_client.cc +41 -28
- data/src/core/lib/surface/lame_client.h +1 -1
- data/src/core/lib/surface/server.cc +46 -55
- data/src/core/lib/surface/server.h +27 -21
- data/src/core/lib/surface/validate_metadata.cc +7 -4
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/bdp_estimator.cc +2 -2
- data/src/core/lib/transport/byte_stream.cc +4 -0
- data/src/core/lib/transport/error_utils.cc +42 -17
- data/src/core/lib/transport/error_utils.h +15 -1
- data/src/core/lib/transport/metadata_batch.h +1167 -176
- data/src/core/lib/transport/{authority_override.cc → parsed_metadata.cc} +14 -17
- data/src/core/lib/transport/parsed_metadata.h +385 -0
- data/src/core/lib/transport/pid_controller.cc +4 -4
- data/src/core/lib/transport/timeout_encoding.cc +200 -66
- data/src/core/lib/transport/timeout_encoding.h +40 -10
- data/src/core/lib/transport/transport.cc +8 -31
- data/src/core/lib/transport/transport.h +1 -2
- data/src/core/lib/transport/transport_op_string.cc +7 -20
- data/src/core/lib/uri/uri_parser.cc +233 -63
- data/src/core/lib/uri/uri_parser.h +38 -23
- data/src/core/plugin_registry/grpc_plugin_registry.cc +69 -45
- data/src/core/tsi/alts/crypt/aes_gcm.cc +3 -1
- data/src/core/tsi/alts/frame_protector/alts_frame_protector.cc +13 -12
- data/src/core/tsi/alts/frame_protector/frame_handler.cc +10 -11
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +3 -4
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +12 -2
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc +1 -1
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +2 -2
- data/src/core/tsi/fake_transport_security.cc +15 -7
- data/src/core/tsi/local_transport_security.cc +43 -80
- data/src/core/tsi/ssl/session_cache/ssl_session.h +2 -4
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +16 -50
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +6 -7
- data/src/core/tsi/ssl_transport_security.cc +93 -16
- data/src/core/tsi/ssl_transport_security.h +19 -6
- data/src/core/tsi/transport_security.cc +12 -0
- data/src/core/tsi/transport_security.h +16 -1
- data/src/core/tsi/transport_security_interface.h +26 -0
- data/src/ruby/ext/grpc/extconf.rb +21 -11
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +12 -10
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +18 -15
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +1 -0
- data/src/ruby/spec/client_server_spec.rb +1 -1
- data/third_party/abseil-cpp/absl/algorithm/container.h +101 -91
- data/third_party/abseil-cpp/absl/base/attributes.h +64 -31
- data/third_party/abseil-cpp/absl/base/config.h +67 -37
- data/third_party/abseil-cpp/absl/base/dynamic_annotations.h +1 -26
- data/third_party/abseil-cpp/absl/base/internal/fast_type_id.h +48 -0
- data/third_party/abseil-cpp/absl/base/internal/spinlock.h +3 -1
- data/third_party/abseil-cpp/absl/base/internal/spinlock_wait.h +2 -0
- data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +69 -0
- data/third_party/abseil-cpp/absl/base/internal/thread_identity.cc +4 -4
- data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +15 -10
- data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +16 -0
- data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h +4 -4
- data/third_party/abseil-cpp/absl/base/options.h +1 -1
- data/third_party/abseil-cpp/absl/container/fixed_array.h +0 -5
- data/third_party/abseil-cpp/absl/container/inlined_vector.h +105 -97
- data/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h +17 -15
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +18 -102
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +37 -78
- data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +388 -423
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_map.h +3 -2
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +14 -8
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +251 -120
- data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +11 -1
- data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.cc +12 -11
- data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.h +6 -2
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_config.h +12 -5
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_emscripten-inl.inc +110 -0
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_riscv-inl.inc +234 -0
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc +25 -7
- data/third_party/abseil-cpp/absl/debugging/internal/symbolize.h +8 -2
- data/third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc +21 -3
- data/third_party/abseil-cpp/absl/debugging/stacktrace.cc +2 -0
- data/third_party/abseil-cpp/absl/debugging/symbolize.cc +2 -0
- data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +14 -0
- data/third_party/abseil-cpp/absl/debugging/symbolize_emscripten.inc +72 -0
- data/third_party/abseil-cpp/absl/functional/function_ref.h +4 -1
- data/third_party/abseil-cpp/absl/hash/hash.h +22 -0
- data/third_party/abseil-cpp/absl/hash/internal/hash.cc +15 -16
- data/third_party/abseil-cpp/absl/hash/internal/hash.h +88 -37
- data/third_party/abseil-cpp/absl/hash/internal/{wyhash.cc → low_level_hash.cc} +23 -11
- data/third_party/abseil-cpp/absl/hash/internal/{wyhash.h → low_level_hash.h} +14 -12
- data/third_party/abseil-cpp/absl/memory/memory.h +1 -1
- data/third_party/abseil-cpp/absl/meta/type_traits.h +32 -2
- data/third_party/abseil-cpp/absl/numeric/int128.cc +3 -10
- data/third_party/abseil-cpp/absl/numeric/int128.h +146 -73
- data/third_party/abseil-cpp/absl/numeric/int128_have_intrinsic.inc +19 -25
- data/third_party/abseil-cpp/absl/numeric/int128_no_intrinsic.inc +73 -70
- data/third_party/abseil-cpp/absl/{base → profiling}/internal/exponential_biased.cc +4 -4
- data/third_party/abseil-cpp/absl/{base → profiling}/internal/exponential_biased.h +6 -6
- data/third_party/abseil-cpp/absl/profiling/internal/sample_recorder.h +230 -0
- data/third_party/abseil-cpp/absl/random/bernoulli_distribution.h +200 -0
- data/third_party/abseil-cpp/absl/random/beta_distribution.h +427 -0
- data/third_party/abseil-cpp/absl/random/discrete_distribution.cc +98 -0
- data/third_party/abseil-cpp/absl/random/discrete_distribution.h +247 -0
- data/third_party/abseil-cpp/absl/random/distributions.h +452 -0
- data/third_party/abseil-cpp/absl/random/exponential_distribution.h +165 -0
- data/third_party/abseil-cpp/absl/random/gaussian_distribution.cc +104 -0
- data/third_party/abseil-cpp/absl/random/gaussian_distribution.h +275 -0
- data/third_party/abseil-cpp/absl/random/internal/distribution_caller.h +92 -0
- data/third_party/abseil-cpp/absl/random/internal/fast_uniform_bits.h +268 -0
- data/third_party/abseil-cpp/absl/random/internal/fastmath.h +57 -0
- data/third_party/abseil-cpp/absl/random/internal/generate_real.h +144 -0
- data/third_party/abseil-cpp/absl/random/internal/iostream_state_saver.h +245 -0
- data/third_party/abseil-cpp/absl/random/internal/nonsecure_base.h +150 -0
- data/third_party/abseil-cpp/absl/random/internal/pcg_engine.h +308 -0
- data/third_party/abseil-cpp/absl/random/internal/platform.h +171 -0
- data/third_party/abseil-cpp/absl/random/internal/pool_urbg.cc +253 -0
- data/third_party/abseil-cpp/absl/random/internal/pool_urbg.h +131 -0
- data/third_party/abseil-cpp/absl/random/internal/randen.cc +91 -0
- data/third_party/abseil-cpp/absl/random/internal/randen.h +102 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_detect.cc +221 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_detect.h +33 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_engine.h +239 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_hwaes.cc +526 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_hwaes.h +50 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_round_keys.cc +462 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_slow.cc +471 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_slow.h +40 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_traits.h +88 -0
- data/third_party/abseil-cpp/absl/random/internal/salted_seed_seq.h +167 -0
- data/third_party/abseil-cpp/absl/random/internal/seed_material.cc +267 -0
- data/third_party/abseil-cpp/absl/random/internal/seed_material.h +104 -0
- data/third_party/abseil-cpp/absl/random/internal/traits.h +101 -0
- data/third_party/abseil-cpp/absl/random/internal/uniform_helper.h +244 -0
- data/third_party/abseil-cpp/absl/random/internal/wide_multiply.h +111 -0
- data/third_party/abseil-cpp/absl/random/log_uniform_int_distribution.h +257 -0
- data/third_party/abseil-cpp/absl/random/poisson_distribution.h +258 -0
- data/third_party/abseil-cpp/absl/random/random.h +189 -0
- data/third_party/abseil-cpp/absl/random/seed_gen_exception.cc +46 -0
- data/third_party/abseil-cpp/absl/random/seed_gen_exception.h +55 -0
- data/third_party/abseil-cpp/absl/random/seed_sequences.cc +29 -0
- data/third_party/abseil-cpp/absl/random/seed_sequences.h +110 -0
- data/third_party/abseil-cpp/absl/random/uniform_int_distribution.h +275 -0
- data/third_party/abseil-cpp/absl/random/uniform_real_distribution.h +202 -0
- data/third_party/abseil-cpp/absl/random/zipf_distribution.h +271 -0
- data/third_party/abseil-cpp/absl/status/internal/status_internal.h +5 -5
- data/third_party/abseil-cpp/absl/status/status.cc +9 -17
- data/third_party/abseil-cpp/absl/status/status.h +19 -15
- data/third_party/abseil-cpp/absl/status/statusor.cc +34 -2
- data/third_party/abseil-cpp/absl/status/statusor.h +31 -21
- data/third_party/abseil-cpp/absl/strings/charconv.cc +3 -3
- data/third_party/abseil-cpp/absl/strings/charconv.h +3 -2
- data/third_party/abseil-cpp/absl/strings/cord.cc +453 -359
- data/third_party/abseil-cpp/absl/strings/cord.h +197 -70
- data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc +1 -1
- data/third_party/abseil-cpp/absl/strings/internal/cord_internal.cc +6 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +140 -63
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_btree.cc +1128 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_btree.h +939 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_btree_navigator.cc +185 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_btree_navigator.h +265 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_btree_reader.cc +68 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_btree_reader.h +211 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_consume.cc +129 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_consume.h +50 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_flat.h +7 -7
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_ring.cc +55 -181
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_ring.h +42 -24
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_ring_reader.h +4 -0
- data/third_party/abseil-cpp/absl/strings/internal/cordz_functions.cc +96 -0
- data/third_party/abseil-cpp/absl/strings/internal/cordz_functions.h +85 -0
- data/third_party/abseil-cpp/absl/strings/internal/cordz_handle.cc +139 -0
- data/third_party/abseil-cpp/absl/strings/internal/cordz_handle.h +131 -0
- data/third_party/abseil-cpp/absl/strings/internal/cordz_info.cc +445 -0
- data/third_party/abseil-cpp/absl/strings/internal/cordz_info.h +298 -0
- data/third_party/abseil-cpp/absl/strings/internal/cordz_statistics.h +87 -0
- data/third_party/abseil-cpp/absl/strings/internal/cordz_update_scope.h +71 -0
- data/third_party/abseil-cpp/absl/strings/internal/cordz_update_tracker.h +121 -0
- data/third_party/abseil-cpp/absl/strings/internal/resize_uninitialized.h +48 -2
- data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +8 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc +3 -4
- data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +1 -1
- data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.cc +6 -6
- data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.h +36 -18
- data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc +62 -73
- data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h +24 -16
- data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +35 -35
- data/third_party/abseil-cpp/absl/strings/numbers.cc +1 -1
- data/third_party/abseil-cpp/absl/strings/numbers.h +34 -0
- data/third_party/abseil-cpp/absl/strings/str_cat.cc +4 -4
- data/third_party/abseil-cpp/absl/strings/str_format.h +1 -2
- data/third_party/abseil-cpp/absl/strings/string_view.cc +16 -21
- data/third_party/abseil-cpp/absl/strings/string_view.h +120 -39
- data/third_party/abseil-cpp/absl/strings/substitute.cc +2 -1
- data/third_party/abseil-cpp/absl/strings/substitute.h +99 -74
- data/third_party/abseil-cpp/absl/synchronization/blocking_counter.cc +25 -15
- data/third_party/abseil-cpp/absl/synchronization/blocking_counter.h +5 -3
- data/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc +1 -1
- data/third_party/abseil-cpp/absl/synchronization/mutex.h +3 -3
- data/third_party/abseil-cpp/absl/time/civil_time.cc +1 -3
- data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h +93 -20
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.cc +1 -1
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.h +2 -1
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc +83 -21
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc +49 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +1 -1
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc +2 -3
- data/third_party/abseil-cpp/absl/time/time.h +67 -36
- data/third_party/abseil-cpp/absl/types/bad_optional_access.h +1 -1
- data/third_party/abseil-cpp/absl/types/bad_variant_access.h +2 -2
- data/third_party/abseil-cpp/absl/types/span.h +3 -3
- data/third_party/address_sorting/address_sorting_posix.c +1 -0
- data/third_party/boringssl-with-bazel/err_data.c +681 -677
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bitstr.c +19 -11
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bool.c +20 -21
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +41 -30
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strnid.c +104 -114
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_time.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_lib.c +59 -47
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn_pack.c +24 -28
- data/third_party/boringssl-with-bazel/src/crypto/asn1/f_int.c +5 -0
- data/third_party/boringssl-with-bazel/src/crypto/asn1/internal.h +41 -0
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_dec.c +48 -272
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_typ.c +8 -6
- data/third_party/boringssl-with-bazel/src/crypto/base64/base64.c +13 -0
- data/third_party/boringssl-with-bazel/src/crypto/blake2/blake2.c +4 -6
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/ber.c +3 -1
- data/third_party/boringssl-with-bazel/src/crypto/chacha/chacha.c +38 -47
- data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +21 -0
- data/third_party/boringssl-with-bazel/src/crypto/evp/evp_asn1.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/evp/scrypt.c +32 -34
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/sqrt.c +5 -9
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/cipher.c +12 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/des/des.c +10 -11
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/des/internal.h +1 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +1 -2
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md4/md4.c +3 -6
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/md5.c +4 -7
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +7 -7
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1.c +35 -35
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha256.c +11 -10
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +10 -37
- data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/internal.h +39 -0
- data/third_party/boringssl-with-bazel/src/crypto/mem.c +18 -0
- data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7.c +29 -0
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/internal.h +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/pool/internal.h +5 -1
- data/third_party/boringssl-with-bazel/src/crypto/pool/pool.c +59 -23
- data/third_party/boringssl-with-bazel/src/crypto/siphash/siphash.c +6 -6
- data/third_party/boringssl-with-bazel/src/crypto/x509/asn1_gen.c +2 -18
- data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +8 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +216 -11
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_cache.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_data.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_lib.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_map.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_node.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_tree.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_alt.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_cpols.c +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_lib.c +21 -4
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +0 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +1019 -274
- data/third_party/boringssl-with-bazel/src/include/openssl/asn1t.h +3 -3
- data/third_party/boringssl-with-bazel/src/include/openssl/base.h +5 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/base64.h +8 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +13 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/dh.h +4 -12
- data/third_party/boringssl-with-bazel/src/include/openssl/dsa.h +27 -41
- data/third_party/boringssl-with-bazel/src/include/openssl/ec_key.h +12 -27
- data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +8 -10
- data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +29 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +1 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +12 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/pkcs8.h +6 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/pool.h +7 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +24 -28
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +31 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +491 -58
- data/third_party/boringssl-with-bazel/src/include/openssl/x509_vfy.h +16 -564
- data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +4 -3
- data/third_party/boringssl-with-bazel/src/ssl/internal.h +3 -3
- data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +4 -0
- data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +4 -0
- data/third_party/boringssl-with-bazel/src/ssl/ssl_x509.cc +0 -1
- data/third_party/re2/re2/compile.cc +91 -109
- data/third_party/re2/re2/dfa.cc +27 -39
- data/third_party/re2/re2/filtered_re2.cc +18 -2
- data/third_party/re2/re2/filtered_re2.h +10 -5
- data/third_party/re2/re2/nfa.cc +1 -1
- data/third_party/re2/re2/parse.cc +42 -23
- data/third_party/re2/re2/perl_groups.cc +34 -34
- data/third_party/re2/re2/prefilter.cc +3 -2
- data/third_party/re2/re2/prog.cc +182 -4
- data/third_party/re2/re2/prog.h +28 -9
- data/third_party/re2/re2/re2.cc +87 -118
- data/third_party/re2/re2/re2.h +156 -141
- data/third_party/re2/re2/regexp.cc +12 -5
- data/third_party/re2/re2/regexp.h +8 -2
- data/third_party/re2/re2/set.cc +31 -9
- data/third_party/re2/re2/set.h +9 -4
- data/third_party/re2/re2/simplify.cc +11 -3
- data/third_party/re2/re2/tostring.cc +1 -1
- data/third_party/re2/re2/walker-inl.h +1 -1
- data/third_party/re2/util/mutex.h +2 -2
- data/third_party/re2/util/pcre.h +3 -3
- data/third_party/upb/upb/decode.c +309 -178
- data/third_party/upb/upb/decode_fast.c +1 -1
- data/third_party/upb/upb/decode_internal.h +1 -0
- data/third_party/upb/upb/def.c +330 -85
- data/third_party/upb/upb/def.h +45 -14
- data/third_party/upb/upb/def.hpp +17 -4
- data/third_party/upb/upb/encode.c +100 -40
- data/third_party/upb/upb/msg.c +22 -9
- data/third_party/upb/upb/msg_internal.h +90 -8
- data/third_party/upb/upb/reflection.c +98 -58
- data/third_party/upb/upb/reflection.h +6 -2
- data/third_party/upb/upb/text_encode.c +3 -3
- data/third_party/upb/upb/upb.c +8 -0
- data/third_party/xxhash/xxhash.h +607 -352
- metadata +259 -115
- data/include/grpc/event_engine/slice_allocator.h +0 -71
- data/src/core/ext/filters/client_channel/service_config_call_data.h +0 -126
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +0 -211
- data/src/core/ext/filters/workarounds/workaround_utils.cc +0 -53
- data/src/core/ext/filters/workarounds/workaround_utils.h +0 -39
- data/src/core/ext/transport/chttp2/client/authority.cc +0 -42
- data/src/core/ext/transport/chttp2/client/authority.h +0 -36
- data/src/core/ext/transport/chttp2/transport/chttp2_slice_allocator.cc +0 -67
- data/src/core/ext/transport/chttp2/transport/chttp2_slice_allocator.h +0 -74
- data/src/core/ext/transport/chttp2/transport/hpack_encoder_index.h +0 -107
- data/src/core/ext/transport/chttp2/transport/hpack_utils.cc +0 -46
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +0 -66
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +0 -58
- data/src/core/ext/transport/chttp2/transport/popularity_count.h +0 -60
- data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c +0 -58
- data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h +0 -130
- data/src/core/ext/upb-generated/udpa/type/v1/typed_struct.upb.c +0 -33
- data/src/core/ext/upb-generated/udpa/type/v1/typed_struct.upb.h +0 -83
- data/src/core/ext/upbdefs-generated/udpa/type/v1/typed_struct.upbdefs.c +0 -44
- data/src/core/ext/upbdefs-generated/udpa/type/v1/typed_struct.upbdefs.h +0 -35
- data/src/core/lib/avl/avl.cc +0 -306
- data/src/core/lib/compression/algorithm_metadata.h +0 -62
- data/src/core/lib/compression/compression_args.cc +0 -136
- data/src/core/lib/compression/compression_args.h +0 -56
- data/src/core/lib/compression/stream_compression.cc +0 -81
- data/src/core/lib/compression/stream_compression.h +0 -117
- data/src/core/lib/compression/stream_compression_gzip.cc +0 -231
- data/src/core/lib/compression/stream_compression_identity.cc +0 -91
- data/src/core/lib/compression/stream_compression_identity.h +0 -29
- data/src/core/lib/gprpp/match.h +0 -73
- data/src/core/lib/gprpp/overload.h +0 -59
- data/src/core/lib/iomgr/event_engine/iomgr.h +0 -42
- data/src/core/lib/iomgr/resource_quota.cc +0 -1104
- data/src/core/lib/iomgr/resource_quota.h +0 -226
- data/src/core/lib/iomgr/udp_server.cc +0 -747
- data/src/core/lib/iomgr/udp_server.h +0 -103
- data/src/core/lib/security/credentials/credentials_metadata.cc +0 -61
- data/src/core/lib/transport/metadata.cc +0 -693
- data/src/core/lib/transport/metadata.h +0 -448
- data/src/core/lib/transport/metadata_batch.cc +0 -430
- data/src/core/lib/transport/static_metadata.cc +0 -1249
- data/src/core/lib/transport/static_metadata.h +0 -604
- data/src/core/lib/transport/status_metadata.cc +0 -62
- data/src/core/lib/transport/status_metadata.h +0 -48
- data/third_party/boringssl-with-bazel/src/crypto/asn1/f_enum.c +0 -93
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_int.h +0 -217
data/src/core/ext/xds/xds_api.cc
CHANGED
@@ -1,88 +1,42 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
*
|
17
|
-
*/
|
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
|
+
//
|
18
16
|
|
19
17
|
#include <grpc/support/port_platform.h>
|
20
18
|
|
21
19
|
#include "src/core/ext/xds/xds_api.h"
|
22
20
|
|
23
|
-
#include <
|
24
|
-
#include <cctype>
|
25
|
-
#include <cstdint>
|
26
|
-
#include <cstdlib>
|
21
|
+
#include <set>
|
27
22
|
#include <string>
|
23
|
+
#include <vector>
|
28
24
|
|
29
25
|
#include "absl/strings/str_cat.h"
|
30
|
-
#include "absl/strings/str_format.h"
|
31
|
-
#include "absl/strings/str_join.h"
|
32
|
-
#include "absl/strings/str_split.h"
|
33
26
|
#include "envoy/admin/v3/config_dump.upb.h"
|
34
|
-
#include "envoy/config/cluster/v3/circuit_breaker.upb.h"
|
35
|
-
#include "envoy/config/cluster/v3/cluster.upb.h"
|
36
|
-
#include "envoy/config/cluster/v3/cluster.upbdefs.h"
|
37
|
-
#include "envoy/config/core/v3/address.upb.h"
|
38
27
|
#include "envoy/config/core/v3/base.upb.h"
|
39
|
-
#include "envoy/config/core/v3/base.upbdefs.h"
|
40
|
-
#include "envoy/config/core/v3/config_source.upb.h"
|
41
|
-
#include "envoy/config/core/v3/health_check.upb.h"
|
42
|
-
#include "envoy/config/core/v3/protocol.upb.h"
|
43
|
-
#include "envoy/config/endpoint/v3/endpoint.upb.h"
|
44
|
-
#include "envoy/config/endpoint/v3/endpoint.upbdefs.h"
|
45
|
-
#include "envoy/config/endpoint/v3/endpoint_components.upb.h"
|
46
28
|
#include "envoy/config/endpoint/v3/load_report.upb.h"
|
47
|
-
#include "envoy/config/listener/v3/api_listener.upb.h"
|
48
|
-
#include "envoy/config/listener/v3/listener.upb.h"
|
49
|
-
#include "envoy/config/listener/v3/listener.upbdefs.h"
|
50
|
-
#include "envoy/config/listener/v3/listener_components.upb.h"
|
51
|
-
#include "envoy/config/route/v3/route.upb.h"
|
52
|
-
#include "envoy/config/route/v3/route.upbdefs.h"
|
53
|
-
#include "envoy/config/route/v3/route_components.upb.h"
|
54
|
-
#include "envoy/config/route/v3/route_components.upbdefs.h"
|
55
|
-
#include "envoy/extensions/clusters/aggregate/v3/cluster.upb.h"
|
56
|
-
#include "envoy/extensions/clusters/aggregate/v3/cluster.upbdefs.h"
|
57
|
-
#include "envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h"
|
58
|
-
#include "envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h"
|
59
|
-
#include "envoy/extensions/transport_sockets/tls/v3/common.upb.h"
|
60
|
-
#include "envoy/extensions/transport_sockets/tls/v3/tls.upb.h"
|
61
|
-
#include "envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.h"
|
62
|
-
#include "envoy/service/cluster/v3/cds.upb.h"
|
63
|
-
#include "envoy/service/cluster/v3/cds.upbdefs.h"
|
64
29
|
#include "envoy/service/discovery/v3/discovery.upb.h"
|
65
30
|
#include "envoy/service/discovery/v3/discovery.upbdefs.h"
|
66
|
-
#include "envoy/service/endpoint/v3/eds.upb.h"
|
67
|
-
#include "envoy/service/endpoint/v3/eds.upbdefs.h"
|
68
|
-
#include "envoy/service/listener/v3/lds.upb.h"
|
69
31
|
#include "envoy/service/load_stats/v3/lrs.upb.h"
|
70
32
|
#include "envoy/service/load_stats/v3/lrs.upbdefs.h"
|
71
|
-
#include "envoy/service/route/v3/rds.upb.h"
|
72
|
-
#include "envoy/service/route/v3/rds.upbdefs.h"
|
73
33
|
#include "envoy/service/status/v3/csds.upb.h"
|
74
34
|
#include "envoy/service/status/v3/csds.upbdefs.h"
|
75
|
-
#include "envoy/type/matcher/v3/regex.upb.h"
|
76
|
-
#include "envoy/type/matcher/v3/string.upb.h"
|
77
|
-
#include "envoy/type/v3/percent.upb.h"
|
78
|
-
#include "envoy/type/v3/range.upb.h"
|
79
35
|
#include "google/protobuf/any.upb.h"
|
80
|
-
#include "google/protobuf/duration.upb.h"
|
81
36
|
#include "google/protobuf/struct.upb.h"
|
82
37
|
#include "google/protobuf/timestamp.upb.h"
|
83
38
|
#include "google/protobuf/wrappers.upb.h"
|
84
39
|
#include "google/rpc/status.upb.h"
|
85
|
-
#include "udpa/type/v1/typed_struct.upb.h"
|
86
40
|
#include "upb/text_encode.h"
|
87
41
|
#include "upb/upb.h"
|
88
42
|
#include "upb/upb.hpp"
|
@@ -91,742 +45,23 @@
|
|
91
45
|
#include <grpc/support/alloc.h>
|
92
46
|
#include <grpc/support/string_util.h>
|
93
47
|
|
48
|
+
#include "src/core/ext/xds/upb_utils.h"
|
49
|
+
#include "src/core/ext/xds/xds_common_types.h"
|
50
|
+
#include "src/core/ext/xds/xds_resource_type.h"
|
51
|
+
#include "src/core/ext/xds/xds_routing.h"
|
52
|
+
#include "src/core/lib/address_utils/parse_address.h"
|
94
53
|
#include "src/core/lib/address_utils/sockaddr_utils.h"
|
95
54
|
#include "src/core/lib/gpr/env.h"
|
96
55
|
#include "src/core/lib/gpr/string.h"
|
97
|
-
#include "src/core/lib/gpr/useful.h"
|
98
56
|
#include "src/core/lib/gprpp/host_port.h"
|
99
57
|
#include "src/core/lib/iomgr/error.h"
|
100
58
|
#include "src/core/lib/iomgr/sockaddr.h"
|
101
59
|
#include "src/core/lib/iomgr/socket_utils.h"
|
102
60
|
#include "src/core/lib/slice/slice_utils.h"
|
61
|
+
#include "src/core/lib/uri/uri_parser.h"
|
103
62
|
|
104
63
|
namespace grpc_core {
|
105
64
|
|
106
|
-
// TODO(donnadionne): Check to see if cluster types aggregate_cluster and
|
107
|
-
// logical_dns are enabled, this will be
|
108
|
-
// removed once the cluster types are fully integration-tested and enabled by
|
109
|
-
// default.
|
110
|
-
bool XdsAggregateAndLogicalDnsClusterEnabled() {
|
111
|
-
char* value = gpr_getenv(
|
112
|
-
"GRPC_XDS_EXPERIMENTAL_ENABLE_AGGREGATE_AND_LOGICAL_DNS_CLUSTER");
|
113
|
-
bool parsed_value;
|
114
|
-
bool parse_succeeded = gpr_parse_bool_value(value, &parsed_value);
|
115
|
-
gpr_free(value);
|
116
|
-
return parse_succeeded && parsed_value;
|
117
|
-
}
|
118
|
-
|
119
|
-
//
|
120
|
-
// XdsApi::Route::HashPolicy
|
121
|
-
//
|
122
|
-
|
123
|
-
XdsApi::Route::HashPolicy::HashPolicy(const HashPolicy& other)
|
124
|
-
: type(other.type),
|
125
|
-
header_name(other.header_name),
|
126
|
-
regex_substitution(other.regex_substitution) {
|
127
|
-
if (other.regex != nullptr) {
|
128
|
-
regex =
|
129
|
-
absl::make_unique<RE2>(other.regex->pattern(), other.regex->options());
|
130
|
-
}
|
131
|
-
}
|
132
|
-
|
133
|
-
XdsApi::Route::HashPolicy& XdsApi::Route::HashPolicy::operator=(
|
134
|
-
const HashPolicy& other) {
|
135
|
-
type = other.type;
|
136
|
-
header_name = other.header_name;
|
137
|
-
if (other.regex != nullptr) {
|
138
|
-
regex =
|
139
|
-
absl::make_unique<RE2>(other.regex->pattern(), other.regex->options());
|
140
|
-
}
|
141
|
-
regex_substitution = other.regex_substitution;
|
142
|
-
return *this;
|
143
|
-
}
|
144
|
-
|
145
|
-
XdsApi::Route::HashPolicy::HashPolicy(HashPolicy&& other) noexcept
|
146
|
-
: type(other.type),
|
147
|
-
header_name(std::move(other.header_name)),
|
148
|
-
regex(std::move(other.regex)),
|
149
|
-
regex_substitution(std::move(other.regex_substitution)) {}
|
150
|
-
|
151
|
-
XdsApi::Route::HashPolicy& XdsApi::Route::HashPolicy::operator=(
|
152
|
-
HashPolicy&& other) noexcept {
|
153
|
-
type = other.type;
|
154
|
-
header_name = std::move(other.header_name);
|
155
|
-
regex = std::move(other.regex);
|
156
|
-
regex_substitution = std::move(other.regex_substitution);
|
157
|
-
return *this;
|
158
|
-
}
|
159
|
-
|
160
|
-
bool XdsApi::Route::HashPolicy::HashPolicy::operator==(
|
161
|
-
const HashPolicy& other) const {
|
162
|
-
if (type != other.type) return false;
|
163
|
-
if (type == Type::HEADER) {
|
164
|
-
if (regex == nullptr) {
|
165
|
-
if (other.regex != nullptr) return false;
|
166
|
-
} else {
|
167
|
-
if (other.regex == nullptr) return false;
|
168
|
-
return header_name == other.header_name &&
|
169
|
-
regex->pattern() == other.regex->pattern() &&
|
170
|
-
regex_substitution == other.regex_substitution;
|
171
|
-
}
|
172
|
-
}
|
173
|
-
return true;
|
174
|
-
}
|
175
|
-
|
176
|
-
std::string XdsApi::Route::HashPolicy::ToString() const {
|
177
|
-
std::vector<std::string> contents;
|
178
|
-
switch (type) {
|
179
|
-
case Type::HEADER:
|
180
|
-
contents.push_back("type=HEADER");
|
181
|
-
break;
|
182
|
-
case Type::CHANNEL_ID:
|
183
|
-
contents.push_back("type=CHANNEL_ID");
|
184
|
-
break;
|
185
|
-
}
|
186
|
-
contents.push_back(
|
187
|
-
absl::StrFormat("terminal=%s", terminal ? "true" : "false"));
|
188
|
-
if (type == Type::HEADER) {
|
189
|
-
contents.push_back(absl::StrFormat(
|
190
|
-
"Header %s:/%s/%s", header_name,
|
191
|
-
(regex == nullptr) ? "" : regex->pattern(), regex_substitution));
|
192
|
-
}
|
193
|
-
return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
|
194
|
-
}
|
195
|
-
|
196
|
-
//
|
197
|
-
// XdsApi::Route::RetryPolicy
|
198
|
-
//
|
199
|
-
std::string XdsApi::Route::RetryPolicy::RetryBackOff::ToString() const {
|
200
|
-
std::vector<std::string> contents;
|
201
|
-
contents.push_back(
|
202
|
-
absl::StrCat("RetryBackOff Base: ", base_interval.ToString()));
|
203
|
-
contents.push_back(
|
204
|
-
absl::StrCat("RetryBackOff max: ", max_interval.ToString()));
|
205
|
-
return absl::StrJoin(contents, ",");
|
206
|
-
}
|
207
|
-
|
208
|
-
std::string XdsApi::Route::RetryPolicy::ToString() const {
|
209
|
-
std::vector<std::string> contents;
|
210
|
-
contents.push_back(absl::StrFormat("num_retries=%d", num_retries));
|
211
|
-
contents.push_back(retry_back_off.ToString());
|
212
|
-
return absl::StrJoin(contents, ",");
|
213
|
-
}
|
214
|
-
|
215
|
-
//
|
216
|
-
// XdsApi::Route
|
217
|
-
//
|
218
|
-
|
219
|
-
std::string XdsApi::Route::Matchers::ToString() const {
|
220
|
-
std::vector<std::string> contents;
|
221
|
-
contents.push_back(
|
222
|
-
absl::StrFormat("PathMatcher{%s}", path_matcher.ToString()));
|
223
|
-
for (const HeaderMatcher& header_matcher : header_matchers) {
|
224
|
-
contents.push_back(header_matcher.ToString());
|
225
|
-
}
|
226
|
-
if (fraction_per_million.has_value()) {
|
227
|
-
contents.push_back(absl::StrFormat("Fraction Per Million %d",
|
228
|
-
fraction_per_million.value()));
|
229
|
-
}
|
230
|
-
return absl::StrJoin(contents, "\n");
|
231
|
-
}
|
232
|
-
|
233
|
-
std::string XdsApi::Route::ClusterWeight::ToString() const {
|
234
|
-
std::vector<std::string> contents;
|
235
|
-
contents.push_back(absl::StrCat("cluster=", name));
|
236
|
-
contents.push_back(absl::StrCat("weight=", weight));
|
237
|
-
if (!typed_per_filter_config.empty()) {
|
238
|
-
std::vector<std::string> parts;
|
239
|
-
for (const auto& p : typed_per_filter_config) {
|
240
|
-
const std::string& key = p.first;
|
241
|
-
const auto& config = p.second;
|
242
|
-
parts.push_back(absl::StrCat(key, "=", config.ToString()));
|
243
|
-
}
|
244
|
-
contents.push_back(absl::StrCat("typed_per_filter_config={",
|
245
|
-
absl::StrJoin(parts, ", "), "}"));
|
246
|
-
}
|
247
|
-
return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
|
248
|
-
}
|
249
|
-
|
250
|
-
std::string XdsApi::Route::ToString() const {
|
251
|
-
std::vector<std::string> contents;
|
252
|
-
contents.push_back(matchers.ToString());
|
253
|
-
for (const HashPolicy& hash_policy : hash_policies) {
|
254
|
-
contents.push_back(absl::StrCat("hash_policy=", hash_policy.ToString()));
|
255
|
-
}
|
256
|
-
if (retry_policy.has_value()) {
|
257
|
-
contents.push_back(
|
258
|
-
absl::StrCat("retry_policy={", retry_policy->ToString(), "}"));
|
259
|
-
}
|
260
|
-
if (!cluster_name.empty()) {
|
261
|
-
contents.push_back(absl::StrFormat("Cluster name: %s", cluster_name));
|
262
|
-
}
|
263
|
-
for (const ClusterWeight& cluster_weight : weighted_clusters) {
|
264
|
-
contents.push_back(cluster_weight.ToString());
|
265
|
-
}
|
266
|
-
if (max_stream_duration.has_value()) {
|
267
|
-
contents.push_back(max_stream_duration->ToString());
|
268
|
-
}
|
269
|
-
if (!typed_per_filter_config.empty()) {
|
270
|
-
contents.push_back("typed_per_filter_config={");
|
271
|
-
for (const auto& p : typed_per_filter_config) {
|
272
|
-
const std::string& name = p.first;
|
273
|
-
const auto& config = p.second;
|
274
|
-
contents.push_back(absl::StrCat(" ", name, "=", config.ToString()));
|
275
|
-
}
|
276
|
-
contents.push_back("}");
|
277
|
-
}
|
278
|
-
return absl::StrJoin(contents, "\n");
|
279
|
-
}
|
280
|
-
|
281
|
-
//
|
282
|
-
// XdsApi::RdsUpdate
|
283
|
-
//
|
284
|
-
|
285
|
-
std::string XdsApi::RdsUpdate::ToString() const {
|
286
|
-
std::vector<std::string> vhosts;
|
287
|
-
for (const VirtualHost& vhost : virtual_hosts) {
|
288
|
-
vhosts.push_back(
|
289
|
-
absl::StrCat("vhost={\n"
|
290
|
-
" domains=[",
|
291
|
-
absl::StrJoin(vhost.domains, ", "),
|
292
|
-
"]\n"
|
293
|
-
" routes=[\n"));
|
294
|
-
for (const XdsApi::Route& route : vhost.routes) {
|
295
|
-
vhosts.push_back(" {\n");
|
296
|
-
vhosts.push_back(route.ToString());
|
297
|
-
vhosts.push_back("\n }\n");
|
298
|
-
}
|
299
|
-
vhosts.push_back(" ]\n");
|
300
|
-
vhosts.push_back(" typed_per_filter_config={\n");
|
301
|
-
for (const auto& p : vhost.typed_per_filter_config) {
|
302
|
-
const std::string& name = p.first;
|
303
|
-
const auto& config = p.second;
|
304
|
-
vhosts.push_back(
|
305
|
-
absl::StrCat(" ", name, "=", config.ToString(), "\n"));
|
306
|
-
}
|
307
|
-
vhosts.push_back(" }\n");
|
308
|
-
vhosts.push_back("]\n");
|
309
|
-
}
|
310
|
-
return absl::StrJoin(vhosts, "");
|
311
|
-
}
|
312
|
-
|
313
|
-
namespace {
|
314
|
-
|
315
|
-
// Better match type has smaller value.
|
316
|
-
enum MatchType {
|
317
|
-
EXACT_MATCH,
|
318
|
-
SUFFIX_MATCH,
|
319
|
-
PREFIX_MATCH,
|
320
|
-
UNIVERSE_MATCH,
|
321
|
-
INVALID_MATCH,
|
322
|
-
};
|
323
|
-
|
324
|
-
// Returns true if match succeeds.
|
325
|
-
bool DomainMatch(MatchType match_type, const std::string& domain_pattern_in,
|
326
|
-
const std::string& expected_host_name_in) {
|
327
|
-
// Normalize the args to lower-case. Domain matching is case-insensitive.
|
328
|
-
std::string domain_pattern = domain_pattern_in;
|
329
|
-
std::string expected_host_name = expected_host_name_in;
|
330
|
-
std::transform(domain_pattern.begin(), domain_pattern.end(),
|
331
|
-
domain_pattern.begin(),
|
332
|
-
[](unsigned char c) { return std::tolower(c); });
|
333
|
-
std::transform(expected_host_name.begin(), expected_host_name.end(),
|
334
|
-
expected_host_name.begin(),
|
335
|
-
[](unsigned char c) { return std::tolower(c); });
|
336
|
-
if (match_type == EXACT_MATCH) {
|
337
|
-
return domain_pattern == expected_host_name;
|
338
|
-
} else if (match_type == SUFFIX_MATCH) {
|
339
|
-
// Asterisk must match at least one char.
|
340
|
-
if (expected_host_name.size() < domain_pattern.size()) return false;
|
341
|
-
absl::string_view pattern_suffix(domain_pattern.c_str() + 1);
|
342
|
-
absl::string_view host_suffix(expected_host_name.c_str() +
|
343
|
-
expected_host_name.size() -
|
344
|
-
pattern_suffix.size());
|
345
|
-
return pattern_suffix == host_suffix;
|
346
|
-
} else if (match_type == PREFIX_MATCH) {
|
347
|
-
// Asterisk must match at least one char.
|
348
|
-
if (expected_host_name.size() < domain_pattern.size()) return false;
|
349
|
-
absl::string_view pattern_prefix(domain_pattern.c_str(),
|
350
|
-
domain_pattern.size() - 1);
|
351
|
-
absl::string_view host_prefix(expected_host_name.c_str(),
|
352
|
-
pattern_prefix.size());
|
353
|
-
return pattern_prefix == host_prefix;
|
354
|
-
} else {
|
355
|
-
return match_type == UNIVERSE_MATCH;
|
356
|
-
}
|
357
|
-
}
|
358
|
-
|
359
|
-
MatchType DomainPatternMatchType(const std::string& domain_pattern) {
|
360
|
-
if (domain_pattern.empty()) return INVALID_MATCH;
|
361
|
-
if (domain_pattern.find('*') == std::string::npos) return EXACT_MATCH;
|
362
|
-
if (domain_pattern == "*") return UNIVERSE_MATCH;
|
363
|
-
if (domain_pattern[0] == '*') return SUFFIX_MATCH;
|
364
|
-
if (domain_pattern[domain_pattern.size() - 1] == '*') return PREFIX_MATCH;
|
365
|
-
return INVALID_MATCH;
|
366
|
-
}
|
367
|
-
|
368
|
-
} // namespace
|
369
|
-
|
370
|
-
XdsApi::RdsUpdate::VirtualHost* XdsApi::RdsUpdate::FindVirtualHostForDomain(
|
371
|
-
const std::string& domain) {
|
372
|
-
// Find the best matched virtual host.
|
373
|
-
// The search order for 4 groups of domain patterns:
|
374
|
-
// 1. Exact match.
|
375
|
-
// 2. Suffix match (e.g., "*ABC").
|
376
|
-
// 3. Prefix match (e.g., "ABC*").
|
377
|
-
// 4. Universe match (i.e., "*").
|
378
|
-
// Within each group, longest match wins.
|
379
|
-
// If the same best matched domain pattern appears in multiple virtual hosts,
|
380
|
-
// the first matched virtual host wins.
|
381
|
-
VirtualHost* target_vhost = nullptr;
|
382
|
-
MatchType best_match_type = INVALID_MATCH;
|
383
|
-
size_t longest_match = 0;
|
384
|
-
// Check each domain pattern in each virtual host to determine the best
|
385
|
-
// matched virtual host.
|
386
|
-
for (VirtualHost& vhost : virtual_hosts) {
|
387
|
-
for (const std::string& domain_pattern : vhost.domains) {
|
388
|
-
// Check the match type first. Skip the pattern if it's not better than
|
389
|
-
// current match.
|
390
|
-
const MatchType match_type = DomainPatternMatchType(domain_pattern);
|
391
|
-
// This should be caught by RouteConfigParse().
|
392
|
-
GPR_ASSERT(match_type != INVALID_MATCH);
|
393
|
-
if (match_type > best_match_type) continue;
|
394
|
-
if (match_type == best_match_type &&
|
395
|
-
domain_pattern.size() <= longest_match) {
|
396
|
-
continue;
|
397
|
-
}
|
398
|
-
// Skip if match fails.
|
399
|
-
if (!DomainMatch(match_type, domain_pattern, domain)) continue;
|
400
|
-
// Choose this match.
|
401
|
-
target_vhost = &vhost;
|
402
|
-
best_match_type = match_type;
|
403
|
-
longest_match = domain_pattern.size();
|
404
|
-
if (best_match_type == EXACT_MATCH) break;
|
405
|
-
}
|
406
|
-
if (best_match_type == EXACT_MATCH) break;
|
407
|
-
}
|
408
|
-
return target_vhost;
|
409
|
-
}
|
410
|
-
|
411
|
-
//
|
412
|
-
// XdsApi::CommonTlsContext::CertificateValidationContext
|
413
|
-
//
|
414
|
-
|
415
|
-
std::string XdsApi::CommonTlsContext::CertificateValidationContext::ToString()
|
416
|
-
const {
|
417
|
-
std::vector<std::string> contents;
|
418
|
-
for (const auto& match : match_subject_alt_names) {
|
419
|
-
contents.push_back(match.ToString());
|
420
|
-
}
|
421
|
-
return absl::StrFormat("{match_subject_alt_names=[%s]}",
|
422
|
-
absl::StrJoin(contents, ", "));
|
423
|
-
}
|
424
|
-
|
425
|
-
bool XdsApi::CommonTlsContext::CertificateValidationContext::Empty() const {
|
426
|
-
return match_subject_alt_names.empty();
|
427
|
-
}
|
428
|
-
|
429
|
-
//
|
430
|
-
// XdsApi::CommonTlsContext::CertificateProviderPluginInstance
|
431
|
-
//
|
432
|
-
|
433
|
-
std::string
|
434
|
-
XdsApi::CommonTlsContext::CertificateProviderPluginInstance::ToString() const {
|
435
|
-
absl::InlinedVector<std::string, 2> contents;
|
436
|
-
if (!instance_name.empty()) {
|
437
|
-
contents.push_back(absl::StrFormat("instance_name=%s", instance_name));
|
438
|
-
}
|
439
|
-
if (!certificate_name.empty()) {
|
440
|
-
contents.push_back(
|
441
|
-
absl::StrFormat("certificate_name=%s", certificate_name));
|
442
|
-
}
|
443
|
-
return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
|
444
|
-
}
|
445
|
-
|
446
|
-
bool XdsApi::CommonTlsContext::CertificateProviderPluginInstance::Empty()
|
447
|
-
const {
|
448
|
-
return instance_name.empty() && certificate_name.empty();
|
449
|
-
}
|
450
|
-
|
451
|
-
//
|
452
|
-
// XdsApi::CommonTlsContext
|
453
|
-
//
|
454
|
-
|
455
|
-
std::string XdsApi::CommonTlsContext::ToString() const {
|
456
|
-
absl::InlinedVector<std::string, 2> contents;
|
457
|
-
if (!tls_certificate_provider_instance.Empty()) {
|
458
|
-
contents.push_back(
|
459
|
-
absl::StrFormat("tls_certificate_provider_instance=%s",
|
460
|
-
tls_certificate_provider_instance.ToString()));
|
461
|
-
}
|
462
|
-
if (!certificate_validation_context.Empty()) {
|
463
|
-
contents.push_back(
|
464
|
-
absl::StrFormat("certificate_validation_context=%s",
|
465
|
-
certificate_validation_context.ToString()));
|
466
|
-
}
|
467
|
-
return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
|
468
|
-
}
|
469
|
-
|
470
|
-
bool XdsApi::CommonTlsContext::Empty() const {
|
471
|
-
return tls_certificate_provider_instance.Empty() &&
|
472
|
-
certificate_validation_context.Empty();
|
473
|
-
}
|
474
|
-
|
475
|
-
//
|
476
|
-
// XdsApi::DownstreamTlsContext
|
477
|
-
//
|
478
|
-
|
479
|
-
std::string XdsApi::DownstreamTlsContext::ToString() const {
|
480
|
-
return absl::StrFormat("common_tls_context=%s, require_client_certificate=%s",
|
481
|
-
common_tls_context.ToString(),
|
482
|
-
require_client_certificate ? "true" : "false");
|
483
|
-
}
|
484
|
-
|
485
|
-
bool XdsApi::DownstreamTlsContext::Empty() const {
|
486
|
-
return common_tls_context.Empty();
|
487
|
-
}
|
488
|
-
|
489
|
-
//
|
490
|
-
// XdsApi::LdsUpdate::HttpConnectionManager
|
491
|
-
//
|
492
|
-
|
493
|
-
std::string XdsApi::LdsUpdate::HttpConnectionManager::ToString() const {
|
494
|
-
absl::InlinedVector<std::string, 4> contents;
|
495
|
-
contents.push_back(absl::StrFormat(
|
496
|
-
"route_config_name=%s",
|
497
|
-
!route_config_name.empty() ? route_config_name.c_str() : "<inlined>"));
|
498
|
-
contents.push_back(absl::StrFormat("http_max_stream_duration=%s",
|
499
|
-
http_max_stream_duration.ToString()));
|
500
|
-
if (rds_update.has_value()) {
|
501
|
-
contents.push_back(
|
502
|
-
absl::StrFormat("rds_update=%s", rds_update->ToString()));
|
503
|
-
}
|
504
|
-
if (!http_filters.empty()) {
|
505
|
-
std::vector<std::string> filter_strings;
|
506
|
-
for (const auto& http_filter : http_filters) {
|
507
|
-
filter_strings.push_back(http_filter.ToString());
|
508
|
-
}
|
509
|
-
contents.push_back(absl::StrCat("http_filters=[",
|
510
|
-
absl::StrJoin(filter_strings, ", "), "]"));
|
511
|
-
}
|
512
|
-
return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
|
513
|
-
}
|
514
|
-
|
515
|
-
//
|
516
|
-
// XdsApi::LdsUpdate::HttpFilter
|
517
|
-
//
|
518
|
-
|
519
|
-
std::string XdsApi::LdsUpdate::HttpConnectionManager::HttpFilter::ToString()
|
520
|
-
const {
|
521
|
-
return absl::StrCat("{name=", name, ", config=", config.ToString(), "}");
|
522
|
-
}
|
523
|
-
|
524
|
-
//
|
525
|
-
// XdsApi::LdsUpdate::FilterChainData
|
526
|
-
//
|
527
|
-
|
528
|
-
std::string XdsApi::LdsUpdate::FilterChainData::ToString() const {
|
529
|
-
return absl::StrCat(
|
530
|
-
"{downstream_tls_context=", downstream_tls_context.ToString(),
|
531
|
-
" http_connection_manager=", http_connection_manager.ToString(), "}");
|
532
|
-
}
|
533
|
-
|
534
|
-
//
|
535
|
-
// XdsApi::LdsUpdate::FilterChainMap::CidrRange
|
536
|
-
//
|
537
|
-
|
538
|
-
std::string XdsApi::LdsUpdate::FilterChainMap::CidrRange::ToString() const {
|
539
|
-
return absl::StrCat(
|
540
|
-
"{address_prefix=", grpc_sockaddr_to_string(&address, false),
|
541
|
-
", prefix_len=", prefix_len, "}");
|
542
|
-
}
|
543
|
-
|
544
|
-
//
|
545
|
-
// FilterChain
|
546
|
-
//
|
547
|
-
|
548
|
-
struct FilterChain {
|
549
|
-
struct FilterChainMatch {
|
550
|
-
uint32_t destination_port = 0;
|
551
|
-
std::vector<XdsApi::LdsUpdate::FilterChainMap::CidrRange> prefix_ranges;
|
552
|
-
XdsApi::LdsUpdate::FilterChainMap::ConnectionSourceType source_type =
|
553
|
-
XdsApi::LdsUpdate::FilterChainMap::ConnectionSourceType::kAny;
|
554
|
-
std::vector<XdsApi::LdsUpdate::FilterChainMap::CidrRange>
|
555
|
-
source_prefix_ranges;
|
556
|
-
std::vector<uint32_t> source_ports;
|
557
|
-
std::vector<std::string> server_names;
|
558
|
-
std::string transport_protocol;
|
559
|
-
std::vector<std::string> application_protocols;
|
560
|
-
|
561
|
-
std::string ToString() const;
|
562
|
-
} filter_chain_match;
|
563
|
-
|
564
|
-
std::shared_ptr<XdsApi::LdsUpdate::FilterChainData> filter_chain_data;
|
565
|
-
};
|
566
|
-
|
567
|
-
std::string FilterChain::FilterChainMatch::ToString() const {
|
568
|
-
absl::InlinedVector<std::string, 8> contents;
|
569
|
-
if (destination_port != 0) {
|
570
|
-
contents.push_back(absl::StrCat("destination_port=", destination_port));
|
571
|
-
}
|
572
|
-
if (!prefix_ranges.empty()) {
|
573
|
-
std::vector<std::string> prefix_ranges_content;
|
574
|
-
for (const auto& range : prefix_ranges) {
|
575
|
-
prefix_ranges_content.push_back(range.ToString());
|
576
|
-
}
|
577
|
-
contents.push_back(absl::StrCat(
|
578
|
-
"prefix_ranges={", absl::StrJoin(prefix_ranges_content, ", "), "}"));
|
579
|
-
}
|
580
|
-
if (source_type == XdsApi::LdsUpdate::FilterChainMap::ConnectionSourceType::
|
581
|
-
kSameIpOrLoopback) {
|
582
|
-
contents.push_back("source_type=SAME_IP_OR_LOOPBACK");
|
583
|
-
} else if (source_type == XdsApi::LdsUpdate::FilterChainMap::
|
584
|
-
ConnectionSourceType::kExternal) {
|
585
|
-
contents.push_back("source_type=EXTERNAL");
|
586
|
-
}
|
587
|
-
if (!source_prefix_ranges.empty()) {
|
588
|
-
std::vector<std::string> source_prefix_ranges_content;
|
589
|
-
for (const auto& range : source_prefix_ranges) {
|
590
|
-
source_prefix_ranges_content.push_back(range.ToString());
|
591
|
-
}
|
592
|
-
contents.push_back(
|
593
|
-
absl::StrCat("source_prefix_ranges={",
|
594
|
-
absl::StrJoin(source_prefix_ranges_content, ", "), "}"));
|
595
|
-
}
|
596
|
-
if (!source_ports.empty()) {
|
597
|
-
contents.push_back(
|
598
|
-
absl::StrCat("source_ports={", absl::StrJoin(source_ports, ", "), "}"));
|
599
|
-
}
|
600
|
-
if (!server_names.empty()) {
|
601
|
-
contents.push_back(
|
602
|
-
absl::StrCat("server_names={", absl::StrJoin(server_names, ", "), "}"));
|
603
|
-
}
|
604
|
-
if (!transport_protocol.empty()) {
|
605
|
-
contents.push_back(absl::StrCat("transport_protocol=", transport_protocol));
|
606
|
-
}
|
607
|
-
if (!application_protocols.empty()) {
|
608
|
-
contents.push_back(absl::StrCat("application_protocols={",
|
609
|
-
absl::StrJoin(application_protocols, ", "),
|
610
|
-
"}"));
|
611
|
-
}
|
612
|
-
return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
|
613
|
-
}
|
614
|
-
|
615
|
-
//
|
616
|
-
// XdsApi::LdsUpdate::FilterChainMap
|
617
|
-
//
|
618
|
-
|
619
|
-
std::string XdsApi::LdsUpdate::FilterChainMap::ToString() const {
|
620
|
-
std::vector<std::string> contents;
|
621
|
-
for (const auto& destination_ip : destination_ip_vector) {
|
622
|
-
for (int source_type = 0; source_type < 3; ++source_type) {
|
623
|
-
for (const auto& source_ip :
|
624
|
-
destination_ip.source_types_array[source_type]) {
|
625
|
-
for (const auto& source_port_pair : source_ip.ports_map) {
|
626
|
-
FilterChain::FilterChainMatch filter_chain_match;
|
627
|
-
if (destination_ip.prefix_range.has_value()) {
|
628
|
-
filter_chain_match.prefix_ranges.push_back(
|
629
|
-
*destination_ip.prefix_range);
|
630
|
-
}
|
631
|
-
filter_chain_match.source_type = static_cast<
|
632
|
-
XdsApi::LdsUpdate::FilterChainMap::ConnectionSourceType>(
|
633
|
-
source_type);
|
634
|
-
if (source_ip.prefix_range.has_value()) {
|
635
|
-
filter_chain_match.source_prefix_ranges.push_back(
|
636
|
-
*source_ip.prefix_range);
|
637
|
-
}
|
638
|
-
if (source_port_pair.first != 0) {
|
639
|
-
filter_chain_match.source_ports.push_back(source_port_pair.first);
|
640
|
-
}
|
641
|
-
contents.push_back(absl::StrCat(
|
642
|
-
"{filter_chain_match=", filter_chain_match.ToString(),
|
643
|
-
", filter_chain=", source_port_pair.second.data->ToString(),
|
644
|
-
"}"));
|
645
|
-
}
|
646
|
-
}
|
647
|
-
}
|
648
|
-
}
|
649
|
-
return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
|
650
|
-
}
|
651
|
-
|
652
|
-
//
|
653
|
-
// XdsApi::LdsUpdate
|
654
|
-
//
|
655
|
-
|
656
|
-
std::string XdsApi::LdsUpdate::ToString() const {
|
657
|
-
absl::InlinedVector<std::string, 4> contents;
|
658
|
-
if (type == ListenerType::kTcpListener) {
|
659
|
-
contents.push_back(absl::StrCat("address=", address));
|
660
|
-
contents.push_back(
|
661
|
-
absl::StrCat("filter_chain_map=", filter_chain_map.ToString()));
|
662
|
-
if (default_filter_chain.has_value()) {
|
663
|
-
contents.push_back(absl::StrCat("default_filter_chain=",
|
664
|
-
default_filter_chain->ToString()));
|
665
|
-
}
|
666
|
-
} else if (type == ListenerType::kHttpApiListener) {
|
667
|
-
contents.push_back(absl::StrFormat("http_connection_manager=%s",
|
668
|
-
http_connection_manager.ToString()));
|
669
|
-
}
|
670
|
-
return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
|
671
|
-
}
|
672
|
-
|
673
|
-
//
|
674
|
-
// XdsApi::CdsUpdate
|
675
|
-
//
|
676
|
-
|
677
|
-
std::string XdsApi::CdsUpdate::ToString() const {
|
678
|
-
absl::InlinedVector<std::string, 8> contents;
|
679
|
-
switch (cluster_type) {
|
680
|
-
case EDS:
|
681
|
-
contents.push_back("cluster_type=EDS");
|
682
|
-
if (!eds_service_name.empty()) {
|
683
|
-
contents.push_back(
|
684
|
-
absl::StrFormat("eds_service_name=%s", eds_service_name));
|
685
|
-
}
|
686
|
-
break;
|
687
|
-
case LOGICAL_DNS:
|
688
|
-
contents.push_back("cluster_type=LOGICAL_DNS");
|
689
|
-
contents.push_back(absl::StrFormat("dns_hostname=%s", dns_hostname));
|
690
|
-
break;
|
691
|
-
case AGGREGATE:
|
692
|
-
contents.push_back("cluster_type=AGGREGATE");
|
693
|
-
contents.push_back(
|
694
|
-
absl::StrFormat("prioritized_cluster_names=[%s]",
|
695
|
-
absl::StrJoin(prioritized_cluster_names, ", ")));
|
696
|
-
}
|
697
|
-
if (!common_tls_context.Empty()) {
|
698
|
-
contents.push_back(absl::StrFormat("common_tls_context=%s",
|
699
|
-
common_tls_context.ToString()));
|
700
|
-
}
|
701
|
-
if (lrs_load_reporting_server_name.has_value()) {
|
702
|
-
contents.push_back(absl::StrFormat("lrs_load_reporting_server_name=%s",
|
703
|
-
lrs_load_reporting_server_name.value()));
|
704
|
-
}
|
705
|
-
contents.push_back(absl::StrCat("lb_policy=", lb_policy));
|
706
|
-
if (lb_policy == "RING_HASH") {
|
707
|
-
contents.push_back(absl::StrCat("min_ring_size=", min_ring_size));
|
708
|
-
contents.push_back(absl::StrCat("max_ring_size=", max_ring_size));
|
709
|
-
}
|
710
|
-
contents.push_back(
|
711
|
-
absl::StrFormat("max_concurrent_requests=%d", max_concurrent_requests));
|
712
|
-
return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
|
713
|
-
}
|
714
|
-
|
715
|
-
//
|
716
|
-
// XdsApi::EdsUpdate
|
717
|
-
//
|
718
|
-
|
719
|
-
std::string XdsApi::EdsUpdate::Priority::Locality::ToString() const {
|
720
|
-
std::vector<std::string> endpoint_strings;
|
721
|
-
for (const ServerAddress& endpoint : endpoints) {
|
722
|
-
endpoint_strings.emplace_back(endpoint.ToString());
|
723
|
-
}
|
724
|
-
return absl::StrCat("{name=", name->AsHumanReadableString(),
|
725
|
-
", lb_weight=", lb_weight, ", endpoints=[",
|
726
|
-
absl::StrJoin(endpoint_strings, ", "), "]}");
|
727
|
-
}
|
728
|
-
|
729
|
-
bool XdsApi::EdsUpdate::Priority::operator==(const Priority& other) const {
|
730
|
-
if (localities.size() != other.localities.size()) return false;
|
731
|
-
auto it1 = localities.begin();
|
732
|
-
auto it2 = other.localities.begin();
|
733
|
-
while (it1 != localities.end()) {
|
734
|
-
if (*it1->first != *it2->first) return false;
|
735
|
-
if (it1->second != it2->second) return false;
|
736
|
-
++it1;
|
737
|
-
++it2;
|
738
|
-
}
|
739
|
-
return true;
|
740
|
-
}
|
741
|
-
|
742
|
-
std::string XdsApi::EdsUpdate::Priority::ToString() const {
|
743
|
-
std::vector<std::string> locality_strings;
|
744
|
-
for (const auto& p : localities) {
|
745
|
-
locality_strings.emplace_back(p.second.ToString());
|
746
|
-
}
|
747
|
-
return absl::StrCat("[", absl::StrJoin(locality_strings, ", "), "]");
|
748
|
-
}
|
749
|
-
|
750
|
-
bool XdsApi::EdsUpdate::DropConfig::ShouldDrop(
|
751
|
-
const std::string** category_name) const {
|
752
|
-
for (size_t i = 0; i < drop_category_list_.size(); ++i) {
|
753
|
-
const auto& drop_category = drop_category_list_[i];
|
754
|
-
// Generate a random number in [0, 1000000).
|
755
|
-
const uint32_t random = static_cast<uint32_t>(rand()) % 1000000;
|
756
|
-
if (random < drop_category.parts_per_million) {
|
757
|
-
*category_name = &drop_category.name;
|
758
|
-
return true;
|
759
|
-
}
|
760
|
-
}
|
761
|
-
return false;
|
762
|
-
}
|
763
|
-
|
764
|
-
std::string XdsApi::EdsUpdate::DropConfig::ToString() const {
|
765
|
-
std::vector<std::string> category_strings;
|
766
|
-
for (const DropCategory& category : drop_category_list_) {
|
767
|
-
category_strings.emplace_back(
|
768
|
-
absl::StrCat(category.name, "=", category.parts_per_million));
|
769
|
-
}
|
770
|
-
return absl::StrCat("{[", absl::StrJoin(category_strings, ", "),
|
771
|
-
"], drop_all=", drop_all_, "}");
|
772
|
-
}
|
773
|
-
|
774
|
-
std::string XdsApi::EdsUpdate::ToString() const {
|
775
|
-
std::vector<std::string> priority_strings;
|
776
|
-
for (size_t i = 0; i < priorities.size(); ++i) {
|
777
|
-
const Priority& priority = priorities[i];
|
778
|
-
priority_strings.emplace_back(
|
779
|
-
absl::StrCat("priority ", i, ": ", priority.ToString()));
|
780
|
-
}
|
781
|
-
return absl::StrCat("priorities=[", absl::StrJoin(priority_strings, ", "),
|
782
|
-
"], drop_config=", drop_config->ToString());
|
783
|
-
}
|
784
|
-
|
785
|
-
//
|
786
|
-
// XdsApi
|
787
|
-
//
|
788
|
-
|
789
|
-
const char* XdsApi::kLdsTypeUrl =
|
790
|
-
"type.googleapis.com/envoy.config.listener.v3.Listener";
|
791
|
-
const char* XdsApi::kRdsTypeUrl =
|
792
|
-
"type.googleapis.com/envoy.config.route.v3.RouteConfiguration";
|
793
|
-
const char* XdsApi::kCdsTypeUrl =
|
794
|
-
"type.googleapis.com/envoy.config.cluster.v3.Cluster";
|
795
|
-
const char* XdsApi::kEdsTypeUrl =
|
796
|
-
"type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment";
|
797
|
-
|
798
|
-
namespace {
|
799
|
-
|
800
|
-
const char* kLdsV2TypeUrl = "type.googleapis.com/envoy.api.v2.Listener";
|
801
|
-
const char* kRdsV2TypeUrl =
|
802
|
-
"type.googleapis.com/envoy.api.v2.RouteConfiguration";
|
803
|
-
const char* kCdsV2TypeUrl = "type.googleapis.com/envoy.api.v2.Cluster";
|
804
|
-
const char* kEdsV2TypeUrl =
|
805
|
-
"type.googleapis.com/envoy.api.v2.ClusterLoadAssignment";
|
806
|
-
|
807
|
-
bool IsLds(absl::string_view type_url, bool* is_v2 = nullptr) {
|
808
|
-
if (type_url == XdsApi::kLdsTypeUrl) return true;
|
809
|
-
if (type_url == kLdsV2TypeUrl) {
|
810
|
-
if (is_v2 != nullptr) *is_v2 = true;
|
811
|
-
return true;
|
812
|
-
}
|
813
|
-
return false;
|
814
|
-
}
|
815
|
-
|
816
|
-
bool IsRds(absl::string_view type_url, bool* /*is_v2*/ = nullptr) {
|
817
|
-
return type_url == XdsApi::kRdsTypeUrl || type_url == kRdsV2TypeUrl;
|
818
|
-
}
|
819
|
-
|
820
|
-
bool IsCds(absl::string_view type_url, bool* /*is_v2*/ = nullptr) {
|
821
|
-
return type_url == XdsApi::kCdsTypeUrl || type_url == kCdsV2TypeUrl;
|
822
|
-
}
|
823
|
-
|
824
|
-
bool IsEds(absl::string_view type_url, bool* /*is_v2*/ = nullptr) {
|
825
|
-
return type_url == XdsApi::kEdsTypeUrl || type_url == kEdsV2TypeUrl;
|
826
|
-
}
|
827
|
-
|
828
|
-
} // namespace
|
829
|
-
|
830
65
|
// If gRPC is built with -DGRPC_XDS_USER_AGENT_NAME_SUFFIX="...", that string
|
831
66
|
// will be appended to the user agent name reported to the xDS server.
|
832
67
|
#ifdef GRPC_XDS_USER_AGENT_NAME_SUFFIX
|
@@ -848,11 +83,13 @@ bool IsEds(absl::string_view type_url, bool* /*is_v2*/ = nullptr) {
|
|
848
83
|
XdsApi::XdsApi(XdsClient* client, TraceFlag* tracer,
|
849
84
|
const XdsBootstrap::Node* node,
|
850
85
|
const CertificateProviderStore::PluginDefinitionMap*
|
851
|
-
certificate_provider_definition_map
|
86
|
+
certificate_provider_definition_map,
|
87
|
+
upb::SymbolTable* symtab)
|
852
88
|
: client_(client),
|
853
89
|
tracer_(tracer),
|
854
90
|
node_(node),
|
855
91
|
certificate_provider_definition_map_(certificate_provider_definition_map),
|
92
|
+
symtab_(symtab),
|
856
93
|
build_version_(absl::StrCat("gRPC C-core ", GPR_PLATFORM_STRING, " ",
|
857
94
|
grpc_version_string(),
|
858
95
|
GRPC_XDS_USER_AGENT_NAME_SUFFIX_STRING,
|
@@ -862,47 +99,14 @@ XdsApi::XdsApi(XdsClient* client, TraceFlag* tracer,
|
|
862
99
|
user_agent_version_(
|
863
100
|
absl::StrCat("C-core ", grpc_version_string(),
|
864
101
|
GRPC_XDS_USER_AGENT_NAME_SUFFIX_STRING,
|
865
|
-
GRPC_XDS_USER_AGENT_VERSION_SUFFIX_STRING)) {
|
866
|
-
// Populate upb symtab with xDS proto messages that we want to print
|
867
|
-
// properly in logs.
|
868
|
-
// Note: This won't actually work properly until upb adds support for
|
869
|
-
// Any fields in textproto printing (internal b/178821188).
|
870
|
-
envoy_config_listener_v3_Listener_getmsgdef(symtab_.ptr());
|
871
|
-
envoy_config_route_v3_RouteConfiguration_getmsgdef(symtab_.ptr());
|
872
|
-
envoy_config_cluster_v3_Cluster_getmsgdef(symtab_.ptr());
|
873
|
-
envoy_extensions_clusters_aggregate_v3_ClusterConfig_getmsgdef(symtab_.ptr());
|
874
|
-
envoy_config_cluster_v3_Cluster_getmsgdef(symtab_.ptr());
|
875
|
-
envoy_config_endpoint_v3_ClusterLoadAssignment_getmsgdef(symtab_.ptr());
|
876
|
-
envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_getmsgdef(
|
877
|
-
symtab_.ptr());
|
878
|
-
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_getmsgdef(
|
879
|
-
symtab_.ptr());
|
880
|
-
// Load HTTP filter proto messages into the upb symtab.
|
881
|
-
XdsHttpFilterRegistry::PopulateSymtab(symtab_.ptr());
|
882
|
-
}
|
102
|
+
GRPC_XDS_USER_AGENT_VERSION_SUFFIX_STRING)) {}
|
883
103
|
|
884
104
|
namespace {
|
885
105
|
|
886
|
-
|
887
|
-
XdsClient* client; // Used only for logging. Unsafe for dereferencing.
|
888
|
-
TraceFlag* tracer;
|
889
|
-
upb_symtab* symtab;
|
890
|
-
upb_arena* arena;
|
891
|
-
bool use_v3;
|
892
|
-
const CertificateProviderStore::PluginDefinitionMap*
|
893
|
-
certificate_provider_definition_map;
|
894
|
-
};
|
895
|
-
|
896
|
-
// Works for both std::string and absl::string_view.
|
897
|
-
template <typename T>
|
898
|
-
inline upb_strview StdStringToUpbString(const T& str) {
|
899
|
-
return upb_strview_make(str.data(), str.size());
|
900
|
-
}
|
901
|
-
|
902
|
-
void PopulateMetadataValue(const EncodingContext& context,
|
106
|
+
void PopulateMetadataValue(const XdsEncodingContext& context,
|
903
107
|
google_protobuf_Value* value_pb, const Json& value);
|
904
108
|
|
905
|
-
void PopulateListValue(const
|
109
|
+
void PopulateListValue(const XdsEncodingContext& context,
|
906
110
|
google_protobuf_ListValue* list_value,
|
907
111
|
const Json::Array& values) {
|
908
112
|
for (const auto& value : values) {
|
@@ -912,7 +116,7 @@ void PopulateListValue(const EncodingContext& context,
|
|
912
116
|
}
|
913
117
|
}
|
914
118
|
|
915
|
-
void PopulateMetadata(const
|
119
|
+
void PopulateMetadata(const XdsEncodingContext& context,
|
916
120
|
google_protobuf_Struct* metadata_pb,
|
917
121
|
const Json::Object& metadata) {
|
918
122
|
for (const auto& p : metadata) {
|
@@ -923,7 +127,7 @@ void PopulateMetadata(const EncodingContext& context,
|
|
923
127
|
}
|
924
128
|
}
|
925
129
|
|
926
|
-
void PopulateMetadataValue(const
|
130
|
+
void PopulateMetadataValue(const XdsEncodingContext& context,
|
927
131
|
google_protobuf_Value* value_pb, const Json& value) {
|
928
132
|
switch (value.type()) {
|
929
133
|
case Json::Type::JSON_NULL:
|
@@ -979,7 +183,7 @@ std::string EncodeStringField(uint32_t field_number, const std::string& str) {
|
|
979
183
|
EncodeVarint(str.size()) + str;
|
980
184
|
}
|
981
185
|
|
982
|
-
void PopulateBuildVersion(const
|
186
|
+
void PopulateBuildVersion(const XdsEncodingContext& context,
|
983
187
|
envoy_config_core_v3_Node* node_msg,
|
984
188
|
const std::string& build_version) {
|
985
189
|
std::string encoded_build_version = EncodeStringField(5, build_version);
|
@@ -991,7 +195,7 @@ void PopulateBuildVersion(const EncodingContext& context,
|
|
991
195
|
encoded_build_version.size(), context.arena);
|
992
196
|
}
|
993
197
|
|
994
|
-
void PopulateNode(const
|
198
|
+
void PopulateNode(const XdsEncodingContext& context,
|
995
199
|
const XdsBootstrap::Node* node,
|
996
200
|
const std::string& build_version,
|
997
201
|
const std::string& user_agent_name,
|
@@ -1041,16 +245,8 @@ void PopulateNode(const EncodingContext& context,
|
|
1041
245
|
context.arena);
|
1042
246
|
}
|
1043
247
|
|
1044
|
-
inline absl::string_view UpbStringToAbsl(const upb_strview& str) {
|
1045
|
-
return absl::string_view(str.data, str.size);
|
1046
|
-
}
|
1047
|
-
|
1048
|
-
inline std::string UpbStringToStdString(const upb_strview& str) {
|
1049
|
-
return std::string(str.data, str.size);
|
1050
|
-
}
|
1051
|
-
|
1052
248
|
void MaybeLogDiscoveryRequest(
|
1053
|
-
const
|
249
|
+
const XdsEncodingContext& context,
|
1054
250
|
const envoy_service_discovery_v3_DiscoveryRequest* request) {
|
1055
251
|
if (GRPC_TRACE_FLAG_ENABLED(*context.tracer) &&
|
1056
252
|
gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
|
@@ -1064,7 +260,7 @@ void MaybeLogDiscoveryRequest(
|
|
1064
260
|
}
|
1065
261
|
|
1066
262
|
grpc_slice SerializeDiscoveryRequest(
|
1067
|
-
const
|
263
|
+
const XdsEncodingContext& context,
|
1068
264
|
envoy_service_discovery_v3_DiscoveryRequest* request) {
|
1069
265
|
size_t output_length;
|
1070
266
|
char* output = envoy_service_discovery_v3_DiscoveryRequest_serialize(
|
@@ -1072,47 +268,27 @@ grpc_slice SerializeDiscoveryRequest(
|
|
1072
268
|
return grpc_slice_from_copied_buffer(output, output_length);
|
1073
269
|
}
|
1074
270
|
|
1075
|
-
absl::string_view TypeUrlExternalToInternal(bool use_v3,
|
1076
|
-
const std::string& type_url) {
|
1077
|
-
if (!use_v3) {
|
1078
|
-
if (type_url == XdsApi::kLdsTypeUrl) {
|
1079
|
-
return kLdsV2TypeUrl;
|
1080
|
-
}
|
1081
|
-
if (type_url == XdsApi::kRdsTypeUrl) {
|
1082
|
-
return kRdsV2TypeUrl;
|
1083
|
-
}
|
1084
|
-
if (type_url == XdsApi::kCdsTypeUrl) {
|
1085
|
-
return kCdsV2TypeUrl;
|
1086
|
-
}
|
1087
|
-
if (type_url == XdsApi::kEdsTypeUrl) {
|
1088
|
-
return kEdsV2TypeUrl;
|
1089
|
-
}
|
1090
|
-
}
|
1091
|
-
return type_url;
|
1092
|
-
}
|
1093
|
-
|
1094
271
|
} // namespace
|
1095
272
|
|
1096
273
|
grpc_slice XdsApi::CreateAdsRequest(
|
1097
|
-
const XdsBootstrap::XdsServer& server,
|
1098
|
-
|
1099
|
-
const std::string
|
1100
|
-
|
274
|
+
const XdsBootstrap::XdsServer& server, absl::string_view type_url,
|
275
|
+
absl::string_view version, absl::string_view nonce,
|
276
|
+
const std::vector<std::string>& resource_names, grpc_error_handle error,
|
277
|
+
bool populate_node) {
|
1101
278
|
upb::Arena arena;
|
1102
|
-
const
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
279
|
+
const XdsEncodingContext context = {client_,
|
280
|
+
tracer_,
|
281
|
+
symtab_->ptr(),
|
282
|
+
arena.ptr(),
|
283
|
+
server.ShouldUseV3(),
|
284
|
+
certificate_provider_definition_map_};
|
1108
285
|
// Create a request.
|
1109
286
|
envoy_service_discovery_v3_DiscoveryRequest* request =
|
1110
287
|
envoy_service_discovery_v3_DiscoveryRequest_new(arena.ptr());
|
1111
288
|
// Set type_url.
|
1112
|
-
|
1113
|
-
TypeUrlExternalToInternal(server.ShouldUseV3(), type_url);
|
289
|
+
std::string type_url_str = absl::StrCat("type.googleapis.com/", type_url);
|
1114
290
|
envoy_service_discovery_v3_DiscoveryRequest_set_type_url(
|
1115
|
-
request, StdStringToUpbString(
|
291
|
+
request, StdStringToUpbString(type_url_str));
|
1116
292
|
// Set version_info.
|
1117
293
|
if (!version.empty()) {
|
1118
294
|
envoy_service_discovery_v3_DiscoveryRequest_set_version_info(
|
@@ -1149,7 +325,7 @@ grpc_slice XdsApi::CreateAdsRequest(
|
|
1149
325
|
user_agent_version_, node_msg);
|
1150
326
|
}
|
1151
327
|
// Add resource_names.
|
1152
|
-
for (const
|
328
|
+
for (const std::string& resource_name : resource_names) {
|
1153
329
|
envoy_service_discovery_v3_DiscoveryRequest_add_resource_names(
|
1154
330
|
request, StdStringToUpbString(resource_name), arena.ptr());
|
1155
331
|
}
|
@@ -1160,7 +336,7 @@ grpc_slice XdsApi::CreateAdsRequest(
|
|
1160
336
|
namespace {
|
1161
337
|
|
1162
338
|
void MaybeLogDiscoveryResponse(
|
1163
|
-
const
|
339
|
+
const XdsEncodingContext& context,
|
1164
340
|
const envoy_service_discovery_v3_DiscoveryResponse* response) {
|
1165
341
|
if (GRPC_TRACE_FLAG_ENABLED(*context.tracer) &&
|
1166
342
|
gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
|
@@ -1173,2355 +349,61 @@ void MaybeLogDiscoveryResponse(
|
|
1173
349
|
}
|
1174
350
|
}
|
1175
351
|
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
352
|
+
} // namespace
|
353
|
+
|
354
|
+
absl::Status XdsApi::ParseAdsResponse(const XdsBootstrap::XdsServer& server,
|
355
|
+
const grpc_slice& encoded_response,
|
356
|
+
AdsResponseParserInterface* parser) {
|
357
|
+
upb::Arena arena;
|
358
|
+
const XdsEncodingContext context = {client_,
|
359
|
+
tracer_,
|
360
|
+
symtab_->ptr(),
|
361
|
+
arena.ptr(),
|
362
|
+
server.ShouldUseV3(),
|
363
|
+
certificate_provider_definition_map_};
|
364
|
+
// Decode the response.
|
365
|
+
const envoy_service_discovery_v3_DiscoveryResponse* response =
|
366
|
+
envoy_service_discovery_v3_DiscoveryResponse_parse(
|
367
|
+
reinterpret_cast<const char*>(GRPC_SLICE_START_PTR(encoded_response)),
|
368
|
+
GRPC_SLICE_LENGTH(encoded_response), arena.ptr());
|
369
|
+
// If decoding fails, report a fatal error and return.
|
370
|
+
if (response == nullptr) {
|
371
|
+
return absl::InvalidArgumentError("Can't decode DiscoveryResponse.");
|
1185
372
|
}
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
gpr_log(GPR_DEBUG, "[xds_client %p] RouteConfiguration: %s", context.client,
|
1215
|
-
buf);
|
1216
|
-
}
|
1217
|
-
}
|
1218
|
-
|
1219
|
-
void MaybeLogCluster(const EncodingContext& context,
|
1220
|
-
const envoy_config_cluster_v3_Cluster* cluster) {
|
1221
|
-
if (GRPC_TRACE_FLAG_ENABLED(*context.tracer) &&
|
1222
|
-
gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
|
1223
|
-
const upb_msgdef* msg_type =
|
1224
|
-
envoy_config_cluster_v3_Cluster_getmsgdef(context.symtab);
|
1225
|
-
char buf[10240];
|
1226
|
-
upb_text_encode(cluster, msg_type, nullptr, 0, buf, sizeof(buf));
|
1227
|
-
gpr_log(GPR_DEBUG, "[xds_client %p] Cluster: %s", context.client, buf);
|
1228
|
-
}
|
1229
|
-
}
|
1230
|
-
|
1231
|
-
void MaybeLogClusterLoadAssignment(
|
1232
|
-
const EncodingContext& context,
|
1233
|
-
const envoy_config_endpoint_v3_ClusterLoadAssignment* cla) {
|
1234
|
-
if (GRPC_TRACE_FLAG_ENABLED(*context.tracer) &&
|
1235
|
-
gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
|
1236
|
-
const upb_msgdef* msg_type =
|
1237
|
-
envoy_config_endpoint_v3_ClusterLoadAssignment_getmsgdef(
|
1238
|
-
context.symtab);
|
1239
|
-
char buf[10240];
|
1240
|
-
upb_text_encode(cla, msg_type, nullptr, 0, buf, sizeof(buf));
|
1241
|
-
gpr_log(GPR_DEBUG, "[xds_client %p] ClusterLoadAssignment: %s",
|
1242
|
-
context.client, buf);
|
1243
|
-
}
|
1244
|
-
}
|
1245
|
-
|
1246
|
-
grpc_error_handle RoutePathMatchParse(
|
1247
|
-
const envoy_config_route_v3_RouteMatch* match, XdsApi::Route* route,
|
1248
|
-
bool* ignore_route) {
|
1249
|
-
auto* case_sensitive_ptr =
|
1250
|
-
envoy_config_route_v3_RouteMatch_case_sensitive(match);
|
1251
|
-
bool case_sensitive = true;
|
1252
|
-
if (case_sensitive_ptr != nullptr) {
|
1253
|
-
case_sensitive = google_protobuf_BoolValue_value(case_sensitive_ptr);
|
1254
|
-
}
|
1255
|
-
StringMatcher::Type type;
|
1256
|
-
std::string match_string;
|
1257
|
-
if (envoy_config_route_v3_RouteMatch_has_prefix(match)) {
|
1258
|
-
absl::string_view prefix =
|
1259
|
-
UpbStringToAbsl(envoy_config_route_v3_RouteMatch_prefix(match));
|
1260
|
-
// Empty prefix "" is accepted.
|
1261
|
-
if (!prefix.empty()) {
|
1262
|
-
// Prefix "/" is accepted.
|
1263
|
-
if (prefix[0] != '/') {
|
1264
|
-
// Prefix which does not start with a / will never match anything, so
|
1265
|
-
// ignore this route.
|
1266
|
-
*ignore_route = true;
|
1267
|
-
return GRPC_ERROR_NONE;
|
1268
|
-
}
|
1269
|
-
std::vector<absl::string_view> prefix_elements =
|
1270
|
-
absl::StrSplit(prefix.substr(1), absl::MaxSplits('/', 2));
|
1271
|
-
if (prefix_elements.size() > 2) {
|
1272
|
-
// Prefix cannot have more than 2 slashes.
|
1273
|
-
*ignore_route = true;
|
1274
|
-
return GRPC_ERROR_NONE;
|
1275
|
-
} else if (prefix_elements.size() == 2 && prefix_elements[0].empty()) {
|
1276
|
-
// Prefix contains empty string between the 2 slashes
|
1277
|
-
*ignore_route = true;
|
1278
|
-
return GRPC_ERROR_NONE;
|
1279
|
-
}
|
1280
|
-
}
|
1281
|
-
type = StringMatcher::Type::kPrefix;
|
1282
|
-
match_string = std::string(prefix);
|
1283
|
-
} else if (envoy_config_route_v3_RouteMatch_has_path(match)) {
|
1284
|
-
absl::string_view path =
|
1285
|
-
UpbStringToAbsl(envoy_config_route_v3_RouteMatch_path(match));
|
1286
|
-
if (path.empty()) {
|
1287
|
-
// Path that is empty will never match anything, so ignore this route.
|
1288
|
-
*ignore_route = true;
|
1289
|
-
return GRPC_ERROR_NONE;
|
1290
|
-
}
|
1291
|
-
if (path[0] != '/') {
|
1292
|
-
// Path which does not start with a / will never match anything, so
|
1293
|
-
// ignore this route.
|
1294
|
-
*ignore_route = true;
|
1295
|
-
return GRPC_ERROR_NONE;
|
1296
|
-
}
|
1297
|
-
std::vector<absl::string_view> path_elements =
|
1298
|
-
absl::StrSplit(path.substr(1), absl::MaxSplits('/', 2));
|
1299
|
-
if (path_elements.size() != 2) {
|
1300
|
-
// Path not in the required format of /service/method will never match
|
1301
|
-
// anything, so ignore this route.
|
1302
|
-
*ignore_route = true;
|
1303
|
-
return GRPC_ERROR_NONE;
|
1304
|
-
} else if (path_elements[0].empty()) {
|
1305
|
-
// Path contains empty service name will never match anything, so ignore
|
1306
|
-
// this route.
|
1307
|
-
*ignore_route = true;
|
1308
|
-
return GRPC_ERROR_NONE;
|
1309
|
-
} else if (path_elements[1].empty()) {
|
1310
|
-
// Path contains empty method name will never match anything, so ignore
|
1311
|
-
// this route.
|
1312
|
-
*ignore_route = true;
|
1313
|
-
return GRPC_ERROR_NONE;
|
1314
|
-
}
|
1315
|
-
type = StringMatcher::Type::kExact;
|
1316
|
-
match_string = std::string(path);
|
1317
|
-
} else if (envoy_config_route_v3_RouteMatch_has_safe_regex(match)) {
|
1318
|
-
const envoy_type_matcher_v3_RegexMatcher* regex_matcher =
|
1319
|
-
envoy_config_route_v3_RouteMatch_safe_regex(match);
|
1320
|
-
GPR_ASSERT(regex_matcher != nullptr);
|
1321
|
-
type = StringMatcher::Type::kSafeRegex;
|
1322
|
-
match_string = UpbStringToStdString(
|
1323
|
-
envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher));
|
1324
|
-
} else {
|
1325
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1326
|
-
"Invalid route path specifier specified.");
|
1327
|
-
}
|
1328
|
-
absl::StatusOr<StringMatcher> string_matcher =
|
1329
|
-
StringMatcher::Create(type, match_string, case_sensitive);
|
1330
|
-
if (!string_matcher.ok()) {
|
1331
|
-
return GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
1332
|
-
absl::StrCat("path matcher: ", string_matcher.status().message()));
|
1333
|
-
}
|
1334
|
-
route->matchers.path_matcher = std::move(string_matcher.value());
|
1335
|
-
return GRPC_ERROR_NONE;
|
1336
|
-
}
|
1337
|
-
|
1338
|
-
grpc_error_handle RouteHeaderMatchersParse(
|
1339
|
-
const envoy_config_route_v3_RouteMatch* match, XdsApi::Route* route) {
|
1340
|
-
size_t size;
|
1341
|
-
const envoy_config_route_v3_HeaderMatcher* const* headers =
|
1342
|
-
envoy_config_route_v3_RouteMatch_headers(match, &size);
|
1343
|
-
for (size_t i = 0; i < size; ++i) {
|
1344
|
-
const envoy_config_route_v3_HeaderMatcher* header = headers[i];
|
1345
|
-
const std::string name =
|
1346
|
-
UpbStringToStdString(envoy_config_route_v3_HeaderMatcher_name(header));
|
1347
|
-
HeaderMatcher::Type type;
|
1348
|
-
std::string match_string;
|
1349
|
-
int64_t range_start = 0;
|
1350
|
-
int64_t range_end = 0;
|
1351
|
-
bool present_match = false;
|
1352
|
-
if (envoy_config_route_v3_HeaderMatcher_has_exact_match(header)) {
|
1353
|
-
type = HeaderMatcher::Type::kExact;
|
1354
|
-
match_string = UpbStringToStdString(
|
1355
|
-
envoy_config_route_v3_HeaderMatcher_exact_match(header));
|
1356
|
-
} else if (envoy_config_route_v3_HeaderMatcher_has_safe_regex_match(
|
1357
|
-
header)) {
|
1358
|
-
const envoy_type_matcher_v3_RegexMatcher* regex_matcher =
|
1359
|
-
envoy_config_route_v3_HeaderMatcher_safe_regex_match(header);
|
1360
|
-
GPR_ASSERT(regex_matcher != nullptr);
|
1361
|
-
type = HeaderMatcher::Type::kSafeRegex;
|
1362
|
-
match_string = UpbStringToStdString(
|
1363
|
-
envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher));
|
1364
|
-
} else if (envoy_config_route_v3_HeaderMatcher_has_range_match(header)) {
|
1365
|
-
type = HeaderMatcher::Type::kRange;
|
1366
|
-
const envoy_type_v3_Int64Range* range_matcher =
|
1367
|
-
envoy_config_route_v3_HeaderMatcher_range_match(header);
|
1368
|
-
range_start = envoy_type_v3_Int64Range_start(range_matcher);
|
1369
|
-
range_end = envoy_type_v3_Int64Range_end(range_matcher);
|
1370
|
-
} else if (envoy_config_route_v3_HeaderMatcher_has_present_match(header)) {
|
1371
|
-
type = HeaderMatcher::Type::kPresent;
|
1372
|
-
present_match = envoy_config_route_v3_HeaderMatcher_present_match(header);
|
1373
|
-
} else if (envoy_config_route_v3_HeaderMatcher_has_prefix_match(header)) {
|
1374
|
-
type = HeaderMatcher::Type::kPrefix;
|
1375
|
-
match_string = UpbStringToStdString(
|
1376
|
-
envoy_config_route_v3_HeaderMatcher_prefix_match(header));
|
1377
|
-
} else if (envoy_config_route_v3_HeaderMatcher_has_suffix_match(header)) {
|
1378
|
-
type = HeaderMatcher::Type::kSuffix;
|
1379
|
-
match_string = UpbStringToStdString(
|
1380
|
-
envoy_config_route_v3_HeaderMatcher_suffix_match(header));
|
1381
|
-
} else if (envoy_config_route_v3_HeaderMatcher_has_contains_match(header)) {
|
1382
|
-
type = HeaderMatcher::Type::kContains;
|
1383
|
-
match_string = UpbStringToStdString(
|
1384
|
-
envoy_config_route_v3_HeaderMatcher_contains_match(header));
|
1385
|
-
} else {
|
1386
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1387
|
-
"Invalid route header matcher specified.");
|
1388
|
-
}
|
1389
|
-
bool invert_match =
|
1390
|
-
envoy_config_route_v3_HeaderMatcher_invert_match(header);
|
1391
|
-
absl::StatusOr<HeaderMatcher> header_matcher =
|
1392
|
-
HeaderMatcher::Create(name, type, match_string, range_start, range_end,
|
1393
|
-
present_match, invert_match);
|
1394
|
-
if (!header_matcher.ok()) {
|
1395
|
-
return GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
1396
|
-
absl::StrCat("header matcher: ", header_matcher.status().message()));
|
1397
|
-
}
|
1398
|
-
route->matchers.header_matchers.emplace_back(
|
1399
|
-
std::move(header_matcher.value()));
|
1400
|
-
}
|
1401
|
-
return GRPC_ERROR_NONE;
|
1402
|
-
}
|
1403
|
-
|
1404
|
-
grpc_error_handle RouteRuntimeFractionParse(
|
1405
|
-
const envoy_config_route_v3_RouteMatch* match, XdsApi::Route* route) {
|
1406
|
-
const envoy_config_core_v3_RuntimeFractionalPercent* runtime_fraction =
|
1407
|
-
envoy_config_route_v3_RouteMatch_runtime_fraction(match);
|
1408
|
-
if (runtime_fraction != nullptr) {
|
1409
|
-
const envoy_type_v3_FractionalPercent* fraction =
|
1410
|
-
envoy_config_core_v3_RuntimeFractionalPercent_default_value(
|
1411
|
-
runtime_fraction);
|
1412
|
-
if (fraction != nullptr) {
|
1413
|
-
uint32_t numerator = envoy_type_v3_FractionalPercent_numerator(fraction);
|
1414
|
-
const auto denominator =
|
1415
|
-
static_cast<envoy_type_v3_FractionalPercent_DenominatorType>(
|
1416
|
-
envoy_type_v3_FractionalPercent_denominator(fraction));
|
1417
|
-
// Normalize to million.
|
1418
|
-
switch (denominator) {
|
1419
|
-
case envoy_type_v3_FractionalPercent_HUNDRED:
|
1420
|
-
numerator *= 10000;
|
1421
|
-
break;
|
1422
|
-
case envoy_type_v3_FractionalPercent_TEN_THOUSAND:
|
1423
|
-
numerator *= 100;
|
1424
|
-
break;
|
1425
|
-
case envoy_type_v3_FractionalPercent_MILLION:
|
1426
|
-
break;
|
1427
|
-
default:
|
1428
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1429
|
-
"Unknown denominator type");
|
1430
|
-
}
|
1431
|
-
route->matchers.fraction_per_million = numerator;
|
1432
|
-
}
|
1433
|
-
}
|
1434
|
-
return GRPC_ERROR_NONE;
|
1435
|
-
}
|
1436
|
-
|
1437
|
-
grpc_error_handle ExtractHttpFilterTypeName(const EncodingContext& context,
|
1438
|
-
const google_protobuf_Any* any,
|
1439
|
-
absl::string_view* filter_type) {
|
1440
|
-
*filter_type = UpbStringToAbsl(google_protobuf_Any_type_url(any));
|
1441
|
-
if (*filter_type == "type.googleapis.com/udpa.type.v1.TypedStruct") {
|
1442
|
-
upb_strview any_value = google_protobuf_Any_value(any);
|
1443
|
-
const auto* typed_struct = udpa_type_v1_TypedStruct_parse(
|
1444
|
-
any_value.data, any_value.size, context.arena);
|
1445
|
-
if (typed_struct == nullptr) {
|
1446
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1447
|
-
"could not parse TypedStruct from filter config");
|
1448
|
-
}
|
1449
|
-
*filter_type =
|
1450
|
-
UpbStringToAbsl(udpa_type_v1_TypedStruct_type_url(typed_struct));
|
1451
|
-
}
|
1452
|
-
*filter_type = absl::StripPrefix(*filter_type, "type.googleapis.com/");
|
1453
|
-
return GRPC_ERROR_NONE;
|
1454
|
-
}
|
1455
|
-
|
1456
|
-
template <typename ParentType, typename EntryType>
|
1457
|
-
grpc_error_handle ParseTypedPerFilterConfig(
|
1458
|
-
const EncodingContext& context, const ParentType* parent,
|
1459
|
-
const EntryType* (*entry_func)(const ParentType*, size_t*),
|
1460
|
-
upb_strview (*key_func)(const EntryType*),
|
1461
|
-
const google_protobuf_Any* (*value_func)(const EntryType*),
|
1462
|
-
XdsApi::TypedPerFilterConfig* typed_per_filter_config) {
|
1463
|
-
size_t filter_it = UPB_MAP_BEGIN;
|
1464
|
-
while (true) {
|
1465
|
-
const auto* filter_entry = entry_func(parent, &filter_it);
|
1466
|
-
if (filter_entry == nullptr) break;
|
1467
|
-
absl::string_view key = UpbStringToAbsl(key_func(filter_entry));
|
1468
|
-
if (key.empty()) {
|
1469
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("empty filter name in map");
|
1470
|
-
}
|
1471
|
-
const google_protobuf_Any* any = value_func(filter_entry);
|
1472
|
-
GPR_ASSERT(any != nullptr);
|
1473
|
-
absl::string_view filter_type =
|
1474
|
-
UpbStringToAbsl(google_protobuf_Any_type_url(any));
|
1475
|
-
if (filter_type.empty()) {
|
1476
|
-
return GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
1477
|
-
absl::StrCat("no filter config specified for filter name ", key));
|
1478
|
-
}
|
1479
|
-
bool is_optional = false;
|
1480
|
-
if (filter_type ==
|
1481
|
-
"type.googleapis.com/envoy.config.route.v3.FilterConfig") {
|
1482
|
-
upb_strview any_value = google_protobuf_Any_value(any);
|
1483
|
-
const auto* filter_config = envoy_config_route_v3_FilterConfig_parse(
|
1484
|
-
any_value.data, any_value.size, context.arena);
|
1485
|
-
if (filter_config == nullptr) {
|
1486
|
-
return GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
1487
|
-
absl::StrCat("could not parse FilterConfig wrapper for ", key));
|
1488
|
-
}
|
1489
|
-
is_optional =
|
1490
|
-
envoy_config_route_v3_FilterConfig_is_optional(filter_config);
|
1491
|
-
any = envoy_config_route_v3_FilterConfig_config(filter_config);
|
1492
|
-
if (any == nullptr) {
|
1493
|
-
if (is_optional) continue;
|
1494
|
-
return GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
1495
|
-
absl::StrCat("no filter config specified for filter name ", key));
|
1496
|
-
}
|
1497
|
-
}
|
1498
|
-
grpc_error_handle error =
|
1499
|
-
ExtractHttpFilterTypeName(context, any, &filter_type);
|
1500
|
-
if (error != GRPC_ERROR_NONE) return error;
|
1501
|
-
const XdsHttpFilterImpl* filter_impl =
|
1502
|
-
XdsHttpFilterRegistry::GetFilterForType(filter_type);
|
1503
|
-
if (filter_impl == nullptr) {
|
1504
|
-
if (is_optional) continue;
|
1505
|
-
return GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
1506
|
-
absl::StrCat("no filter registered for config type ", filter_type));
|
1507
|
-
}
|
1508
|
-
absl::StatusOr<XdsHttpFilterImpl::FilterConfig> filter_config =
|
1509
|
-
filter_impl->GenerateFilterConfigOverride(
|
1510
|
-
google_protobuf_Any_value(any), context.arena);
|
1511
|
-
if (!filter_config.ok()) {
|
1512
|
-
return GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrCat(
|
1513
|
-
"filter config for type ", filter_type,
|
1514
|
-
" failed to parse: ", filter_config.status().ToString()));
|
1515
|
-
}
|
1516
|
-
(*typed_per_filter_config)[std::string(key)] = std::move(*filter_config);
|
1517
|
-
}
|
1518
|
-
return GRPC_ERROR_NONE;
|
1519
|
-
}
|
1520
|
-
|
1521
|
-
XdsApi::Duration DurationParse(const google_protobuf_Duration* proto_duration) {
|
1522
|
-
XdsApi::Duration duration;
|
1523
|
-
duration.seconds = google_protobuf_Duration_seconds(proto_duration);
|
1524
|
-
duration.nanos = google_protobuf_Duration_nanos(proto_duration);
|
1525
|
-
return duration;
|
1526
|
-
}
|
1527
|
-
|
1528
|
-
grpc_error_handle RetryPolicyParse(
|
1529
|
-
const EncodingContext& context,
|
1530
|
-
const envoy_config_route_v3_RetryPolicy* retry_policy,
|
1531
|
-
absl::optional<XdsApi::Route::RetryPolicy>* retry) {
|
1532
|
-
std::vector<grpc_error_handle> errors;
|
1533
|
-
XdsApi::Route::RetryPolicy retry_to_return;
|
1534
|
-
auto retry_on = UpbStringToStdString(
|
1535
|
-
envoy_config_route_v3_RetryPolicy_retry_on(retry_policy));
|
1536
|
-
std::vector<absl::string_view> codes = absl::StrSplit(retry_on, ',');
|
1537
|
-
for (const auto& code : codes) {
|
1538
|
-
if (code == "cancelled") {
|
1539
|
-
retry_to_return.retry_on.Add(GRPC_STATUS_CANCELLED);
|
1540
|
-
} else if (code == "deadline-exceeded") {
|
1541
|
-
retry_to_return.retry_on.Add(GRPC_STATUS_DEADLINE_EXCEEDED);
|
1542
|
-
} else if (code == "internal") {
|
1543
|
-
retry_to_return.retry_on.Add(GRPC_STATUS_INTERNAL);
|
1544
|
-
} else if (code == "resource-exhausted") {
|
1545
|
-
retry_to_return.retry_on.Add(GRPC_STATUS_RESOURCE_EXHAUSTED);
|
1546
|
-
} else if (code == "unavailable") {
|
1547
|
-
retry_to_return.retry_on.Add(GRPC_STATUS_UNAVAILABLE);
|
1548
|
-
} else {
|
1549
|
-
if (GRPC_TRACE_FLAG_ENABLED(*context.tracer)) {
|
1550
|
-
gpr_log(GPR_INFO, "Unsupported retry_on policy %s.",
|
1551
|
-
std::string(code).c_str());
|
1552
|
-
}
|
1553
|
-
}
|
1554
|
-
}
|
1555
|
-
// TODO(donnadionne): when we add support for per_try_timeout, we will need to
|
1556
|
-
// return a policy if per_try_timeout is set even if retry_on specified no
|
1557
|
-
// supported policies.
|
1558
|
-
if (retry_to_return.retry_on.Empty()) return GRPC_ERROR_NONE;
|
1559
|
-
const google_protobuf_UInt32Value* num_retries =
|
1560
|
-
envoy_config_route_v3_RetryPolicy_num_retries(retry_policy);
|
1561
|
-
if (num_retries != nullptr) {
|
1562
|
-
uint32_t num_retries_value = google_protobuf_UInt32Value_value(num_retries);
|
1563
|
-
if (num_retries_value == 0) {
|
1564
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1565
|
-
"RouteAction RetryPolicy num_retries set to invalid value 0."));
|
1566
|
-
} else {
|
1567
|
-
retry_to_return.num_retries = num_retries_value;
|
1568
|
-
}
|
1569
|
-
} else {
|
1570
|
-
retry_to_return.num_retries = 1;
|
1571
|
-
}
|
1572
|
-
const envoy_config_route_v3_RetryPolicy_RetryBackOff* backoff =
|
1573
|
-
envoy_config_route_v3_RetryPolicy_retry_back_off(retry_policy);
|
1574
|
-
if (backoff != nullptr) {
|
1575
|
-
const google_protobuf_Duration* base_interval =
|
1576
|
-
envoy_config_route_v3_RetryPolicy_RetryBackOff_base_interval(backoff);
|
1577
|
-
if (base_interval == nullptr) {
|
1578
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1579
|
-
"RouteAction RetryPolicy RetryBackoff missing base interval."));
|
1580
|
-
} else {
|
1581
|
-
retry_to_return.retry_back_off.base_interval =
|
1582
|
-
DurationParse(base_interval);
|
1583
|
-
}
|
1584
|
-
const google_protobuf_Duration* max_interval =
|
1585
|
-
envoy_config_route_v3_RetryPolicy_RetryBackOff_max_interval(backoff);
|
1586
|
-
XdsApi::Duration max;
|
1587
|
-
if (max_interval != nullptr) {
|
1588
|
-
max = DurationParse(max_interval);
|
1589
|
-
} else {
|
1590
|
-
// if max interval is not set, it is 10x the base, if the value in nanos
|
1591
|
-
// can yield another second, adjust the value in seconds accordingly.
|
1592
|
-
max.seconds = retry_to_return.retry_back_off.base_interval.seconds * 10;
|
1593
|
-
max.nanos = retry_to_return.retry_back_off.base_interval.nanos * 10;
|
1594
|
-
if (max.nanos > 1000000000) {
|
1595
|
-
max.seconds += max.nanos / 1000000000;
|
1596
|
-
max.nanos = max.nanos % 1000000000;
|
1597
|
-
}
|
1598
|
-
}
|
1599
|
-
retry_to_return.retry_back_off.max_interval = max;
|
1600
|
-
} else {
|
1601
|
-
retry_to_return.retry_back_off.base_interval.seconds = 0;
|
1602
|
-
retry_to_return.retry_back_off.base_interval.nanos = 25000000;
|
1603
|
-
retry_to_return.retry_back_off.max_interval.seconds = 0;
|
1604
|
-
retry_to_return.retry_back_off.max_interval.nanos = 250000000;
|
1605
|
-
}
|
1606
|
-
if (errors.empty()) {
|
1607
|
-
*retry = retry_to_return;
|
1608
|
-
return GRPC_ERROR_NONE;
|
1609
|
-
} else {
|
1610
|
-
return GRPC_ERROR_CREATE_FROM_VECTOR("errors parsing retry policy",
|
1611
|
-
&errors);
|
1612
|
-
}
|
1613
|
-
}
|
1614
|
-
|
1615
|
-
grpc_error_handle RouteActionParse(const EncodingContext& context,
|
1616
|
-
const envoy_config_route_v3_Route* route_msg,
|
1617
|
-
XdsApi::Route* route, bool* ignore_route) {
|
1618
|
-
if (!envoy_config_route_v3_Route_has_route(route_msg)) {
|
1619
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1620
|
-
"No RouteAction found in route.");
|
1621
|
-
}
|
1622
|
-
const envoy_config_route_v3_RouteAction* route_action =
|
1623
|
-
envoy_config_route_v3_Route_route(route_msg);
|
1624
|
-
// Get the cluster or weighted_clusters in the RouteAction.
|
1625
|
-
if (envoy_config_route_v3_RouteAction_has_cluster(route_action)) {
|
1626
|
-
route->cluster_name = UpbStringToStdString(
|
1627
|
-
envoy_config_route_v3_RouteAction_cluster(route_action));
|
1628
|
-
if (route->cluster_name.empty()) {
|
1629
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1630
|
-
"RouteAction cluster contains empty cluster name.");
|
1631
|
-
}
|
1632
|
-
} else if (envoy_config_route_v3_RouteAction_has_weighted_clusters(
|
1633
|
-
route_action)) {
|
1634
|
-
const envoy_config_route_v3_WeightedCluster* weighted_cluster =
|
1635
|
-
envoy_config_route_v3_RouteAction_weighted_clusters(route_action);
|
1636
|
-
uint32_t total_weight = 100;
|
1637
|
-
const google_protobuf_UInt32Value* weight =
|
1638
|
-
envoy_config_route_v3_WeightedCluster_total_weight(weighted_cluster);
|
1639
|
-
if (weight != nullptr) {
|
1640
|
-
total_weight = google_protobuf_UInt32Value_value(weight);
|
1641
|
-
}
|
1642
|
-
size_t clusters_size;
|
1643
|
-
const envoy_config_route_v3_WeightedCluster_ClusterWeight* const* clusters =
|
1644
|
-
envoy_config_route_v3_WeightedCluster_clusters(weighted_cluster,
|
1645
|
-
&clusters_size);
|
1646
|
-
uint32_t sum_of_weights = 0;
|
1647
|
-
for (size_t j = 0; j < clusters_size; ++j) {
|
1648
|
-
const envoy_config_route_v3_WeightedCluster_ClusterWeight*
|
1649
|
-
cluster_weight = clusters[j];
|
1650
|
-
XdsApi::Route::ClusterWeight cluster;
|
1651
|
-
cluster.name = UpbStringToStdString(
|
1652
|
-
envoy_config_route_v3_WeightedCluster_ClusterWeight_name(
|
1653
|
-
cluster_weight));
|
1654
|
-
if (cluster.name.empty()) {
|
1655
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1656
|
-
"RouteAction weighted_cluster cluster contains empty cluster "
|
1657
|
-
"name.");
|
1658
|
-
}
|
1659
|
-
const google_protobuf_UInt32Value* weight =
|
1660
|
-
envoy_config_route_v3_WeightedCluster_ClusterWeight_weight(
|
1661
|
-
cluster_weight);
|
1662
|
-
if (weight == nullptr) {
|
1663
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1664
|
-
"RouteAction weighted_cluster cluster missing weight");
|
1665
|
-
}
|
1666
|
-
cluster.weight = google_protobuf_UInt32Value_value(weight);
|
1667
|
-
if (cluster.weight == 0) continue;
|
1668
|
-
sum_of_weights += cluster.weight;
|
1669
|
-
if (context.use_v3) {
|
1670
|
-
grpc_error_handle error = ParseTypedPerFilterConfig<
|
1671
|
-
envoy_config_route_v3_WeightedCluster_ClusterWeight,
|
1672
|
-
envoy_config_route_v3_WeightedCluster_ClusterWeight_TypedPerFilterConfigEntry>(
|
1673
|
-
context, cluster_weight,
|
1674
|
-
envoy_config_route_v3_WeightedCluster_ClusterWeight_typed_per_filter_config_next,
|
1675
|
-
envoy_config_route_v3_WeightedCluster_ClusterWeight_TypedPerFilterConfigEntry_key,
|
1676
|
-
envoy_config_route_v3_WeightedCluster_ClusterWeight_TypedPerFilterConfigEntry_value,
|
1677
|
-
&cluster.typed_per_filter_config);
|
1678
|
-
if (error != GRPC_ERROR_NONE) return error;
|
1679
|
-
}
|
1680
|
-
route->weighted_clusters.emplace_back(std::move(cluster));
|
1681
|
-
}
|
1682
|
-
if (total_weight != sum_of_weights) {
|
1683
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1684
|
-
"RouteAction weighted_cluster has incorrect total weight");
|
1685
|
-
}
|
1686
|
-
if (route->weighted_clusters.empty()) {
|
1687
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1688
|
-
"RouteAction weighted_cluster has no valid clusters specified.");
|
1689
|
-
}
|
1690
|
-
} else {
|
1691
|
-
// No cluster or weighted_clusters found in RouteAction, ignore this route.
|
1692
|
-
*ignore_route = true;
|
1693
|
-
}
|
1694
|
-
if (!*ignore_route) {
|
1695
|
-
const envoy_config_route_v3_RouteAction_MaxStreamDuration*
|
1696
|
-
max_stream_duration =
|
1697
|
-
envoy_config_route_v3_RouteAction_max_stream_duration(route_action);
|
1698
|
-
if (max_stream_duration != nullptr) {
|
1699
|
-
const google_protobuf_Duration* duration =
|
1700
|
-
envoy_config_route_v3_RouteAction_MaxStreamDuration_grpc_timeout_header_max(
|
1701
|
-
max_stream_duration);
|
1702
|
-
if (duration == nullptr) {
|
1703
|
-
duration =
|
1704
|
-
envoy_config_route_v3_RouteAction_MaxStreamDuration_max_stream_duration(
|
1705
|
-
max_stream_duration);
|
1706
|
-
}
|
1707
|
-
if (duration != nullptr) {
|
1708
|
-
route->max_stream_duration = DurationParse(duration);
|
1709
|
-
}
|
1710
|
-
}
|
1711
|
-
}
|
1712
|
-
// Get HashPolicy from RouteAction
|
1713
|
-
size_t size = 0;
|
1714
|
-
const envoy_config_route_v3_RouteAction_HashPolicy* const* hash_policies =
|
1715
|
-
envoy_config_route_v3_RouteAction_hash_policy(route_action, &size);
|
1716
|
-
for (size_t i = 0; i < size; ++i) {
|
1717
|
-
const envoy_config_route_v3_RouteAction_HashPolicy* hash_policy =
|
1718
|
-
hash_policies[i];
|
1719
|
-
XdsApi::Route::HashPolicy policy;
|
1720
|
-
policy.terminal =
|
1721
|
-
envoy_config_route_v3_RouteAction_HashPolicy_terminal(hash_policy);
|
1722
|
-
const envoy_config_route_v3_RouteAction_HashPolicy_Header* header;
|
1723
|
-
const envoy_config_route_v3_RouteAction_HashPolicy_FilterState*
|
1724
|
-
filter_state;
|
1725
|
-
if ((header = envoy_config_route_v3_RouteAction_HashPolicy_header(
|
1726
|
-
hash_policy)) != nullptr) {
|
1727
|
-
policy.type = XdsApi::Route::HashPolicy::Type::HEADER;
|
1728
|
-
policy.header_name = UpbStringToStdString(
|
1729
|
-
envoy_config_route_v3_RouteAction_HashPolicy_Header_header_name(
|
1730
|
-
header));
|
1731
|
-
const struct envoy_type_matcher_v3_RegexMatchAndSubstitute*
|
1732
|
-
regex_rewrite =
|
1733
|
-
envoy_config_route_v3_RouteAction_HashPolicy_Header_regex_rewrite(
|
1734
|
-
header);
|
1735
|
-
if (regex_rewrite != nullptr) {
|
1736
|
-
const envoy_type_matcher_v3_RegexMatcher* regex_matcher =
|
1737
|
-
envoy_type_matcher_v3_RegexMatchAndSubstitute_pattern(
|
1738
|
-
regex_rewrite);
|
1739
|
-
if (regex_matcher == nullptr) {
|
1740
|
-
gpr_log(
|
1741
|
-
GPR_DEBUG,
|
1742
|
-
"RouteAction HashPolicy contains policy specifier Header with "
|
1743
|
-
"RegexMatchAndSubstitution but RegexMatcher pattern is "
|
1744
|
-
"missing");
|
1745
|
-
continue;
|
1746
|
-
}
|
1747
|
-
RE2::Options options;
|
1748
|
-
policy.regex = absl::make_unique<RE2>(
|
1749
|
-
UpbStringToStdString(
|
1750
|
-
envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher)),
|
1751
|
-
options);
|
1752
|
-
if (!policy.regex->ok()) {
|
1753
|
-
gpr_log(
|
1754
|
-
GPR_DEBUG,
|
1755
|
-
"RouteAction HashPolicy contains policy specifier Header with "
|
1756
|
-
"RegexMatchAndSubstitution but RegexMatcher pattern does not "
|
1757
|
-
"compile");
|
1758
|
-
continue;
|
1759
|
-
}
|
1760
|
-
policy.regex_substitution = UpbStringToStdString(
|
1761
|
-
envoy_type_matcher_v3_RegexMatchAndSubstitute_substitution(
|
1762
|
-
regex_rewrite));
|
1763
|
-
}
|
1764
|
-
} else if ((filter_state =
|
1765
|
-
envoy_config_route_v3_RouteAction_HashPolicy_filter_state(
|
1766
|
-
hash_policy)) != nullptr) {
|
1767
|
-
std::string key = UpbStringToStdString(
|
1768
|
-
envoy_config_route_v3_RouteAction_HashPolicy_FilterState_key(
|
1769
|
-
filter_state));
|
1770
|
-
if (key == "io.grpc.channel_id") {
|
1771
|
-
policy.type = XdsApi::Route::HashPolicy::Type::CHANNEL_ID;
|
1772
|
-
} else {
|
1773
|
-
gpr_log(GPR_DEBUG,
|
1774
|
-
"RouteAction HashPolicy contains policy specifier "
|
1775
|
-
"FilterState but "
|
1776
|
-
"key is not io.grpc.channel_id.");
|
1777
|
-
continue;
|
1778
|
-
}
|
1779
|
-
} else {
|
1780
|
-
gpr_log(GPR_DEBUG,
|
1781
|
-
"RouteAction HashPolicy contains unsupported policy specifier.");
|
1782
|
-
continue;
|
1783
|
-
}
|
1784
|
-
route->hash_policies.emplace_back(std::move(policy));
|
1785
|
-
}
|
1786
|
-
// Get retry policy
|
1787
|
-
const envoy_config_route_v3_RetryPolicy* retry_policy =
|
1788
|
-
envoy_config_route_v3_RouteAction_retry_policy(route_action);
|
1789
|
-
if (retry_policy != nullptr) {
|
1790
|
-
absl::optional<XdsApi::Route::RetryPolicy> retry;
|
1791
|
-
grpc_error_handle error = RetryPolicyParse(context, retry_policy, &retry);
|
1792
|
-
if (error != GRPC_ERROR_NONE) return error;
|
1793
|
-
route->retry_policy = retry;
|
1794
|
-
}
|
1795
|
-
return GRPC_ERROR_NONE;
|
1796
|
-
}
|
1797
|
-
|
1798
|
-
grpc_error_handle RouteConfigParse(
|
1799
|
-
const EncodingContext& context,
|
1800
|
-
const envoy_config_route_v3_RouteConfiguration* route_config,
|
1801
|
-
bool /*is_v2*/, XdsApi::RdsUpdate* rds_update) {
|
1802
|
-
MaybeLogRouteConfiguration(context, route_config);
|
1803
|
-
// Get the virtual hosts.
|
1804
|
-
size_t num_virtual_hosts;
|
1805
|
-
const envoy_config_route_v3_VirtualHost* const* virtual_hosts =
|
1806
|
-
envoy_config_route_v3_RouteConfiguration_virtual_hosts(
|
1807
|
-
route_config, &num_virtual_hosts);
|
1808
|
-
for (size_t i = 0; i < num_virtual_hosts; ++i) {
|
1809
|
-
rds_update->virtual_hosts.emplace_back();
|
1810
|
-
XdsApi::RdsUpdate::VirtualHost& vhost = rds_update->virtual_hosts.back();
|
1811
|
-
// Parse domains.
|
1812
|
-
size_t domain_size;
|
1813
|
-
upb_strview const* domains = envoy_config_route_v3_VirtualHost_domains(
|
1814
|
-
virtual_hosts[i], &domain_size);
|
1815
|
-
for (size_t j = 0; j < domain_size; ++j) {
|
1816
|
-
std::string domain_pattern = UpbStringToStdString(domains[j]);
|
1817
|
-
const MatchType match_type = DomainPatternMatchType(domain_pattern);
|
1818
|
-
if (match_type == INVALID_MATCH) {
|
1819
|
-
return GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
1820
|
-
absl::StrCat("Invalid domain pattern \"", domain_pattern, "\"."));
|
1821
|
-
}
|
1822
|
-
vhost.domains.emplace_back(std::move(domain_pattern));
|
1823
|
-
}
|
1824
|
-
if (vhost.domains.empty()) {
|
1825
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("VirtualHost has no domains");
|
1826
|
-
}
|
1827
|
-
// Parse typed_per_filter_config.
|
1828
|
-
if (context.use_v3) {
|
1829
|
-
grpc_error_handle error = ParseTypedPerFilterConfig<
|
1830
|
-
envoy_config_route_v3_VirtualHost,
|
1831
|
-
envoy_config_route_v3_VirtualHost_TypedPerFilterConfigEntry>(
|
1832
|
-
context, virtual_hosts[i],
|
1833
|
-
envoy_config_route_v3_VirtualHost_typed_per_filter_config_next,
|
1834
|
-
envoy_config_route_v3_VirtualHost_TypedPerFilterConfigEntry_key,
|
1835
|
-
envoy_config_route_v3_VirtualHost_TypedPerFilterConfigEntry_value,
|
1836
|
-
&vhost.typed_per_filter_config);
|
1837
|
-
if (error != GRPC_ERROR_NONE) return error;
|
1838
|
-
}
|
1839
|
-
// Parse retry policy.
|
1840
|
-
absl::optional<XdsApi::Route::RetryPolicy> virtual_host_retry_policy;
|
1841
|
-
const envoy_config_route_v3_RetryPolicy* retry_policy =
|
1842
|
-
envoy_config_route_v3_VirtualHost_retry_policy(virtual_hosts[i]);
|
1843
|
-
if (retry_policy != nullptr) {
|
1844
|
-
grpc_error_handle error =
|
1845
|
-
RetryPolicyParse(context, retry_policy, &virtual_host_retry_policy);
|
1846
|
-
if (error != GRPC_ERROR_NONE) return error;
|
1847
|
-
}
|
1848
|
-
// Parse routes.
|
1849
|
-
size_t num_routes;
|
1850
|
-
const envoy_config_route_v3_Route* const* routes =
|
1851
|
-
envoy_config_route_v3_VirtualHost_routes(virtual_hosts[i], &num_routes);
|
1852
|
-
if (num_routes < 1) {
|
1853
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1854
|
-
"No route found in the virtual host.");
|
1855
|
-
}
|
1856
|
-
// Loop over the whole list of routes
|
1857
|
-
for (size_t j = 0; j < num_routes; ++j) {
|
1858
|
-
const envoy_config_route_v3_RouteMatch* match =
|
1859
|
-
envoy_config_route_v3_Route_match(routes[j]);
|
1860
|
-
if (match == nullptr) {
|
1861
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Match can't be null.");
|
1862
|
-
}
|
1863
|
-
size_t query_parameters_size;
|
1864
|
-
static_cast<void>(envoy_config_route_v3_RouteMatch_query_parameters(
|
1865
|
-
match, &query_parameters_size));
|
1866
|
-
if (query_parameters_size > 0) {
|
1867
|
-
continue;
|
1868
|
-
}
|
1869
|
-
XdsApi::Route route;
|
1870
|
-
bool ignore_route = false;
|
1871
|
-
grpc_error_handle error =
|
1872
|
-
RoutePathMatchParse(match, &route, &ignore_route);
|
1873
|
-
if (error != GRPC_ERROR_NONE) return error;
|
1874
|
-
if (ignore_route) continue;
|
1875
|
-
error = RouteHeaderMatchersParse(match, &route);
|
1876
|
-
if (error != GRPC_ERROR_NONE) return error;
|
1877
|
-
error = RouteRuntimeFractionParse(match, &route);
|
1878
|
-
if (error != GRPC_ERROR_NONE) return error;
|
1879
|
-
error = RouteActionParse(context, routes[j], &route, &ignore_route);
|
1880
|
-
if (error != GRPC_ERROR_NONE) return error;
|
1881
|
-
if (ignore_route) continue;
|
1882
|
-
if (route.retry_policy == absl::nullopt && retry_policy != nullptr) {
|
1883
|
-
route.retry_policy = virtual_host_retry_policy;
|
1884
|
-
}
|
1885
|
-
if (context.use_v3) {
|
1886
|
-
grpc_error_handle error = ParseTypedPerFilterConfig<
|
1887
|
-
envoy_config_route_v3_Route,
|
1888
|
-
envoy_config_route_v3_Route_TypedPerFilterConfigEntry>(
|
1889
|
-
context, routes[j],
|
1890
|
-
envoy_config_route_v3_Route_typed_per_filter_config_next,
|
1891
|
-
envoy_config_route_v3_Route_TypedPerFilterConfigEntry_key,
|
1892
|
-
envoy_config_route_v3_Route_TypedPerFilterConfigEntry_value,
|
1893
|
-
&route.typed_per_filter_config);
|
1894
|
-
if (error != GRPC_ERROR_NONE) return error;
|
1895
|
-
}
|
1896
|
-
vhost.routes.emplace_back(std::move(route));
|
1897
|
-
}
|
1898
|
-
if (vhost.routes.empty()) {
|
1899
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("No valid routes specified.");
|
1900
|
-
}
|
1901
|
-
}
|
1902
|
-
return GRPC_ERROR_NONE;
|
1903
|
-
}
|
1904
|
-
|
1905
|
-
// CertificateProviderInstance is deprecated but we are still supporting it for
|
1906
|
-
// backward compatibility reasons. Note that we still parse the data into the
|
1907
|
-
// same CertificateProviderPluginInstance struct since the fields are the same.
|
1908
|
-
// TODO(yashykt): Remove this once we stop supporting the old way of fetching
|
1909
|
-
// certificate provider instances.
|
1910
|
-
grpc_error_handle CertificateProviderInstanceParse(
|
1911
|
-
const EncodingContext& context,
|
1912
|
-
const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance*
|
1913
|
-
certificate_provider_instance_proto,
|
1914
|
-
XdsApi::CommonTlsContext::CertificateProviderPluginInstance*
|
1915
|
-
certificate_provider_plugin_instance) {
|
1916
|
-
*certificate_provider_plugin_instance = {
|
1917
|
-
UpbStringToStdString(
|
1918
|
-
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_instance_name(
|
1919
|
-
certificate_provider_instance_proto)),
|
1920
|
-
UpbStringToStdString(
|
1921
|
-
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_certificate_name(
|
1922
|
-
certificate_provider_instance_proto))};
|
1923
|
-
if (context.certificate_provider_definition_map->find(
|
1924
|
-
certificate_provider_plugin_instance->instance_name) ==
|
1925
|
-
context.certificate_provider_definition_map->end()) {
|
1926
|
-
return GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
1927
|
-
absl::StrCat("Unrecognized certificate provider instance name: ",
|
1928
|
-
certificate_provider_plugin_instance->instance_name));
|
1929
|
-
}
|
1930
|
-
return GRPC_ERROR_NONE;
|
1931
|
-
}
|
1932
|
-
|
1933
|
-
grpc_error_handle CertificateProviderPluginInstanceParse(
|
1934
|
-
const EncodingContext& context,
|
1935
|
-
const envoy_extensions_transport_sockets_tls_v3_CertificateProviderPluginInstance*
|
1936
|
-
certificate_provider_plugin_instance_proto,
|
1937
|
-
XdsApi::CommonTlsContext::CertificateProviderPluginInstance*
|
1938
|
-
certificate_provider_plugin_instance) {
|
1939
|
-
*certificate_provider_plugin_instance = {
|
1940
|
-
UpbStringToStdString(
|
1941
|
-
envoy_extensions_transport_sockets_tls_v3_CertificateProviderPluginInstance_instance_name(
|
1942
|
-
certificate_provider_plugin_instance_proto)),
|
1943
|
-
UpbStringToStdString(
|
1944
|
-
envoy_extensions_transport_sockets_tls_v3_CertificateProviderPluginInstance_certificate_name(
|
1945
|
-
certificate_provider_plugin_instance_proto))};
|
1946
|
-
if (context.certificate_provider_definition_map->find(
|
1947
|
-
certificate_provider_plugin_instance->instance_name) ==
|
1948
|
-
context.certificate_provider_definition_map->end()) {
|
1949
|
-
return GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
1950
|
-
absl::StrCat("Unrecognized certificate provider instance name: ",
|
1951
|
-
certificate_provider_plugin_instance->instance_name));
|
1952
|
-
}
|
1953
|
-
return GRPC_ERROR_NONE;
|
1954
|
-
}
|
1955
|
-
|
1956
|
-
grpc_error_handle CertificateValidationContextParse(
|
1957
|
-
const EncodingContext& context,
|
1958
|
-
const envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext*
|
1959
|
-
certificate_validation_context_proto,
|
1960
|
-
XdsApi::CommonTlsContext::CertificateValidationContext*
|
1961
|
-
certificate_validation_context) {
|
1962
|
-
std::vector<grpc_error_handle> errors;
|
1963
|
-
size_t len = 0;
|
1964
|
-
auto* subject_alt_names_matchers =
|
1965
|
-
envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_match_subject_alt_names(
|
1966
|
-
certificate_validation_context_proto, &len);
|
1967
|
-
for (size_t i = 0; i < len; ++i) {
|
1968
|
-
StringMatcher::Type type;
|
1969
|
-
std::string matcher;
|
1970
|
-
if (envoy_type_matcher_v3_StringMatcher_has_exact(
|
1971
|
-
subject_alt_names_matchers[i])) {
|
1972
|
-
type = StringMatcher::Type::kExact;
|
1973
|
-
matcher = UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_exact(
|
1974
|
-
subject_alt_names_matchers[i]));
|
1975
|
-
} else if (envoy_type_matcher_v3_StringMatcher_has_prefix(
|
1976
|
-
subject_alt_names_matchers[i])) {
|
1977
|
-
type = StringMatcher::Type::kPrefix;
|
1978
|
-
matcher = UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_prefix(
|
1979
|
-
subject_alt_names_matchers[i]));
|
1980
|
-
} else if (envoy_type_matcher_v3_StringMatcher_has_suffix(
|
1981
|
-
subject_alt_names_matchers[i])) {
|
1982
|
-
type = StringMatcher::Type::kSuffix;
|
1983
|
-
matcher = UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_suffix(
|
1984
|
-
subject_alt_names_matchers[i]));
|
1985
|
-
} else if (envoy_type_matcher_v3_StringMatcher_has_contains(
|
1986
|
-
subject_alt_names_matchers[i])) {
|
1987
|
-
type = StringMatcher::Type::kContains;
|
1988
|
-
matcher =
|
1989
|
-
UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_contains(
|
1990
|
-
subject_alt_names_matchers[i]));
|
1991
|
-
} else if (envoy_type_matcher_v3_StringMatcher_has_safe_regex(
|
1992
|
-
subject_alt_names_matchers[i])) {
|
1993
|
-
type = StringMatcher::Type::kSafeRegex;
|
1994
|
-
auto* regex_matcher = envoy_type_matcher_v3_StringMatcher_safe_regex(
|
1995
|
-
subject_alt_names_matchers[i]);
|
1996
|
-
matcher = UpbStringToStdString(
|
1997
|
-
envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher));
|
1998
|
-
} else {
|
1999
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2000
|
-
"Invalid StringMatcher specified"));
|
2001
|
-
continue;
|
2002
|
-
}
|
2003
|
-
bool ignore_case = envoy_type_matcher_v3_StringMatcher_ignore_case(
|
2004
|
-
subject_alt_names_matchers[i]);
|
2005
|
-
absl::StatusOr<StringMatcher> string_matcher =
|
2006
|
-
StringMatcher::Create(type, matcher,
|
2007
|
-
/*case_sensitive=*/!ignore_case);
|
2008
|
-
if (!string_matcher.ok()) {
|
2009
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
2010
|
-
absl::StrCat("string matcher: ", string_matcher.status().message())));
|
2011
|
-
continue;
|
2012
|
-
}
|
2013
|
-
if (type == StringMatcher::Type::kSafeRegex && ignore_case) {
|
2014
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2015
|
-
"StringMatcher: ignore_case has no effect for SAFE_REGEX."));
|
2016
|
-
continue;
|
2017
|
-
}
|
2018
|
-
certificate_validation_context->match_subject_alt_names.push_back(
|
2019
|
-
std::move(string_matcher.value()));
|
2020
|
-
}
|
2021
|
-
auto* ca_certificate_provider_instance =
|
2022
|
-
envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_ca_certificate_provider_instance(
|
2023
|
-
certificate_validation_context_proto);
|
2024
|
-
if (ca_certificate_provider_instance != nullptr) {
|
2025
|
-
grpc_error_handle error = CertificateProviderPluginInstanceParse(
|
2026
|
-
context, ca_certificate_provider_instance,
|
2027
|
-
&certificate_validation_context->ca_certificate_provider_instance);
|
2028
|
-
if (error != GRPC_ERROR_NONE) errors.push_back(error);
|
2029
|
-
}
|
2030
|
-
if (envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_verify_certificate_spki(
|
2031
|
-
certificate_validation_context_proto, nullptr) != nullptr) {
|
2032
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2033
|
-
"CertificateValidationContext: verify_certificate_spki "
|
2034
|
-
"unsupported"));
|
2035
|
-
}
|
2036
|
-
if (envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_verify_certificate_hash(
|
2037
|
-
certificate_validation_context_proto, nullptr) != nullptr) {
|
2038
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2039
|
-
"CertificateValidationContext: verify_certificate_hash "
|
2040
|
-
"unsupported"));
|
2041
|
-
}
|
2042
|
-
auto* require_signed_certificate_timestamp =
|
2043
|
-
envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_require_signed_certificate_timestamp(
|
2044
|
-
certificate_validation_context_proto);
|
2045
|
-
if (require_signed_certificate_timestamp != nullptr &&
|
2046
|
-
google_protobuf_BoolValue_value(require_signed_certificate_timestamp)) {
|
2047
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2048
|
-
"CertificateValidationContext: "
|
2049
|
-
"require_signed_certificate_timestamp unsupported"));
|
2050
|
-
}
|
2051
|
-
if (envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_has_crl(
|
2052
|
-
certificate_validation_context_proto)) {
|
2053
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2054
|
-
"CertificateValidationContext: crl unsupported"));
|
2055
|
-
}
|
2056
|
-
if (envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_has_custom_validator_config(
|
2057
|
-
certificate_validation_context_proto)) {
|
2058
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2059
|
-
"CertificateValidationContext: custom_validator_config "
|
2060
|
-
"unsupported"));
|
2061
|
-
}
|
2062
|
-
return GRPC_ERROR_CREATE_FROM_VECTOR(
|
2063
|
-
"Error parsing CertificateValidationContext", &errors);
|
2064
|
-
}
|
2065
|
-
|
2066
|
-
grpc_error_handle CommonTlsContextParse(
|
2067
|
-
const EncodingContext& context,
|
2068
|
-
const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext*
|
2069
|
-
common_tls_context_proto,
|
2070
|
-
XdsApi::CommonTlsContext* common_tls_context) {
|
2071
|
-
std::vector<grpc_error_handle> errors;
|
2072
|
-
// The validation context is derived from the oneof in
|
2073
|
-
// 'validation_context_type'. 'validation_context_sds_secret_config' is not
|
2074
|
-
// supported.
|
2075
|
-
auto* combined_validation_context =
|
2076
|
-
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_combined_validation_context(
|
2077
|
-
common_tls_context_proto);
|
2078
|
-
if (combined_validation_context != nullptr) {
|
2079
|
-
auto* default_validation_context =
|
2080
|
-
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_default_validation_context(
|
2081
|
-
combined_validation_context);
|
2082
|
-
if (default_validation_context != nullptr) {
|
2083
|
-
grpc_error_handle error = CertificateValidationContextParse(
|
2084
|
-
context, default_validation_context,
|
2085
|
-
&common_tls_context->certificate_validation_context);
|
2086
|
-
if (error != GRPC_ERROR_NONE) errors.push_back(error);
|
2087
|
-
}
|
2088
|
-
// If after parsing default_validation_context,
|
2089
|
-
// common_tls_context->certificate_validation_context.ca_certificate_provider_instance
|
2090
|
-
// is empty, fall back onto
|
2091
|
-
// 'validation_context_certificate_provider_instance' inside
|
2092
|
-
// 'combined_validation_context'. Note that this way of fetching root
|
2093
|
-
// certificates is deprecated and will be removed in the future.
|
2094
|
-
// TODO(yashykt): Remove this once it's no longer needed.
|
2095
|
-
auto* validation_context_certificate_provider_instance =
|
2096
|
-
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_validation_context_certificate_provider_instance(
|
2097
|
-
combined_validation_context);
|
2098
|
-
if (common_tls_context->certificate_validation_context
|
2099
|
-
.ca_certificate_provider_instance.Empty() &&
|
2100
|
-
validation_context_certificate_provider_instance != nullptr) {
|
2101
|
-
grpc_error_handle error = CertificateProviderInstanceParse(
|
2102
|
-
context, validation_context_certificate_provider_instance,
|
2103
|
-
&common_tls_context->certificate_validation_context
|
2104
|
-
.ca_certificate_provider_instance);
|
2105
|
-
if (error != GRPC_ERROR_NONE) errors.push_back(error);
|
2106
|
-
}
|
2107
|
-
} else {
|
2108
|
-
auto* validation_context =
|
2109
|
-
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context(
|
2110
|
-
common_tls_context_proto);
|
2111
|
-
if (validation_context != nullptr) {
|
2112
|
-
grpc_error_handle error = CertificateValidationContextParse(
|
2113
|
-
context, validation_context,
|
2114
|
-
&common_tls_context->certificate_validation_context);
|
2115
|
-
if (error != GRPC_ERROR_NONE) errors.push_back(error);
|
2116
|
-
} else if (
|
2117
|
-
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_validation_context_sds_secret_config(
|
2118
|
-
common_tls_context_proto)) {
|
2119
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2120
|
-
"validation_context_sds_secret_config unsupported"));
|
2121
|
-
}
|
2122
|
-
}
|
2123
|
-
auto* tls_certificate_provider_instance =
|
2124
|
-
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_tls_certificate_provider_instance(
|
2125
|
-
common_tls_context_proto);
|
2126
|
-
if (tls_certificate_provider_instance != nullptr) {
|
2127
|
-
grpc_error_handle error = CertificateProviderPluginInstanceParse(
|
2128
|
-
context, tls_certificate_provider_instance,
|
2129
|
-
&common_tls_context->tls_certificate_provider_instance);
|
2130
|
-
if (error != GRPC_ERROR_NONE) errors.push_back(error);
|
2131
|
-
} else {
|
2132
|
-
// Fall back onto 'tls_certificate_certificate_provider_instance'. Note that
|
2133
|
-
// this way of fetching identity certificates is deprecated and will be
|
2134
|
-
// removed in the future.
|
2135
|
-
// TODO(yashykt): Remove this once it's no longer needed.
|
2136
|
-
auto* tls_certificate_certificate_provider_instance =
|
2137
|
-
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_tls_certificate_certificate_provider_instance(
|
2138
|
-
common_tls_context_proto);
|
2139
|
-
if (tls_certificate_certificate_provider_instance != nullptr) {
|
2140
|
-
grpc_error_handle error = CertificateProviderInstanceParse(
|
2141
|
-
context, tls_certificate_certificate_provider_instance,
|
2142
|
-
&common_tls_context->tls_certificate_provider_instance);
|
2143
|
-
if (error != GRPC_ERROR_NONE) errors.push_back(error);
|
2144
|
-
} else {
|
2145
|
-
if (envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_tls_certificates(
|
2146
|
-
common_tls_context_proto)) {
|
2147
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2148
|
-
"tls_certificates unsupported"));
|
2149
|
-
}
|
2150
|
-
if (envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_tls_certificate_sds_secret_configs(
|
2151
|
-
common_tls_context_proto)) {
|
2152
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2153
|
-
"tls_certificate_sds_secret_configs unsupported"));
|
2154
|
-
}
|
2155
|
-
}
|
2156
|
-
}
|
2157
|
-
if (envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_tls_params(
|
2158
|
-
common_tls_context_proto)) {
|
2159
|
-
errors.push_back(
|
2160
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("tls_params unsupported"));
|
2161
|
-
}
|
2162
|
-
if (envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_custom_handshaker(
|
2163
|
-
common_tls_context_proto)) {
|
2164
|
-
errors.push_back(
|
2165
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("custom_handshaker unsupported"));
|
2166
|
-
}
|
2167
|
-
return GRPC_ERROR_CREATE_FROM_VECTOR("Error parsing CommonTlsContext",
|
2168
|
-
&errors);
|
2169
|
-
}
|
2170
|
-
|
2171
|
-
grpc_error_handle HttpConnectionManagerParse(
|
2172
|
-
bool is_client, const EncodingContext& context,
|
2173
|
-
const envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager*
|
2174
|
-
http_connection_manager_proto,
|
2175
|
-
bool is_v2,
|
2176
|
-
XdsApi::LdsUpdate::HttpConnectionManager* http_connection_manager) {
|
2177
|
-
MaybeLogHttpConnectionManager(context, http_connection_manager_proto);
|
2178
|
-
// Obtain max_stream_duration from Http Protocol Options.
|
2179
|
-
const envoy_config_core_v3_HttpProtocolOptions* options =
|
2180
|
-
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_common_http_protocol_options(
|
2181
|
-
http_connection_manager_proto);
|
2182
|
-
if (options != nullptr) {
|
2183
|
-
const google_protobuf_Duration* duration =
|
2184
|
-
envoy_config_core_v3_HttpProtocolOptions_max_stream_duration(options);
|
2185
|
-
if (duration != nullptr) {
|
2186
|
-
http_connection_manager->http_max_stream_duration =
|
2187
|
-
DurationParse(duration);
|
2188
|
-
}
|
2189
|
-
}
|
2190
|
-
// Parse filters.
|
2191
|
-
if (!is_v2) {
|
2192
|
-
size_t num_filters = 0;
|
2193
|
-
const auto* http_filters =
|
2194
|
-
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_http_filters(
|
2195
|
-
http_connection_manager_proto, &num_filters);
|
2196
|
-
std::set<absl::string_view> names_seen;
|
2197
|
-
for (size_t i = 0; i < num_filters; ++i) {
|
2198
|
-
const auto* http_filter = http_filters[i];
|
2199
|
-
absl::string_view name = UpbStringToAbsl(
|
2200
|
-
envoy_extensions_filters_network_http_connection_manager_v3_HttpFilter_name(
|
2201
|
-
http_filter));
|
2202
|
-
if (name.empty()) {
|
2203
|
-
return GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
2204
|
-
absl::StrCat("empty filter name at index ", i));
|
2205
|
-
}
|
2206
|
-
if (names_seen.find(name) != names_seen.end()) {
|
2207
|
-
return GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
2208
|
-
absl::StrCat("duplicate HTTP filter name: ", name));
|
2209
|
-
}
|
2210
|
-
names_seen.insert(name);
|
2211
|
-
const bool is_optional =
|
2212
|
-
envoy_extensions_filters_network_http_connection_manager_v3_HttpFilter_is_optional(
|
2213
|
-
http_filter);
|
2214
|
-
const google_protobuf_Any* any =
|
2215
|
-
envoy_extensions_filters_network_http_connection_manager_v3_HttpFilter_typed_config(
|
2216
|
-
http_filter);
|
2217
|
-
if (any == nullptr) {
|
2218
|
-
if (is_optional) continue;
|
2219
|
-
return GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
2220
|
-
absl::StrCat("no filter config specified for filter name ", name));
|
2221
|
-
}
|
2222
|
-
absl::string_view filter_type;
|
2223
|
-
grpc_error_handle error =
|
2224
|
-
ExtractHttpFilterTypeName(context, any, &filter_type);
|
2225
|
-
if (error != GRPC_ERROR_NONE) return error;
|
2226
|
-
const XdsHttpFilterImpl* filter_impl =
|
2227
|
-
XdsHttpFilterRegistry::GetFilterForType(filter_type);
|
2228
|
-
if (filter_impl == nullptr) {
|
2229
|
-
if (is_optional) continue;
|
2230
|
-
return GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
2231
|
-
absl::StrCat("no filter registered for config type ", filter_type));
|
2232
|
-
}
|
2233
|
-
if ((is_client && !filter_impl->IsSupportedOnClients()) ||
|
2234
|
-
(!is_client && !filter_impl->IsSupportedOnServers())) {
|
2235
|
-
if (is_optional) continue;
|
2236
|
-
return GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
2237
|
-
absl::StrFormat("Filter %s is not supported on %s", filter_type,
|
2238
|
-
is_client ? "clients" : "servers"));
|
2239
|
-
}
|
2240
|
-
if (i < num_filters - 1) {
|
2241
|
-
// Filters before the last filter must not be terminal.
|
2242
|
-
if (filter_impl->IsTerminalFilter()) {
|
2243
|
-
return GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
2244
|
-
absl::StrCat("terminal filter for config type ", filter_type,
|
2245
|
-
" must be the last filter in the chain"));
|
2246
|
-
}
|
2247
|
-
} else {
|
2248
|
-
// The last filter must be terminal.
|
2249
|
-
if (!filter_impl->IsTerminalFilter()) {
|
2250
|
-
return GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
2251
|
-
absl::StrCat("non-terminal filter for config type ", filter_type,
|
2252
|
-
" is the last filter in the chain"));
|
2253
|
-
}
|
2254
|
-
}
|
2255
|
-
absl::StatusOr<XdsHttpFilterImpl::FilterConfig> filter_config =
|
2256
|
-
filter_impl->GenerateFilterConfig(google_protobuf_Any_value(any),
|
2257
|
-
context.arena);
|
2258
|
-
if (!filter_config.ok()) {
|
2259
|
-
return GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrCat(
|
2260
|
-
"filter config for type ", filter_type,
|
2261
|
-
" failed to parse: ", filter_config.status().ToString()));
|
2262
|
-
}
|
2263
|
-
http_connection_manager->http_filters.emplace_back(
|
2264
|
-
XdsApi::LdsUpdate::HttpConnectionManager::HttpFilter{
|
2265
|
-
std::string(name), std::move(*filter_config)});
|
2266
|
-
}
|
2267
|
-
} else {
|
2268
|
-
// If using a v2 config, we just hard-code a list containing only the
|
2269
|
-
// router filter without actually looking at the config. This ensures
|
2270
|
-
// that the right thing happens in the xds resolver without having
|
2271
|
-
// to expose whether the resource we received was v2 or v3.
|
2272
|
-
http_connection_manager->http_filters.emplace_back(
|
2273
|
-
XdsApi::LdsUpdate::HttpConnectionManager::HttpFilter{
|
2274
|
-
"router", {kXdsHttpRouterFilterConfigName, Json()}});
|
2275
|
-
}
|
2276
|
-
if (is_client) {
|
2277
|
-
// Found inlined route_config. Parse it to find the cluster_name.
|
2278
|
-
if (envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_has_route_config(
|
2279
|
-
http_connection_manager_proto)) {
|
2280
|
-
const envoy_config_route_v3_RouteConfiguration* route_config =
|
2281
|
-
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_route_config(
|
2282
|
-
http_connection_manager_proto);
|
2283
|
-
XdsApi::RdsUpdate rds_update;
|
2284
|
-
grpc_error_handle error =
|
2285
|
-
RouteConfigParse(context, route_config, is_v2, &rds_update);
|
2286
|
-
if (error != GRPC_ERROR_NONE) return error;
|
2287
|
-
http_connection_manager->rds_update = std::move(rds_update);
|
2288
|
-
return GRPC_ERROR_NONE;
|
2289
|
-
}
|
2290
|
-
// Validate that RDS must be used to get the route_config dynamically.
|
2291
|
-
const envoy_extensions_filters_network_http_connection_manager_v3_Rds* rds =
|
2292
|
-
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_rds(
|
2293
|
-
http_connection_manager_proto);
|
2294
|
-
if (rds == nullptr) {
|
2295
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2296
|
-
"HttpConnectionManager neither has inlined route_config nor RDS.");
|
2297
|
-
}
|
2298
|
-
// Check that the ConfigSource specifies ADS.
|
2299
|
-
const envoy_config_core_v3_ConfigSource* config_source =
|
2300
|
-
envoy_extensions_filters_network_http_connection_manager_v3_Rds_config_source(
|
2301
|
-
rds);
|
2302
|
-
if (config_source == nullptr) {
|
2303
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2304
|
-
"HttpConnectionManager missing config_source for RDS.");
|
2305
|
-
}
|
2306
|
-
if (!envoy_config_core_v3_ConfigSource_has_ads(config_source)) {
|
2307
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2308
|
-
"HttpConnectionManager ConfigSource for RDS does not specify ADS.");
|
2309
|
-
}
|
2310
|
-
// Get the route_config_name.
|
2311
|
-
http_connection_manager->route_config_name = UpbStringToStdString(
|
2312
|
-
envoy_extensions_filters_network_http_connection_manager_v3_Rds_route_config_name(
|
2313
|
-
rds));
|
2314
|
-
}
|
2315
|
-
return GRPC_ERROR_NONE;
|
2316
|
-
}
|
2317
|
-
|
2318
|
-
grpc_error_handle LdsResourceParseClient(
|
2319
|
-
const EncodingContext& context,
|
2320
|
-
const envoy_config_listener_v3_ApiListener* api_listener, bool is_v2,
|
2321
|
-
XdsApi::LdsUpdate* lds_update) {
|
2322
|
-
lds_update->type = XdsApi::LdsUpdate::ListenerType::kHttpApiListener;
|
2323
|
-
const upb_strview encoded_api_listener = google_protobuf_Any_value(
|
2324
|
-
envoy_config_listener_v3_ApiListener_api_listener(api_listener));
|
2325
|
-
const auto* http_connection_manager =
|
2326
|
-
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_parse(
|
2327
|
-
encoded_api_listener.data, encoded_api_listener.size, context.arena);
|
2328
|
-
if (http_connection_manager == nullptr) {
|
2329
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2330
|
-
"Could not parse HttpConnectionManager config from ApiListener");
|
2331
|
-
}
|
2332
|
-
return HttpConnectionManagerParse(true /* is_client */, context,
|
2333
|
-
http_connection_manager, is_v2,
|
2334
|
-
&lds_update->http_connection_manager);
|
2335
|
-
}
|
2336
|
-
|
2337
|
-
grpc_error_handle DownstreamTlsContextParse(
|
2338
|
-
const EncodingContext& context,
|
2339
|
-
const envoy_config_core_v3_TransportSocket* transport_socket,
|
2340
|
-
XdsApi::DownstreamTlsContext* downstream_tls_context) {
|
2341
|
-
absl::string_view name = UpbStringToAbsl(
|
2342
|
-
envoy_config_core_v3_TransportSocket_name(transport_socket));
|
2343
|
-
if (name != "envoy.transport_sockets.tls") {
|
2344
|
-
return GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
2345
|
-
absl::StrCat("Unrecognized transport socket: ", name));
|
2346
|
-
}
|
2347
|
-
auto* typed_config =
|
2348
|
-
envoy_config_core_v3_TransportSocket_typed_config(transport_socket);
|
2349
|
-
std::vector<grpc_error_handle> errors;
|
2350
|
-
if (typed_config != nullptr) {
|
2351
|
-
const upb_strview encoded_downstream_tls_context =
|
2352
|
-
google_protobuf_Any_value(typed_config);
|
2353
|
-
auto* downstream_tls_context_proto =
|
2354
|
-
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_parse(
|
2355
|
-
encoded_downstream_tls_context.data,
|
2356
|
-
encoded_downstream_tls_context.size, context.arena);
|
2357
|
-
if (downstream_tls_context_proto == nullptr) {
|
2358
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2359
|
-
"Can't decode downstream tls context.");
|
2360
|
-
}
|
2361
|
-
auto* common_tls_context =
|
2362
|
-
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_common_tls_context(
|
2363
|
-
downstream_tls_context_proto);
|
2364
|
-
if (common_tls_context != nullptr) {
|
2365
|
-
grpc_error_handle error =
|
2366
|
-
CommonTlsContextParse(context, common_tls_context,
|
2367
|
-
&downstream_tls_context->common_tls_context);
|
2368
|
-
if (error != GRPC_ERROR_NONE) errors.push_back(error);
|
2369
|
-
}
|
2370
|
-
auto* require_client_certificate =
|
2371
|
-
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_require_client_certificate(
|
2372
|
-
downstream_tls_context_proto);
|
2373
|
-
if (require_client_certificate != nullptr) {
|
2374
|
-
downstream_tls_context->require_client_certificate =
|
2375
|
-
google_protobuf_BoolValue_value(require_client_certificate);
|
2376
|
-
}
|
2377
|
-
auto* require_sni =
|
2378
|
-
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_require_sni(
|
2379
|
-
downstream_tls_context_proto);
|
2380
|
-
if (require_sni != nullptr &&
|
2381
|
-
google_protobuf_BoolValue_value(require_sni)) {
|
2382
|
-
errors.push_back(
|
2383
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("require_sni: unsupported"));
|
2384
|
-
}
|
2385
|
-
if (envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_ocsp_staple_policy(
|
2386
|
-
downstream_tls_context_proto) !=
|
2387
|
-
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_LENIENT_STAPLING) {
|
2388
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2389
|
-
"ocsp_staple_policy: Only LENIENT_STAPLING supported"));
|
2390
|
-
}
|
2391
|
-
}
|
2392
|
-
if (downstream_tls_context->common_tls_context
|
2393
|
-
.tls_certificate_provider_instance.instance_name.empty()) {
|
2394
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2395
|
-
"TLS configuration provided but no "
|
2396
|
-
"tls_certificate_provider_instance found."));
|
2397
|
-
}
|
2398
|
-
if (downstream_tls_context->require_client_certificate &&
|
2399
|
-
downstream_tls_context->common_tls_context.certificate_validation_context
|
2400
|
-
.ca_certificate_provider_instance.instance_name.empty()) {
|
2401
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2402
|
-
"TLS configuration requires client certificates but no certificate "
|
2403
|
-
"provider instance specified for validation."));
|
2404
|
-
}
|
2405
|
-
if (!downstream_tls_context->common_tls_context.certificate_validation_context
|
2406
|
-
.match_subject_alt_names.empty()) {
|
2407
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2408
|
-
"match_subject_alt_names not supported on servers"));
|
2409
|
-
}
|
2410
|
-
return GRPC_ERROR_CREATE_FROM_VECTOR("Error parsing DownstreamTlsContext",
|
2411
|
-
&errors);
|
2412
|
-
}
|
2413
|
-
|
2414
|
-
grpc_error_handle CidrRangeParse(
|
2415
|
-
const envoy_config_core_v3_CidrRange* cidr_range_proto,
|
2416
|
-
XdsApi::LdsUpdate::FilterChainMap::CidrRange* cidr_range) {
|
2417
|
-
std::string address_prefix = UpbStringToStdString(
|
2418
|
-
envoy_config_core_v3_CidrRange_address_prefix(cidr_range_proto));
|
2419
|
-
grpc_error_handle error =
|
2420
|
-
grpc_string_to_sockaddr(&cidr_range->address, address_prefix.c_str(), 0);
|
2421
|
-
if (error != GRPC_ERROR_NONE) return error;
|
2422
|
-
cidr_range->prefix_len = 0;
|
2423
|
-
auto* prefix_len_proto =
|
2424
|
-
envoy_config_core_v3_CidrRange_prefix_len(cidr_range_proto);
|
2425
|
-
if (prefix_len_proto != nullptr) {
|
2426
|
-
cidr_range->prefix_len = std::min(
|
2427
|
-
google_protobuf_UInt32Value_value(prefix_len_proto),
|
2428
|
-
(reinterpret_cast<const grpc_sockaddr*>(cidr_range->address.addr))
|
2429
|
-
->sa_family == GRPC_AF_INET
|
2430
|
-
? uint32_t(32)
|
2431
|
-
: uint32_t(128));
|
2432
|
-
}
|
2433
|
-
// Normalize the network address by masking it with prefix_len
|
2434
|
-
grpc_sockaddr_mask_bits(&cidr_range->address, cidr_range->prefix_len);
|
2435
|
-
return GRPC_ERROR_NONE;
|
2436
|
-
}
|
2437
|
-
|
2438
|
-
grpc_error_handle FilterChainMatchParse(
|
2439
|
-
const envoy_config_listener_v3_FilterChainMatch* filter_chain_match_proto,
|
2440
|
-
FilterChain::FilterChainMatch* filter_chain_match) {
|
2441
|
-
auto* destination_port =
|
2442
|
-
envoy_config_listener_v3_FilterChainMatch_destination_port(
|
2443
|
-
filter_chain_match_proto);
|
2444
|
-
if (destination_port != nullptr) {
|
2445
|
-
filter_chain_match->destination_port =
|
2446
|
-
google_protobuf_UInt32Value_value(destination_port);
|
2447
|
-
}
|
2448
|
-
size_t size = 0;
|
2449
|
-
auto* prefix_ranges = envoy_config_listener_v3_FilterChainMatch_prefix_ranges(
|
2450
|
-
filter_chain_match_proto, &size);
|
2451
|
-
filter_chain_match->prefix_ranges.reserve(size);
|
2452
|
-
for (size_t i = 0; i < size; i++) {
|
2453
|
-
XdsApi::LdsUpdate::FilterChainMap::CidrRange cidr_range;
|
2454
|
-
grpc_error_handle error = CidrRangeParse(prefix_ranges[i], &cidr_range);
|
2455
|
-
if (error != GRPC_ERROR_NONE) return error;
|
2456
|
-
filter_chain_match->prefix_ranges.push_back(cidr_range);
|
2457
|
-
}
|
2458
|
-
filter_chain_match->source_type =
|
2459
|
-
static_cast<XdsApi::LdsUpdate::FilterChainMap::ConnectionSourceType>(
|
2460
|
-
envoy_config_listener_v3_FilterChainMatch_source_type(
|
2461
|
-
filter_chain_match_proto));
|
2462
|
-
auto* source_prefix_ranges =
|
2463
|
-
envoy_config_listener_v3_FilterChainMatch_source_prefix_ranges(
|
2464
|
-
filter_chain_match_proto, &size);
|
2465
|
-
filter_chain_match->source_prefix_ranges.reserve(size);
|
2466
|
-
for (size_t i = 0; i < size; i++) {
|
2467
|
-
XdsApi::LdsUpdate::FilterChainMap::CidrRange cidr_range;
|
2468
|
-
grpc_error_handle error =
|
2469
|
-
CidrRangeParse(source_prefix_ranges[i], &cidr_range);
|
2470
|
-
if (error != GRPC_ERROR_NONE) return error;
|
2471
|
-
filter_chain_match->source_prefix_ranges.push_back(cidr_range);
|
2472
|
-
}
|
2473
|
-
auto* source_ports = envoy_config_listener_v3_FilterChainMatch_source_ports(
|
2474
|
-
filter_chain_match_proto, &size);
|
2475
|
-
filter_chain_match->source_ports.reserve(size);
|
2476
|
-
for (size_t i = 0; i < size; i++) {
|
2477
|
-
filter_chain_match->source_ports.push_back(source_ports[i]);
|
2478
|
-
}
|
2479
|
-
auto* server_names = envoy_config_listener_v3_FilterChainMatch_server_names(
|
2480
|
-
filter_chain_match_proto, &size);
|
2481
|
-
for (size_t i = 0; i < size; i++) {
|
2482
|
-
filter_chain_match->server_names.push_back(
|
2483
|
-
UpbStringToStdString(server_names[i]));
|
2484
|
-
}
|
2485
|
-
filter_chain_match->transport_protocol = UpbStringToStdString(
|
2486
|
-
envoy_config_listener_v3_FilterChainMatch_transport_protocol(
|
2487
|
-
filter_chain_match_proto));
|
2488
|
-
auto* application_protocols =
|
2489
|
-
envoy_config_listener_v3_FilterChainMatch_application_protocols(
|
2490
|
-
filter_chain_match_proto, &size);
|
2491
|
-
for (size_t i = 0; i < size; i++) {
|
2492
|
-
filter_chain_match->application_protocols.push_back(
|
2493
|
-
UpbStringToStdString(application_protocols[i]));
|
2494
|
-
}
|
2495
|
-
return GRPC_ERROR_NONE;
|
2496
|
-
}
|
2497
|
-
|
2498
|
-
grpc_error_handle FilterChainParse(
|
2499
|
-
const EncodingContext& context,
|
2500
|
-
const envoy_config_listener_v3_FilterChain* filter_chain_proto, bool is_v2,
|
2501
|
-
FilterChain* filter_chain) {
|
2502
|
-
std::vector<grpc_error_handle> errors;
|
2503
|
-
auto* filter_chain_match =
|
2504
|
-
envoy_config_listener_v3_FilterChain_filter_chain_match(
|
2505
|
-
filter_chain_proto);
|
2506
|
-
if (filter_chain_match != nullptr) {
|
2507
|
-
grpc_error_handle error = FilterChainMatchParse(
|
2508
|
-
filter_chain_match, &filter_chain->filter_chain_match);
|
2509
|
-
if (error != GRPC_ERROR_NONE) errors.push_back(error);
|
2510
|
-
}
|
2511
|
-
// Parse the filters list. Currently we only support HttpConnectionManager.
|
2512
|
-
size_t size = 0;
|
2513
|
-
auto* filters =
|
2514
|
-
envoy_config_listener_v3_FilterChain_filters(filter_chain_proto, &size);
|
2515
|
-
if (size != 1) {
|
2516
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2517
|
-
"FilterChain should have exactly one filter: HttpConnectionManager; no "
|
2518
|
-
"other filter is supported at the moment"));
|
2519
|
-
} else {
|
2520
|
-
auto* typed_config =
|
2521
|
-
envoy_config_listener_v3_Filter_typed_config(filters[0]);
|
2522
|
-
if (typed_config == nullptr) {
|
2523
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2524
|
-
"No typed_config found in filter."));
|
2525
|
-
} else {
|
2526
|
-
absl::string_view type_url =
|
2527
|
-
UpbStringToAbsl(google_protobuf_Any_type_url(typed_config));
|
2528
|
-
if (type_url !=
|
2529
|
-
"type.googleapis.com/"
|
2530
|
-
"envoy.extensions.filters.network.http_connection_manager.v3."
|
2531
|
-
"HttpConnectionManager") {
|
2532
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
2533
|
-
absl::StrCat("Unsupported filter type ", type_url)));
|
2534
|
-
} else {
|
2535
|
-
const upb_strview encoded_http_connection_manager =
|
2536
|
-
google_protobuf_Any_value(typed_config);
|
2537
|
-
const auto* http_connection_manager =
|
2538
|
-
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_parse(
|
2539
|
-
encoded_http_connection_manager.data,
|
2540
|
-
encoded_http_connection_manager.size, context.arena);
|
2541
|
-
if (http_connection_manager == nullptr) {
|
2542
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2543
|
-
"Could not parse HttpConnectionManager config from filter "
|
2544
|
-
"typed_config"));
|
2545
|
-
} else {
|
2546
|
-
filter_chain->filter_chain_data =
|
2547
|
-
std::make_shared<XdsApi::LdsUpdate::FilterChainData>();
|
2548
|
-
grpc_error_handle error = HttpConnectionManagerParse(
|
2549
|
-
false /* is_client */, context, http_connection_manager, is_v2,
|
2550
|
-
&filter_chain->filter_chain_data->http_connection_manager);
|
2551
|
-
if (error != GRPC_ERROR_NONE) errors.push_back(error);
|
2552
|
-
}
|
2553
|
-
}
|
2554
|
-
}
|
2555
|
-
}
|
2556
|
-
auto* transport_socket =
|
2557
|
-
envoy_config_listener_v3_FilterChain_transport_socket(filter_chain_proto);
|
2558
|
-
if (transport_socket != nullptr) {
|
2559
|
-
grpc_error_handle error = DownstreamTlsContextParse(
|
2560
|
-
context, transport_socket,
|
2561
|
-
&filter_chain->filter_chain_data->downstream_tls_context);
|
2562
|
-
if (error != GRPC_ERROR_NONE) errors.push_back(error);
|
2563
|
-
}
|
2564
|
-
return GRPC_ERROR_CREATE_FROM_VECTOR("Error parsing FilterChain", &errors);
|
2565
|
-
}
|
2566
|
-
|
2567
|
-
grpc_error_handle AddressParse(
|
2568
|
-
const envoy_config_core_v3_Address* address_proto, std::string* address) {
|
2569
|
-
const auto* socket_address =
|
2570
|
-
envoy_config_core_v3_Address_socket_address(address_proto);
|
2571
|
-
if (socket_address == nullptr) {
|
2572
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2573
|
-
"Address does not have socket_address");
|
2574
|
-
}
|
2575
|
-
if (envoy_config_core_v3_SocketAddress_protocol(socket_address) !=
|
2576
|
-
envoy_config_core_v3_SocketAddress_TCP) {
|
2577
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2578
|
-
"SocketAddress protocol is not TCP");
|
2579
|
-
}
|
2580
|
-
uint32_t port = envoy_config_core_v3_SocketAddress_port_value(socket_address);
|
2581
|
-
if (port > 65535) {
|
2582
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Invalid port");
|
2583
|
-
}
|
2584
|
-
*address = JoinHostPort(
|
2585
|
-
UpbStringToAbsl(
|
2586
|
-
envoy_config_core_v3_SocketAddress_address(socket_address)),
|
2587
|
-
port);
|
2588
|
-
return GRPC_ERROR_NONE;
|
2589
|
-
}
|
2590
|
-
|
2591
|
-
// An intermediate map for filter chains that we create to validate the list of
|
2592
|
-
// filter chains received from the control plane and to finally create
|
2593
|
-
// XdsApi::LdsUpdate::FilterChainMap
|
2594
|
-
struct InternalFilterChainMap {
|
2595
|
-
using SourceIpMap =
|
2596
|
-
std::map<std::string, XdsApi::LdsUpdate::FilterChainMap::SourceIp>;
|
2597
|
-
using ConnectionSourceTypesArray = std::array<SourceIpMap, 3>;
|
2598
|
-
struct DestinationIp {
|
2599
|
-
absl::optional<XdsApi::LdsUpdate::FilterChainMap::CidrRange> prefix_range;
|
2600
|
-
bool transport_protocol_raw_buffer_provided = false;
|
2601
|
-
ConnectionSourceTypesArray source_types_array;
|
2602
|
-
};
|
2603
|
-
using DestinationIpMap = std::map<std::string, DestinationIp>;
|
2604
|
-
DestinationIpMap destination_ip_map;
|
2605
|
-
};
|
2606
|
-
|
2607
|
-
grpc_error_handle AddFilterChainDataForSourcePort(
|
2608
|
-
const FilterChain& filter_chain,
|
2609
|
-
XdsApi::LdsUpdate::FilterChainMap::SourcePortsMap* ports_map,
|
2610
|
-
uint32_t port) {
|
2611
|
-
auto insert_result = ports_map->emplace(
|
2612
|
-
port, XdsApi::LdsUpdate::FilterChainMap::FilterChainDataSharedPtr{
|
2613
|
-
filter_chain.filter_chain_data});
|
2614
|
-
if (!insert_result.second) {
|
2615
|
-
return GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrCat(
|
2616
|
-
"Duplicate matching rules detected when adding filter chain: ",
|
2617
|
-
filter_chain.filter_chain_match.ToString()));
|
2618
|
-
}
|
2619
|
-
return GRPC_ERROR_NONE;
|
2620
|
-
}
|
2621
|
-
|
2622
|
-
grpc_error_handle AddFilterChainDataForSourcePorts(
|
2623
|
-
const FilterChain& filter_chain,
|
2624
|
-
XdsApi::LdsUpdate::FilterChainMap::SourcePortsMap* ports_map) {
|
2625
|
-
if (filter_chain.filter_chain_match.source_ports.empty()) {
|
2626
|
-
return AddFilterChainDataForSourcePort(filter_chain, ports_map, 0);
|
2627
|
-
} else {
|
2628
|
-
for (uint32_t port : filter_chain.filter_chain_match.source_ports) {
|
2629
|
-
grpc_error_handle error =
|
2630
|
-
AddFilterChainDataForSourcePort(filter_chain, ports_map, port);
|
2631
|
-
if (error != GRPC_ERROR_NONE) return error;
|
2632
|
-
}
|
2633
|
-
}
|
2634
|
-
return GRPC_ERROR_NONE;
|
2635
|
-
}
|
2636
|
-
|
2637
|
-
grpc_error_handle AddFilterChainDataForSourceIpRange(
|
2638
|
-
const FilterChain& filter_chain,
|
2639
|
-
InternalFilterChainMap::SourceIpMap* source_ip_map) {
|
2640
|
-
if (filter_chain.filter_chain_match.source_prefix_ranges.empty()) {
|
2641
|
-
auto insert_result = source_ip_map->emplace(
|
2642
|
-
"", XdsApi::LdsUpdate::FilterChainMap::SourceIp());
|
2643
|
-
return AddFilterChainDataForSourcePorts(
|
2644
|
-
filter_chain, &insert_result.first->second.ports_map);
|
2645
|
-
} else {
|
2646
|
-
for (const auto& prefix_range :
|
2647
|
-
filter_chain.filter_chain_match.source_prefix_ranges) {
|
2648
|
-
auto insert_result = source_ip_map->emplace(
|
2649
|
-
absl::StrCat(grpc_sockaddr_to_string(&prefix_range.address, false),
|
2650
|
-
"/", prefix_range.prefix_len),
|
2651
|
-
XdsApi::LdsUpdate::FilterChainMap::SourceIp());
|
2652
|
-
if (insert_result.second) {
|
2653
|
-
insert_result.first->second.prefix_range.emplace(prefix_range);
|
2654
|
-
}
|
2655
|
-
grpc_error_handle error = AddFilterChainDataForSourcePorts(
|
2656
|
-
filter_chain, &insert_result.first->second.ports_map);
|
2657
|
-
if (error != GRPC_ERROR_NONE) return error;
|
2658
|
-
}
|
2659
|
-
}
|
2660
|
-
return GRPC_ERROR_NONE;
|
2661
|
-
}
|
2662
|
-
|
2663
|
-
grpc_error_handle AddFilterChainDataForSourceType(
|
2664
|
-
const FilterChain& filter_chain,
|
2665
|
-
InternalFilterChainMap::DestinationIp* destination_ip) {
|
2666
|
-
GPR_ASSERT(static_cast<unsigned int>(
|
2667
|
-
filter_chain.filter_chain_match.source_type) < 3);
|
2668
|
-
return AddFilterChainDataForSourceIpRange(
|
2669
|
-
filter_chain, &destination_ip->source_types_array[static_cast<int>(
|
2670
|
-
filter_chain.filter_chain_match.source_type)]);
|
2671
|
-
}
|
2672
|
-
|
2673
|
-
grpc_error_handle AddFilterChainDataForApplicationProtocols(
|
2674
|
-
const FilterChain& filter_chain,
|
2675
|
-
InternalFilterChainMap::DestinationIp* destination_ip) {
|
2676
|
-
// Only allow filter chains that do not mention application protocols
|
2677
|
-
if (!filter_chain.filter_chain_match.application_protocols.empty()) {
|
2678
|
-
return GRPC_ERROR_NONE;
|
2679
|
-
}
|
2680
|
-
return AddFilterChainDataForSourceType(filter_chain, destination_ip);
|
2681
|
-
}
|
2682
|
-
|
2683
|
-
grpc_error_handle AddFilterChainDataForTransportProtocol(
|
2684
|
-
const FilterChain& filter_chain,
|
2685
|
-
InternalFilterChainMap::DestinationIp* destination_ip) {
|
2686
|
-
const std::string& transport_protocol =
|
2687
|
-
filter_chain.filter_chain_match.transport_protocol;
|
2688
|
-
// Only allow filter chains with no transport protocol or "raw_buffer"
|
2689
|
-
if (!transport_protocol.empty() && transport_protocol != "raw_buffer") {
|
2690
|
-
return GRPC_ERROR_NONE;
|
2691
|
-
}
|
2692
|
-
// If for this configuration, we've already seen filter chains that mention
|
2693
|
-
// the transport protocol as "raw_buffer", we will never match filter chains
|
2694
|
-
// that do not mention it.
|
2695
|
-
if (destination_ip->transport_protocol_raw_buffer_provided &&
|
2696
|
-
transport_protocol.empty()) {
|
2697
|
-
return GRPC_ERROR_NONE;
|
2698
|
-
}
|
2699
|
-
if (!transport_protocol.empty() &&
|
2700
|
-
!destination_ip->transport_protocol_raw_buffer_provided) {
|
2701
|
-
destination_ip->transport_protocol_raw_buffer_provided = true;
|
2702
|
-
// Clear out the previous entries if any since those entries did not mention
|
2703
|
-
// "raw_buffer"
|
2704
|
-
destination_ip->source_types_array =
|
2705
|
-
InternalFilterChainMap::ConnectionSourceTypesArray();
|
2706
|
-
}
|
2707
|
-
return AddFilterChainDataForApplicationProtocols(filter_chain,
|
2708
|
-
destination_ip);
|
2709
|
-
}
|
2710
|
-
|
2711
|
-
grpc_error_handle AddFilterChainDataForServerNames(
|
2712
|
-
const FilterChain& filter_chain,
|
2713
|
-
InternalFilterChainMap::DestinationIp* destination_ip) {
|
2714
|
-
// Don't continue adding filter chains with server names mentioned
|
2715
|
-
if (!filter_chain.filter_chain_match.server_names.empty()) {
|
2716
|
-
return GRPC_ERROR_NONE;
|
2717
|
-
}
|
2718
|
-
return AddFilterChainDataForTransportProtocol(filter_chain, destination_ip);
|
2719
|
-
}
|
2720
|
-
|
2721
|
-
grpc_error_handle AddFilterChainDataForDestinationIpRange(
|
2722
|
-
const FilterChain& filter_chain,
|
2723
|
-
InternalFilterChainMap::DestinationIpMap* destination_ip_map) {
|
2724
|
-
if (filter_chain.filter_chain_match.prefix_ranges.empty()) {
|
2725
|
-
auto insert_result = destination_ip_map->emplace(
|
2726
|
-
"", InternalFilterChainMap::DestinationIp());
|
2727
|
-
return AddFilterChainDataForServerNames(filter_chain,
|
2728
|
-
&insert_result.first->second);
|
2729
|
-
} else {
|
2730
|
-
for (const auto& prefix_range :
|
2731
|
-
filter_chain.filter_chain_match.prefix_ranges) {
|
2732
|
-
auto insert_result = destination_ip_map->emplace(
|
2733
|
-
absl::StrCat(grpc_sockaddr_to_string(&prefix_range.address, false),
|
2734
|
-
"/", prefix_range.prefix_len),
|
2735
|
-
InternalFilterChainMap::DestinationIp());
|
2736
|
-
if (insert_result.second) {
|
2737
|
-
insert_result.first->second.prefix_range.emplace(prefix_range);
|
2738
|
-
}
|
2739
|
-
grpc_error_handle error = AddFilterChainDataForServerNames(
|
2740
|
-
filter_chain, &insert_result.first->second);
|
2741
|
-
if (error != GRPC_ERROR_NONE) return error;
|
2742
|
-
}
|
2743
|
-
}
|
2744
|
-
return GRPC_ERROR_NONE;
|
2745
|
-
}
|
2746
|
-
|
2747
|
-
XdsApi::LdsUpdate::FilterChainMap BuildFromInternalFilterChainMap(
|
2748
|
-
InternalFilterChainMap* internal_filter_chain_map) {
|
2749
|
-
XdsApi::LdsUpdate::FilterChainMap filter_chain_map;
|
2750
|
-
for (auto& destination_ip_pair :
|
2751
|
-
internal_filter_chain_map->destination_ip_map) {
|
2752
|
-
XdsApi::LdsUpdate::FilterChainMap::DestinationIp destination_ip;
|
2753
|
-
destination_ip.prefix_range = destination_ip_pair.second.prefix_range;
|
2754
|
-
for (int i = 0; i < 3; i++) {
|
2755
|
-
auto& source_ip_map = destination_ip_pair.second.source_types_array[i];
|
2756
|
-
for (auto& source_ip_pair : source_ip_map) {
|
2757
|
-
destination_ip.source_types_array[i].push_back(
|
2758
|
-
std::move(source_ip_pair.second));
|
2759
|
-
}
|
2760
|
-
}
|
2761
|
-
filter_chain_map.destination_ip_vector.push_back(std::move(destination_ip));
|
2762
|
-
}
|
2763
|
-
return filter_chain_map;
|
2764
|
-
}
|
2765
|
-
|
2766
|
-
grpc_error_handle BuildFilterChainMap(
|
2767
|
-
const std::vector<FilterChain>& filter_chains,
|
2768
|
-
XdsApi::LdsUpdate::FilterChainMap* filter_chain_map) {
|
2769
|
-
InternalFilterChainMap internal_filter_chain_map;
|
2770
|
-
for (const auto& filter_chain : filter_chains) {
|
2771
|
-
// Discard filter chain entries that specify destination port
|
2772
|
-
if (filter_chain.filter_chain_match.destination_port != 0) continue;
|
2773
|
-
grpc_error_handle error = AddFilterChainDataForDestinationIpRange(
|
2774
|
-
filter_chain, &internal_filter_chain_map.destination_ip_map);
|
2775
|
-
if (error != GRPC_ERROR_NONE) return error;
|
2776
|
-
}
|
2777
|
-
*filter_chain_map =
|
2778
|
-
BuildFromInternalFilterChainMap(&internal_filter_chain_map);
|
2779
|
-
return GRPC_ERROR_NONE;
|
2780
|
-
}
|
2781
|
-
|
2782
|
-
grpc_error_handle LdsResourceParseServer(
|
2783
|
-
const EncodingContext& context,
|
2784
|
-
const envoy_config_listener_v3_Listener* listener, bool is_v2,
|
2785
|
-
XdsApi::LdsUpdate* lds_update) {
|
2786
|
-
lds_update->type = XdsApi::LdsUpdate::ListenerType::kTcpListener;
|
2787
|
-
grpc_error_handle error =
|
2788
|
-
AddressParse(envoy_config_listener_v3_Listener_address(listener),
|
2789
|
-
&lds_update->address);
|
2790
|
-
if (error != GRPC_ERROR_NONE) return error;
|
2791
|
-
const auto* use_original_dst =
|
2792
|
-
envoy_config_listener_v3_Listener_use_original_dst(listener);
|
2793
|
-
if (use_original_dst != nullptr) {
|
2794
|
-
if (google_protobuf_BoolValue_value(use_original_dst)) {
|
2795
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2796
|
-
"Field \'use_original_dst\' is not supported.");
|
2797
|
-
}
|
2798
|
-
}
|
2799
|
-
size_t size = 0;
|
2800
|
-
auto* filter_chains =
|
2801
|
-
envoy_config_listener_v3_Listener_filter_chains(listener, &size);
|
2802
|
-
std::vector<FilterChain> parsed_filter_chains;
|
2803
|
-
parsed_filter_chains.reserve(size);
|
2804
|
-
for (size_t i = 0; i < size; i++) {
|
2805
|
-
FilterChain filter_chain;
|
2806
|
-
error = FilterChainParse(context, filter_chains[i], is_v2, &filter_chain);
|
2807
|
-
if (error != GRPC_ERROR_NONE) return error;
|
2808
|
-
parsed_filter_chains.push_back(std::move(filter_chain));
|
2809
|
-
}
|
2810
|
-
error =
|
2811
|
-
BuildFilterChainMap(parsed_filter_chains, &lds_update->filter_chain_map);
|
2812
|
-
if (error != GRPC_ERROR_NONE) return error;
|
2813
|
-
auto* default_filter_chain =
|
2814
|
-
envoy_config_listener_v3_Listener_default_filter_chain(listener);
|
2815
|
-
if (default_filter_chain != nullptr) {
|
2816
|
-
FilterChain filter_chain;
|
2817
|
-
error =
|
2818
|
-
FilterChainParse(context, default_filter_chain, is_v2, &filter_chain);
|
2819
|
-
if (error != GRPC_ERROR_NONE) return error;
|
2820
|
-
if (filter_chain.filter_chain_data != nullptr) {
|
2821
|
-
lds_update->default_filter_chain =
|
2822
|
-
std::move(*filter_chain.filter_chain_data);
|
2823
|
-
}
|
2824
|
-
}
|
2825
|
-
if (size == 0 && default_filter_chain == nullptr) {
|
2826
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("No filter chain provided.");
|
2827
|
-
}
|
2828
|
-
return GRPC_ERROR_NONE;
|
2829
|
-
}
|
2830
|
-
|
2831
|
-
grpc_error_handle LdsResourceParse(
|
2832
|
-
const EncodingContext& context,
|
2833
|
-
const envoy_config_listener_v3_Listener* listener, bool is_v2,
|
2834
|
-
XdsApi::LdsUpdate* lds_update) {
|
2835
|
-
// Check whether it's a client or server listener.
|
2836
|
-
const envoy_config_listener_v3_ApiListener* api_listener =
|
2837
|
-
envoy_config_listener_v3_Listener_api_listener(listener);
|
2838
|
-
const envoy_config_core_v3_Address* address =
|
2839
|
-
envoy_config_listener_v3_Listener_address(listener);
|
2840
|
-
if (api_listener != nullptr && address != nullptr) {
|
2841
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2842
|
-
"Listener has both address and ApiListener");
|
2843
|
-
}
|
2844
|
-
if (api_listener == nullptr && address == nullptr) {
|
2845
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2846
|
-
"Listener has neither address nor ApiListener");
|
2847
|
-
}
|
2848
|
-
// Validate Listener fields.
|
2849
|
-
grpc_error_handle error = GRPC_ERROR_NONE;
|
2850
|
-
if (api_listener != nullptr) {
|
2851
|
-
error = LdsResourceParseClient(context, api_listener, is_v2, lds_update);
|
2852
|
-
} else {
|
2853
|
-
error = LdsResourceParseServer(context, listener, is_v2, lds_update);
|
2854
|
-
}
|
2855
|
-
return error;
|
2856
|
-
}
|
2857
|
-
|
2858
|
-
grpc_error_handle UpstreamTlsContextParse(
|
2859
|
-
const EncodingContext& context,
|
2860
|
-
const envoy_config_core_v3_TransportSocket* transport_socket,
|
2861
|
-
XdsApi::CommonTlsContext* common_tls_context) {
|
2862
|
-
// Record Upstream tls context
|
2863
|
-
absl::string_view name = UpbStringToAbsl(
|
2864
|
-
envoy_config_core_v3_TransportSocket_name(transport_socket));
|
2865
|
-
if (name != "envoy.transport_sockets.tls") {
|
2866
|
-
return GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
2867
|
-
absl::StrCat("Unrecognized transport socket: ", name));
|
2868
|
-
}
|
2869
|
-
auto* typed_config =
|
2870
|
-
envoy_config_core_v3_TransportSocket_typed_config(transport_socket);
|
2871
|
-
if (typed_config != nullptr) {
|
2872
|
-
const upb_strview encoded_upstream_tls_context =
|
2873
|
-
google_protobuf_Any_value(typed_config);
|
2874
|
-
auto* upstream_tls_context =
|
2875
|
-
envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_parse(
|
2876
|
-
encoded_upstream_tls_context.data,
|
2877
|
-
encoded_upstream_tls_context.size, context.arena);
|
2878
|
-
if (upstream_tls_context == nullptr) {
|
2879
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2880
|
-
"Can't decode upstream tls context.");
|
2881
|
-
}
|
2882
|
-
auto* common_tls_context_proto =
|
2883
|
-
envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_common_tls_context(
|
2884
|
-
upstream_tls_context);
|
2885
|
-
if (common_tls_context_proto != nullptr) {
|
2886
|
-
grpc_error_handle error = CommonTlsContextParse(
|
2887
|
-
context, common_tls_context_proto, common_tls_context);
|
2888
|
-
if (error != GRPC_ERROR_NONE) {
|
2889
|
-
return grpc_error_add_child(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2890
|
-
"Error parsing UpstreamTlsContext"),
|
2891
|
-
error);
|
2892
|
-
}
|
2893
|
-
}
|
2894
|
-
}
|
2895
|
-
if (common_tls_context->certificate_validation_context
|
2896
|
-
.ca_certificate_provider_instance.instance_name.empty()) {
|
2897
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2898
|
-
"UpstreamTlsContext: TLS configuration provided but no "
|
2899
|
-
"ca_certificate_provider_instance found.");
|
2900
|
-
}
|
2901
|
-
return GRPC_ERROR_NONE;
|
2902
|
-
}
|
2903
|
-
|
2904
|
-
grpc_error_handle CdsLogicalDnsParse(
|
2905
|
-
const envoy_config_cluster_v3_Cluster* cluster,
|
2906
|
-
XdsApi::CdsUpdate* cds_update) {
|
2907
|
-
const auto* load_assignment =
|
2908
|
-
envoy_config_cluster_v3_Cluster_load_assignment(cluster);
|
2909
|
-
if (load_assignment == nullptr) {
|
2910
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2911
|
-
"load_assignment not present for LOGICAL_DNS cluster");
|
2912
|
-
}
|
2913
|
-
size_t num_localities;
|
2914
|
-
const auto* const* localities =
|
2915
|
-
envoy_config_endpoint_v3_ClusterLoadAssignment_endpoints(load_assignment,
|
2916
|
-
&num_localities);
|
2917
|
-
if (num_localities != 1) {
|
2918
|
-
return GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
2919
|
-
absl::StrCat("load_assignment for LOGICAL_DNS cluster must have "
|
2920
|
-
"exactly one locality, found ",
|
2921
|
-
num_localities));
|
2922
|
-
}
|
2923
|
-
size_t num_endpoints;
|
2924
|
-
const auto* const* endpoints =
|
2925
|
-
envoy_config_endpoint_v3_LocalityLbEndpoints_lb_endpoints(localities[0],
|
2926
|
-
&num_endpoints);
|
2927
|
-
if (num_endpoints != 1) {
|
2928
|
-
return GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
2929
|
-
absl::StrCat("locality for LOGICAL_DNS cluster must have "
|
2930
|
-
"exactly one endpoint, found ",
|
2931
|
-
num_endpoints));
|
2932
|
-
}
|
2933
|
-
const auto* endpoint =
|
2934
|
-
envoy_config_endpoint_v3_LbEndpoint_endpoint(endpoints[0]);
|
2935
|
-
if (endpoint == nullptr) {
|
2936
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2937
|
-
"LbEndpoint endpoint field not set");
|
2938
|
-
}
|
2939
|
-
const auto* address = envoy_config_endpoint_v3_Endpoint_address(endpoint);
|
2940
|
-
if (address == nullptr) {
|
2941
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2942
|
-
"Endpoint address field not set");
|
2943
|
-
}
|
2944
|
-
const auto* socket_address =
|
2945
|
-
envoy_config_core_v3_Address_socket_address(address);
|
2946
|
-
if (socket_address == nullptr) {
|
2947
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2948
|
-
"Address socket_address field not set");
|
2949
|
-
}
|
2950
|
-
if (envoy_config_core_v3_SocketAddress_resolver_name(socket_address).size !=
|
2951
|
-
0) {
|
2952
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2953
|
-
"LOGICAL_DNS clusters must NOT have a custom resolver name set");
|
2954
|
-
}
|
2955
|
-
absl::string_view address_str = UpbStringToAbsl(
|
2956
|
-
envoy_config_core_v3_SocketAddress_address(socket_address));
|
2957
|
-
if (address_str.empty()) {
|
2958
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2959
|
-
"SocketAddress address field not set");
|
2960
|
-
}
|
2961
|
-
if (!envoy_config_core_v3_SocketAddress_has_port_value(socket_address)) {
|
2962
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2963
|
-
"SocketAddress port_value field not set");
|
2964
|
-
}
|
2965
|
-
cds_update->dns_hostname = JoinHostPort(
|
2966
|
-
address_str,
|
2967
|
-
envoy_config_core_v3_SocketAddress_port_value(socket_address));
|
2968
|
-
return GRPC_ERROR_NONE;
|
2969
|
-
}
|
2970
|
-
|
2971
|
-
grpc_error_handle CdsResourceParse(
|
2972
|
-
const EncodingContext& context,
|
2973
|
-
const envoy_config_cluster_v3_Cluster* cluster, bool /*is_v2*/,
|
2974
|
-
XdsApi::CdsUpdate* cds_update) {
|
2975
|
-
std::vector<grpc_error_handle> errors;
|
2976
|
-
// Check the cluster_discovery_type.
|
2977
|
-
if (!envoy_config_cluster_v3_Cluster_has_type(cluster) &&
|
2978
|
-
!envoy_config_cluster_v3_Cluster_has_cluster_type(cluster)) {
|
2979
|
-
errors.push_back(
|
2980
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("DiscoveryType not found."));
|
2981
|
-
} else if (envoy_config_cluster_v3_Cluster_type(cluster) ==
|
2982
|
-
envoy_config_cluster_v3_Cluster_EDS) {
|
2983
|
-
cds_update->cluster_type = XdsApi::CdsUpdate::ClusterType::EDS;
|
2984
|
-
// Check the EDS config source.
|
2985
|
-
const envoy_config_cluster_v3_Cluster_EdsClusterConfig* eds_cluster_config =
|
2986
|
-
envoy_config_cluster_v3_Cluster_eds_cluster_config(cluster);
|
2987
|
-
const envoy_config_core_v3_ConfigSource* eds_config =
|
2988
|
-
envoy_config_cluster_v3_Cluster_EdsClusterConfig_eds_config(
|
2989
|
-
eds_cluster_config);
|
2990
|
-
if (!envoy_config_core_v3_ConfigSource_has_ads(eds_config)) {
|
2991
|
-
errors.push_back(
|
2992
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("EDS ConfigSource is not ADS."));
|
2993
|
-
}
|
2994
|
-
// Record EDS service_name (if any).
|
2995
|
-
upb_strview service_name =
|
2996
|
-
envoy_config_cluster_v3_Cluster_EdsClusterConfig_service_name(
|
2997
|
-
eds_cluster_config);
|
2998
|
-
if (service_name.size != 0) {
|
2999
|
-
cds_update->eds_service_name = UpbStringToStdString(service_name);
|
3000
|
-
}
|
3001
|
-
} else if (!XdsAggregateAndLogicalDnsClusterEnabled()) {
|
3002
|
-
errors.push_back(
|
3003
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("DiscoveryType is not valid."));
|
3004
|
-
} else if (envoy_config_cluster_v3_Cluster_type(cluster) ==
|
3005
|
-
envoy_config_cluster_v3_Cluster_LOGICAL_DNS) {
|
3006
|
-
cds_update->cluster_type = XdsApi::CdsUpdate::ClusterType::LOGICAL_DNS;
|
3007
|
-
grpc_error_handle error = CdsLogicalDnsParse(cluster, cds_update);
|
3008
|
-
if (error != GRPC_ERROR_NONE) errors.push_back(error);
|
3009
|
-
} else {
|
3010
|
-
if (!envoy_config_cluster_v3_Cluster_has_cluster_type(cluster)) {
|
3011
|
-
errors.push_back(
|
3012
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("DiscoveryType is not valid."));
|
3013
|
-
} else {
|
3014
|
-
const envoy_config_cluster_v3_Cluster_CustomClusterType*
|
3015
|
-
custom_cluster_type =
|
3016
|
-
envoy_config_cluster_v3_Cluster_cluster_type(cluster);
|
3017
|
-
upb_strview type_name =
|
3018
|
-
envoy_config_cluster_v3_Cluster_CustomClusterType_name(
|
3019
|
-
custom_cluster_type);
|
3020
|
-
if (UpbStringToAbsl(type_name) != "envoy.clusters.aggregate") {
|
3021
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
3022
|
-
"DiscoveryType is not valid."));
|
3023
|
-
} else {
|
3024
|
-
cds_update->cluster_type = XdsApi::CdsUpdate::ClusterType::AGGREGATE;
|
3025
|
-
// Retrieve aggregate clusters.
|
3026
|
-
const google_protobuf_Any* typed_config =
|
3027
|
-
envoy_config_cluster_v3_Cluster_CustomClusterType_typed_config(
|
3028
|
-
custom_cluster_type);
|
3029
|
-
const upb_strview aggregate_cluster_config_upb_strview =
|
3030
|
-
google_protobuf_Any_value(typed_config);
|
3031
|
-
const envoy_extensions_clusters_aggregate_v3_ClusterConfig*
|
3032
|
-
aggregate_cluster_config =
|
3033
|
-
envoy_extensions_clusters_aggregate_v3_ClusterConfig_parse(
|
3034
|
-
aggregate_cluster_config_upb_strview.data,
|
3035
|
-
aggregate_cluster_config_upb_strview.size, context.arena);
|
3036
|
-
if (aggregate_cluster_config == nullptr) {
|
3037
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
3038
|
-
"Can't parse aggregate cluster."));
|
3039
|
-
} else {
|
3040
|
-
size_t size;
|
3041
|
-
const upb_strview* clusters =
|
3042
|
-
envoy_extensions_clusters_aggregate_v3_ClusterConfig_clusters(
|
3043
|
-
aggregate_cluster_config, &size);
|
3044
|
-
for (size_t i = 0; i < size; ++i) {
|
3045
|
-
const upb_strview cluster = clusters[i];
|
3046
|
-
cds_update->prioritized_cluster_names.emplace_back(
|
3047
|
-
UpbStringToStdString(cluster));
|
3048
|
-
}
|
3049
|
-
}
|
3050
|
-
}
|
3051
|
-
}
|
3052
|
-
}
|
3053
|
-
// Check the LB policy.
|
3054
|
-
if (envoy_config_cluster_v3_Cluster_lb_policy(cluster) ==
|
3055
|
-
envoy_config_cluster_v3_Cluster_ROUND_ROBIN) {
|
3056
|
-
cds_update->lb_policy = "ROUND_ROBIN";
|
3057
|
-
} else if (envoy_config_cluster_v3_Cluster_lb_policy(cluster) ==
|
3058
|
-
envoy_config_cluster_v3_Cluster_RING_HASH) {
|
3059
|
-
cds_update->lb_policy = "RING_HASH";
|
3060
|
-
// Record ring hash lb config
|
3061
|
-
auto* ring_hash_config =
|
3062
|
-
envoy_config_cluster_v3_Cluster_ring_hash_lb_config(cluster);
|
3063
|
-
if (ring_hash_config != nullptr) {
|
3064
|
-
const google_protobuf_UInt64Value* max_ring_size =
|
3065
|
-
envoy_config_cluster_v3_Cluster_RingHashLbConfig_maximum_ring_size(
|
3066
|
-
ring_hash_config);
|
3067
|
-
if (max_ring_size != nullptr) {
|
3068
|
-
cds_update->max_ring_size =
|
3069
|
-
google_protobuf_UInt64Value_value(max_ring_size);
|
3070
|
-
if (cds_update->max_ring_size > 8388608 ||
|
3071
|
-
cds_update->max_ring_size == 0) {
|
3072
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
3073
|
-
"max_ring_size is not in the range of 1 to 8388608."));
|
3074
|
-
}
|
3075
|
-
}
|
3076
|
-
const google_protobuf_UInt64Value* min_ring_size =
|
3077
|
-
envoy_config_cluster_v3_Cluster_RingHashLbConfig_minimum_ring_size(
|
3078
|
-
ring_hash_config);
|
3079
|
-
if (min_ring_size != nullptr) {
|
3080
|
-
cds_update->min_ring_size =
|
3081
|
-
google_protobuf_UInt64Value_value(min_ring_size);
|
3082
|
-
if (cds_update->min_ring_size > 8388608 ||
|
3083
|
-
cds_update->min_ring_size == 0) {
|
3084
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
3085
|
-
"min_ring_size is not in the range of 1 to 8388608."));
|
3086
|
-
}
|
3087
|
-
if (cds_update->min_ring_size > cds_update->max_ring_size) {
|
3088
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
3089
|
-
"min_ring_size cannot be greater than max_ring_size."));
|
3090
|
-
}
|
3091
|
-
}
|
3092
|
-
if (envoy_config_cluster_v3_Cluster_RingHashLbConfig_hash_function(
|
3093
|
-
ring_hash_config) !=
|
3094
|
-
envoy_config_cluster_v3_Cluster_RingHashLbConfig_XX_HASH) {
|
3095
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
3096
|
-
"ring hash lb config has invalid hash function."));
|
3097
|
-
}
|
3098
|
-
}
|
3099
|
-
} else {
|
3100
|
-
errors.push_back(
|
3101
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("LB policy is not supported."));
|
3102
|
-
}
|
3103
|
-
auto* transport_socket =
|
3104
|
-
envoy_config_cluster_v3_Cluster_transport_socket(cluster);
|
3105
|
-
if (transport_socket != nullptr) {
|
3106
|
-
grpc_error_handle error = UpstreamTlsContextParse(
|
3107
|
-
context, transport_socket, &cds_update->common_tls_context);
|
3108
|
-
if (error != GRPC_ERROR_NONE) {
|
3109
|
-
errors.push_back(
|
3110
|
-
grpc_error_add_child(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
3111
|
-
"Error parsing security configuration"),
|
3112
|
-
error));
|
3113
|
-
}
|
3114
|
-
}
|
3115
|
-
// Record LRS server name (if any).
|
3116
|
-
const envoy_config_core_v3_ConfigSource* lrs_server =
|
3117
|
-
envoy_config_cluster_v3_Cluster_lrs_server(cluster);
|
3118
|
-
if (lrs_server != nullptr) {
|
3119
|
-
if (!envoy_config_core_v3_ConfigSource_has_self(lrs_server)) {
|
3120
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
3121
|
-
": LRS ConfigSource is not self."));
|
3122
|
-
}
|
3123
|
-
cds_update->lrs_load_reporting_server_name.emplace("");
|
3124
|
-
}
|
3125
|
-
// The Cluster resource encodes the circuit breaking parameters in a list of
|
3126
|
-
// Thresholds messages, where each message specifies the parameters for a
|
3127
|
-
// particular RoutingPriority. we will look only at the first entry in the
|
3128
|
-
// list for priority DEFAULT and default to 1024 if not found.
|
3129
|
-
if (envoy_config_cluster_v3_Cluster_has_circuit_breakers(cluster)) {
|
3130
|
-
const envoy_config_cluster_v3_CircuitBreakers* circuit_breakers =
|
3131
|
-
envoy_config_cluster_v3_Cluster_circuit_breakers(cluster);
|
3132
|
-
size_t num_thresholds;
|
3133
|
-
const envoy_config_cluster_v3_CircuitBreakers_Thresholds* const*
|
3134
|
-
thresholds = envoy_config_cluster_v3_CircuitBreakers_thresholds(
|
3135
|
-
circuit_breakers, &num_thresholds);
|
3136
|
-
for (size_t i = 0; i < num_thresholds; ++i) {
|
3137
|
-
const auto* threshold = thresholds[i];
|
3138
|
-
if (envoy_config_cluster_v3_CircuitBreakers_Thresholds_priority(
|
3139
|
-
threshold) == envoy_config_core_v3_DEFAULT) {
|
3140
|
-
const google_protobuf_UInt32Value* max_requests =
|
3141
|
-
envoy_config_cluster_v3_CircuitBreakers_Thresholds_max_requests(
|
3142
|
-
threshold);
|
3143
|
-
if (max_requests != nullptr) {
|
3144
|
-
cds_update->max_concurrent_requests =
|
3145
|
-
google_protobuf_UInt32Value_value(max_requests);
|
3146
|
-
}
|
3147
|
-
break;
|
3148
|
-
}
|
3149
|
-
}
|
3150
|
-
}
|
3151
|
-
return GRPC_ERROR_CREATE_FROM_VECTOR("errors parsing CDS resource", &errors);
|
3152
|
-
}
|
3153
|
-
|
3154
|
-
grpc_error_handle ServerAddressParseAndAppend(
|
3155
|
-
const envoy_config_endpoint_v3_LbEndpoint* lb_endpoint,
|
3156
|
-
ServerAddressList* list) {
|
3157
|
-
// If health_status is not HEALTHY or UNKNOWN, skip this endpoint.
|
3158
|
-
const int32_t health_status =
|
3159
|
-
envoy_config_endpoint_v3_LbEndpoint_health_status(lb_endpoint);
|
3160
|
-
if (health_status != envoy_config_core_v3_UNKNOWN &&
|
3161
|
-
health_status != envoy_config_core_v3_HEALTHY) {
|
3162
|
-
return GRPC_ERROR_NONE;
|
3163
|
-
}
|
3164
|
-
// Find the ip:port.
|
3165
|
-
const envoy_config_endpoint_v3_Endpoint* endpoint =
|
3166
|
-
envoy_config_endpoint_v3_LbEndpoint_endpoint(lb_endpoint);
|
3167
|
-
const envoy_config_core_v3_Address* address =
|
3168
|
-
envoy_config_endpoint_v3_Endpoint_address(endpoint);
|
3169
|
-
const envoy_config_core_v3_SocketAddress* socket_address =
|
3170
|
-
envoy_config_core_v3_Address_socket_address(address);
|
3171
|
-
std::string address_str = UpbStringToStdString(
|
3172
|
-
envoy_config_core_v3_SocketAddress_address(socket_address));
|
3173
|
-
uint32_t port = envoy_config_core_v3_SocketAddress_port_value(socket_address);
|
3174
|
-
if (GPR_UNLIKELY(port >> 16) != 0) {
|
3175
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Invalid port.");
|
3176
|
-
}
|
3177
|
-
// Find load_balancing_weight for the endpoint.
|
3178
|
-
const google_protobuf_UInt32Value* load_balancing_weight =
|
3179
|
-
envoy_config_endpoint_v3_LbEndpoint_load_balancing_weight(lb_endpoint);
|
3180
|
-
const int32_t weight =
|
3181
|
-
load_balancing_weight != nullptr
|
3182
|
-
? google_protobuf_UInt32Value_value(load_balancing_weight)
|
3183
|
-
: 500;
|
3184
|
-
if (weight == 0) {
|
3185
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
3186
|
-
"Invalid endpoint weight of 0.");
|
3187
|
-
}
|
3188
|
-
// Populate grpc_resolved_address.
|
3189
|
-
grpc_resolved_address addr;
|
3190
|
-
grpc_error_handle error =
|
3191
|
-
grpc_string_to_sockaddr(&addr, address_str.c_str(), port);
|
3192
|
-
if (error != GRPC_ERROR_NONE) return error;
|
3193
|
-
// Append the address to the list.
|
3194
|
-
std::map<const char*, std::unique_ptr<ServerAddress::AttributeInterface>>
|
3195
|
-
attributes;
|
3196
|
-
attributes[ServerAddressWeightAttribute::kServerAddressWeightAttributeKey] =
|
3197
|
-
absl::make_unique<ServerAddressWeightAttribute>(weight);
|
3198
|
-
list->emplace_back(addr, nullptr, std::move(attributes));
|
3199
|
-
return GRPC_ERROR_NONE;
|
3200
|
-
}
|
3201
|
-
|
3202
|
-
grpc_error_handle LocalityParse(
|
3203
|
-
const envoy_config_endpoint_v3_LocalityLbEndpoints* locality_lb_endpoints,
|
3204
|
-
XdsApi::EdsUpdate::Priority::Locality* output_locality, size_t* priority) {
|
3205
|
-
// Parse LB weight.
|
3206
|
-
const google_protobuf_UInt32Value* lb_weight =
|
3207
|
-
envoy_config_endpoint_v3_LocalityLbEndpoints_load_balancing_weight(
|
3208
|
-
locality_lb_endpoints);
|
3209
|
-
// If LB weight is not specified, it means this locality is assigned no load.
|
3210
|
-
// TODO(juanlishen): When we support CDS to configure the inter-locality
|
3211
|
-
// policy, we should change the LB weight handling.
|
3212
|
-
output_locality->lb_weight =
|
3213
|
-
lb_weight != nullptr ? google_protobuf_UInt32Value_value(lb_weight) : 0;
|
3214
|
-
if (output_locality->lb_weight == 0) return GRPC_ERROR_NONE;
|
3215
|
-
// Parse locality name.
|
3216
|
-
const envoy_config_core_v3_Locality* locality =
|
3217
|
-
envoy_config_endpoint_v3_LocalityLbEndpoints_locality(
|
3218
|
-
locality_lb_endpoints);
|
3219
|
-
if (locality == nullptr) {
|
3220
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty locality.");
|
3221
|
-
}
|
3222
|
-
std::string region =
|
3223
|
-
UpbStringToStdString(envoy_config_core_v3_Locality_region(locality));
|
3224
|
-
std::string zone =
|
3225
|
-
UpbStringToStdString(envoy_config_core_v3_Locality_region(locality));
|
3226
|
-
std::string sub_zone =
|
3227
|
-
UpbStringToStdString(envoy_config_core_v3_Locality_sub_zone(locality));
|
3228
|
-
output_locality->name = MakeRefCounted<XdsLocalityName>(
|
3229
|
-
std::move(region), std::move(zone), std::move(sub_zone));
|
3230
|
-
// Parse the addresses.
|
3231
|
-
size_t size;
|
3232
|
-
const envoy_config_endpoint_v3_LbEndpoint* const* lb_endpoints =
|
3233
|
-
envoy_config_endpoint_v3_LocalityLbEndpoints_lb_endpoints(
|
3234
|
-
locality_lb_endpoints, &size);
|
3235
|
-
for (size_t i = 0; i < size; ++i) {
|
3236
|
-
grpc_error_handle error = ServerAddressParseAndAppend(
|
3237
|
-
lb_endpoints[i], &output_locality->endpoints);
|
3238
|
-
if (error != GRPC_ERROR_NONE) return error;
|
3239
|
-
}
|
3240
|
-
// Parse the priority.
|
3241
|
-
*priority = envoy_config_endpoint_v3_LocalityLbEndpoints_priority(
|
3242
|
-
locality_lb_endpoints);
|
3243
|
-
return GRPC_ERROR_NONE;
|
3244
|
-
}
|
3245
|
-
|
3246
|
-
grpc_error_handle DropParseAndAppend(
|
3247
|
-
const envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload*
|
3248
|
-
drop_overload,
|
3249
|
-
XdsApi::EdsUpdate::DropConfig* drop_config) {
|
3250
|
-
// Get the category.
|
3251
|
-
std::string category = UpbStringToStdString(
|
3252
|
-
envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload_category(
|
3253
|
-
drop_overload));
|
3254
|
-
if (category.empty()) {
|
3255
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty drop category name");
|
3256
|
-
}
|
3257
|
-
// Get the drop rate (per million).
|
3258
|
-
const envoy_type_v3_FractionalPercent* drop_percentage =
|
3259
|
-
envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload_drop_percentage(
|
3260
|
-
drop_overload);
|
3261
|
-
uint32_t numerator =
|
3262
|
-
envoy_type_v3_FractionalPercent_numerator(drop_percentage);
|
3263
|
-
const auto denominator =
|
3264
|
-
static_cast<envoy_type_v3_FractionalPercent_DenominatorType>(
|
3265
|
-
envoy_type_v3_FractionalPercent_denominator(drop_percentage));
|
3266
|
-
// Normalize to million.
|
3267
|
-
switch (denominator) {
|
3268
|
-
case envoy_type_v3_FractionalPercent_HUNDRED:
|
3269
|
-
numerator *= 10000;
|
3270
|
-
break;
|
3271
|
-
case envoy_type_v3_FractionalPercent_TEN_THOUSAND:
|
3272
|
-
numerator *= 100;
|
3273
|
-
break;
|
3274
|
-
case envoy_type_v3_FractionalPercent_MILLION:
|
3275
|
-
break;
|
3276
|
-
default:
|
3277
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unknown denominator type");
|
3278
|
-
}
|
3279
|
-
// Cap numerator to 1000000.
|
3280
|
-
numerator = GPR_MIN(numerator, 1000000);
|
3281
|
-
drop_config->AddCategory(std::move(category), numerator);
|
3282
|
-
return GRPC_ERROR_NONE;
|
3283
|
-
}
|
3284
|
-
|
3285
|
-
grpc_error_handle EdsResourceParse(
|
3286
|
-
const EncodingContext& /*context*/,
|
3287
|
-
const envoy_config_endpoint_v3_ClusterLoadAssignment*
|
3288
|
-
cluster_load_assignment,
|
3289
|
-
bool /*is_v2*/, XdsApi::EdsUpdate* eds_update) {
|
3290
|
-
std::vector<grpc_error_handle> errors;
|
3291
|
-
// Get the endpoints.
|
3292
|
-
size_t locality_size;
|
3293
|
-
const envoy_config_endpoint_v3_LocalityLbEndpoints* const* endpoints =
|
3294
|
-
envoy_config_endpoint_v3_ClusterLoadAssignment_endpoints(
|
3295
|
-
cluster_load_assignment, &locality_size);
|
3296
|
-
for (size_t j = 0; j < locality_size; ++j) {
|
3297
|
-
size_t priority;
|
3298
|
-
XdsApi::EdsUpdate::Priority::Locality locality;
|
3299
|
-
grpc_error_handle error = LocalityParse(endpoints[j], &locality, &priority);
|
3300
|
-
if (error != GRPC_ERROR_NONE) {
|
3301
|
-
errors.push_back(error);
|
3302
|
-
continue;
|
3303
|
-
}
|
3304
|
-
// Filter out locality with weight 0.
|
3305
|
-
if (locality.lb_weight == 0) continue;
|
3306
|
-
// Make sure prorities is big enough. Note that they might not
|
3307
|
-
// arrive in priority order.
|
3308
|
-
while (eds_update->priorities.size() < priority + 1) {
|
3309
|
-
eds_update->priorities.emplace_back();
|
3310
|
-
}
|
3311
|
-
eds_update->priorities[priority].localities.emplace(locality.name.get(),
|
3312
|
-
std::move(locality));
|
3313
|
-
}
|
3314
|
-
for (const auto& priority : eds_update->priorities) {
|
3315
|
-
if (priority.localities.empty()) {
|
3316
|
-
errors.push_back(
|
3317
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("sparse priority list"));
|
3318
|
-
}
|
3319
|
-
}
|
3320
|
-
// Get the drop config.
|
3321
|
-
eds_update->drop_config = MakeRefCounted<XdsApi::EdsUpdate::DropConfig>();
|
3322
|
-
const envoy_config_endpoint_v3_ClusterLoadAssignment_Policy* policy =
|
3323
|
-
envoy_config_endpoint_v3_ClusterLoadAssignment_policy(
|
3324
|
-
cluster_load_assignment);
|
3325
|
-
if (policy != nullptr) {
|
3326
|
-
size_t drop_size;
|
3327
|
-
const envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload* const*
|
3328
|
-
drop_overload =
|
3329
|
-
envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_drop_overloads(
|
3330
|
-
policy, &drop_size);
|
3331
|
-
for (size_t j = 0; j < drop_size; ++j) {
|
3332
|
-
grpc_error_handle error =
|
3333
|
-
DropParseAndAppend(drop_overload[j], eds_update->drop_config.get());
|
3334
|
-
if (error != GRPC_ERROR_NONE) {
|
3335
|
-
errors.push_back(
|
3336
|
-
grpc_error_add_child(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
3337
|
-
"drop config validation error"),
|
3338
|
-
error));
|
3339
|
-
}
|
3340
|
-
}
|
3341
|
-
}
|
3342
|
-
return GRPC_ERROR_CREATE_FROM_VECTOR("errors parsing EDS resource", &errors);
|
3343
|
-
}
|
3344
|
-
|
3345
|
-
template <typename ProtoParseFunction, typename ProtoResourceNameFunction,
|
3346
|
-
typename ResourceTypeSelectorFunction, typename ProtoLogFunction,
|
3347
|
-
typename ResourceParseFunction, typename UpdateMap>
|
3348
|
-
grpc_error_handle AdsResponseParse(
|
3349
|
-
const EncodingContext& context, ProtoParseFunction proto_parse_function,
|
3350
|
-
ProtoResourceNameFunction proto_resource_name_function,
|
3351
|
-
ResourceTypeSelectorFunction resource_type_selector_function,
|
3352
|
-
ProtoLogFunction proto_log_function,
|
3353
|
-
ResourceParseFunction resource_parse_function,
|
3354
|
-
const envoy_service_discovery_v3_DiscoveryResponse* response,
|
3355
|
-
const char* resource_type_string,
|
3356
|
-
const std::set<absl::string_view>& expected_resource_names,
|
3357
|
-
UpdateMap* update_map, std::set<std::string>* resource_names_failed) {
|
3358
|
-
std::vector<grpc_error_handle> errors;
|
3359
|
-
// Get the resources from the response.
|
3360
|
-
size_t size;
|
3361
|
-
const google_protobuf_Any* const* resources =
|
3362
|
-
envoy_service_discovery_v3_DiscoveryResponse_resources(response, &size);
|
3363
|
-
for (size_t i = 0; i < size; ++i) {
|
3364
|
-
// Check the type_url of the resource.
|
3365
|
-
absl::string_view type_url =
|
3366
|
-
UpbStringToAbsl(google_protobuf_Any_type_url(resources[i]));
|
3367
|
-
bool is_v2 = false;
|
3368
|
-
if (!resource_type_selector_function(type_url, &is_v2)) {
|
3369
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
3370
|
-
absl::StrCat("resource index ", i, ": Resource is not ",
|
3371
|
-
resource_type_string, ".")));
|
3372
|
-
continue;
|
3373
|
-
}
|
3374
|
-
// Parse the resource.
|
3375
|
-
upb_strview serialized_resource = google_protobuf_Any_value(resources[i]);
|
3376
|
-
auto* resource = proto_parse_function(
|
3377
|
-
serialized_resource.data, serialized_resource.size, context.arena);
|
3378
|
-
if (resource == nullptr) {
|
3379
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
3380
|
-
absl::StrCat("resource index ", i, ": Can't parse ",
|
3381
|
-
resource_type_string, " resource.")));
|
3382
|
-
continue;
|
3383
|
-
}
|
3384
|
-
proto_log_function(context, resource);
|
3385
|
-
// Check the resource name. Ignore unexpected names.
|
3386
|
-
std::string resource_name =
|
3387
|
-
UpbStringToStdString(proto_resource_name_function(resource));
|
3388
|
-
if (expected_resource_names.find(resource_name) ==
|
3389
|
-
expected_resource_names.end()) {
|
3390
|
-
continue;
|
3391
|
-
}
|
3392
|
-
// Fail on duplicate resources.
|
3393
|
-
if (update_map->find(resource_name) != update_map->end()) {
|
3394
|
-
errors.push_back(GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
3395
|
-
absl::StrCat("duplicate resource name \"", resource_name, "\"")));
|
3396
|
-
resource_names_failed->insert(resource_name);
|
3397
|
-
continue;
|
3398
|
-
}
|
3399
|
-
// Validate resource.
|
3400
|
-
decltype(UpdateMap::mapped_type::resource) update;
|
3401
|
-
grpc_error_handle error =
|
3402
|
-
resource_parse_function(context, resource, is_v2, &update);
|
3403
|
-
if (error != GRPC_ERROR_NONE) {
|
3404
|
-
errors.push_back(
|
3405
|
-
grpc_error_add_child(GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrCat(
|
3406
|
-
resource_name, ": validation error")),
|
3407
|
-
error));
|
3408
|
-
resource_names_failed->insert(resource_name);
|
3409
|
-
} else {
|
3410
|
-
// Store result in update map, in both validated and serialized form.
|
3411
|
-
auto& resource_data = (*update_map)[resource_name];
|
3412
|
-
resource_data.resource = std::move(update);
|
3413
|
-
resource_data.serialized_proto =
|
3414
|
-
UpbStringToStdString(serialized_resource);
|
3415
|
-
}
|
3416
|
-
}
|
3417
|
-
return GRPC_ERROR_CREATE_FROM_VECTOR("errors parsing ADS response", &errors);
|
3418
|
-
}
|
3419
|
-
|
3420
|
-
std::string TypeUrlInternalToExternal(absl::string_view type_url) {
|
3421
|
-
if (type_url == kLdsV2TypeUrl) {
|
3422
|
-
return XdsApi::kLdsTypeUrl;
|
3423
|
-
} else if (type_url == kRdsV2TypeUrl) {
|
3424
|
-
return XdsApi::kRdsTypeUrl;
|
3425
|
-
} else if (type_url == kCdsV2TypeUrl) {
|
3426
|
-
return XdsApi::kCdsTypeUrl;
|
3427
|
-
} else if (type_url == kEdsV2TypeUrl) {
|
3428
|
-
return XdsApi::kEdsTypeUrl;
|
3429
|
-
}
|
3430
|
-
return std::string(type_url);
|
3431
|
-
}
|
3432
|
-
|
3433
|
-
upb_strview LdsResourceName(
|
3434
|
-
const envoy_config_listener_v3_Listener* lds_resource) {
|
3435
|
-
return envoy_config_listener_v3_Listener_name(lds_resource);
|
3436
|
-
}
|
3437
|
-
|
3438
|
-
upb_strview RdsResourceName(
|
3439
|
-
const envoy_config_route_v3_RouteConfiguration* rds_resource) {
|
3440
|
-
return envoy_config_route_v3_RouteConfiguration_name(rds_resource);
|
3441
|
-
}
|
3442
|
-
|
3443
|
-
upb_strview CdsResourceName(
|
3444
|
-
const envoy_config_cluster_v3_Cluster* cds_resource) {
|
3445
|
-
return envoy_config_cluster_v3_Cluster_name(cds_resource);
|
3446
|
-
}
|
3447
|
-
|
3448
|
-
upb_strview EdsResourceName(
|
3449
|
-
const envoy_config_endpoint_v3_ClusterLoadAssignment* eds_resource) {
|
3450
|
-
return envoy_config_endpoint_v3_ClusterLoadAssignment_cluster_name(
|
3451
|
-
eds_resource);
|
3452
|
-
}
|
3453
|
-
|
3454
|
-
} // namespace
|
3455
|
-
|
3456
|
-
XdsApi::AdsParseResult XdsApi::ParseAdsResponse(
|
3457
|
-
const XdsBootstrap::XdsServer& server, const grpc_slice& encoded_response,
|
3458
|
-
const std::set<absl::string_view>& expected_listener_names,
|
3459
|
-
const std::set<absl::string_view>& expected_route_configuration_names,
|
3460
|
-
const std::set<absl::string_view>& expected_cluster_names,
|
3461
|
-
const std::set<absl::string_view>& expected_eds_service_names) {
|
3462
|
-
AdsParseResult result;
|
3463
|
-
upb::Arena arena;
|
3464
|
-
const EncodingContext context = {client_,
|
3465
|
-
tracer_,
|
3466
|
-
symtab_.ptr(),
|
3467
|
-
arena.ptr(),
|
3468
|
-
server.ShouldUseV3(),
|
3469
|
-
certificate_provider_definition_map_};
|
3470
|
-
// Decode the response.
|
3471
|
-
const envoy_service_discovery_v3_DiscoveryResponse* response =
|
3472
|
-
envoy_service_discovery_v3_DiscoveryResponse_parse(
|
3473
|
-
reinterpret_cast<const char*>(GRPC_SLICE_START_PTR(encoded_response)),
|
3474
|
-
GRPC_SLICE_LENGTH(encoded_response), arena.ptr());
|
3475
|
-
// If decoding fails, output an empty type_url and return.
|
3476
|
-
if (response == nullptr) {
|
3477
|
-
result.parse_error =
|
3478
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode DiscoveryResponse.");
|
3479
|
-
return result;
|
3480
|
-
}
|
3481
|
-
MaybeLogDiscoveryResponse(context, response);
|
3482
|
-
// Record the type_url, the version_info, and the nonce of the response.
|
3483
|
-
result.type_url = TypeUrlInternalToExternal(UpbStringToAbsl(
|
3484
|
-
envoy_service_discovery_v3_DiscoveryResponse_type_url(response)));
|
3485
|
-
result.version = UpbStringToStdString(
|
3486
|
-
envoy_service_discovery_v3_DiscoveryResponse_version_info(response));
|
3487
|
-
result.nonce = UpbStringToStdString(
|
3488
|
-
envoy_service_discovery_v3_DiscoveryResponse_nonce(response));
|
3489
|
-
// Parse the response according to the resource type.
|
3490
|
-
// TODO(roth): When we have time, consider defining an interface for the
|
3491
|
-
// methods of each resource type, so that we don't have to pass
|
3492
|
-
// individual functions into each call to AdsResponseParse().
|
3493
|
-
if (IsLds(result.type_url)) {
|
3494
|
-
result.parse_error = AdsResponseParse(
|
3495
|
-
context, envoy_config_listener_v3_Listener_parse, LdsResourceName,
|
3496
|
-
IsLds, MaybeLogListener, LdsResourceParse, response, "LDS",
|
3497
|
-
expected_listener_names, &result.lds_update_map,
|
3498
|
-
&result.resource_names_failed);
|
3499
|
-
} else if (IsRds(result.type_url)) {
|
3500
|
-
result.parse_error = AdsResponseParse(
|
3501
|
-
context, envoy_config_route_v3_RouteConfiguration_parse,
|
3502
|
-
RdsResourceName, IsRds, MaybeLogRouteConfiguration, RouteConfigParse,
|
3503
|
-
response, "RDS", expected_route_configuration_names,
|
3504
|
-
&result.rds_update_map, &result.resource_names_failed);
|
3505
|
-
} else if (IsCds(result.type_url)) {
|
3506
|
-
result.parse_error = AdsResponseParse(
|
3507
|
-
context, envoy_config_cluster_v3_Cluster_parse, CdsResourceName, IsCds,
|
3508
|
-
MaybeLogCluster, CdsResourceParse, response, "CDS",
|
3509
|
-
expected_cluster_names, &result.cds_update_map,
|
3510
|
-
&result.resource_names_failed);
|
3511
|
-
} else if (IsEds(result.type_url)) {
|
3512
|
-
result.parse_error = AdsResponseParse(
|
3513
|
-
context, envoy_config_endpoint_v3_ClusterLoadAssignment_parse,
|
3514
|
-
EdsResourceName, IsEds, MaybeLogClusterLoadAssignment, EdsResourceParse,
|
3515
|
-
response, "EDS", expected_eds_service_names, &result.eds_update_map,
|
3516
|
-
&result.resource_names_failed);
|
3517
|
-
}
|
3518
|
-
return result;
|
373
|
+
MaybeLogDiscoveryResponse(context, response);
|
374
|
+
// Report the type_url, version, nonce, and number of resources to the parser.
|
375
|
+
AdsResponseParserInterface::AdsResponseFields fields;
|
376
|
+
fields.type_url = std::string(absl::StripPrefix(
|
377
|
+
UpbStringToAbsl(
|
378
|
+
envoy_service_discovery_v3_DiscoveryResponse_type_url(response)),
|
379
|
+
"type.googleapis.com/"));
|
380
|
+
fields.version = UpbStringToStdString(
|
381
|
+
envoy_service_discovery_v3_DiscoveryResponse_version_info(response));
|
382
|
+
fields.nonce = UpbStringToStdString(
|
383
|
+
envoy_service_discovery_v3_DiscoveryResponse_nonce(response));
|
384
|
+
size_t num_resources;
|
385
|
+
const google_protobuf_Any* const* resources =
|
386
|
+
envoy_service_discovery_v3_DiscoveryResponse_resources(response,
|
387
|
+
&num_resources);
|
388
|
+
fields.num_resources = num_resources;
|
389
|
+
absl::Status status = parser->ProcessAdsResponseFields(std::move(fields));
|
390
|
+
if (!status.ok()) return status;
|
391
|
+
// Process each resource.
|
392
|
+
for (size_t i = 0; i < num_resources; ++i) {
|
393
|
+
absl::string_view type_url = absl::StripPrefix(
|
394
|
+
UpbStringToAbsl(google_protobuf_Any_type_url(resources[i])),
|
395
|
+
"type.googleapis.com/");
|
396
|
+
absl::string_view serialized_resource =
|
397
|
+
UpbStringToAbsl(google_protobuf_Any_value(resources[i]));
|
398
|
+
parser->ParseResource(context, i, type_url, serialized_resource);
|
399
|
+
}
|
400
|
+
return absl::OkStatus();
|
3519
401
|
}
|
3520
402
|
|
3521
403
|
namespace {
|
3522
404
|
|
3523
405
|
void MaybeLogLrsRequest(
|
3524
|
-
const
|
406
|
+
const XdsEncodingContext& context,
|
3525
407
|
const envoy_service_load_stats_v3_LoadStatsRequest* request) {
|
3526
408
|
if (GRPC_TRACE_FLAG_ENABLED(*context.tracer) &&
|
3527
409
|
gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
|
@@ -3535,7 +417,7 @@ void MaybeLogLrsRequest(
|
|
3535
417
|
}
|
3536
418
|
|
3537
419
|
grpc_slice SerializeLrsRequest(
|
3538
|
-
const
|
420
|
+
const XdsEncodingContext& context,
|
3539
421
|
const envoy_service_load_stats_v3_LoadStatsRequest* request) {
|
3540
422
|
size_t output_length;
|
3541
423
|
char* output = envoy_service_load_stats_v3_LoadStatsRequest_serialize(
|
@@ -3548,12 +430,12 @@ grpc_slice SerializeLrsRequest(
|
|
3548
430
|
grpc_slice XdsApi::CreateLrsInitialRequest(
|
3549
431
|
const XdsBootstrap::XdsServer& server) {
|
3550
432
|
upb::Arena arena;
|
3551
|
-
const
|
3552
|
-
|
3553
|
-
|
3554
|
-
|
3555
|
-
|
3556
|
-
|
433
|
+
const XdsEncodingContext context = {client_,
|
434
|
+
tracer_,
|
435
|
+
symtab_->ptr(),
|
436
|
+
arena.ptr(),
|
437
|
+
server.ShouldUseV3(),
|
438
|
+
certificate_provider_definition_map_};
|
3557
439
|
// Create a request.
|
3558
440
|
envoy_service_load_stats_v3_LoadStatsRequest* request =
|
3559
441
|
envoy_service_load_stats_v3_LoadStatsRequest_new(arena.ptr());
|
@@ -3573,7 +455,7 @@ grpc_slice XdsApi::CreateLrsInitialRequest(
|
|
3573
455
|
namespace {
|
3574
456
|
|
3575
457
|
void LocalityStatsPopulate(
|
3576
|
-
const
|
458
|
+
const XdsEncodingContext& context,
|
3577
459
|
envoy_config_endpoint_v3_UpstreamLocalityStats* output,
|
3578
460
|
const XdsLocalityName& locality_name,
|
3579
461
|
const XdsClusterLocalityStats::Snapshot& snapshot) {
|
@@ -3623,8 +505,8 @@ void LocalityStatsPopulate(
|
|
3623
505
|
grpc_slice XdsApi::CreateLrsRequest(
|
3624
506
|
ClusterLoadReportMap cluster_load_report_map) {
|
3625
507
|
upb::Arena arena;
|
3626
|
-
const
|
3627
|
-
client_, tracer_, symtab_
|
508
|
+
const XdsEncodingContext context = {
|
509
|
+
client_, tracer_, symtab_->ptr(),
|
3628
510
|
arena.ptr(), false, certificate_provider_definition_map_};
|
3629
511
|
// Create a request.
|
3630
512
|
envoy_service_load_stats_v3_LoadStatsRequest* request =
|
@@ -3726,8 +608,9 @@ grpc_error_handle XdsApi::ParseLrsResponse(
|
|
3726
608
|
}
|
3727
609
|
|
3728
610
|
namespace {
|
3729
|
-
|
3730
|
-
|
611
|
+
|
612
|
+
google_protobuf_Timestamp* GrpcMillisToTimestamp(
|
613
|
+
const XdsEncodingContext& context, grpc_millis value) {
|
3731
614
|
google_protobuf_Timestamp* timestamp =
|
3732
615
|
google_protobuf_Timestamp_new(context.arena);
|
3733
616
|
gpr_timespec timespec = grpc_millis_to_timespec(value, GPR_CLOCK_REALTIME);
|
@@ -3736,218 +619,6 @@ google_protobuf_Timestamp* GrpcMillisToTimestamp(const EncodingContext& context,
|
|
3736
619
|
return timestamp;
|
3737
620
|
}
|
3738
621
|
|
3739
|
-
envoy_admin_v3_UpdateFailureState* CreateUpdateFailureStateUpb(
|
3740
|
-
const EncodingContext& context,
|
3741
|
-
const XdsApi::ResourceMetadata* resource_metadata) {
|
3742
|
-
auto* update_failure_state =
|
3743
|
-
envoy_admin_v3_UpdateFailureState_new(context.arena);
|
3744
|
-
envoy_admin_v3_UpdateFailureState_set_details(
|
3745
|
-
update_failure_state,
|
3746
|
-
StdStringToUpbString(resource_metadata->failed_details));
|
3747
|
-
envoy_admin_v3_UpdateFailureState_set_version_info(
|
3748
|
-
update_failure_state,
|
3749
|
-
StdStringToUpbString(resource_metadata->failed_version));
|
3750
|
-
envoy_admin_v3_UpdateFailureState_set_last_update_attempt(
|
3751
|
-
update_failure_state,
|
3752
|
-
GrpcMillisToTimestamp(context, resource_metadata->failed_update_time));
|
3753
|
-
return update_failure_state;
|
3754
|
-
}
|
3755
|
-
|
3756
|
-
void DumpLdsConfig(const EncodingContext& context,
|
3757
|
-
const XdsApi::ResourceTypeMetadata& resource_type_metadata,
|
3758
|
-
envoy_service_status_v3_PerXdsConfig* per_xds_config) {
|
3759
|
-
upb_strview kLdsTypeUrlUpb = upb_strview_makez(XdsApi::kLdsTypeUrl);
|
3760
|
-
auto* listener_config_dump =
|
3761
|
-
envoy_service_status_v3_PerXdsConfig_mutable_listener_config(
|
3762
|
-
per_xds_config, context.arena);
|
3763
|
-
envoy_admin_v3_ListenersConfigDump_set_version_info(
|
3764
|
-
listener_config_dump,
|
3765
|
-
StdStringToUpbString(resource_type_metadata.version));
|
3766
|
-
for (auto& p : resource_type_metadata.resource_metadata_map) {
|
3767
|
-
absl::string_view name = p.first;
|
3768
|
-
const XdsApi::ResourceMetadata* meta = p.second;
|
3769
|
-
const upb_strview name_upb = StdStringToUpbString(name);
|
3770
|
-
auto* dynamic_listener =
|
3771
|
-
envoy_admin_v3_ListenersConfigDump_add_dynamic_listeners(
|
3772
|
-
listener_config_dump, context.arena);
|
3773
|
-
envoy_admin_v3_ListenersConfigDump_DynamicListener_set_name(
|
3774
|
-
dynamic_listener, name_upb);
|
3775
|
-
envoy_admin_v3_ListenersConfigDump_DynamicListener_set_client_status(
|
3776
|
-
dynamic_listener, meta->client_status);
|
3777
|
-
if (!meta->serialized_proto.empty()) {
|
3778
|
-
// Set in-effective listeners
|
3779
|
-
auto* dynamic_listener_state =
|
3780
|
-
envoy_admin_v3_ListenersConfigDump_DynamicListener_mutable_active_state(
|
3781
|
-
dynamic_listener, context.arena);
|
3782
|
-
envoy_admin_v3_ListenersConfigDump_DynamicListenerState_set_version_info(
|
3783
|
-
dynamic_listener_state, StdStringToUpbString(meta->version));
|
3784
|
-
envoy_admin_v3_ListenersConfigDump_DynamicListenerState_set_last_updated(
|
3785
|
-
dynamic_listener_state,
|
3786
|
-
GrpcMillisToTimestamp(context, meta->update_time));
|
3787
|
-
auto* listener_any =
|
3788
|
-
envoy_admin_v3_ListenersConfigDump_DynamicListenerState_mutable_listener(
|
3789
|
-
dynamic_listener_state, context.arena);
|
3790
|
-
google_protobuf_Any_set_type_url(listener_any, kLdsTypeUrlUpb);
|
3791
|
-
google_protobuf_Any_set_value(
|
3792
|
-
listener_any, StdStringToUpbString(meta->serialized_proto));
|
3793
|
-
}
|
3794
|
-
if (meta->client_status == XdsApi::ResourceMetadata::NACKED) {
|
3795
|
-
// Set error_state if NACKED
|
3796
|
-
envoy_admin_v3_ListenersConfigDump_DynamicListener_set_error_state(
|
3797
|
-
dynamic_listener, CreateUpdateFailureStateUpb(context, meta));
|
3798
|
-
}
|
3799
|
-
}
|
3800
|
-
}
|
3801
|
-
|
3802
|
-
void DumpRdsConfig(const EncodingContext& context,
|
3803
|
-
const XdsApi::ResourceTypeMetadata& resource_type_metadata,
|
3804
|
-
envoy_service_status_v3_PerXdsConfig* per_xds_config) {
|
3805
|
-
upb_strview kRdsTypeUrlUpb = upb_strview_makez(XdsApi::kRdsTypeUrl);
|
3806
|
-
auto* route_config_dump =
|
3807
|
-
envoy_service_status_v3_PerXdsConfig_mutable_route_config(per_xds_config,
|
3808
|
-
context.arena);
|
3809
|
-
for (auto& p : resource_type_metadata.resource_metadata_map) {
|
3810
|
-
absl::string_view name = p.first;
|
3811
|
-
const XdsApi::ResourceMetadata* meta = p.second;
|
3812
|
-
const upb_strview name_upb = StdStringToUpbString(name);
|
3813
|
-
auto* dynamic_route_config =
|
3814
|
-
envoy_admin_v3_RoutesConfigDump_add_dynamic_route_configs(
|
3815
|
-
route_config_dump, context.arena);
|
3816
|
-
envoy_admin_v3_RoutesConfigDump_DynamicRouteConfig_set_client_status(
|
3817
|
-
dynamic_route_config, meta->client_status);
|
3818
|
-
auto* route_config_any =
|
3819
|
-
envoy_admin_v3_RoutesConfigDump_DynamicRouteConfig_mutable_route_config(
|
3820
|
-
dynamic_route_config, context.arena);
|
3821
|
-
if (!meta->serialized_proto.empty()) {
|
3822
|
-
// Set in-effective route configs
|
3823
|
-
envoy_admin_v3_RoutesConfigDump_DynamicRouteConfig_set_version_info(
|
3824
|
-
dynamic_route_config, StdStringToUpbString(meta->version));
|
3825
|
-
envoy_admin_v3_RoutesConfigDump_DynamicRouteConfig_set_last_updated(
|
3826
|
-
dynamic_route_config,
|
3827
|
-
GrpcMillisToTimestamp(context, meta->update_time));
|
3828
|
-
google_protobuf_Any_set_type_url(route_config_any, kRdsTypeUrlUpb);
|
3829
|
-
google_protobuf_Any_set_value(
|
3830
|
-
route_config_any, StdStringToUpbString(meta->serialized_proto));
|
3831
|
-
} else {
|
3832
|
-
// If there isn't a working route config, we still need to print the
|
3833
|
-
// name.
|
3834
|
-
auto* route_config =
|
3835
|
-
envoy_config_route_v3_RouteConfiguration_new(context.arena);
|
3836
|
-
envoy_config_route_v3_RouteConfiguration_set_name(route_config, name_upb);
|
3837
|
-
size_t length;
|
3838
|
-
char* bytes = envoy_config_route_v3_RouteConfiguration_serialize(
|
3839
|
-
route_config, context.arena, &length);
|
3840
|
-
google_protobuf_Any_set_type_url(route_config_any, kRdsTypeUrlUpb);
|
3841
|
-
google_protobuf_Any_set_value(route_config_any,
|
3842
|
-
upb_strview_make(bytes, length));
|
3843
|
-
}
|
3844
|
-
if (meta->client_status == XdsApi::ResourceMetadata::NACKED) {
|
3845
|
-
// Set error_state if NACKED
|
3846
|
-
envoy_admin_v3_RoutesConfigDump_DynamicRouteConfig_set_error_state(
|
3847
|
-
dynamic_route_config, CreateUpdateFailureStateUpb(context, meta));
|
3848
|
-
}
|
3849
|
-
}
|
3850
|
-
}
|
3851
|
-
|
3852
|
-
void DumpCdsConfig(const EncodingContext& context,
|
3853
|
-
const XdsApi::ResourceTypeMetadata& resource_type_metadata,
|
3854
|
-
envoy_service_status_v3_PerXdsConfig* per_xds_config) {
|
3855
|
-
upb_strview kCdsTypeUrlUpb = upb_strview_makez(XdsApi::kCdsTypeUrl);
|
3856
|
-
auto* cluster_config_dump =
|
3857
|
-
envoy_service_status_v3_PerXdsConfig_mutable_cluster_config(
|
3858
|
-
per_xds_config, context.arena);
|
3859
|
-
envoy_admin_v3_ClustersConfigDump_set_version_info(
|
3860
|
-
cluster_config_dump,
|
3861
|
-
StdStringToUpbString(resource_type_metadata.version));
|
3862
|
-
for (auto& p : resource_type_metadata.resource_metadata_map) {
|
3863
|
-
absl::string_view name = p.first;
|
3864
|
-
const XdsApi::ResourceMetadata* meta = p.second;
|
3865
|
-
const upb_strview name_upb = StdStringToUpbString(name);
|
3866
|
-
auto* dynamic_cluster =
|
3867
|
-
envoy_admin_v3_ClustersConfigDump_add_dynamic_active_clusters(
|
3868
|
-
cluster_config_dump, context.arena);
|
3869
|
-
envoy_admin_v3_ClustersConfigDump_DynamicCluster_set_client_status(
|
3870
|
-
dynamic_cluster, meta->client_status);
|
3871
|
-
auto* cluster_any =
|
3872
|
-
envoy_admin_v3_ClustersConfigDump_DynamicCluster_mutable_cluster(
|
3873
|
-
dynamic_cluster, context.arena);
|
3874
|
-
if (!meta->serialized_proto.empty()) {
|
3875
|
-
// Set in-effective clusters
|
3876
|
-
envoy_admin_v3_ClustersConfigDump_DynamicCluster_set_version_info(
|
3877
|
-
dynamic_cluster, StdStringToUpbString(meta->version));
|
3878
|
-
envoy_admin_v3_ClustersConfigDump_DynamicCluster_set_last_updated(
|
3879
|
-
dynamic_cluster, GrpcMillisToTimestamp(context, meta->update_time));
|
3880
|
-
google_protobuf_Any_set_type_url(cluster_any, kCdsTypeUrlUpb);
|
3881
|
-
google_protobuf_Any_set_value(
|
3882
|
-
cluster_any, StdStringToUpbString(meta->serialized_proto));
|
3883
|
-
} else {
|
3884
|
-
// If there isn't a working cluster, we still need to print the name.
|
3885
|
-
auto* cluster = envoy_config_cluster_v3_Cluster_new(context.arena);
|
3886
|
-
envoy_config_cluster_v3_Cluster_set_name(cluster, name_upb);
|
3887
|
-
size_t length;
|
3888
|
-
char* bytes = envoy_config_cluster_v3_Cluster_serialize(
|
3889
|
-
cluster, context.arena, &length);
|
3890
|
-
google_protobuf_Any_set_type_url(cluster_any, kCdsTypeUrlUpb);
|
3891
|
-
google_protobuf_Any_set_value(cluster_any,
|
3892
|
-
upb_strview_make(bytes, length));
|
3893
|
-
}
|
3894
|
-
if (meta->client_status == XdsApi::ResourceMetadata::NACKED) {
|
3895
|
-
// Set error_state if NACKED
|
3896
|
-
envoy_admin_v3_ClustersConfigDump_DynamicCluster_set_error_state(
|
3897
|
-
dynamic_cluster, CreateUpdateFailureStateUpb(context, meta));
|
3898
|
-
}
|
3899
|
-
}
|
3900
|
-
}
|
3901
|
-
|
3902
|
-
void DumpEdsConfig(const EncodingContext& context,
|
3903
|
-
const XdsApi::ResourceTypeMetadata& resource_type_metadata,
|
3904
|
-
envoy_service_status_v3_PerXdsConfig* per_xds_config) {
|
3905
|
-
upb_strview kEdsTypeUrlUpb = upb_strview_makez(XdsApi::kEdsTypeUrl);
|
3906
|
-
auto* endpoint_config_dump =
|
3907
|
-
envoy_service_status_v3_PerXdsConfig_mutable_endpoint_config(
|
3908
|
-
per_xds_config, context.arena);
|
3909
|
-
for (auto& p : resource_type_metadata.resource_metadata_map) {
|
3910
|
-
absl::string_view name = p.first;
|
3911
|
-
const XdsApi::ResourceMetadata* meta = p.second;
|
3912
|
-
const upb_strview name_upb = StdStringToUpbString(name);
|
3913
|
-
auto* dynamic_endpoint =
|
3914
|
-
envoy_admin_v3_EndpointsConfigDump_add_dynamic_endpoint_configs(
|
3915
|
-
endpoint_config_dump, context.arena);
|
3916
|
-
envoy_admin_v3_EndpointsConfigDump_DynamicEndpointConfig_set_client_status(
|
3917
|
-
dynamic_endpoint, meta->client_status);
|
3918
|
-
auto* endpoint_any =
|
3919
|
-
envoy_admin_v3_EndpointsConfigDump_DynamicEndpointConfig_mutable_endpoint_config(
|
3920
|
-
dynamic_endpoint, context.arena);
|
3921
|
-
if (!meta->serialized_proto.empty()) {
|
3922
|
-
// Set in-effective endpoints
|
3923
|
-
envoy_admin_v3_EndpointsConfigDump_DynamicEndpointConfig_set_version_info(
|
3924
|
-
dynamic_endpoint, StdStringToUpbString(meta->version));
|
3925
|
-
envoy_admin_v3_EndpointsConfigDump_DynamicEndpointConfig_set_last_updated(
|
3926
|
-
dynamic_endpoint, GrpcMillisToTimestamp(context, meta->update_time));
|
3927
|
-
google_protobuf_Any_set_type_url(endpoint_any, kEdsTypeUrlUpb);
|
3928
|
-
google_protobuf_Any_set_value(
|
3929
|
-
endpoint_any, StdStringToUpbString(meta->serialized_proto));
|
3930
|
-
} else {
|
3931
|
-
// If there isn't a working endpoint, we still need to print the name.
|
3932
|
-
auto* cluster_load_assignment =
|
3933
|
-
envoy_config_endpoint_v3_ClusterLoadAssignment_new(context.arena);
|
3934
|
-
envoy_config_endpoint_v3_ClusterLoadAssignment_set_cluster_name(
|
3935
|
-
cluster_load_assignment, name_upb);
|
3936
|
-
size_t length;
|
3937
|
-
char* bytes = envoy_config_endpoint_v3_ClusterLoadAssignment_serialize(
|
3938
|
-
cluster_load_assignment, context.arena, &length);
|
3939
|
-
google_protobuf_Any_set_type_url(endpoint_any, kEdsTypeUrlUpb);
|
3940
|
-
google_protobuf_Any_set_value(endpoint_any,
|
3941
|
-
upb_strview_make(bytes, length));
|
3942
|
-
}
|
3943
|
-
if (meta->client_status == XdsApi::ResourceMetadata::NACKED) {
|
3944
|
-
// Set error_state if NACKED
|
3945
|
-
envoy_admin_v3_EndpointsConfigDump_DynamicEndpointConfig_set_error_state(
|
3946
|
-
dynamic_endpoint, CreateUpdateFailureStateUpb(context, meta));
|
3947
|
-
}
|
3948
|
-
}
|
3949
|
-
}
|
3950
|
-
|
3951
622
|
} // namespace
|
3952
623
|
|
3953
624
|
std::string XdsApi::AssembleClientConfig(
|
@@ -3958,38 +629,58 @@ std::string XdsApi::AssembleClientConfig(
|
|
3958
629
|
// Fill-in the node information
|
3959
630
|
auto* node = envoy_service_status_v3_ClientConfig_mutable_node(client_config,
|
3960
631
|
arena.ptr());
|
3961
|
-
const
|
3962
|
-
client_, tracer_, symtab_
|
632
|
+
const XdsEncodingContext context = {
|
633
|
+
client_, tracer_, symtab_->ptr(),
|
3963
634
|
arena.ptr(), true, certificate_provider_definition_map_};
|
3964
635
|
PopulateNode(context, node_, build_version_, user_agent_name_,
|
3965
636
|
user_agent_version_, node);
|
3966
|
-
// Dump each
|
3967
|
-
|
637
|
+
// Dump each resource.
|
638
|
+
std::vector<std::string> type_url_storage;
|
639
|
+
for (const auto& p : resource_type_metadata_map) {
|
3968
640
|
absl::string_view type_url = p.first;
|
3969
|
-
const
|
3970
|
-
|
3971
|
-
|
3972
|
-
|
3973
|
-
|
3974
|
-
|
3975
|
-
|
3976
|
-
|
3977
|
-
|
3978
|
-
|
3979
|
-
|
3980
|
-
|
3981
|
-
|
3982
|
-
|
3983
|
-
|
3984
|
-
|
3985
|
-
|
3986
|
-
|
3987
|
-
|
3988
|
-
|
3989
|
-
|
3990
|
-
|
3991
|
-
|
3992
|
-
|
641
|
+
const ResourceMetadataMap& resource_metadata_map = p.second;
|
642
|
+
type_url_storage.emplace_back(
|
643
|
+
absl::StrCat("type.googleapis.com/", type_url));
|
644
|
+
for (const auto& q : resource_metadata_map) {
|
645
|
+
absl::string_view resource_name = q.first;
|
646
|
+
const ResourceMetadata& metadata = *q.second;
|
647
|
+
auto* entry =
|
648
|
+
envoy_service_status_v3_ClientConfig_add_generic_xds_configs(
|
649
|
+
client_config, context.arena);
|
650
|
+
envoy_service_status_v3_ClientConfig_GenericXdsConfig_set_type_url(
|
651
|
+
entry, StdStringToUpbString(type_url_storage.back()));
|
652
|
+
envoy_service_status_v3_ClientConfig_GenericXdsConfig_set_name(
|
653
|
+
entry, StdStringToUpbString(resource_name));
|
654
|
+
envoy_service_status_v3_ClientConfig_GenericXdsConfig_set_client_status(
|
655
|
+
entry, metadata.client_status);
|
656
|
+
if (!metadata.serialized_proto.empty()) {
|
657
|
+
envoy_service_status_v3_ClientConfig_GenericXdsConfig_set_version_info(
|
658
|
+
entry, StdStringToUpbString(metadata.version));
|
659
|
+
envoy_service_status_v3_ClientConfig_GenericXdsConfig_set_last_updated(
|
660
|
+
entry, GrpcMillisToTimestamp(context, metadata.update_time));
|
661
|
+
auto* any_field =
|
662
|
+
envoy_service_status_v3_ClientConfig_GenericXdsConfig_mutable_xds_config(
|
663
|
+
entry, context.arena);
|
664
|
+
google_protobuf_Any_set_type_url(
|
665
|
+
any_field, StdStringToUpbString(type_url_storage.back()));
|
666
|
+
google_protobuf_Any_set_value(
|
667
|
+
any_field, StdStringToUpbString(metadata.serialized_proto));
|
668
|
+
}
|
669
|
+
if (metadata.client_status == XdsApi::ResourceMetadata::NACKED) {
|
670
|
+
auto* update_failure_state =
|
671
|
+
envoy_admin_v3_UpdateFailureState_new(context.arena);
|
672
|
+
envoy_admin_v3_UpdateFailureState_set_details(
|
673
|
+
update_failure_state,
|
674
|
+
StdStringToUpbString(metadata.failed_details));
|
675
|
+
envoy_admin_v3_UpdateFailureState_set_version_info(
|
676
|
+
update_failure_state,
|
677
|
+
StdStringToUpbString(metadata.failed_version));
|
678
|
+
envoy_admin_v3_UpdateFailureState_set_last_update_attempt(
|
679
|
+
update_failure_state,
|
680
|
+
GrpcMillisToTimestamp(context, metadata.failed_update_time));
|
681
|
+
envoy_service_status_v3_ClientConfig_GenericXdsConfig_set_error_state(
|
682
|
+
entry, update_failure_state);
|
683
|
+
}
|
3993
684
|
}
|
3994
685
|
}
|
3995
686
|
// Serialize the upb message to bytes
|