grpc 1.35.0 → 1.38.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +168 -131
- data/include/grpc/event_engine/README.md +38 -0
- data/include/grpc/event_engine/channel_args.h +28 -0
- data/include/grpc/event_engine/event_engine.h +336 -0
- data/include/grpc/event_engine/port.h +39 -0
- data/include/grpc/event_engine/slice_allocator.h +81 -0
- data/include/grpc/grpc.h +15 -1
- data/include/grpc/grpc_security.h +16 -11
- data/include/grpc/grpc_security_constants.h +14 -0
- data/include/grpc/impl/codegen/grpc_types.h +11 -0
- data/include/grpc/impl/codegen/port_platform.h +7 -0
- data/include/grpc/module.modulemap +14 -14
- data/src/core/ext/filters/client_channel/backup_poller.cc +3 -3
- data/src/core/ext/filters/client_channel/channel_connectivity.cc +177 -202
- data/src/core/ext/filters/client_channel/client_channel.cc +740 -3185
- data/src/core/ext/filters/client_channel/client_channel.h +488 -56
- data/src/core/ext/filters/client_channel/client_channel_channelz.h +1 -1
- data/src/core/ext/filters/client_channel/client_channel_factory.h +2 -1
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +4 -1
- data/src/core/ext/filters/client_channel/config_selector.h +10 -2
- data/src/core/ext/filters/client_channel/connector.h +1 -1
- data/src/core/ext/filters/client_channel/dynamic_filters.cc +18 -14
- data/src/core/ext/filters/client_channel/dynamic_filters.h +3 -3
- data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +24 -142
- data/src/core/ext/filters/client_channel/global_subchannel_pool.h +15 -10
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +26 -27
- data/src/core/ext/filters/client_channel/health/health_check_client.h +27 -26
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +26 -23
- data/src/core/ext/filters/client_channel/lb_policy.cc +4 -1
- data/src/core/ext/filters/client_channel/lb_policy.h +4 -4
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +6 -6
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +49 -48
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +1 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +2 -3
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +2 -1
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +5 -5
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +22 -18
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +23 -0
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +27 -0
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +4 -4
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +15 -15
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +318 -193
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_args.h +5 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +30 -47
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +32 -47
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +316 -171
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +4 -4
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +1 -1
- data/src/core/ext/filters/client_channel/local_subchannel_pool.cc +27 -67
- data/src/core/ext/filters/client_channel/local_subchannel_pool.h +10 -9
- data/src/core/ext/filters/client_channel/resolver.cc +5 -5
- data/src/core/ext/filters/client_channel/resolver.h +3 -14
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +59 -60
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +3 -3
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +4 -4
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +17 -15
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +67 -74
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +1 -1
- 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 +33 -23
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +38 -43
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +7 -5
- data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +379 -0
- 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 +346 -178
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +32 -239
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +20 -49
- data/src/core/ext/filters/client_channel/retry_filter.cc +2188 -0
- data/src/core/ext/filters/client_channel/retry_filter.h +30 -0
- data/src/core/ext/filters/client_channel/retry_service_config.cc +287 -0
- data/src/core/ext/filters/client_channel/retry_service_config.h +90 -0
- data/src/core/ext/filters/client_channel/server_address.cc +10 -1
- data/src/core/ext/filters/client_channel/server_address.h +31 -0
- data/src/core/ext/filters/client_channel/service_config.cc +15 -14
- data/src/core/ext/filters/client_channel/service_config.h +7 -6
- data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +5 -4
- data/src/core/ext/filters/client_channel/service_config_parser.cc +6 -6
- data/src/core/ext/filters/client_channel/service_config_parser.h +7 -4
- data/src/core/ext/filters/client_channel/subchannel.cc +86 -162
- data/src/core/ext/filters/client_channel/subchannel.h +68 -99
- data/src/core/ext/filters/client_channel/subchannel_pool_interface.cc +16 -2
- data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +10 -8
- data/src/core/ext/filters/client_idle/client_idle_filter.cc +17 -16
- data/src/core/ext/filters/deadline/deadline_filter.cc +10 -10
- data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +501 -0
- data/src/core/ext/filters/fault_injection/fault_injection_filter.h +39 -0
- data/src/core/ext/filters/fault_injection/service_config_parser.cc +189 -0
- data/src/core/ext/filters/fault_injection/service_config_parser.h +85 -0
- data/src/core/ext/filters/http/client/http_client_filter.cc +28 -21
- data/src/core/ext/filters/http/client_authority_filter.cc +3 -3
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +23 -22
- data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +21 -21
- data/src/core/ext/filters/http/server/http_server_filter.cc +27 -23
- data/src/core/ext/filters/max_age/max_age_filter.cc +47 -42
- data/src/core/ext/filters/message_size/message_size_filter.cc +14 -11
- data/src/core/ext/filters/message_size/message_size_filter.h +1 -1
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +5 -4
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +8 -8
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +7 -7
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +5 -4
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +2 -2
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +6 -5
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +507 -196
- data/src/core/ext/transport/chttp2/server/chttp2_server.h +11 -2
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +13 -4
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +3 -3
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +64 -21
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +167 -122
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +12 -1
- data/src/core/ext/transport/chttp2/transport/context_list.cc +4 -5
- data/src/core/ext/transport/chttp2/transport/context_list.h +4 -4
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +3 -3
- data/src/core/ext/transport/chttp2/transport/flow_control.h +8 -8
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +13 -9
- data/src/core/ext/transport/chttp2/transport/frame_data.h +10 -10
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +7 -8
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +6 -6
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +7 -8
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +7 -6
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +7 -7
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +6 -6
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +6 -5
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +6 -6
- data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +4 -6
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +4 -6
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +237 -208
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +10 -10
- data/src/core/ext/transport/chttp2/transport/hpack_table.cc +4 -3
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +4 -4
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +2 -2
- data/src/core/ext/transport/chttp2/transport/internal.h +32 -27
- data/src/core/ext/transport/chttp2/transport/parsing.cc +63 -56
- data/src/core/ext/transport/chttp2/transport/writing.cc +7 -3
- data/src/core/ext/transport/inproc/inproc_transport.cc +30 -29
- data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.c +406 -0
- data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.h +1459 -0
- data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c +350 -0
- data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.h +1348 -0
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +11 -16
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +42 -59
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.c +3 -2
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.h +15 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +25 -1
- data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +75 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.c +2 -2
- data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.h +9 -9
- data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c +7 -7
- data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.h +28 -13
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +6 -0
- 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 +0 -1
- data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +11 -5
- data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.h +41 -7
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +23 -21
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +122 -77
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +13 -9
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +37 -5
- data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.c +144 -0
- data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.h +488 -0
- data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.c +141 -0
- data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.h +452 -0
- data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +11 -9
- data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +44 -27
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +57 -16
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +150 -0
- data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/extensions/clusters/aggregate/v3/cluster.upb.c +29 -0
- data/src/core/ext/upb-generated/envoy/extensions/clusters/aggregate/v3/cluster.upb.h +67 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.c +79 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.h +268 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c +78 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.h +281 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +41 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +113 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +19 -21
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +64 -51
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +16 -13
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +50 -18
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.c +4 -7
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.h +0 -17
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.c +30 -23
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.h +85 -73
- data/src/core/ext/upb-generated/envoy/service/endpoint/v3/eds.upb.c +0 -3
- data/src/core/ext/upb-generated/envoy/service/listener/v3/lds.upb.c +0 -3
- data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/service/route/v3/rds.upb.c +0 -2
- data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.c +93 -0
- data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.h +323 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.c +36 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.h +90 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.c +46 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.h +124 -0
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c +21 -4
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.h +29 -0
- data/src/core/ext/upb-generated/udpa/type/v1/typed_struct.upb.c +33 -0
- data/src/core/ext/upb-generated/udpa/type/v1/typed_struct.upb.h +77 -0
- data/src/core/ext/upb-generated/{udpa/core/v1 → xds/core/v3}/authority.upb.c +5 -5
- data/src/core/ext/upb-generated/xds/core/v3/authority.upb.h +60 -0
- data/src/core/ext/upb-generated/xds/core/v3/collection_entry.upb.c +52 -0
- data/src/core/ext/upb-generated/xds/core/v3/collection_entry.upb.h +143 -0
- data/src/core/ext/upb-generated/xds/core/v3/context_params.upb.c +42 -0
- data/src/core/ext/upb-generated/xds/core/v3/context_params.upb.h +84 -0
- data/src/core/ext/upb-generated/{udpa/core/v1 → xds/core/v3}/resource.upb.c +9 -9
- data/src/core/ext/upb-generated/xds/core/v3/resource.upb.h +94 -0
- data/src/core/ext/upb-generated/xds/core/v3/resource_locator.upb.c +54 -0
- data/src/core/ext/upb-generated/xds/core/v3/resource_locator.upb.h +166 -0
- data/src/core/ext/upb-generated/xds/core/v3/resource_name.upb.c +36 -0
- data/src/core/ext/upb-generated/xds/core/v3/resource_name.upb.h +85 -0
- data/src/core/ext/upbdefs-generated/envoy/admin/v3/config_dump.upbdefs.c +354 -0
- data/src/core/ext/upbdefs-generated/envoy/admin/v3/config_dump.upbdefs.h +140 -0
- data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.c +168 -171
- data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.c +383 -0
- data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.h +115 -0
- data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.c +405 -420
- data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.h +2 -2
- data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/outlier_detection.upbdefs.c +12 -9
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.c +177 -171
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.h +10 -0
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.c +88 -88
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.c +153 -153
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +10 -7
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/proxy_protocol.upbdefs.c +4 -7
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/substitution_format_string.upbdefs.c +33 -20
- data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint.upbdefs.c +56 -59
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.c +116 -111
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener_components.upbdefs.c +129 -121
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/udp_listener_config.upbdefs.c +21 -24
- data/src/core/ext/upbdefs-generated/envoy/config/metrics/v3/stats.upbdefs.c +141 -0
- data/src/core/ext/upbdefs-generated/envoy/config/metrics/v3/stats.upbdefs.h +70 -0
- data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.c +141 -0
- data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.h +70 -0
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.c +17 -13
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +753 -724
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.h +10 -0
- data/src/core/ext/upbdefs-generated/envoy/config/trace/v3/http_tracer.upbdefs.c +22 -25
- data/src/core/ext/upbdefs-generated/envoy/extensions/clusters/aggregate/v3/cluster.upbdefs.c +51 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/clusters/aggregate/v3/cluster.upbdefs.h +35 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/common/fault/v3/fault.upbdefs.c +102 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/common/fault/v3/fault.upbdefs.h +55 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.c +120 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.h +45 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.c +76 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.h +35 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +371 -377
- data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/cert.upbdefs.c +12 -16
- data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.c +112 -108
- data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/secret.upbdefs.c +45 -53
- data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +177 -180
- data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/discovery.upbdefs.c +92 -102
- data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/discovery.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/service/endpoint/v3/eds.upbdefs.c +32 -42
- data/src/core/ext/upbdefs-generated/envoy/service/listener/v3/lds.upbdefs.c +30 -40
- data/src/core/ext/upbdefs-generated/envoy/service/load_stats/v3/lrs.upbdefs.c +4 -7
- data/src/core/ext/upbdefs-generated/envoy/service/route/v3/rds.upbdefs.c +38 -44
- data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.c +130 -0
- data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.h +50 -0
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/node.upbdefs.c +56 -0
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/node.upbdefs.h +35 -0
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/string.upbdefs.c +30 -33
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/struct.upbdefs.c +63 -0
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/struct.upbdefs.h +40 -0
- data/src/core/ext/upbdefs-generated/udpa/type/v1/typed_struct.upbdefs.c +44 -0
- data/src/core/ext/upbdefs-generated/udpa/type/v1/typed_struct.upbdefs.h +35 -0
- data/src/core/ext/upbdefs-generated/validate/validate.upbdefs.c +14 -11
- data/src/core/ext/upbdefs-generated/xds/core/v3/authority.upbdefs.c +42 -0
- data/src/core/ext/upbdefs-generated/xds/core/v3/authority.upbdefs.h +35 -0
- data/src/core/ext/upbdefs-generated/xds/core/v3/collection_entry.upbdefs.c +62 -0
- data/src/core/ext/upbdefs-generated/xds/core/v3/collection_entry.upbdefs.h +40 -0
- data/src/core/ext/upbdefs-generated/xds/core/v3/context_params.upbdefs.c +45 -0
- data/src/core/ext/upbdefs-generated/xds/core/v3/context_params.upbdefs.h +40 -0
- data/src/core/ext/upbdefs-generated/xds/core/v3/resource.upbdefs.c +49 -0
- data/src/core/ext/upbdefs-generated/xds/core/v3/resource.upbdefs.h +35 -0
- data/src/core/ext/upbdefs-generated/xds/core/v3/resource_locator.upbdefs.c +67 -0
- data/src/core/ext/upbdefs-generated/xds/core/v3/resource_locator.upbdefs.h +40 -0
- data/src/core/ext/upbdefs-generated/xds/core/v3/resource_name.upbdefs.c +50 -0
- data/src/core/ext/upbdefs-generated/xds/core/v3/resource_name.upbdefs.h +35 -0
- data/src/core/ext/xds/certificate_provider_factory.h +1 -1
- data/src/core/ext/xds/certificate_provider_store.h +3 -3
- data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +3 -3
- data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +2 -2
- data/src/core/ext/xds/xds_api.cc +2179 -688
- data/src/core/ext/xds/xds_api.h +326 -124
- data/src/core/ext/xds/xds_bootstrap.cc +115 -142
- data/src/core/ext/xds/xds_bootstrap.h +24 -17
- data/src/core/ext/xds/xds_certificate_provider.cc +184 -78
- data/src/core/ext/xds/xds_certificate_provider.h +84 -45
- data/src/core/ext/xds/xds_channel_args.h +5 -2
- data/src/core/ext/xds/xds_client.cc +462 -183
- data/src/core/ext/xds/xds_client.h +65 -22
- data/src/core/ext/xds/xds_client_stats.cc +2 -1
- data/src/core/ext/xds/xds_client_stats.h +5 -4
- data/src/core/ext/xds/xds_http_fault_filter.cc +226 -0
- data/src/core/ext/xds/xds_http_fault_filter.h +63 -0
- data/src/core/ext/xds/xds_http_filters.cc +114 -0
- data/src/core/ext/xds/xds_http_filters.h +130 -0
- data/src/core/ext/xds/xds_server_config_fetcher.cc +444 -29
- data/src/core/lib/{iomgr → address_utils}/parse_address.cc +17 -17
- data/src/core/lib/{iomgr → address_utils}/parse_address.h +7 -7
- data/src/core/lib/{iomgr → address_utils}/sockaddr_utils.cc +108 -5
- data/src/core/lib/{iomgr → address_utils}/sockaddr_utils.h +26 -6
- data/src/core/lib/channel/channel_stack.cc +22 -9
- data/src/core/lib/channel/channel_stack.h +17 -9
- data/src/core/lib/channel/channel_stack_builder.cc +2 -2
- data/src/core/lib/channel/channel_stack_builder.h +1 -1
- data/src/core/lib/channel/channelz.cc +108 -12
- data/src/core/lib/channel/channelz.h +30 -1
- data/src/core/lib/channel/channelz_registry.cc +14 -0
- data/src/core/lib/channel/connected_channel.cc +4 -4
- data/src/core/lib/channel/handshaker.cc +9 -50
- data/src/core/lib/channel/handshaker.h +6 -23
- data/src/core/lib/channel/status_util.cc +12 -2
- data/src/core/lib/channel/status_util.h +5 -0
- data/src/core/lib/event_engine/slice_allocator.cc +59 -0
- data/src/core/lib/event_engine/sockaddr.cc +38 -0
- data/src/core/lib/gpr/log.cc +6 -1
- data/src/core/lib/gpr/sync_abseil.cc +3 -6
- data/src/core/lib/gpr/sync_windows.cc +2 -2
- data/src/core/lib/gprpp/atomic.h +3 -3
- data/src/core/lib/gprpp/dual_ref_counted.h +3 -3
- data/src/core/lib/gprpp/mpscq.cc +2 -2
- data/src/core/lib/gprpp/ref_counted.h +29 -15
- data/src/core/lib/gprpp/ref_counted_ptr.h +2 -0
- data/src/core/lib/gprpp/status_helper.cc +407 -0
- data/src/core/lib/gprpp/status_helper.h +180 -0
- data/src/core/lib/gprpp/sync.h +129 -40
- data/src/core/lib/gprpp/thd.h +1 -1
- data/src/core/lib/gprpp/time_util.cc +77 -0
- data/src/core/lib/gprpp/time_util.h +42 -0
- data/src/core/lib/http/httpcli.cc +11 -11
- data/src/core/lib/http/httpcli_security_connector.cc +13 -9
- data/src/core/lib/http/parser.cc +16 -16
- data/src/core/lib/http/parser.h +4 -4
- data/src/core/lib/iomgr/buffer_list.cc +7 -9
- data/src/core/lib/iomgr/buffer_list.h +5 -6
- data/src/core/lib/iomgr/call_combiner.cc +15 -12
- data/src/core/lib/iomgr/call_combiner.h +12 -14
- data/src/core/lib/iomgr/cfstream_handle.cc +5 -5
- data/src/core/lib/iomgr/cfstream_handle.h +1 -1
- data/src/core/lib/iomgr/closure.h +7 -6
- data/src/core/lib/iomgr/combiner.cc +14 -12
- data/src/core/lib/iomgr/combiner.h +2 -2
- data/src/core/lib/iomgr/endpoint.cc +1 -1
- data/src/core/lib/iomgr/endpoint.h +2 -2
- data/src/core/lib/iomgr/endpoint_cfstream.cc +11 -13
- data/src/core/lib/iomgr/endpoint_pair_windows.cc +1 -1
- data/src/core/lib/iomgr/error.cc +167 -61
- data/src/core/lib/iomgr/error.h +218 -107
- data/src/core/lib/iomgr/error_cfstream.cc +3 -2
- data/src/core/lib/iomgr/error_cfstream.h +2 -2
- data/src/core/lib/iomgr/error_internal.h +5 -1
- data/src/core/lib/iomgr/ev_apple.cc +16 -13
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +22 -22
- data/src/core/lib/iomgr/ev_epollex_linux.cc +52 -49
- data/src/core/lib/iomgr/ev_poll_posix.cc +26 -23
- data/src/core/lib/iomgr/ev_posix.cc +12 -11
- data/src/core/lib/iomgr/ev_posix.h +9 -9
- data/src/core/lib/iomgr/exec_ctx.cc +10 -6
- data/src/core/lib/iomgr/exec_ctx.h +1 -1
- data/src/core/lib/iomgr/executor.cc +8 -8
- data/src/core/lib/iomgr/executor.h +2 -2
- data/src/core/lib/iomgr/iomgr.cc +1 -1
- data/src/core/lib/iomgr/iomgr.h +1 -1
- data/src/core/lib/iomgr/iomgr_custom.cc +1 -1
- data/src/core/lib/iomgr/iomgr_internal.cc +2 -2
- data/src/core/lib/iomgr/iomgr_internal.h +3 -3
- data/src/core/lib/iomgr/iomgr_posix.cc +1 -2
- data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +2 -3
- data/src/core/lib/iomgr/iomgr_windows.cc +1 -1
- data/src/core/lib/iomgr/load_file.cc +4 -4
- data/src/core/lib/iomgr/load_file.h +2 -2
- data/src/core/lib/iomgr/lockfree_event.cc +5 -5
- data/src/core/lib/iomgr/lockfree_event.h +1 -1
- data/src/core/lib/iomgr/pollset.cc +5 -5
- data/src/core/lib/iomgr/pollset.h +9 -9
- data/src/core/lib/iomgr/pollset_custom.cc +5 -5
- data/src/core/lib/iomgr/pollset_windows.cc +5 -5
- data/src/core/lib/iomgr/port.h +1 -1
- data/src/core/lib/iomgr/python_util.h +1 -1
- data/src/core/lib/iomgr/resolve_address.cc +3 -3
- data/src/core/lib/iomgr/resolve_address.h +6 -6
- data/src/core/lib/iomgr/resolve_address_custom.cc +10 -9
- data/src/core/lib/iomgr/resolve_address_custom.h +3 -3
- data/src/core/lib/iomgr/resolve_address_posix.cc +3 -3
- data/src/core/lib/iomgr/resolve_address_windows.cc +4 -4
- data/src/core/lib/iomgr/resource_quota.cc +12 -11
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +23 -20
- data/src/core/lib/iomgr/socket_utils_posix.h +20 -20
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +4 -4
- data/src/core/lib/iomgr/tcp_client_custom.cc +5 -6
- data/src/core/lib/iomgr/tcp_client_posix.cc +16 -18
- data/src/core/lib/iomgr/tcp_client_posix.h +3 -4
- data/src/core/lib/iomgr/tcp_client_windows.cc +5 -5
- data/src/core/lib/iomgr/tcp_custom.cc +14 -16
- data/src/core/lib/iomgr/tcp_custom.h +13 -12
- data/src/core/lib/iomgr/tcp_posix.cc +41 -42
- data/src/core/lib/iomgr/tcp_server.cc +6 -6
- data/src/core/lib/iomgr/tcp_server.h +12 -11
- data/src/core/lib/iomgr/tcp_server_custom.cc +23 -21
- data/src/core/lib/iomgr/tcp_server_posix.cc +22 -21
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +13 -12
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +19 -17
- data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +9 -9
- data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc +4 -4
- data/src/core/lib/iomgr/tcp_server_windows.cc +26 -25
- data/src/core/lib/iomgr/tcp_uv.cc +27 -25
- data/src/core/lib/iomgr/tcp_windows.cc +13 -13
- data/src/core/lib/iomgr/tcp_windows.h +2 -2
- data/src/core/lib/iomgr/timer_custom.cc +2 -1
- data/src/core/lib/iomgr/timer_custom.h +1 -1
- data/src/core/lib/iomgr/timer_generic.cc +8 -8
- data/src/core/lib/iomgr/timer_manager.cc +1 -1
- data/src/core/lib/iomgr/udp_server.cc +21 -20
- data/src/core/lib/iomgr/unix_sockets_posix.cc +3 -3
- data/src/core/lib/iomgr/unix_sockets_posix.h +2 -2
- data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +10 -7
- data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +3 -3
- data/src/core/lib/iomgr/wakeup_fd_nospecial.cc +1 -1
- data/src/core/lib/iomgr/wakeup_fd_pipe.cc +4 -4
- data/src/core/lib/iomgr/wakeup_fd_posix.cc +3 -3
- data/src/core/lib/iomgr/wakeup_fd_posix.h +8 -6
- data/src/core/lib/iomgr/work_serializer.h +17 -1
- data/src/core/lib/json/json.h +1 -1
- data/src/core/lib/json/json_reader.cc +4 -4
- data/src/core/lib/matchers/matchers.cc +339 -0
- data/src/core/lib/matchers/matchers.h +160 -0
- data/src/core/lib/security/credentials/alts/alts_credentials.cc +2 -1
- data/src/core/lib/security/credentials/alts/alts_credentials.h +1 -1
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +4 -4
- data/src/core/lib/security/credentials/composite/composite_credentials.h +2 -2
- data/src/core/lib/security/credentials/credentials.h +4 -3
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +18 -14
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.h +13 -11
- data/src/core/lib/security/credentials/external/aws_request_signer.cc +2 -1
- data/src/core/lib/security/credentials/external/aws_request_signer.h +1 -1
- data/src/core/lib/security/credentials/external/external_account_credentials.cc +17 -14
- data/src/core/lib/security/credentials/external/external_account_credentials.h +9 -8
- data/src/core/lib/security/credentials/external/file_external_account_credentials.cc +6 -5
- data/src/core/lib/security/credentials/external/file_external_account_credentials.h +4 -3
- data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +9 -9
- data/src/core/lib/security/credentials/external/url_external_account_credentials.h +9 -7
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +3 -3
- data/src/core/lib/security/credentials/fake/fake_credentials.h +2 -2
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +16 -15
- data/src/core/lib/security/credentials/iam/iam_credentials.cc +2 -2
- data/src/core/lib/security/credentials/iam/iam_credentials.h +2 -2
- data/src/core/lib/security/credentials/insecure/insecure_credentials.cc +2 -2
- data/src/core/lib/security/credentials/jwt/json_token.cc +2 -5
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +3 -3
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +2 -2
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +7 -8
- data/src/core/lib/security/credentials/local/local_credentials.cc +2 -1
- data/src/core/lib/security/credentials/local/local_credentials.h +1 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +21 -19
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +5 -5
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +5 -5
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -2
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +2 -1
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +1 -1
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +8 -7
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h +9 -9
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +19 -13
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +4 -0
- data/src/core/lib/security/credentials/tls/tls_credentials.cc +2 -1
- data/src/core/lib/security/credentials/tls/tls_credentials.h +1 -1
- data/src/core/lib/security/credentials/xds/xds_credentials.cc +130 -61
- data/src/core/lib/security/credentials/xds/xds_credentials.h +3 -3
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +13 -3
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +13 -3
- data/src/core/lib/security/security_connector/insecure/insecure_security_connector.cc +5 -5
- data/src/core/lib/security/security_connector/insecure/insecure_security_connector.h +12 -2
- data/src/core/lib/security/security_connector/load_system_roots_linux.cc +1 -1
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +14 -4
- data/src/core/lib/security/security_connector/security_connector.h +9 -4
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +16 -6
- data/src/core/lib/security/security_connector/ssl_utils.cc +31 -8
- data/src/core/lib/security/security_connector/ssl_utils.h +4 -4
- data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +88 -74
- data/src/core/lib/security/security_connector/tls/tls_security_connector.h +66 -48
- data/src/core/lib/security/transport/client_auth_filter.cc +18 -10
- data/src/core/lib/security/transport/secure_endpoint.cc +4 -4
- data/src/core/lib/security/transport/security_handshaker.cc +66 -37
- data/src/core/lib/security/transport/server_auth_filter.cc +24 -11
- data/src/core/lib/security/transport/tsi_error.cc +2 -1
- data/src/core/lib/security/transport/tsi_error.h +2 -1
- data/src/core/lib/security/util/json_util.cc +2 -2
- data/src/core/lib/security/util/json_util.h +1 -1
- data/src/core/lib/slice/slice_intern.cc +5 -6
- data/src/core/lib/surface/call.cc +46 -45
- data/src/core/lib/surface/call.h +2 -2
- data/src/core/lib/surface/channel.cc +6 -6
- data/src/core/lib/surface/channel.h +6 -5
- data/src/core/lib/surface/channel_ping.cc +1 -1
- data/src/core/lib/surface/completion_queue.cc +46 -47
- data/src/core/lib/surface/completion_queue.h +2 -1
- data/src/core/lib/surface/init.cc +13 -15
- data/src/core/lib/surface/lame_client.cc +43 -24
- data/src/core/lib/surface/lame_client.h +4 -3
- data/src/core/lib/surface/server.cc +71 -58
- data/src/core/lib/surface/server.h +91 -28
- data/src/core/lib/surface/validate_metadata.cc +7 -7
- data/src/core/lib/surface/validate_metadata.h +3 -2
- data/src/core/lib/surface/version.cc +4 -2
- data/src/core/lib/transport/byte_stream.cc +5 -5
- data/src/core/lib/transport/byte_stream.h +8 -8
- data/src/core/lib/transport/connectivity_state.cc +1 -1
- data/src/core/lib/transport/error_utils.cc +19 -8
- data/src/core/lib/transport/error_utils.h +11 -5
- data/src/core/lib/transport/metadata.cc +6 -2
- data/src/core/lib/transport/metadata_batch.cc +64 -37
- data/src/core/lib/transport/metadata_batch.h +33 -18
- data/src/core/lib/transport/transport.cc +4 -3
- data/src/core/lib/transport/transport.h +4 -4
- data/src/core/lib/transport/transport_op_string.cc +5 -5
- data/src/core/plugin_registry/grpc_plugin_registry.cc +12 -0
- data/src/core/tsi/alts/crypt/gsec.h +4 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +23 -28
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +23 -27
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +1 -1
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h +2 -1
- data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +1 -3
- data/src/core/tsi/fake_transport_security.cc +11 -2
- data/src/core/tsi/ssl/session_cache/ssl_session.h +0 -3
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +0 -2
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +2 -4
- data/src/core/tsi/ssl_transport_security.cc +32 -17
- data/src/core/tsi/ssl_transport_security.h +3 -7
- data/src/ruby/bin/math_services_pb.rb +1 -1
- data/src/ruby/ext/grpc/extconf.rb +9 -1
- data/src/ruby/ext/grpc/rb_channel.c +10 -1
- data/src/ruby/ext/grpc/rb_channel_credentials.c +11 -1
- data/src/ruby/ext/grpc/rb_channel_credentials.h +4 -0
- data/src/ruby/ext/grpc/rb_compression_options.c +1 -1
- data/src/ruby/ext/grpc/rb_enable_cpp.cc +1 -1
- data/src/ruby/ext/grpc/rb_grpc.c +4 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +4 -1
- data/src/ruby/ext/grpc/rb_server.c +13 -1
- data/src/ruby/ext/grpc/rb_server_credentials.c +19 -3
- data/src/ruby/ext/grpc/rb_server_credentials.h +4 -0
- data/src/ruby/ext/grpc/rb_xds_channel_credentials.c +215 -0
- data/src/ruby/ext/grpc/rb_xds_channel_credentials.h +35 -0
- data/src/ruby/ext/grpc/rb_xds_server_credentials.c +169 -0
- data/src/ruby/ext/grpc/rb_xds_server_credentials.h +35 -0
- data/src/ruby/lib/grpc/generic/client_stub.rb +4 -2
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +1 -1
- data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +7 -0
- data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +6 -6
- data/src/ruby/spec/call_spec.rb +1 -1
- data/src/ruby/spec/channel_credentials_spec.rb +32 -0
- data/src/ruby/spec/channel_spec.rb +17 -6
- data/src/ruby/spec/client_auth_spec.rb +27 -1
- data/src/ruby/spec/errors_spec.rb +1 -1
- data/src/ruby/spec/generic/active_call_spec.rb +2 -2
- data/src/ruby/spec/generic/client_stub_spec.rb +4 -4
- data/src/ruby/spec/generic/rpc_server_spec.rb +1 -1
- data/src/ruby/spec/server_credentials_spec.rb +25 -0
- data/src/ruby/spec/server_spec.rb +22 -0
- data/third_party/abseil-cpp/absl/algorithm/container.h +3 -3
- data/third_party/abseil-cpp/absl/base/attributes.h +24 -4
- data/third_party/abseil-cpp/absl/base/call_once.h +2 -9
- data/third_party/abseil-cpp/absl/base/config.h +37 -9
- data/third_party/abseil-cpp/absl/base/dynamic_annotations.h +24 -10
- data/third_party/abseil-cpp/absl/base/internal/direct_mmap.h +4 -1
- data/third_party/abseil-cpp/absl/base/internal/endian.h +61 -0
- data/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h +2 -3
- data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +34 -32
- data/third_party/abseil-cpp/absl/base/internal/raw_logging.h +16 -6
- data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +11 -2
- data/third_party/abseil-cpp/absl/base/internal/spinlock.h +14 -5
- data/third_party/abseil-cpp/absl/base/internal/spinlock_akaros.inc +2 -2
- data/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc +3 -3
- data/third_party/abseil-cpp/absl/base/internal/spinlock_posix.inc +2 -2
- data/third_party/abseil-cpp/absl/base/internal/spinlock_wait.h +11 -11
- data/third_party/abseil-cpp/absl/base/internal/spinlock_win32.inc +5 -5
- data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +1 -1
- data/third_party/abseil-cpp/absl/base/internal/thread_identity.cc +5 -2
- data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +43 -42
- data/third_party/abseil-cpp/absl/base/internal/throw_delegate.cc +111 -7
- data/third_party/abseil-cpp/absl/base/internal/unaligned_access.h +0 -76
- data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +1 -3
- data/third_party/abseil-cpp/absl/base/log_severity.h +4 -4
- data/third_party/abseil-cpp/absl/base/macros.h +11 -0
- data/third_party/abseil-cpp/absl/base/optimization.h +10 -7
- data/third_party/abseil-cpp/absl/base/options.h +1 -1
- data/third_party/abseil-cpp/absl/base/port.h +0 -1
- data/third_party/abseil-cpp/absl/base/thread_annotations.h +1 -1
- data/third_party/abseil-cpp/absl/container/fixed_array.h +2 -2
- data/third_party/abseil-cpp/absl/container/inlined_vector.h +5 -3
- data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +1 -1
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +5 -1
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +2 -1
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler_force_weak_definition.cc +2 -1
- data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +141 -66
- data/third_party/abseil-cpp/absl/container/internal/layout.h +4 -4
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +14 -1
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +136 -136
- data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +16 -12
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +5 -2
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_config.h +3 -12
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +6 -1
- data/third_party/abseil-cpp/absl/debugging/internal/symbolize.h +3 -5
- data/third_party/abseil-cpp/absl/debugging/symbolize_darwin.inc +2 -2
- data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +2 -2
- data/third_party/abseil-cpp/absl/hash/internal/city.cc +15 -12
- data/third_party/abseil-cpp/absl/hash/internal/city.h +1 -19
- data/third_party/abseil-cpp/absl/hash/internal/hash.cc +25 -10
- data/third_party/abseil-cpp/absl/hash/internal/hash.h +86 -37
- data/third_party/abseil-cpp/absl/hash/internal/wyhash.cc +111 -0
- data/third_party/abseil-cpp/absl/hash/internal/wyhash.h +48 -0
- data/third_party/abseil-cpp/absl/meta/type_traits.h +16 -2
- data/third_party/abseil-cpp/absl/numeric/bits.h +177 -0
- data/third_party/abseil-cpp/absl/numeric/int128.cc +3 -3
- data/third_party/abseil-cpp/absl/numeric/internal/bits.h +358 -0
- data/third_party/abseil-cpp/absl/numeric/internal/representation.h +55 -0
- data/third_party/abseil-cpp/absl/status/internal/status_internal.h +18 -0
- data/third_party/abseil-cpp/absl/status/internal/statusor_internal.h +4 -7
- data/third_party/abseil-cpp/absl/status/status.cc +29 -22
- data/third_party/abseil-cpp/absl/status/status.h +81 -20
- data/third_party/abseil-cpp/absl/status/statusor.h +3 -3
- data/third_party/abseil-cpp/absl/strings/charconv.cc +5 -5
- data/third_party/abseil-cpp/absl/strings/cord.cc +326 -371
- data/third_party/abseil-cpp/absl/strings/cord.h +182 -64
- data/third_party/abseil-cpp/absl/strings/escaping.cc +4 -4
- data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc +6 -6
- data/third_party/abseil-cpp/absl/strings/internal/cord_internal.cc +83 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +387 -17
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_flat.h +146 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_ring.cc +897 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_ring.h +589 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_ring_reader.h +114 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc +14 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +14 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc +15 -1
- data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +19 -4
- data/third_party/abseil-cpp/absl/strings/internal/str_format/checker.h +14 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +36 -18
- data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.h +14 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc +14 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h +14 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +15 -40
- data/third_party/abseil-cpp/absl/strings/internal/string_constant.h +64 -0
- data/third_party/abseil-cpp/absl/strings/match.cc +6 -3
- data/third_party/abseil-cpp/absl/strings/match.h +16 -6
- data/third_party/abseil-cpp/absl/strings/numbers.cc +132 -4
- data/third_party/abseil-cpp/absl/strings/numbers.h +10 -10
- data/third_party/abseil-cpp/absl/strings/str_join.h +1 -1
- data/third_party/abseil-cpp/absl/strings/str_split.h +38 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/futex.h +154 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc +1 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +2 -1
- data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc +2 -2
- data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +4 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc +1 -65
- data/third_party/abseil-cpp/absl/synchronization/internal/waiter.h +2 -6
- data/third_party/abseil-cpp/absl/synchronization/mutex.cc +71 -59
- data/third_party/abseil-cpp/absl/synchronization/mutex.h +79 -62
- data/third_party/abseil-cpp/absl/time/clock.cc +146 -130
- data/third_party/abseil-cpp/absl/time/clock.h +2 -2
- data/third_party/abseil-cpp/absl/time/duration.cc +3 -2
- data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h +7 -11
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc +7 -1
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +4 -4
- data/third_party/abseil-cpp/absl/time/time.cc +4 -3
- data/third_party/abseil-cpp/absl/time/time.h +26 -24
- data/third_party/abseil-cpp/absl/types/internal/variant.h +1 -1
- data/third_party/abseil-cpp/absl/types/variant.h +9 -4
- data/third_party/boringssl-with-bazel/err_data.c +742 -724
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bitstr.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bool.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_enum.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_int.c +5 -5
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +4 -11
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_octet.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_type.c +22 -10
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utctm.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_lib.c +16 -16
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_locl.h +35 -0
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_dec.c +28 -79
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +40 -86
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_fre.c +6 -17
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_new.c +10 -61
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_typ.c +0 -2
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_utl.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/bio/socket_helper.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/blake2/blake2.c +158 -0
- data/third_party/boringssl-with-bazel/src/crypto/bn_extra/bn_asn1.c +3 -10
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/ber.c +8 -9
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/cbs.c +60 -45
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_chacha20poly1305.c +6 -81
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_tls.c +1 -88
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/internal.h +101 -3
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/tls_cbc.c +119 -273
- data/third_party/boringssl-with-bazel/src/crypto/cpu-aarch64-win.c +41 -0
- data/third_party/boringssl-with-bazel/src/crypto/cpu-arm-linux.c +11 -2
- data/third_party/boringssl-with-bazel/src/crypto/cpu-arm.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/{dh → dh_extra}/dh_asn1.c +0 -0
- data/third_party/boringssl-with-bazel/src/crypto/{dh → dh_extra}/params.c +179 -0
- data/third_party/boringssl-with-bazel/src/crypto/digest_extra/digest_extra.c +25 -0
- data/third_party/boringssl-with-bazel/src/crypto/ec_extra/ec_asn1.c +2 -17
- data/third_party/boringssl-with-bazel/src/crypto/err/err.c +87 -80
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +4 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/bn.c +13 -20
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/div.c +2 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/internal.h +10 -2
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/cipher.c +32 -16
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/e_aes.c +25 -2
- data/third_party/boringssl-with-bazel/src/crypto/{dh → fipsmodule/dh}/check.c +0 -0
- data/third_party/boringssl-with-bazel/src/crypto/{dh → fipsmodule/dh}/dh.c +136 -213
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digests.c +10 -2
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/md32_common.h +4 -43
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +16 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +9 -2
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +0 -4
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +104 -93
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/internal.h +39 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md4/md4.c +43 -46
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/md5.c +43 -46
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cbc.c +33 -22
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cfb.c +9 -8
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ctr.c +9 -8
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm.c +17 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/internal.h +1 -22
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ofb.c +2 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +28 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +135 -43
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +26 -14
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +51 -32
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/fips.c +79 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +161 -9
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1.c +45 -48
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha256.c +38 -43
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +37 -45
- data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +121 -71
- data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +71 -41
- data/third_party/boringssl-with-bazel/src/crypto/internal.h +65 -0
- data/third_party/boringssl-with-bazel/src/crypto/mem.c +14 -0
- data/third_party/boringssl-with-bazel/src/crypto/obj/obj.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7_x509.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +95 -48
- data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305.c +10 -7
- data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305_arm.c +13 -11
- data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305_vec.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/{fipsmodule/is_fips.c → rand_extra/passive.c} +16 -11
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/rand_extra.c +5 -1
- data/third_party/boringssl-with-bazel/src/crypto/stack/stack.c +7 -13
- data/third_party/boringssl-with-bazel/src/crypto/thread_pthread.c +0 -28
- data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +19 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/rsa_pss.c +5 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_req.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_att.c +19 -25
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +4 -31
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_ext.c +10 -7
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +39 -89
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +17 -24
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_v3.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +29 -23
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_algor.c +21 -17
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_attrib.c +21 -34
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +6 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_pkey.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_pubkey.c +25 -22
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_val.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +39 -4
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_akey.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_alt.c +11 -10
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_bitst.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c +25 -25
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_cpols.c +4 -6
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_enum.c +2 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_genn.c +40 -20
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_ia5.c +3 -4
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_lib.c +25 -36
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_prn.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +7 -6
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +6 -6
- data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +0 -3
- data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +3 -3
- data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +737 -551
- data/third_party/boringssl-with-bazel/src/include/openssl/asn1t.h +0 -167
- data/third_party/boringssl-with-bazel/src/include/openssl/base.h +19 -5
- data/third_party/boringssl-with-bazel/src/include/openssl/blake2.h +62 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/bytestring.h +22 -7
- data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +15 -4
- data/third_party/boringssl-with-bazel/src/include/openssl/cpu.h +22 -32
- data/third_party/boringssl-with-bazel/src/include/openssl/crypto.h +24 -4
- data/third_party/boringssl-with-bazel/src/include/openssl/dh.h +56 -26
- data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +1 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/ec.h +20 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +19 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/err.h +3 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +13 -40
- data/third_party/boringssl-with-bazel/src/{crypto/x509/x509_r2x.c → include/openssl/evp_errors.h} +41 -58
- data/third_party/boringssl-with-bazel/src/include/openssl/obj.h +24 -5
- data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +2 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/pkcs8.h +9 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/rand.h +5 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/span.h +2 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +239 -37
- data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +28 -8
- data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +702 -219
- data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +141 -36
- data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +5 -0
- data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +444 -0
- data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +244 -1
- data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +47 -15
- data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +11 -20
- data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +159 -13
- data/third_party/boringssl-with-bazel/src/ssl/internal.h +253 -58
- data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +7 -1
- data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +0 -1
- data/third_party/boringssl-with-bazel/src/ssl/ssl_asn1.cc +7 -8
- data/third_party/boringssl-with-bazel/src/ssl/ssl_cert.cc +4 -6
- data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +23 -26
- data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +90 -25
- data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +7 -8
- data/third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc +2 -2
- data/third_party/boringssl-with-bazel/src/ssl/t1_enc.cc +5 -7
- data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +450 -104
- data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +34 -4
- data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +2 -2
- data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +48 -15
- data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +232 -85
- data/third_party/boringssl-with-bazel/src/ssl/tls_method.cc +4 -2
- data/third_party/xxhash/xxhash.h +5443 -0
- metadata +174 -95
- data/src/core/ext/upb-generated/udpa/core/v1/authority.upb.h +0 -60
- data/src/core/ext/upb-generated/udpa/core/v1/collection_entry.upb.c +0 -52
- data/src/core/ext/upb-generated/udpa/core/v1/collection_entry.upb.h +0 -143
- data/src/core/ext/upb-generated/udpa/core/v1/context_params.upb.c +0 -42
- data/src/core/ext/upb-generated/udpa/core/v1/context_params.upb.h +0 -84
- data/src/core/ext/upb-generated/udpa/core/v1/resource.upb.h +0 -94
- data/src/core/ext/upb-generated/udpa/core/v1/resource_locator.upb.c +0 -54
- data/src/core/ext/upb-generated/udpa/core/v1/resource_locator.upb.h +0 -173
- data/src/core/ext/upb-generated/udpa/core/v1/resource_name.upb.c +0 -36
- data/src/core/ext/upb-generated/udpa/core/v1/resource_name.upb.h +0 -92
- data/src/core/ext/upbdefs-generated/udpa/core/v1/authority.upbdefs.c +0 -42
- data/src/core/ext/upbdefs-generated/udpa/core/v1/authority.upbdefs.h +0 -35
- data/src/core/ext/upbdefs-generated/udpa/core/v1/collection_entry.upbdefs.c +0 -62
- data/src/core/ext/upbdefs-generated/udpa/core/v1/collection_entry.upbdefs.h +0 -40
- data/src/core/ext/upbdefs-generated/udpa/core/v1/context_params.upbdefs.c +0 -45
- data/src/core/ext/upbdefs-generated/udpa/core/v1/context_params.upbdefs.h +0 -40
- data/src/core/ext/upbdefs-generated/udpa/core/v1/resource.upbdefs.c +0 -49
- data/src/core/ext/upbdefs-generated/udpa/core/v1/resource.upbdefs.h +0 -35
- data/src/core/ext/upbdefs-generated/udpa/core/v1/resource_locator.upbdefs.c +0 -68
- data/src/core/ext/upbdefs-generated/udpa/core/v1/resource_locator.upbdefs.h +0 -40
- data/src/core/ext/upbdefs-generated/udpa/core/v1/resource_name.upbdefs.c +0 -51
- data/src/core/ext/upbdefs-generated/udpa/core/v1/resource_name.upbdefs.h +0 -35
- data/src/core/lib/iomgr/iomgr_posix.h +0 -26
- data/src/core/lib/iomgr/poller/eventmanager_libuv.cc +0 -88
- data/src/core/lib/iomgr/poller/eventmanager_libuv.h +0 -88
- data/src/core/lib/security/authorization/authorization_engine.cc +0 -177
- data/src/core/lib/security/authorization/authorization_engine.h +0 -84
- data/src/core/lib/security/authorization/evaluate_args.cc +0 -148
- data/src/core/lib/security/authorization/evaluate_args.h +0 -59
- data/src/core/lib/security/authorization/mock_cel/activation.h +0 -57
- data/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h +0 -44
- data/src/core/lib/security/authorization/mock_cel/cel_expression.h +0 -69
- data/src/core/lib/security/authorization/mock_cel/cel_value.h +0 -97
- data/src/core/lib/security/authorization/mock_cel/evaluator_core.h +0 -67
- data/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h +0 -57
- data/third_party/abseil-cpp/absl/base/internal/bits.h +0 -219
- data/third_party/abseil-cpp/absl/container/flat_hash_set.h +0 -504
- data/third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.inc +0 -249
- data/third_party/upb/upb/json_decode.c +0 -1443
- data/third_party/upb/upb/json_decode.h +0 -23
- data/third_party/upb/upb/json_encode.c +0 -713
- data/third_party/upb/upb/json_encode.h +0 -36
@@ -0,0 +1,40 @@
|
|
1
|
+
/* This file was generated by upbc (the upb compiler) from the input
|
2
|
+
* file:
|
3
|
+
*
|
4
|
+
* xds/core/v3/context_params.proto
|
5
|
+
*
|
6
|
+
* Do not edit -- your changes will be discarded when the file is
|
7
|
+
* regenerated. */
|
8
|
+
|
9
|
+
#ifndef XDS_CORE_V3_CONTEXT_PARAMS_PROTO_UPBDEFS_H_
|
10
|
+
#define XDS_CORE_V3_CONTEXT_PARAMS_PROTO_UPBDEFS_H_
|
11
|
+
|
12
|
+
#include "upb/def.h"
|
13
|
+
#include "upb/port_def.inc"
|
14
|
+
#ifdef __cplusplus
|
15
|
+
extern "C" {
|
16
|
+
#endif
|
17
|
+
|
18
|
+
#include "upb/def.h"
|
19
|
+
|
20
|
+
#include "upb/port_def.inc"
|
21
|
+
|
22
|
+
extern upb_def_init xds_core_v3_context_params_proto_upbdefinit;
|
23
|
+
|
24
|
+
UPB_INLINE const upb_msgdef *xds_core_v3_ContextParams_getmsgdef(upb_symtab *s) {
|
25
|
+
_upb_symtab_loaddefinit(s, &xds_core_v3_context_params_proto_upbdefinit);
|
26
|
+
return upb_symtab_lookupmsg(s, "xds.core.v3.ContextParams");
|
27
|
+
}
|
28
|
+
|
29
|
+
UPB_INLINE const upb_msgdef *xds_core_v3_ContextParams_ParamsEntry_getmsgdef(upb_symtab *s) {
|
30
|
+
_upb_symtab_loaddefinit(s, &xds_core_v3_context_params_proto_upbdefinit);
|
31
|
+
return upb_symtab_lookupmsg(s, "xds.core.v3.ContextParams.ParamsEntry");
|
32
|
+
}
|
33
|
+
|
34
|
+
#ifdef __cplusplus
|
35
|
+
} /* extern "C" */
|
36
|
+
#endif
|
37
|
+
|
38
|
+
#include "upb/port_undef.inc"
|
39
|
+
|
40
|
+
#endif /* XDS_CORE_V3_CONTEXT_PARAMS_PROTO_UPBDEFS_H_ */
|
@@ -0,0 +1,49 @@
|
|
1
|
+
/* This file was generated by upbc (the upb compiler) from the input
|
2
|
+
* file:
|
3
|
+
*
|
4
|
+
* xds/core/v3/resource.proto
|
5
|
+
*
|
6
|
+
* Do not edit -- your changes will be discarded when the file is
|
7
|
+
* regenerated. */
|
8
|
+
|
9
|
+
#include "upb/def.h"
|
10
|
+
#include "xds/core/v3/resource.upbdefs.h"
|
11
|
+
|
12
|
+
extern upb_def_init google_protobuf_any_proto_upbdefinit;
|
13
|
+
extern upb_def_init udpa_annotations_status_proto_upbdefinit;
|
14
|
+
extern upb_def_init xds_core_v3_resource_name_proto_upbdefinit;
|
15
|
+
extern const upb_msglayout xds_core_v3_Resource_msginit;
|
16
|
+
|
17
|
+
static const upb_msglayout *layouts[1] = {
|
18
|
+
&xds_core_v3_Resource_msginit,
|
19
|
+
};
|
20
|
+
|
21
|
+
static const char descriptor[332] = {'\n', '\032', 'x', 'd', 's', '/', 'c', 'o', 'r', 'e', '/', 'v', '3', '/', 'r', 'e', 's', 'o', 'u', 'r', 'c', 'e', '.', 'p', 'r',
|
22
|
+
'o', 't', 'o', '\022', '\013', 'x', 'd', 's', '.', 'c', 'o', 'r', 'e', '.', 'v', '3', '\032', '\031', 'g', 'o', 'o', 'g', 'l', 'e', '/',
|
23
|
+
'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'a', 'n', 'y', '.', 'p', 'r', 'o', 't', 'o', '\032', '\035', 'u', 'd', 'p', 'a', '/',
|
24
|
+
'a', 'n', 'n', 'o', 't', 'a', 't', 'i', 'o', 'n', 's', '/', 's', 't', 'a', 't', 'u', 's', '.', 'p', 'r', 'o', 't', 'o', '\032',
|
25
|
+
'\037', 'x', 'd', 's', '/', 'c', 'o', 'r', 'e', '/', 'v', '3', '/', 'r', 'e', 's', 'o', 'u', 'r', 'c', 'e', '_', 'n', 'a', 'm',
|
26
|
+
'e', '.', 'p', 'r', 'o', 't', 'o', '\"', '\205', '\001', '\n', '\010', 'R', 'e', 's', 'o', 'u', 'r', 'c', 'e', '\022', '-', '\n', '\004', 'n',
|
27
|
+
'a', 'm', 'e', '\030', '\001', ' ', '\001', '(', '\013', '2', '\031', '.', 'x', 'd', 's', '.', 'c', 'o', 'r', 'e', '.', 'v', '3', '.', 'R',
|
28
|
+
'e', 's', 'o', 'u', 'r', 'c', 'e', 'N', 'a', 'm', 'e', 'R', '\004', 'n', 'a', 'm', 'e', '\022', '\030', '\n', '\007', 'v', 'e', 'r', 's',
|
29
|
+
'i', 'o', 'n', '\030', '\002', ' ', '\001', '(', '\t', 'R', '\007', 'v', 'e', 'r', 's', 'i', 'o', 'n', '\022', '0', '\n', '\010', 'r', 'e', 's',
|
30
|
+
'o', 'u', 'r', 'c', 'e', '\030', '\003', ' ', '\001', '(', '\013', '2', '\024', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't',
|
31
|
+
'o', 'b', 'u', 'f', '.', 'A', 'n', 'y', 'R', '\010', 'r', 'e', 's', 'o', 'u', 'r', 'c', 'e', 'B', '6', '\n', '\033', 'c', 'o', 'm',
|
32
|
+
'.', 'g', 'i', 't', 'h', 'u', 'b', '.', 'u', 'd', 'p', 'a', '.', 'x', 'd', 's', '.', 'c', 'o', 'r', 'e', '.', 'v', '3', 'B',
|
33
|
+
'\r', 'R', 'e', 's', 'o', 'u', 'r', 'c', 'e', 'P', 'r', 'o', 't', 'o', 'P', '\001', '\272', '\200', '\310', '\321', '\006', '\002', '\010', '\001', 'b',
|
34
|
+
'\006', 'p', 'r', 'o', 't', 'o', '3',
|
35
|
+
};
|
36
|
+
|
37
|
+
static upb_def_init *deps[4] = {
|
38
|
+
&google_protobuf_any_proto_upbdefinit,
|
39
|
+
&udpa_annotations_status_proto_upbdefinit,
|
40
|
+
&xds_core_v3_resource_name_proto_upbdefinit,
|
41
|
+
NULL
|
42
|
+
};
|
43
|
+
|
44
|
+
upb_def_init xds_core_v3_resource_proto_upbdefinit = {
|
45
|
+
deps,
|
46
|
+
layouts,
|
47
|
+
"xds/core/v3/resource.proto",
|
48
|
+
UPB_STRVIEW_INIT(descriptor, 332)
|
49
|
+
};
|
@@ -0,0 +1,35 @@
|
|
1
|
+
/* This file was generated by upbc (the upb compiler) from the input
|
2
|
+
* file:
|
3
|
+
*
|
4
|
+
* xds/core/v3/resource.proto
|
5
|
+
*
|
6
|
+
* Do not edit -- your changes will be discarded when the file is
|
7
|
+
* regenerated. */
|
8
|
+
|
9
|
+
#ifndef XDS_CORE_V3_RESOURCE_PROTO_UPBDEFS_H_
|
10
|
+
#define XDS_CORE_V3_RESOURCE_PROTO_UPBDEFS_H_
|
11
|
+
|
12
|
+
#include "upb/def.h"
|
13
|
+
#include "upb/port_def.inc"
|
14
|
+
#ifdef __cplusplus
|
15
|
+
extern "C" {
|
16
|
+
#endif
|
17
|
+
|
18
|
+
#include "upb/def.h"
|
19
|
+
|
20
|
+
#include "upb/port_def.inc"
|
21
|
+
|
22
|
+
extern upb_def_init xds_core_v3_resource_proto_upbdefinit;
|
23
|
+
|
24
|
+
UPB_INLINE const upb_msgdef *xds_core_v3_Resource_getmsgdef(upb_symtab *s) {
|
25
|
+
_upb_symtab_loaddefinit(s, &xds_core_v3_resource_proto_upbdefinit);
|
26
|
+
return upb_symtab_lookupmsg(s, "xds.core.v3.Resource");
|
27
|
+
}
|
28
|
+
|
29
|
+
#ifdef __cplusplus
|
30
|
+
} /* extern "C" */
|
31
|
+
#endif
|
32
|
+
|
33
|
+
#include "upb/port_undef.inc"
|
34
|
+
|
35
|
+
#endif /* XDS_CORE_V3_RESOURCE_PROTO_UPBDEFS_H_ */
|
@@ -0,0 +1,67 @@
|
|
1
|
+
/* This file was generated by upbc (the upb compiler) from the input
|
2
|
+
* file:
|
3
|
+
*
|
4
|
+
* xds/core/v3/resource_locator.proto
|
5
|
+
*
|
6
|
+
* Do not edit -- your changes will be discarded when the file is
|
7
|
+
* regenerated. */
|
8
|
+
|
9
|
+
#include "upb/def.h"
|
10
|
+
#include "xds/core/v3/resource_locator.upbdefs.h"
|
11
|
+
|
12
|
+
extern upb_def_init udpa_annotations_status_proto_upbdefinit;
|
13
|
+
extern upb_def_init xds_core_v3_context_params_proto_upbdefinit;
|
14
|
+
extern upb_def_init validate_validate_proto_upbdefinit;
|
15
|
+
extern const upb_msglayout xds_core_v3_ResourceLocator_msginit;
|
16
|
+
extern const upb_msglayout xds_core_v3_ResourceLocator_Directive_msginit;
|
17
|
+
|
18
|
+
static const upb_msglayout *layouts[2] = {
|
19
|
+
&xds_core_v3_ResourceLocator_msginit,
|
20
|
+
&xds_core_v3_ResourceLocator_Directive_msginit,
|
21
|
+
};
|
22
|
+
|
23
|
+
static const char descriptor[739] = {'\n', '\"', 'x', 'd', 's', '/', 'c', 'o', 'r', 'e', '/', 'v', '3', '/', 'r', 'e', 's', 'o', 'u', 'r', 'c', 'e', '_', 'l', 'o',
|
24
|
+
'c', 'a', 't', 'o', 'r', '.', 'p', 'r', 'o', 't', 'o', '\022', '\013', 'x', 'd', 's', '.', 'c', 'o', 'r', 'e', '.', 'v', '3', '\032',
|
25
|
+
'\035', 'u', 'd', 'p', 'a', '/', 'a', 'n', 'n', 'o', 't', 'a', 't', 'i', 'o', 'n', 's', '/', 's', 't', 'a', 't', 'u', 's', '.',
|
26
|
+
'p', 'r', 'o', 't', 'o', '\032', ' ', 'x', 'd', 's', '/', 'c', 'o', 'r', 'e', '/', 'v', '3', '/', 'c', 'o', 'n', 't', 'e', 'x',
|
27
|
+
't', '_', 'p', 'a', 'r', 'a', 'm', 's', '.', 'p', 'r', 'o', 't', 'o', '\032', '\027', 'v', 'a', 'l', 'i', 'd', 'a', 't', 'e', '/',
|
28
|
+
'v', 'a', 'l', 'i', 'd', 'a', 't', 'e', '.', 'p', 'r', 'o', 't', 'o', '\"', '\216', '\004', '\n', '\017', 'R', 'e', 's', 'o', 'u', 'r',
|
29
|
+
'c', 'e', 'L', 'o', 'c', 'a', 't', 'o', 'r', '\022', 'E', '\n', '\006', 's', 'c', 'h', 'e', 'm', 'e', '\030', '\001', ' ', '\001', '(', '\016',
|
30
|
+
'2', '#', '.', 'x', 'd', 's', '.', 'c', 'o', 'r', 'e', '.', 'v', '3', '.', 'R', 'e', 's', 'o', 'u', 'r', 'c', 'e', 'L', 'o',
|
31
|
+
'c', 'a', 't', 'o', 'r', '.', 'S', 'c', 'h', 'e', 'm', 'e', 'B', '\010', '\372', 'B', '\005', '\202', '\001', '\002', '\020', '\001', 'R', '\006', 's',
|
32
|
+
'c', 'h', 'e', 'm', 'e', '\022', '\016', '\n', '\002', 'i', 'd', '\030', '\002', ' ', '\001', '(', '\t', 'R', '\002', 'i', 'd', '\022', '\034', '\n', '\t',
|
33
|
+
'a', 'u', 't', 'h', 'o', 'r', 'i', 't', 'y', '\030', '\003', ' ', '\001', '(', '\t', 'R', '\t', 'a', 'u', 't', 'h', 'o', 'r', 'i', 't',
|
34
|
+
'y', '\022', ',', '\n', '\r', 'r', 'e', 's', 'o', 'u', 'r', 'c', 'e', '_', 't', 'y', 'p', 'e', '\030', '\004', ' ', '\001', '(', '\t', 'B',
|
35
|
+
'\007', '\372', 'B', '\004', 'r', '\002', '\020', '\001', 'R', '\014', 'r', 'e', 's', 'o', 'u', 'r', 'c', 'e', 'T', 'y', 'p', 'e', '\022', 'A', '\n',
|
36
|
+
'\r', 'e', 'x', 'a', 'c', 't', '_', 'c', 'o', 'n', 't', 'e', 'x', 't', '\030', '\005', ' ', '\001', '(', '\013', '2', '\032', '.', 'x', 'd',
|
37
|
+
's', '.', 'c', 'o', 'r', 'e', '.', 'v', '3', '.', 'C', 'o', 'n', 't', 'e', 'x', 't', 'P', 'a', 'r', 'a', 'm', 's', 'H', '\000',
|
38
|
+
'R', '\014', 'e', 'x', 'a', 'c', 't', 'C', 'o', 'n', 't', 'e', 'x', 't', '\022', 'F', '\n', '\n', 'd', 'i', 'r', 'e', 'c', 't', 'i',
|
39
|
+
'v', 'e', 's', '\030', '\006', ' ', '\003', '(', '\013', '2', '&', '.', 'x', 'd', 's', '.', 'c', 'o', 'r', 'e', '.', 'v', '3', '.', 'R',
|
40
|
+
'e', 's', 'o', 'u', 'r', 'c', 'e', 'L', 'o', 'c', 'a', 't', 'o', 'r', '.', 'D', 'i', 'r', 'e', 'c', 't', 'i', 'v', 'e', 'R',
|
41
|
+
'\n', 'd', 'i', 'r', 'e', 'c', 't', 'i', 'v', 'e', 's', '\032', '\210', '\001', '\n', '\t', 'D', 'i', 'r', 'e', 'c', 't', 'i', 'v', 'e',
|
42
|
+
'\022', '0', '\n', '\003', 'a', 'l', 't', '\030', '\001', ' ', '\001', '(', '\013', '2', '\034', '.', 'x', 'd', 's', '.', 'c', 'o', 'r', 'e', '.',
|
43
|
+
'v', '3', '.', 'R', 'e', 's', 'o', 'u', 'r', 'c', 'e', 'L', 'o', 'c', 'a', 't', 'o', 'r', 'H', '\000', 'R', '\003', 'a', 'l', 't',
|
44
|
+
'\022', '7', '\n', '\005', 'e', 'n', 't', 'r', 'y', '\030', '\002', ' ', '\001', '(', '\t', 'B', '\037', '\372', 'B', '\034', 'r', '\032', '\020', '\001', '2',
|
45
|
+
'\026', '^', '[', '0', '-', '9', 'a', '-', 'z', 'A', '-', 'Z', '_', '\\', '-', '\\', '.', '/', '~', ':', ']', '+', '$', 'H', '\000',
|
46
|
+
'R', '\005', 'e', 'n', 't', 'r', 'y', 'B', '\020', '\n', '\t', 'd', 'i', 'r', 'e', 'c', 't', 'i', 'v', 'e', '\022', '\003', '\370', 'B', '\001',
|
47
|
+
'\"', '\'', '\n', '\006', 'S', 'c', 'h', 'e', 'm', 'e', '\022', '\t', '\n', '\005', 'X', 'D', 'S', 'T', 'P', '\020', '\000', '\022', '\010', '\n', '\004',
|
48
|
+
'H', 'T', 'T', 'P', '\020', '\001', '\022', '\010', '\n', '\004', 'F', 'I', 'L', 'E', '\020', '\002', 'B', '\031', '\n', '\027', 'c', 'o', 'n', 't', 'e',
|
49
|
+
'x', 't', '_', 'p', 'a', 'r', 'a', 'm', '_', 's', 'p', 'e', 'c', 'i', 'f', 'i', 'e', 'r', 'B', '=', '\n', '\033', 'c', 'o', 'm',
|
50
|
+
'.', 'g', 'i', 't', 'h', 'u', 'b', '.', 'u', 'd', 'p', 'a', '.', 'x', 'd', 's', '.', 'c', 'o', 'r', 'e', '.', 'v', '3', 'B',
|
51
|
+
'\024', 'R', 'e', 's', 'o', 'u', 'r', 'c', 'e', 'L', 'o', 'c', 'a', 't', 'o', 'r', 'P', 'r', 'o', 't', 'o', 'P', '\001', '\272', '\200',
|
52
|
+
'\310', '\321', '\006', '\002', '\010', '\001', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3',
|
53
|
+
};
|
54
|
+
|
55
|
+
static upb_def_init *deps[4] = {
|
56
|
+
&udpa_annotations_status_proto_upbdefinit,
|
57
|
+
&xds_core_v3_context_params_proto_upbdefinit,
|
58
|
+
&validate_validate_proto_upbdefinit,
|
59
|
+
NULL
|
60
|
+
};
|
61
|
+
|
62
|
+
upb_def_init xds_core_v3_resource_locator_proto_upbdefinit = {
|
63
|
+
deps,
|
64
|
+
layouts,
|
65
|
+
"xds/core/v3/resource_locator.proto",
|
66
|
+
UPB_STRVIEW_INIT(descriptor, 739)
|
67
|
+
};
|
@@ -0,0 +1,40 @@
|
|
1
|
+
/* This file was generated by upbc (the upb compiler) from the input
|
2
|
+
* file:
|
3
|
+
*
|
4
|
+
* xds/core/v3/resource_locator.proto
|
5
|
+
*
|
6
|
+
* Do not edit -- your changes will be discarded when the file is
|
7
|
+
* regenerated. */
|
8
|
+
|
9
|
+
#ifndef XDS_CORE_V3_RESOURCE_LOCATOR_PROTO_UPBDEFS_H_
|
10
|
+
#define XDS_CORE_V3_RESOURCE_LOCATOR_PROTO_UPBDEFS_H_
|
11
|
+
|
12
|
+
#include "upb/def.h"
|
13
|
+
#include "upb/port_def.inc"
|
14
|
+
#ifdef __cplusplus
|
15
|
+
extern "C" {
|
16
|
+
#endif
|
17
|
+
|
18
|
+
#include "upb/def.h"
|
19
|
+
|
20
|
+
#include "upb/port_def.inc"
|
21
|
+
|
22
|
+
extern upb_def_init xds_core_v3_resource_locator_proto_upbdefinit;
|
23
|
+
|
24
|
+
UPB_INLINE const upb_msgdef *xds_core_v3_ResourceLocator_getmsgdef(upb_symtab *s) {
|
25
|
+
_upb_symtab_loaddefinit(s, &xds_core_v3_resource_locator_proto_upbdefinit);
|
26
|
+
return upb_symtab_lookupmsg(s, "xds.core.v3.ResourceLocator");
|
27
|
+
}
|
28
|
+
|
29
|
+
UPB_INLINE const upb_msgdef *xds_core_v3_ResourceLocator_Directive_getmsgdef(upb_symtab *s) {
|
30
|
+
_upb_symtab_loaddefinit(s, &xds_core_v3_resource_locator_proto_upbdefinit);
|
31
|
+
return upb_symtab_lookupmsg(s, "xds.core.v3.ResourceLocator.Directive");
|
32
|
+
}
|
33
|
+
|
34
|
+
#ifdef __cplusplus
|
35
|
+
} /* extern "C" */
|
36
|
+
#endif
|
37
|
+
|
38
|
+
#include "upb/port_undef.inc"
|
39
|
+
|
40
|
+
#endif /* XDS_CORE_V3_RESOURCE_LOCATOR_PROTO_UPBDEFS_H_ */
|
@@ -0,0 +1,50 @@
|
|
1
|
+
/* This file was generated by upbc (the upb compiler) from the input
|
2
|
+
* file:
|
3
|
+
*
|
4
|
+
* xds/core/v3/resource_name.proto
|
5
|
+
*
|
6
|
+
* Do not edit -- your changes will be discarded when the file is
|
7
|
+
* regenerated. */
|
8
|
+
|
9
|
+
#include "upb/def.h"
|
10
|
+
#include "xds/core/v3/resource_name.upbdefs.h"
|
11
|
+
|
12
|
+
extern upb_def_init udpa_annotations_status_proto_upbdefinit;
|
13
|
+
extern upb_def_init xds_core_v3_context_params_proto_upbdefinit;
|
14
|
+
extern upb_def_init validate_validate_proto_upbdefinit;
|
15
|
+
extern const upb_msglayout xds_core_v3_ResourceName_msginit;
|
16
|
+
|
17
|
+
static const upb_msglayout *layouts[1] = {
|
18
|
+
&xds_core_v3_ResourceName_msginit,
|
19
|
+
};
|
20
|
+
|
21
|
+
static const char descriptor[367] = {'\n', '\037', 'x', 'd', 's', '/', 'c', 'o', 'r', 'e', '/', 'v', '3', '/', 'r', 'e', 's', 'o', 'u', 'r', 'c', 'e', '_', 'n', 'a',
|
22
|
+
'm', 'e', '.', 'p', 'r', 'o', 't', 'o', '\022', '\013', 'x', 'd', 's', '.', 'c', 'o', 'r', 'e', '.', 'v', '3', '\032', '\035', 'u', 'd',
|
23
|
+
'p', 'a', '/', 'a', 'n', 'n', 'o', 't', 'a', 't', 'i', 'o', 'n', 's', '/', 's', 't', 'a', 't', 'u', 's', '.', 'p', 'r', 'o',
|
24
|
+
't', 'o', '\032', ' ', 'x', 'd', 's', '/', 'c', 'o', 'r', 'e', '/', 'v', '3', '/', 'c', 'o', 'n', 't', 'e', 'x', 't', '_', 'p',
|
25
|
+
'a', 'r', 'a', 'm', 's', '.', 'p', 'r', 'o', 't', 'o', '\032', '\027', 'v', 'a', 'l', 'i', 'd', 'a', 't', 'e', '/', 'v', 'a', 'l',
|
26
|
+
'i', 'd', 'a', 't', 'e', '.', 'p', 'r', 'o', 't', 'o', '\"', '\240', '\001', '\n', '\014', 'R', 'e', 's', 'o', 'u', 'r', 'c', 'e', 'N',
|
27
|
+
'a', 'm', 'e', '\022', '\016', '\n', '\002', 'i', 'd', '\030', '\001', ' ', '\001', '(', '\t', 'R', '\002', 'i', 'd', '\022', '\034', '\n', '\t', 'a', 'u',
|
28
|
+
't', 'h', 'o', 'r', 'i', 't', 'y', '\030', '\002', ' ', '\001', '(', '\t', 'R', '\t', 'a', 'u', 't', 'h', 'o', 'r', 'i', 't', 'y', '\022',
|
29
|
+
',', '\n', '\r', 'r', 'e', 's', 'o', 'u', 'r', 'c', 'e', '_', 't', 'y', 'p', 'e', '\030', '\003', ' ', '\001', '(', '\t', 'B', '\007', '\372',
|
30
|
+
'B', '\004', 'r', '\002', '\020', '\001', 'R', '\014', 'r', 'e', 's', 'o', 'u', 'r', 'c', 'e', 'T', 'y', 'p', 'e', '\022', '4', '\n', '\007', 'c',
|
31
|
+
'o', 'n', 't', 'e', 'x', 't', '\030', '\004', ' ', '\001', '(', '\013', '2', '\032', '.', 'x', 'd', 's', '.', 'c', 'o', 'r', 'e', '.', 'v',
|
32
|
+
'3', '.', 'C', 'o', 'n', 't', 'e', 'x', 't', 'P', 'a', 'r', 'a', 'm', 's', 'R', '\007', 'c', 'o', 'n', 't', 'e', 'x', 't', 'B',
|
33
|
+
':', '\n', '\033', 'c', 'o', 'm', '.', 'g', 'i', 't', 'h', 'u', 'b', '.', 'u', 'd', 'p', 'a', '.', 'x', 'd', 's', '.', 'c', 'o',
|
34
|
+
'r', 'e', '.', 'v', '3', 'B', '\021', 'R', 'e', 's', 'o', 'u', 'r', 'c', 'e', 'N', 'a', 'm', 'e', 'P', 'r', 'o', 't', 'o', 'P',
|
35
|
+
'\001', '\272', '\200', '\310', '\321', '\006', '\002', '\010', '\001', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3',
|
36
|
+
};
|
37
|
+
|
38
|
+
static upb_def_init *deps[4] = {
|
39
|
+
&udpa_annotations_status_proto_upbdefinit,
|
40
|
+
&xds_core_v3_context_params_proto_upbdefinit,
|
41
|
+
&validate_validate_proto_upbdefinit,
|
42
|
+
NULL
|
43
|
+
};
|
44
|
+
|
45
|
+
upb_def_init xds_core_v3_resource_name_proto_upbdefinit = {
|
46
|
+
deps,
|
47
|
+
layouts,
|
48
|
+
"xds/core/v3/resource_name.proto",
|
49
|
+
UPB_STRVIEW_INIT(descriptor, 367)
|
50
|
+
};
|
@@ -0,0 +1,35 @@
|
|
1
|
+
/* This file was generated by upbc (the upb compiler) from the input
|
2
|
+
* file:
|
3
|
+
*
|
4
|
+
* xds/core/v3/resource_name.proto
|
5
|
+
*
|
6
|
+
* Do not edit -- your changes will be discarded when the file is
|
7
|
+
* regenerated. */
|
8
|
+
|
9
|
+
#ifndef XDS_CORE_V3_RESOURCE_NAME_PROTO_UPBDEFS_H_
|
10
|
+
#define XDS_CORE_V3_RESOURCE_NAME_PROTO_UPBDEFS_H_
|
11
|
+
|
12
|
+
#include "upb/def.h"
|
13
|
+
#include "upb/port_def.inc"
|
14
|
+
#ifdef __cplusplus
|
15
|
+
extern "C" {
|
16
|
+
#endif
|
17
|
+
|
18
|
+
#include "upb/def.h"
|
19
|
+
|
20
|
+
#include "upb/port_def.inc"
|
21
|
+
|
22
|
+
extern upb_def_init xds_core_v3_resource_name_proto_upbdefinit;
|
23
|
+
|
24
|
+
UPB_INLINE const upb_msgdef *xds_core_v3_ResourceName_getmsgdef(upb_symtab *s) {
|
25
|
+
_upb_symtab_loaddefinit(s, &xds_core_v3_resource_name_proto_upbdefinit);
|
26
|
+
return upb_symtab_lookupmsg(s, "xds.core.v3.ResourceName");
|
27
|
+
}
|
28
|
+
|
29
|
+
#ifdef __cplusplus
|
30
|
+
} /* extern "C" */
|
31
|
+
#endif
|
32
|
+
|
33
|
+
#include "upb/port_undef.inc"
|
34
|
+
|
35
|
+
#endif /* XDS_CORE_V3_RESOURCE_NAME_PROTO_UPBDEFS_H_ */
|
@@ -49,7 +49,7 @@ class CertificateProviderFactory {
|
|
49
49
|
virtual const char* name() const = 0;
|
50
50
|
|
51
51
|
virtual RefCountedPtr<Config> CreateCertificateProviderConfig(
|
52
|
-
const Json& config_json,
|
52
|
+
const Json& config_json, grpc_error_handle* error) = 0;
|
53
53
|
|
54
54
|
// Create a CertificateProvider instance from config.
|
55
55
|
virtual RefCountedPtr<grpc_tls_certificate_provider>
|
@@ -92,7 +92,7 @@ class CertificateProviderStore
|
|
92
92
|
};
|
93
93
|
|
94
94
|
RefCountedPtr<CertificateProviderWrapper> CreateCertificateProviderLocked(
|
95
|
-
absl::string_view key);
|
95
|
+
absl::string_view key) ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
|
96
96
|
|
97
97
|
// Releases a previously created certificate provider from the certificate
|
98
98
|
// provider map if the value matches \a wrapper.
|
@@ -101,10 +101,10 @@ class CertificateProviderStore
|
|
101
101
|
|
102
102
|
Mutex mu_;
|
103
103
|
// Map of plugin configurations
|
104
|
-
PluginDefinitionMap plugin_config_map_;
|
104
|
+
PluginDefinitionMap plugin_config_map_ ABSL_GUARDED_BY(mu_);
|
105
105
|
// Underlying map for the providers.
|
106
106
|
std::map<absl::string_view, CertificateProviderWrapper*>
|
107
|
-
certificate_providers_map_;
|
107
|
+
certificate_providers_map_ ABSL_GUARDED_BY(mu_);
|
108
108
|
};
|
109
109
|
|
110
110
|
} // namespace grpc_core
|
@@ -64,14 +64,14 @@ std::string FileWatcherCertificateProviderFactory::Config::ToString() const {
|
|
64
64
|
|
65
65
|
RefCountedPtr<FileWatcherCertificateProviderFactory::Config>
|
66
66
|
FileWatcherCertificateProviderFactory::Config::Parse(const Json& config_json,
|
67
|
-
|
67
|
+
grpc_error_handle* error) {
|
68
68
|
auto config = MakeRefCounted<FileWatcherCertificateProviderFactory::Config>();
|
69
69
|
if (config_json.type() != Json::Type::OBJECT) {
|
70
70
|
*error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
71
71
|
"error:config type should be OBJECT.");
|
72
72
|
return nullptr;
|
73
73
|
}
|
74
|
-
std::vector<
|
74
|
+
std::vector<grpc_error_handle> error_list;
|
75
75
|
ParseJsonObjectField(config_json.object_value(), "certificate_file",
|
76
76
|
&config->identity_cert_file_, &error_list, false);
|
77
77
|
ParseJsonObjectField(config_json.object_value(), "private_key_file",
|
@@ -112,7 +112,7 @@ const char* FileWatcherCertificateProviderFactory::name() const {
|
|
112
112
|
|
113
113
|
RefCountedPtr<CertificateProviderFactory::Config>
|
114
114
|
FileWatcherCertificateProviderFactory::CreateCertificateProviderConfig(
|
115
|
-
const Json& config_json,
|
115
|
+
const Json& config_json, grpc_error_handle* error) {
|
116
116
|
return FileWatcherCertificateProviderFactory::Config::Parse(config_json,
|
117
117
|
error);
|
118
118
|
}
|
@@ -31,7 +31,7 @@ class FileWatcherCertificateProviderFactory
|
|
31
31
|
class Config : public CertificateProviderFactory::Config {
|
32
32
|
public:
|
33
33
|
static RefCountedPtr<Config> Parse(const Json& config_json,
|
34
|
-
|
34
|
+
grpc_error_handle* error);
|
35
35
|
|
36
36
|
const char* name() const override;
|
37
37
|
|
@@ -58,7 +58,7 @@ class FileWatcherCertificateProviderFactory
|
|
58
58
|
|
59
59
|
RefCountedPtr<CertificateProviderFactory::Config>
|
60
60
|
CreateCertificateProviderConfig(const Json& config_json,
|
61
|
-
|
61
|
+
grpc_error_handle* error) override;
|
62
62
|
|
63
63
|
RefCountedPtr<grpc_tls_certificate_provider> CreateCertificateProvider(
|
64
64
|
RefCountedPtr<CertificateProviderFactory::Config> config) override;
|
data/src/core/ext/xds/xds_api.cc
CHANGED
@@ -28,26 +28,13 @@
|
|
28
28
|
#include "absl/strings/str_format.h"
|
29
29
|
#include "absl/strings/str_join.h"
|
30
30
|
#include "absl/strings/str_split.h"
|
31
|
-
|
32
|
-
#include "upb/upb.hpp"
|
33
|
-
|
34
|
-
#include <grpc/impl/codegen/log.h>
|
35
|
-
#include <grpc/support/alloc.h>
|
36
|
-
#include <grpc/support/string_util.h>
|
37
|
-
|
38
|
-
#include "src/core/ext/xds/xds_api.h"
|
39
|
-
#include "src/core/lib/gpr/env.h"
|
40
|
-
#include "src/core/lib/gpr/string.h"
|
41
|
-
#include "src/core/lib/gpr/useful.h"
|
42
|
-
#include "src/core/lib/iomgr/error.h"
|
43
|
-
#include "src/core/lib/iomgr/sockaddr_utils.h"
|
44
|
-
#include "src/core/lib/slice/slice_utils.h"
|
45
|
-
|
31
|
+
#include "envoy/admin/v3/config_dump.upb.h"
|
46
32
|
#include "envoy/config/cluster/v3/circuit_breaker.upb.h"
|
47
33
|
#include "envoy/config/cluster/v3/cluster.upb.h"
|
48
34
|
#include "envoy/config/cluster/v3/cluster.upbdefs.h"
|
49
35
|
#include "envoy/config/core/v3/address.upb.h"
|
50
36
|
#include "envoy/config/core/v3/base.upb.h"
|
37
|
+
#include "envoy/config/core/v3/base.upbdefs.h"
|
51
38
|
#include "envoy/config/core/v3/config_source.upb.h"
|
52
39
|
#include "envoy/config/core/v3/health_check.upb.h"
|
53
40
|
#include "envoy/config/core/v3/protocol.upb.h"
|
@@ -57,12 +44,19 @@
|
|
57
44
|
#include "envoy/config/endpoint/v3/load_report.upb.h"
|
58
45
|
#include "envoy/config/listener/v3/api_listener.upb.h"
|
59
46
|
#include "envoy/config/listener/v3/listener.upb.h"
|
47
|
+
#include "envoy/config/listener/v3/listener.upbdefs.h"
|
48
|
+
#include "envoy/config/listener/v3/listener_components.upb.h"
|
60
49
|
#include "envoy/config/route/v3/route.upb.h"
|
61
50
|
#include "envoy/config/route/v3/route.upbdefs.h"
|
62
51
|
#include "envoy/config/route/v3/route_components.upb.h"
|
52
|
+
#include "envoy/config/route/v3/route_components.upbdefs.h"
|
53
|
+
#include "envoy/extensions/clusters/aggregate/v3/cluster.upb.h"
|
54
|
+
#include "envoy/extensions/clusters/aggregate/v3/cluster.upbdefs.h"
|
63
55
|
#include "envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h"
|
56
|
+
#include "envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h"
|
64
57
|
#include "envoy/extensions/transport_sockets/tls/v3/common.upb.h"
|
65
58
|
#include "envoy/extensions/transport_sockets/tls/v3/tls.upb.h"
|
59
|
+
#include "envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.h"
|
66
60
|
#include "envoy/service/cluster/v3/cds.upb.h"
|
67
61
|
#include "envoy/service/cluster/v3/cds.upbdefs.h"
|
68
62
|
#include "envoy/service/discovery/v3/discovery.upb.h"
|
@@ -74,6 +68,8 @@
|
|
74
68
|
#include "envoy/service/load_stats/v3/lrs.upbdefs.h"
|
75
69
|
#include "envoy/service/route/v3/rds.upb.h"
|
76
70
|
#include "envoy/service/route/v3/rds.upbdefs.h"
|
71
|
+
#include "envoy/service/status/v3/csds.upb.h"
|
72
|
+
#include "envoy/service/status/v3/csds.upbdefs.h"
|
77
73
|
#include "envoy/type/matcher/v3/regex.upb.h"
|
78
74
|
#include "envoy/type/matcher/v3/string.upb.h"
|
79
75
|
#include "envoy/type/v3/percent.upb.h"
|
@@ -81,18 +77,49 @@
|
|
81
77
|
#include "google/protobuf/any.upb.h"
|
82
78
|
#include "google/protobuf/duration.upb.h"
|
83
79
|
#include "google/protobuf/struct.upb.h"
|
80
|
+
#include "google/protobuf/timestamp.upb.h"
|
84
81
|
#include "google/protobuf/wrappers.upb.h"
|
85
82
|
#include "google/rpc/status.upb.h"
|
83
|
+
#include "udpa/type/v1/typed_struct.upb.h"
|
86
84
|
#include "upb/text_encode.h"
|
87
85
|
#include "upb/upb.h"
|
86
|
+
#include "upb/upb.hpp"
|
87
|
+
|
88
|
+
#include <grpc/impl/codegen/log.h>
|
89
|
+
#include <grpc/support/alloc.h>
|
90
|
+
#include <grpc/support/string_util.h>
|
91
|
+
|
92
|
+
#include "src/core/ext/xds/xds_api.h"
|
93
|
+
#include "src/core/lib/address_utils/sockaddr_utils.h"
|
94
|
+
#include "src/core/lib/gpr/env.h"
|
95
|
+
#include "src/core/lib/gpr/string.h"
|
96
|
+
#include "src/core/lib/gpr/useful.h"
|
97
|
+
#include "src/core/lib/gprpp/host_port.h"
|
98
|
+
#include "src/core/lib/iomgr/error.h"
|
99
|
+
#include "src/core/lib/iomgr/sockaddr.h"
|
100
|
+
#include "src/core/lib/iomgr/socket_utils.h"
|
101
|
+
#include "src/core/lib/slice/slice_utils.h"
|
88
102
|
|
89
103
|
namespace grpc_core {
|
90
104
|
|
91
|
-
// TODO
|
92
|
-
//
|
105
|
+
// TODO(donnadionne): Check to see if cluster types aggregate_cluster and
|
106
|
+
// logical_dns are enabled, this will be
|
107
|
+
// removed once the cluster types are fully integration-tested and enabled by
|
108
|
+
// default.
|
109
|
+
bool XdsAggregateAndLogicalDnsClusterEnabled() {
|
110
|
+
char* value = gpr_getenv(
|
111
|
+
"GRPC_XDS_EXPERIMENTAL_ENABLE_AGGREGATE_AND_LOGICAL_DNS_CLUSTER");
|
112
|
+
bool parsed_value;
|
113
|
+
bool parse_succeeded = gpr_parse_bool_value(value, &parsed_value);
|
114
|
+
gpr_free(value);
|
115
|
+
return parse_succeeded && parsed_value;
|
116
|
+
}
|
117
|
+
|
118
|
+
// TODO(donnadionne): Check to see if ring hash policy is enabled, this will be
|
119
|
+
// removed once ring hash policy is fully integration-tested and enabled by
|
93
120
|
// default.
|
94
|
-
bool
|
95
|
-
char* value = gpr_getenv("
|
121
|
+
bool XdsRingHashEnabled() {
|
122
|
+
char* value = gpr_getenv("GRPC_XDS_EXPERIMENTAL_ENABLE_RING_HASH");
|
96
123
|
bool parsed_value;
|
97
124
|
bool parse_succeeded = gpr_parse_bool_value(value, &parsed_value);
|
98
125
|
gpr_free(value);
|
@@ -111,160 +138,80 @@ bool XdsSecurityEnabled() {
|
|
111
138
|
}
|
112
139
|
|
113
140
|
//
|
114
|
-
// XdsApi::Route::
|
141
|
+
// XdsApi::Route::HashPolicy
|
115
142
|
//
|
116
143
|
|
117
|
-
XdsApi::Route::
|
118
|
-
: type(other.type),
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
absl::make_unique<RE2>(other.
|
124
|
-
} else {
|
125
|
-
string_matcher = other.string_matcher;
|
144
|
+
XdsApi::Route::HashPolicy::HashPolicy(const HashPolicy& other)
|
145
|
+
: type(other.type),
|
146
|
+
header_name(other.header_name),
|
147
|
+
regex_substitution(other.regex_substitution) {
|
148
|
+
if (other.regex != nullptr) {
|
149
|
+
regex =
|
150
|
+
absl::make_unique<RE2>(other.regex->pattern(), other.regex->options());
|
126
151
|
}
|
127
152
|
}
|
128
153
|
|
129
|
-
XdsApi::Route::
|
130
|
-
|
154
|
+
XdsApi::Route::HashPolicy& XdsApi::Route::HashPolicy::operator=(
|
155
|
+
const HashPolicy& other) {
|
131
156
|
type = other.type;
|
132
|
-
|
133
|
-
if (
|
134
|
-
|
135
|
-
|
136
|
-
regex_matcher =
|
137
|
-
absl::make_unique<RE2>(other.regex_matcher->pattern(), options);
|
138
|
-
} else {
|
139
|
-
string_matcher = other.string_matcher;
|
157
|
+
header_name = other.header_name;
|
158
|
+
if (other.regex != nullptr) {
|
159
|
+
regex =
|
160
|
+
absl::make_unique<RE2>(other.regex->pattern(), other.regex->options());
|
140
161
|
}
|
162
|
+
regex_substitution = other.regex_substitution;
|
141
163
|
return *this;
|
142
164
|
}
|
143
165
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
// Should never be null.
|
150
|
-
if (regex_matcher == nullptr || other.regex_matcher == nullptr) {
|
151
|
-
return false;
|
152
|
-
}
|
153
|
-
return regex_matcher->pattern() == other.regex_matcher->pattern();
|
154
|
-
}
|
155
|
-
return string_matcher == other.string_matcher;
|
156
|
-
}
|
157
|
-
|
158
|
-
std::string XdsApi::Route::Matchers::PathMatcher::ToString() const {
|
159
|
-
std::string path_type_string;
|
160
|
-
switch (type) {
|
161
|
-
case PathMatcherType::PATH:
|
162
|
-
path_type_string = "path match";
|
163
|
-
break;
|
164
|
-
case PathMatcherType::PREFIX:
|
165
|
-
path_type_string = "prefix match";
|
166
|
-
break;
|
167
|
-
case PathMatcherType::REGEX:
|
168
|
-
path_type_string = "regex match";
|
169
|
-
break;
|
170
|
-
default:
|
171
|
-
break;
|
172
|
-
}
|
173
|
-
return absl::StrFormat("Path %s:%s%s", path_type_string,
|
174
|
-
type == PathMatcherType::REGEX
|
175
|
-
? regex_matcher->pattern()
|
176
|
-
: string_matcher,
|
177
|
-
case_sensitive ? "" : "[case_sensitive=false]");
|
178
|
-
}
|
179
|
-
|
180
|
-
//
|
181
|
-
// XdsApi::Route::Matchers::HeaderMatcher
|
182
|
-
//
|
183
|
-
|
184
|
-
XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcher(
|
185
|
-
const HeaderMatcher& other)
|
186
|
-
: name(other.name), type(other.type), invert_match(other.invert_match) {
|
187
|
-
switch (type) {
|
188
|
-
case HeaderMatcherType::REGEX:
|
189
|
-
regex_match = absl::make_unique<RE2>(other.regex_match->pattern());
|
190
|
-
break;
|
191
|
-
case HeaderMatcherType::RANGE:
|
192
|
-
range_start = other.range_start;
|
193
|
-
range_end = other.range_end;
|
194
|
-
break;
|
195
|
-
case HeaderMatcherType::PRESENT:
|
196
|
-
present_match = other.present_match;
|
197
|
-
break;
|
198
|
-
default:
|
199
|
-
string_matcher = other.string_matcher;
|
200
|
-
}
|
201
|
-
}
|
166
|
+
XdsApi::Route::HashPolicy::HashPolicy(HashPolicy&& other) noexcept
|
167
|
+
: type(other.type),
|
168
|
+
header_name(std::move(other.header_name)),
|
169
|
+
regex(std::move(other.regex)),
|
170
|
+
regex_substitution(std::move(other.regex_substitution)) {}
|
202
171
|
|
203
|
-
XdsApi::Route::
|
204
|
-
|
205
|
-
name = other.name;
|
172
|
+
XdsApi::Route::HashPolicy& XdsApi::Route::HashPolicy::operator=(
|
173
|
+
HashPolicy&& other) noexcept {
|
206
174
|
type = other.type;
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
regex_match = absl::make_unique<RE2>(other.regex_match->pattern());
|
211
|
-
break;
|
212
|
-
case HeaderMatcherType::RANGE:
|
213
|
-
range_start = other.range_start;
|
214
|
-
range_end = other.range_end;
|
215
|
-
break;
|
216
|
-
case HeaderMatcherType::PRESENT:
|
217
|
-
present_match = other.present_match;
|
218
|
-
break;
|
219
|
-
default:
|
220
|
-
string_matcher = other.string_matcher;
|
221
|
-
}
|
175
|
+
header_name = std::move(other.header_name);
|
176
|
+
regex = std::move(other.regex);
|
177
|
+
regex_substitution = std::move(other.regex_substitution);
|
222
178
|
return *this;
|
223
179
|
}
|
224
180
|
|
225
|
-
bool XdsApi::Route::
|
226
|
-
const
|
227
|
-
if (name != other.name) return false;
|
181
|
+
bool XdsApi::Route::HashPolicy::HashPolicy::operator==(
|
182
|
+
const HashPolicy& other) const {
|
228
183
|
if (type != other.type) return false;
|
229
|
-
if (
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
return
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
return string_matcher != other.string_matcher;
|
184
|
+
if (type == Type::HEADER) {
|
185
|
+
if (regex == nullptr) {
|
186
|
+
if (other.regex != nullptr) return false;
|
187
|
+
} else {
|
188
|
+
if (other.regex == nullptr) return false;
|
189
|
+
return header_name == other.header_name &&
|
190
|
+
regex->pattern() == other.regex->pattern() &&
|
191
|
+
regex_substitution == other.regex_substitution;
|
192
|
+
}
|
239
193
|
}
|
194
|
+
return true;
|
240
195
|
}
|
241
196
|
|
242
|
-
std::string XdsApi::Route::
|
197
|
+
std::string XdsApi::Route::HashPolicy::ToString() const {
|
198
|
+
std::vector<std::string> contents;
|
243
199
|
switch (type) {
|
244
|
-
case
|
245
|
-
|
246
|
-
|
247
|
-
case
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
invert_match ? " not" : "", name,
|
258
|
-
present_match ? "true" : "false");
|
259
|
-
case HeaderMatcherType::PREFIX:
|
260
|
-
return absl::StrFormat("Header prefix match:%s %s:%s",
|
261
|
-
invert_match ? " not" : "", name, string_matcher);
|
262
|
-
case HeaderMatcherType::SUFFIX:
|
263
|
-
return absl::StrFormat("Header suffix match:%s %s:%s",
|
264
|
-
invert_match ? " not" : "", name, string_matcher);
|
265
|
-
default:
|
266
|
-
return "";
|
200
|
+
case Type::HEADER:
|
201
|
+
contents.push_back("type=HEADER");
|
202
|
+
break;
|
203
|
+
case Type::CHANNEL_ID:
|
204
|
+
contents.push_back("type=CHANNEL_ID");
|
205
|
+
break;
|
206
|
+
}
|
207
|
+
contents.push_back(
|
208
|
+
absl::StrFormat("terminal=%s", terminal ? "true" : "false"));
|
209
|
+
if (type == Type::HEADER) {
|
210
|
+
contents.push_back(absl::StrFormat(
|
211
|
+
"Header %s:/%s/%s", header_name,
|
212
|
+
(regex == nullptr) ? "" : regex->pattern(), regex_substitution));
|
267
213
|
}
|
214
|
+
return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
|
268
215
|
}
|
269
216
|
|
270
217
|
//
|
@@ -273,7 +220,8 @@ std::string XdsApi::Route::Matchers::HeaderMatcher::ToString() const {
|
|
273
220
|
|
274
221
|
std::string XdsApi::Route::Matchers::ToString() const {
|
275
222
|
std::vector<std::string> contents;
|
276
|
-
contents.push_back(
|
223
|
+
contents.push_back(
|
224
|
+
absl::StrFormat("PathMatcher{%s}", path_matcher.ToString()));
|
277
225
|
for (const HeaderMatcher& header_matcher : header_matchers) {
|
278
226
|
contents.push_back(header_matcher.ToString());
|
279
227
|
}
|
@@ -285,12 +233,28 @@ std::string XdsApi::Route::Matchers::ToString() const {
|
|
285
233
|
}
|
286
234
|
|
287
235
|
std::string XdsApi::Route::ClusterWeight::ToString() const {
|
288
|
-
|
236
|
+
std::vector<std::string> contents;
|
237
|
+
contents.push_back(absl::StrCat("cluster=", name));
|
238
|
+
contents.push_back(absl::StrCat("weight=", weight));
|
239
|
+
if (!typed_per_filter_config.empty()) {
|
240
|
+
std::vector<std::string> parts;
|
241
|
+
for (const auto& p : typed_per_filter_config) {
|
242
|
+
const std::string& key = p.first;
|
243
|
+
const auto& config = p.second;
|
244
|
+
parts.push_back(absl::StrCat(key, "=", config.ToString()));
|
245
|
+
}
|
246
|
+
contents.push_back(absl::StrCat("typed_per_filter_config={",
|
247
|
+
absl::StrJoin(parts, ", "), "}"));
|
248
|
+
}
|
249
|
+
return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
|
289
250
|
}
|
290
251
|
|
291
252
|
std::string XdsApi::Route::ToString() const {
|
292
253
|
std::vector<std::string> contents;
|
293
254
|
contents.push_back(matchers.ToString());
|
255
|
+
for (const HashPolicy& hash_policy : hash_policies) {
|
256
|
+
contents.push_back(absl::StrCat("hash_policy=", hash_policy.ToString()));
|
257
|
+
}
|
294
258
|
if (!cluster_name.empty()) {
|
295
259
|
contents.push_back(absl::StrFormat("Cluster name: %s", cluster_name));
|
296
260
|
}
|
@@ -300,6 +264,15 @@ std::string XdsApi::Route::ToString() const {
|
|
300
264
|
if (max_stream_duration.has_value()) {
|
301
265
|
contents.push_back(max_stream_duration->ToString());
|
302
266
|
}
|
267
|
+
if (!typed_per_filter_config.empty()) {
|
268
|
+
contents.push_back("typed_per_filter_config={");
|
269
|
+
for (const auto& p : typed_per_filter_config) {
|
270
|
+
const std::string& name = p.first;
|
271
|
+
const auto& config = p.second;
|
272
|
+
contents.push_back(absl::StrCat(" ", name, "=", config.ToString()));
|
273
|
+
}
|
274
|
+
contents.push_back("}");
|
275
|
+
}
|
303
276
|
return absl::StrJoin(contents, "\n");
|
304
277
|
}
|
305
278
|
|
@@ -322,6 +295,14 @@ std::string XdsApi::RdsUpdate::ToString() const {
|
|
322
295
|
vhosts.push_back("\n }\n");
|
323
296
|
}
|
324
297
|
vhosts.push_back(" ]\n");
|
298
|
+
vhosts.push_back(" typed_per_filter_config={\n");
|
299
|
+
for (const auto& p : vhost.typed_per_filter_config) {
|
300
|
+
const std::string& name = p.first;
|
301
|
+
const auto& config = p.second;
|
302
|
+
vhosts.push_back(
|
303
|
+
absl::StrCat(" ", name, "=", config.ToString(), "\n"));
|
304
|
+
}
|
305
|
+
vhosts.push_back(" }\n");
|
325
306
|
vhosts.push_back("]\n");
|
326
307
|
}
|
327
308
|
return absl::StrJoin(vhosts, "");
|
@@ -425,102 +406,6 @@ XdsApi::RdsUpdate::VirtualHost* XdsApi::RdsUpdate::FindVirtualHostForDomain(
|
|
425
406
|
return target_vhost;
|
426
407
|
}
|
427
408
|
|
428
|
-
//
|
429
|
-
// XdsApi::StringMatcher
|
430
|
-
//
|
431
|
-
|
432
|
-
XdsApi::StringMatcher::StringMatcher(StringMatcherType type,
|
433
|
-
const std::string& matcher,
|
434
|
-
bool ignore_case)
|
435
|
-
: type_(type), ignore_case_(ignore_case) {
|
436
|
-
if (type_ == StringMatcherType::SAFE_REGEX) {
|
437
|
-
regex_matcher_ = absl::make_unique<RE2>(matcher);
|
438
|
-
} else {
|
439
|
-
string_matcher_ = matcher;
|
440
|
-
}
|
441
|
-
}
|
442
|
-
|
443
|
-
XdsApi::StringMatcher::StringMatcher(const StringMatcher& other)
|
444
|
-
: type_(other.type_), ignore_case_(other.ignore_case_) {
|
445
|
-
switch (type_) {
|
446
|
-
case StringMatcherType::SAFE_REGEX:
|
447
|
-
regex_matcher_ = absl::make_unique<RE2>(other.regex_matcher_->pattern());
|
448
|
-
break;
|
449
|
-
default:
|
450
|
-
string_matcher_ = other.string_matcher_;
|
451
|
-
}
|
452
|
-
}
|
453
|
-
|
454
|
-
XdsApi::StringMatcher& XdsApi::StringMatcher::operator=(
|
455
|
-
const StringMatcher& other) {
|
456
|
-
type_ = other.type_;
|
457
|
-
switch (type_) {
|
458
|
-
case StringMatcherType::SAFE_REGEX:
|
459
|
-
regex_matcher_ = absl::make_unique<RE2>(other.regex_matcher_->pattern());
|
460
|
-
break;
|
461
|
-
default:
|
462
|
-
string_matcher_ = other.string_matcher_;
|
463
|
-
}
|
464
|
-
ignore_case_ = other.ignore_case_;
|
465
|
-
return *this;
|
466
|
-
}
|
467
|
-
|
468
|
-
bool XdsApi::StringMatcher::operator==(const StringMatcher& other) const {
|
469
|
-
if (type_ != other.type_ || ignore_case_ != other.ignore_case_) return false;
|
470
|
-
switch (type_) {
|
471
|
-
case StringMatcherType::SAFE_REGEX:
|
472
|
-
return regex_matcher_->pattern() == other.regex_matcher_->pattern();
|
473
|
-
default:
|
474
|
-
return string_matcher_ == other.string_matcher_;
|
475
|
-
}
|
476
|
-
}
|
477
|
-
|
478
|
-
bool XdsApi::StringMatcher::Match(absl::string_view value) const {
|
479
|
-
switch (type_) {
|
480
|
-
case XdsApi::StringMatcher::StringMatcherType::EXACT:
|
481
|
-
return ignore_case_ ? absl::EqualsIgnoreCase(value, string_matcher_)
|
482
|
-
: value == string_matcher_;
|
483
|
-
case XdsApi::StringMatcher::StringMatcherType::PREFIX:
|
484
|
-
return ignore_case_ ? absl::StartsWithIgnoreCase(value, string_matcher_)
|
485
|
-
: absl::StartsWith(value, string_matcher_);
|
486
|
-
case XdsApi::StringMatcher::StringMatcherType::SUFFIX:
|
487
|
-
return ignore_case_ ? absl::EndsWithIgnoreCase(value, string_matcher_)
|
488
|
-
: absl::EndsWith(value, string_matcher_);
|
489
|
-
case XdsApi::StringMatcher::StringMatcherType::CONTAINS:
|
490
|
-
return ignore_case_
|
491
|
-
? absl::StrContains(absl::AsciiStrToLower(value),
|
492
|
-
absl::AsciiStrToLower(string_matcher_))
|
493
|
-
: absl::StrContains(value, string_matcher_);
|
494
|
-
case XdsApi::StringMatcher::StringMatcherType::SAFE_REGEX:
|
495
|
-
// ignore_case_ is ignored for SAFE_REGEX
|
496
|
-
return RE2::FullMatch(std::string(value), *regex_matcher_);
|
497
|
-
default:
|
498
|
-
return false;
|
499
|
-
}
|
500
|
-
}
|
501
|
-
|
502
|
-
std::string XdsApi::StringMatcher::ToString() const {
|
503
|
-
switch (type_) {
|
504
|
-
case StringMatcherType::EXACT:
|
505
|
-
return absl::StrFormat("StringMatcher{exact=%s%s}", string_matcher_,
|
506
|
-
ignore_case_ ? ", ignore_case" : "");
|
507
|
-
case StringMatcherType::PREFIX:
|
508
|
-
return absl::StrFormat("StringMatcher{prefix=%s%s}", string_matcher_,
|
509
|
-
ignore_case_ ? ", ignore_case" : "");
|
510
|
-
case StringMatcherType::SUFFIX:
|
511
|
-
return absl::StrFormat("StringMatcher{suffix=%s%s}", string_matcher_,
|
512
|
-
ignore_case_ ? ", ignore_case" : "");
|
513
|
-
case StringMatcherType::CONTAINS:
|
514
|
-
return absl::StrFormat("StringMatcher{contains=%s%s}", string_matcher_,
|
515
|
-
ignore_case_ ? ", ignore_case" : "");
|
516
|
-
case StringMatcherType::SAFE_REGEX:
|
517
|
-
return absl::StrFormat("StringMatcher{safe_regex=%s}",
|
518
|
-
regex_matcher_->pattern());
|
519
|
-
default:
|
520
|
-
return "";
|
521
|
-
}
|
522
|
-
}
|
523
|
-
|
524
409
|
//
|
525
410
|
// XdsApi::CommonTlsContext::CertificateValidationContext
|
526
411
|
//
|
@@ -609,6 +494,204 @@ bool XdsApi::CommonTlsContext::Empty() const {
|
|
609
494
|
combined_validation_context.Empty();
|
610
495
|
}
|
611
496
|
|
497
|
+
//
|
498
|
+
// XdsApi::DownstreamTlsContext
|
499
|
+
//
|
500
|
+
|
501
|
+
std::string XdsApi::DownstreamTlsContext::ToString() const {
|
502
|
+
return absl::StrFormat("common_tls_context=%s, require_client_certificate=%s",
|
503
|
+
common_tls_context.ToString(),
|
504
|
+
require_client_certificate ? "true" : "false");
|
505
|
+
}
|
506
|
+
|
507
|
+
bool XdsApi::DownstreamTlsContext::Empty() const {
|
508
|
+
return common_tls_context.Empty();
|
509
|
+
}
|
510
|
+
|
511
|
+
//
|
512
|
+
// XdsApi::LdsUpdate::HttpConnectionManager
|
513
|
+
//
|
514
|
+
|
515
|
+
std::string XdsApi::LdsUpdate::HttpConnectionManager::ToString() const {
|
516
|
+
absl::InlinedVector<std::string, 4> contents;
|
517
|
+
contents.push_back(absl::StrFormat(
|
518
|
+
"route_config_name=%s",
|
519
|
+
!route_config_name.empty() ? route_config_name.c_str() : "<inlined>"));
|
520
|
+
contents.push_back(absl::StrFormat("http_max_stream_duration=%s",
|
521
|
+
http_max_stream_duration.ToString()));
|
522
|
+
if (rds_update.has_value()) {
|
523
|
+
contents.push_back(
|
524
|
+
absl::StrFormat("rds_update=%s", rds_update->ToString()));
|
525
|
+
}
|
526
|
+
if (!http_filters.empty()) {
|
527
|
+
std::vector<std::string> filter_strings;
|
528
|
+
for (const auto& http_filter : http_filters) {
|
529
|
+
filter_strings.push_back(http_filter.ToString());
|
530
|
+
}
|
531
|
+
contents.push_back(absl::StrCat("http_filters=[",
|
532
|
+
absl::StrJoin(filter_strings, ", "), "]"));
|
533
|
+
}
|
534
|
+
return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
|
535
|
+
}
|
536
|
+
|
537
|
+
//
|
538
|
+
// XdsApi::LdsUpdate::HttpFilter
|
539
|
+
//
|
540
|
+
|
541
|
+
std::string XdsApi::LdsUpdate::HttpConnectionManager::HttpFilter::ToString()
|
542
|
+
const {
|
543
|
+
return absl::StrCat("{name=", name, ", config=", config.ToString(), "}");
|
544
|
+
}
|
545
|
+
|
546
|
+
//
|
547
|
+
// XdsApi::LdsUpdate::FilterChainData
|
548
|
+
//
|
549
|
+
|
550
|
+
std::string XdsApi::LdsUpdate::FilterChainData::ToString() const {
|
551
|
+
return absl::StrCat(
|
552
|
+
"{downstream_tls_context=", downstream_tls_context.ToString(),
|
553
|
+
" http_connection_manager=", http_connection_manager.ToString(), "}");
|
554
|
+
}
|
555
|
+
|
556
|
+
//
|
557
|
+
// XdsApi::LdsUpdate::FilterChainMap::CidrRange
|
558
|
+
//
|
559
|
+
|
560
|
+
std::string XdsApi::LdsUpdate::FilterChainMap::CidrRange::ToString() const {
|
561
|
+
return absl::StrCat(
|
562
|
+
"{address_prefix=", grpc_sockaddr_to_string(&address, false),
|
563
|
+
", prefix_len=", prefix_len, "}");
|
564
|
+
}
|
565
|
+
|
566
|
+
//
|
567
|
+
// FilterChain
|
568
|
+
//
|
569
|
+
|
570
|
+
struct FilterChain {
|
571
|
+
struct FilterChainMatch {
|
572
|
+
uint32_t destination_port = 0;
|
573
|
+
std::vector<XdsApi::LdsUpdate::FilterChainMap::CidrRange> prefix_ranges;
|
574
|
+
XdsApi::LdsUpdate::FilterChainMap::ConnectionSourceType source_type =
|
575
|
+
XdsApi::LdsUpdate::FilterChainMap::ConnectionSourceType::kAny;
|
576
|
+
std::vector<XdsApi::LdsUpdate::FilterChainMap::CidrRange>
|
577
|
+
source_prefix_ranges;
|
578
|
+
std::vector<uint32_t> source_ports;
|
579
|
+
std::vector<std::string> server_names;
|
580
|
+
std::string transport_protocol;
|
581
|
+
std::vector<std::string> application_protocols;
|
582
|
+
|
583
|
+
std::string ToString() const;
|
584
|
+
} filter_chain_match;
|
585
|
+
|
586
|
+
std::shared_ptr<XdsApi::LdsUpdate::FilterChainData> filter_chain_data;
|
587
|
+
};
|
588
|
+
|
589
|
+
std::string FilterChain::FilterChainMatch::ToString() const {
|
590
|
+
absl::InlinedVector<std::string, 8> contents;
|
591
|
+
if (destination_port != 0) {
|
592
|
+
contents.push_back(absl::StrCat("destination_port=", destination_port));
|
593
|
+
}
|
594
|
+
if (!prefix_ranges.empty()) {
|
595
|
+
std::vector<std::string> prefix_ranges_content;
|
596
|
+
for (const auto& range : prefix_ranges) {
|
597
|
+
prefix_ranges_content.push_back(range.ToString());
|
598
|
+
}
|
599
|
+
contents.push_back(absl::StrCat(
|
600
|
+
"prefix_ranges={", absl::StrJoin(prefix_ranges_content, ", "), "}"));
|
601
|
+
}
|
602
|
+
if (source_type == XdsApi::LdsUpdate::FilterChainMap::ConnectionSourceType::
|
603
|
+
kSameIpOrLoopback) {
|
604
|
+
contents.push_back("source_type=SAME_IP_OR_LOOPBACK");
|
605
|
+
} else if (source_type == XdsApi::LdsUpdate::FilterChainMap::
|
606
|
+
ConnectionSourceType::kExternal) {
|
607
|
+
contents.push_back("source_type=EXTERNAL");
|
608
|
+
}
|
609
|
+
if (!source_prefix_ranges.empty()) {
|
610
|
+
std::vector<std::string> source_prefix_ranges_content;
|
611
|
+
for (const auto& range : source_prefix_ranges) {
|
612
|
+
source_prefix_ranges_content.push_back(range.ToString());
|
613
|
+
}
|
614
|
+
contents.push_back(
|
615
|
+
absl::StrCat("source_prefix_ranges={",
|
616
|
+
absl::StrJoin(source_prefix_ranges_content, ", "), "}"));
|
617
|
+
}
|
618
|
+
if (!source_ports.empty()) {
|
619
|
+
contents.push_back(
|
620
|
+
absl::StrCat("source_ports={", absl::StrJoin(source_ports, ", "), "}"));
|
621
|
+
}
|
622
|
+
if (!server_names.empty()) {
|
623
|
+
contents.push_back(
|
624
|
+
absl::StrCat("server_names={", absl::StrJoin(server_names, ", "), "}"));
|
625
|
+
}
|
626
|
+
if (!transport_protocol.empty()) {
|
627
|
+
contents.push_back(absl::StrCat("transport_protocol=", transport_protocol));
|
628
|
+
}
|
629
|
+
if (!application_protocols.empty()) {
|
630
|
+
contents.push_back(absl::StrCat("application_protocols={",
|
631
|
+
absl::StrJoin(application_protocols, ", "),
|
632
|
+
"}"));
|
633
|
+
}
|
634
|
+
return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
|
635
|
+
}
|
636
|
+
|
637
|
+
//
|
638
|
+
// XdsApi::LdsUpdate::FilterChainMap
|
639
|
+
//
|
640
|
+
|
641
|
+
std::string XdsApi::LdsUpdate::FilterChainMap::ToString() const {
|
642
|
+
std::vector<std::string> contents;
|
643
|
+
for (const auto& destination_ip : destination_ip_vector) {
|
644
|
+
for (int source_type = 0; source_type < 3; ++source_type) {
|
645
|
+
for (const auto& source_ip :
|
646
|
+
destination_ip.source_types_array[source_type]) {
|
647
|
+
for (const auto& source_port_pair : source_ip.ports_map) {
|
648
|
+
FilterChain::FilterChainMatch filter_chain_match;
|
649
|
+
if (destination_ip.prefix_range.has_value()) {
|
650
|
+
filter_chain_match.prefix_ranges.push_back(
|
651
|
+
*destination_ip.prefix_range);
|
652
|
+
}
|
653
|
+
filter_chain_match.source_type = static_cast<
|
654
|
+
XdsApi::LdsUpdate::FilterChainMap::ConnectionSourceType>(
|
655
|
+
source_type);
|
656
|
+
if (source_ip.prefix_range.has_value()) {
|
657
|
+
filter_chain_match.source_prefix_ranges.push_back(
|
658
|
+
*source_ip.prefix_range);
|
659
|
+
}
|
660
|
+
if (source_port_pair.first != 0) {
|
661
|
+
filter_chain_match.source_ports.push_back(source_port_pair.first);
|
662
|
+
}
|
663
|
+
contents.push_back(absl::StrCat(
|
664
|
+
"{filter_chain_match=", filter_chain_match.ToString(),
|
665
|
+
", filter_chain=", source_port_pair.second.data->ToString(),
|
666
|
+
"}"));
|
667
|
+
}
|
668
|
+
}
|
669
|
+
}
|
670
|
+
}
|
671
|
+
return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
|
672
|
+
}
|
673
|
+
|
674
|
+
//
|
675
|
+
// XdsApi::LdsUpdate
|
676
|
+
//
|
677
|
+
|
678
|
+
std::string XdsApi::LdsUpdate::ToString() const {
|
679
|
+
absl::InlinedVector<std::string, 4> contents;
|
680
|
+
if (type == ListenerType::kTcpListener) {
|
681
|
+
contents.push_back(absl::StrCat("address=", address));
|
682
|
+
contents.push_back(
|
683
|
+
absl::StrCat("filter_chain_map=", filter_chain_map.ToString()));
|
684
|
+
if (default_filter_chain.has_value()) {
|
685
|
+
contents.push_back(absl::StrCat("default_filter_chain=",
|
686
|
+
default_filter_chain->ToString()));
|
687
|
+
}
|
688
|
+
} else if (type == ListenerType::kHttpApiListener) {
|
689
|
+
contents.push_back(absl::StrFormat("http_connection_manager=%s",
|
690
|
+
http_connection_manager.ToString()));
|
691
|
+
}
|
692
|
+
return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
|
693
|
+
}
|
694
|
+
|
612
695
|
//
|
613
696
|
// XdsApi::CdsUpdate
|
614
697
|
//
|
@@ -724,8 +807,13 @@ const char* kCdsV2TypeUrl = "type.googleapis.com/envoy.api.v2.Cluster";
|
|
724
807
|
const char* kEdsV2TypeUrl =
|
725
808
|
"type.googleapis.com/envoy.api.v2.ClusterLoadAssignment";
|
726
809
|
|
727
|
-
bool IsLds(absl::string_view type_url) {
|
728
|
-
|
810
|
+
bool IsLds(absl::string_view type_url, bool* is_v2 = nullptr) {
|
811
|
+
if (type_url == XdsApi::kLdsTypeUrl) return true;
|
812
|
+
if (type_url == kLdsV2TypeUrl) {
|
813
|
+
if (is_v2 != nullptr) *is_v2 = true;
|
814
|
+
return true;
|
815
|
+
}
|
816
|
+
return false;
|
729
817
|
}
|
730
818
|
|
731
819
|
bool IsRds(absl::string_view type_url) {
|
@@ -749,39 +837,67 @@ XdsApi::XdsApi(XdsClient* client, TraceFlag* tracer,
|
|
749
837
|
node_(node),
|
750
838
|
build_version_(absl::StrCat("gRPC C-core ", GPR_PLATFORM_STRING, " ",
|
751
839
|
grpc_version_string())),
|
752
|
-
user_agent_name_(absl::StrCat("gRPC C-core ", GPR_PLATFORM_STRING)) {
|
840
|
+
user_agent_name_(absl::StrCat("gRPC C-core ", GPR_PLATFORM_STRING)) {
|
841
|
+
// Populate upb symtab with xDS proto messages that we want to print
|
842
|
+
// properly in logs.
|
843
|
+
// Note: This won't actually work properly until upb adds support for
|
844
|
+
// Any fields in textproto printing (internal b/178821188).
|
845
|
+
envoy_config_listener_v3_Listener_getmsgdef(symtab_.ptr());
|
846
|
+
envoy_config_route_v3_RouteConfiguration_getmsgdef(symtab_.ptr());
|
847
|
+
envoy_config_cluster_v3_Cluster_getmsgdef(symtab_.ptr());
|
848
|
+
envoy_extensions_clusters_aggregate_v3_ClusterConfig_getmsgdef(symtab_.ptr());
|
849
|
+
envoy_config_cluster_v3_Cluster_getmsgdef(symtab_.ptr());
|
850
|
+
envoy_config_endpoint_v3_ClusterLoadAssignment_getmsgdef(symtab_.ptr());
|
851
|
+
envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_getmsgdef(
|
852
|
+
symtab_.ptr());
|
853
|
+
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_getmsgdef(
|
854
|
+
symtab_.ptr());
|
855
|
+
// Load HTTP filter proto messages into the upb symtab.
|
856
|
+
XdsHttpFilterRegistry::PopulateSymtab(symtab_.ptr());
|
857
|
+
}
|
753
858
|
|
754
859
|
namespace {
|
755
860
|
|
861
|
+
struct EncodingContext {
|
862
|
+
XdsClient* client;
|
863
|
+
TraceFlag* tracer;
|
864
|
+
upb_symtab* symtab;
|
865
|
+
upb_arena* arena;
|
866
|
+
bool use_v3;
|
867
|
+
};
|
868
|
+
|
756
869
|
// Works for both std::string and absl::string_view.
|
757
870
|
template <typename T>
|
758
871
|
inline upb_strview StdStringToUpbString(const T& str) {
|
759
872
|
return upb_strview_make(str.data(), str.size());
|
760
873
|
}
|
761
874
|
|
762
|
-
void PopulateMetadataValue(
|
763
|
-
const Json& value);
|
875
|
+
void PopulateMetadataValue(const EncodingContext& context,
|
876
|
+
google_protobuf_Value* value_pb, const Json& value);
|
764
877
|
|
765
|
-
void PopulateListValue(
|
878
|
+
void PopulateListValue(const EncodingContext& context,
|
879
|
+
google_protobuf_ListValue* list_value,
|
766
880
|
const Json::Array& values) {
|
767
881
|
for (const auto& value : values) {
|
768
|
-
auto* value_pb =
|
769
|
-
|
882
|
+
auto* value_pb =
|
883
|
+
google_protobuf_ListValue_add_values(list_value, context.arena);
|
884
|
+
PopulateMetadataValue(context, value_pb, value);
|
770
885
|
}
|
771
886
|
}
|
772
887
|
|
773
|
-
void PopulateMetadata(
|
888
|
+
void PopulateMetadata(const EncodingContext& context,
|
889
|
+
google_protobuf_Struct* metadata_pb,
|
774
890
|
const Json::Object& metadata) {
|
775
891
|
for (const auto& p : metadata) {
|
776
|
-
google_protobuf_Value* value = google_protobuf_Value_new(arena);
|
777
|
-
PopulateMetadataValue(
|
892
|
+
google_protobuf_Value* value = google_protobuf_Value_new(context.arena);
|
893
|
+
PopulateMetadataValue(context, value, p.second);
|
778
894
|
google_protobuf_Struct_fields_set(
|
779
|
-
metadata_pb, StdStringToUpbString(p.first), value, arena);
|
895
|
+
metadata_pb, StdStringToUpbString(p.first), value, context.arena);
|
780
896
|
}
|
781
897
|
}
|
782
898
|
|
783
|
-
void PopulateMetadataValue(
|
784
|
-
const Json& value) {
|
899
|
+
void PopulateMetadataValue(const EncodingContext& context,
|
900
|
+
google_protobuf_Value* value_pb, const Json& value) {
|
785
901
|
switch (value.type()) {
|
786
902
|
case Json::Type::JSON_NULL:
|
787
903
|
google_protobuf_Value_set_null_value(value_pb, 0);
|
@@ -802,14 +918,14 @@ void PopulateMetadataValue(upb_arena* arena, google_protobuf_Value* value_pb,
|
|
802
918
|
break;
|
803
919
|
case Json::Type::OBJECT: {
|
804
920
|
google_protobuf_Struct* struct_value =
|
805
|
-
google_protobuf_Value_mutable_struct_value(value_pb, arena);
|
806
|
-
PopulateMetadata(
|
921
|
+
google_protobuf_Value_mutable_struct_value(value_pb, context.arena);
|
922
|
+
PopulateMetadata(context, struct_value, value.object_value());
|
807
923
|
break;
|
808
924
|
}
|
809
925
|
case Json::Type::ARRAY: {
|
810
926
|
google_protobuf_ListValue* list_value =
|
811
|
-
google_protobuf_Value_mutable_list_value(value_pb, arena);
|
812
|
-
PopulateListValue(
|
927
|
+
google_protobuf_Value_mutable_list_value(value_pb, context.arena);
|
928
|
+
PopulateListValue(context, list_value, value.array_value());
|
813
929
|
break;
|
814
930
|
}
|
815
931
|
}
|
@@ -836,7 +952,8 @@ std::string EncodeStringField(uint32_t field_number, const std::string& str) {
|
|
836
952
|
EncodeVarint(str.size()) + str;
|
837
953
|
}
|
838
954
|
|
839
|
-
void PopulateBuildVersion(
|
955
|
+
void PopulateBuildVersion(const EncodingContext& context,
|
956
|
+
envoy_config_core_v3_Node* node_msg,
|
840
957
|
const std::string& build_version) {
|
841
958
|
std::string encoded_build_version = EncodeStringField(5, build_version);
|
842
959
|
// TODO(roth): This should use upb_msg_addunknown(), but that API is
|
@@ -844,10 +961,11 @@ void PopulateBuildVersion(upb_arena* arena, envoy_config_core_v3_Node* node_msg,
|
|
844
961
|
// API for now. Change this once we upgrade to a version of upb that
|
845
962
|
// fixes this bug.
|
846
963
|
_upb_msg_addunknown(node_msg, encoded_build_version.data(),
|
847
|
-
encoded_build_version.size(), arena);
|
964
|
+
encoded_build_version.size(), context.arena);
|
848
965
|
}
|
849
966
|
|
850
|
-
void PopulateNode(
|
967
|
+
void PopulateNode(const EncodingContext& context,
|
968
|
+
const XdsBootstrap::Node* node,
|
851
969
|
const std::string& build_version,
|
852
970
|
const std::string& user_agent_name,
|
853
971
|
envoy_config_core_v3_Node* node_msg) {
|
@@ -862,13 +980,13 @@ void PopulateNode(upb_arena* arena, const XdsBootstrap::Node* node, bool use_v3,
|
|
862
980
|
}
|
863
981
|
if (!node->metadata.object_value().empty()) {
|
864
982
|
google_protobuf_Struct* metadata =
|
865
|
-
envoy_config_core_v3_Node_mutable_metadata(node_msg, arena);
|
866
|
-
PopulateMetadata(
|
983
|
+
envoy_config_core_v3_Node_mutable_metadata(node_msg, context.arena);
|
984
|
+
PopulateMetadata(context, metadata, node->metadata.object_value());
|
867
985
|
}
|
868
986
|
if (!node->locality_region.empty() || !node->locality_zone.empty() ||
|
869
|
-
!node->
|
987
|
+
!node->locality_sub_zone.empty()) {
|
870
988
|
envoy_config_core_v3_Locality* locality =
|
871
|
-
envoy_config_core_v3_Node_mutable_locality(node_msg, arena);
|
989
|
+
envoy_config_core_v3_Node_mutable_locality(node_msg, context.arena);
|
872
990
|
if (!node->locality_region.empty()) {
|
873
991
|
envoy_config_core_v3_Locality_set_region(
|
874
992
|
locality, StdStringToUpbString(node->locality_region));
|
@@ -877,14 +995,14 @@ void PopulateNode(upb_arena* arena, const XdsBootstrap::Node* node, bool use_v3,
|
|
877
995
|
envoy_config_core_v3_Locality_set_zone(
|
878
996
|
locality, StdStringToUpbString(node->locality_zone));
|
879
997
|
}
|
880
|
-
if (!node->
|
998
|
+
if (!node->locality_sub_zone.empty()) {
|
881
999
|
envoy_config_core_v3_Locality_set_sub_zone(
|
882
|
-
locality, StdStringToUpbString(node->
|
1000
|
+
locality, StdStringToUpbString(node->locality_sub_zone));
|
883
1001
|
}
|
884
1002
|
}
|
885
1003
|
}
|
886
|
-
if (!use_v3) {
|
887
|
-
PopulateBuildVersion(
|
1004
|
+
if (!context.use_v3) {
|
1005
|
+
PopulateBuildVersion(context, node_msg, build_version);
|
888
1006
|
}
|
889
1007
|
envoy_config_core_v3_Node_set_user_agent_name(
|
890
1008
|
node_msg, StdStringToUpbString(user_agent_name));
|
@@ -892,7 +1010,7 @@ void PopulateNode(upb_arena* arena, const XdsBootstrap::Node* node, bool use_v3,
|
|
892
1010
|
node_msg, upb_strview_makez(grpc_version_string()));
|
893
1011
|
envoy_config_core_v3_Node_add_client_features(
|
894
1012
|
node_msg, upb_strview_makez("envoy.lb.does_not_support_overprovisioning"),
|
895
|
-
arena);
|
1013
|
+
context.arena);
|
896
1014
|
}
|
897
1015
|
|
898
1016
|
inline absl::string_view UpbStringToAbsl(const upb_strview& str) {
|
@@ -904,24 +1022,25 @@ inline std::string UpbStringToStdString(const upb_strview& str) {
|
|
904
1022
|
}
|
905
1023
|
|
906
1024
|
void MaybeLogDiscoveryRequest(
|
907
|
-
|
1025
|
+
const EncodingContext& context,
|
908
1026
|
const envoy_service_discovery_v3_DiscoveryRequest* request) {
|
909
|
-
if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
|
1027
|
+
if (GRPC_TRACE_FLAG_ENABLED(*context.tracer) &&
|
910
1028
|
gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
|
911
1029
|
const upb_msgdef* msg_type =
|
912
|
-
envoy_service_discovery_v3_DiscoveryRequest_getmsgdef(symtab);
|
1030
|
+
envoy_service_discovery_v3_DiscoveryRequest_getmsgdef(context.symtab);
|
913
1031
|
char buf[10240];
|
914
1032
|
upb_text_encode(request, msg_type, nullptr, 0, buf, sizeof(buf));
|
915
|
-
gpr_log(GPR_DEBUG, "[xds_client %p] constructed ADS request: %s",
|
916
|
-
buf);
|
1033
|
+
gpr_log(GPR_DEBUG, "[xds_client %p] constructed ADS request: %s",
|
1034
|
+
context.client, buf);
|
917
1035
|
}
|
918
1036
|
}
|
919
1037
|
|
920
1038
|
grpc_slice SerializeDiscoveryRequest(
|
921
|
-
|
1039
|
+
const EncodingContext& context,
|
1040
|
+
envoy_service_discovery_v3_DiscoveryRequest* request) {
|
922
1041
|
size_t output_length;
|
923
1042
|
char* output = envoy_service_discovery_v3_DiscoveryRequest_serialize(
|
924
|
-
request, arena, &output_length);
|
1043
|
+
request, context.arena, &output_length);
|
925
1044
|
return grpc_slice_from_copied_buffer(output, output_length);
|
926
1045
|
}
|
927
1046
|
|
@@ -949,9 +1068,11 @@ absl::string_view TypeUrlExternalToInternal(bool use_v3,
|
|
949
1068
|
grpc_slice XdsApi::CreateAdsRequest(
|
950
1069
|
const XdsBootstrap::XdsServer& server, const std::string& type_url,
|
951
1070
|
const std::set<absl::string_view>& resource_names,
|
952
|
-
const std::string& version, const std::string& nonce,
|
953
|
-
bool populate_node) {
|
1071
|
+
const std::string& version, const std::string& nonce,
|
1072
|
+
grpc_error_handle error, bool populate_node) {
|
954
1073
|
upb::Arena arena;
|
1074
|
+
const EncodingContext context = {client_, tracer_, symtab_.ptr(), arena.ptr(),
|
1075
|
+
server.ShouldUseV3()};
|
955
1076
|
// Create a request.
|
956
1077
|
envoy_service_discovery_v3_DiscoveryRequest* request =
|
957
1078
|
envoy_service_discovery_v3_DiscoveryRequest_new(arena.ptr());
|
@@ -971,6 +1092,7 @@ grpc_slice XdsApi::CreateAdsRequest(
|
|
971
1092
|
request, StdStringToUpbString(nonce));
|
972
1093
|
}
|
973
1094
|
// Set error_detail if it's a NACK.
|
1095
|
+
std::string error_string_storage;
|
974
1096
|
if (error != GRPC_ERROR_NONE) {
|
975
1097
|
google_rpc_Status* error_detail =
|
976
1098
|
envoy_service_discovery_v3_DiscoveryRequest_mutable_error_detail(
|
@@ -981,12 +1103,9 @@ grpc_slice XdsApi::CreateAdsRequest(
|
|
981
1103
|
// generate them in the parsing code, and then use that here.
|
982
1104
|
google_rpc_Status_set_code(error_detail, GRPC_STATUS_INVALID_ARGUMENT);
|
983
1105
|
// Error description comes from the error that was passed in.
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
upb_strview error_description_strview =
|
988
|
-
StdStringToUpbString(StringViewFromSlice(error_description_slice));
|
989
|
-
google_rpc_Status_set_message(error_detail, error_description_strview);
|
1106
|
+
error_string_storage = grpc_error_std_string(error);
|
1107
|
+
upb_strview error_description = StdStringToUpbString(error_string_storage);
|
1108
|
+
google_rpc_Status_set_message(error_detail, error_description);
|
990
1109
|
GRPC_ERROR_UNREF(error);
|
991
1110
|
}
|
992
1111
|
// Populate node.
|
@@ -994,79 +1113,102 @@ grpc_slice XdsApi::CreateAdsRequest(
|
|
994
1113
|
envoy_config_core_v3_Node* node_msg =
|
995
1114
|
envoy_service_discovery_v3_DiscoveryRequest_mutable_node(request,
|
996
1115
|
arena.ptr());
|
997
|
-
PopulateNode(
|
998
|
-
user_agent_name_, node_msg);
|
1116
|
+
PopulateNode(context, node_, build_version_, user_agent_name_, node_msg);
|
999
1117
|
}
|
1000
1118
|
// Add resource_names.
|
1001
1119
|
for (const auto& resource_name : resource_names) {
|
1002
1120
|
envoy_service_discovery_v3_DiscoveryRequest_add_resource_names(
|
1003
1121
|
request, StdStringToUpbString(resource_name), arena.ptr());
|
1004
1122
|
}
|
1005
|
-
MaybeLogDiscoveryRequest(
|
1006
|
-
return SerializeDiscoveryRequest(
|
1123
|
+
MaybeLogDiscoveryRequest(context, request);
|
1124
|
+
return SerializeDiscoveryRequest(context, request);
|
1007
1125
|
}
|
1008
1126
|
|
1009
1127
|
namespace {
|
1010
1128
|
|
1011
1129
|
void MaybeLogDiscoveryResponse(
|
1012
|
-
|
1130
|
+
const EncodingContext& context,
|
1013
1131
|
const envoy_service_discovery_v3_DiscoveryResponse* response) {
|
1014
|
-
if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
|
1132
|
+
if (GRPC_TRACE_FLAG_ENABLED(*context.tracer) &&
|
1015
1133
|
gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
|
1016
1134
|
const upb_msgdef* msg_type =
|
1017
|
-
envoy_service_discovery_v3_DiscoveryResponse_getmsgdef(symtab);
|
1135
|
+
envoy_service_discovery_v3_DiscoveryResponse_getmsgdef(context.symtab);
|
1018
1136
|
char buf[10240];
|
1019
1137
|
upb_text_encode(response, msg_type, nullptr, 0, buf, sizeof(buf));
|
1020
|
-
gpr_log(GPR_DEBUG, "[xds_client %p] received response: %s", client,
|
1138
|
+
gpr_log(GPR_DEBUG, "[xds_client %p] received response: %s", context.client,
|
1139
|
+
buf);
|
1140
|
+
}
|
1141
|
+
}
|
1142
|
+
|
1143
|
+
void MaybeLogHttpConnectionManager(
|
1144
|
+
const EncodingContext& context,
|
1145
|
+
const envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager*
|
1146
|
+
http_connection_manager_config) {
|
1147
|
+
if (GRPC_TRACE_FLAG_ENABLED(*context.tracer) &&
|
1148
|
+
gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
|
1149
|
+
const upb_msgdef* msg_type =
|
1150
|
+
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_getmsgdef(
|
1151
|
+
context.symtab);
|
1152
|
+
char buf[10240];
|
1153
|
+
upb_text_encode(http_connection_manager_config, msg_type, nullptr, 0, buf,
|
1154
|
+
sizeof(buf));
|
1155
|
+
gpr_log(GPR_DEBUG, "[xds_client %p] HttpConnectionManager: %s",
|
1156
|
+
context.client, buf);
|
1021
1157
|
}
|
1022
1158
|
}
|
1023
1159
|
|
1024
1160
|
void MaybeLogRouteConfiguration(
|
1025
|
-
|
1161
|
+
const EncodingContext& context,
|
1026
1162
|
const envoy_config_route_v3_RouteConfiguration* route_config) {
|
1027
|
-
if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
|
1163
|
+
if (GRPC_TRACE_FLAG_ENABLED(*context.tracer) &&
|
1028
1164
|
gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
|
1029
1165
|
const upb_msgdef* msg_type =
|
1030
|
-
envoy_config_route_v3_RouteConfiguration_getmsgdef(symtab);
|
1166
|
+
envoy_config_route_v3_RouteConfiguration_getmsgdef(context.symtab);
|
1031
1167
|
char buf[10240];
|
1032
1168
|
upb_text_encode(route_config, msg_type, nullptr, 0, buf, sizeof(buf));
|
1033
|
-
gpr_log(GPR_DEBUG, "[xds_client %p] RouteConfiguration: %s", client,
|
1169
|
+
gpr_log(GPR_DEBUG, "[xds_client %p] RouteConfiguration: %s", context.client,
|
1170
|
+
buf);
|
1034
1171
|
}
|
1035
1172
|
}
|
1036
1173
|
|
1037
|
-
void MaybeLogCluster(
|
1174
|
+
void MaybeLogCluster(const EncodingContext& context,
|
1038
1175
|
const envoy_config_cluster_v3_Cluster* cluster) {
|
1039
|
-
if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
|
1176
|
+
if (GRPC_TRACE_FLAG_ENABLED(*context.tracer) &&
|
1040
1177
|
gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
|
1041
1178
|
const upb_msgdef* msg_type =
|
1042
|
-
envoy_config_cluster_v3_Cluster_getmsgdef(symtab);
|
1179
|
+
envoy_config_cluster_v3_Cluster_getmsgdef(context.symtab);
|
1043
1180
|
char buf[10240];
|
1044
1181
|
upb_text_encode(cluster, msg_type, nullptr, 0, buf, sizeof(buf));
|
1045
|
-
gpr_log(GPR_DEBUG, "[xds_client %p] Cluster: %s", client, buf);
|
1182
|
+
gpr_log(GPR_DEBUG, "[xds_client %p] Cluster: %s", context.client, buf);
|
1046
1183
|
}
|
1047
1184
|
}
|
1048
1185
|
|
1049
1186
|
void MaybeLogClusterLoadAssignment(
|
1050
|
-
|
1187
|
+
const EncodingContext& context,
|
1051
1188
|
const envoy_config_endpoint_v3_ClusterLoadAssignment* cla) {
|
1052
|
-
if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
|
1189
|
+
if (GRPC_TRACE_FLAG_ENABLED(*context.tracer) &&
|
1053
1190
|
gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
|
1054
1191
|
const upb_msgdef* msg_type =
|
1055
|
-
envoy_config_endpoint_v3_ClusterLoadAssignment_getmsgdef(
|
1192
|
+
envoy_config_endpoint_v3_ClusterLoadAssignment_getmsgdef(
|
1193
|
+
context.symtab);
|
1056
1194
|
char buf[10240];
|
1057
1195
|
upb_text_encode(cla, msg_type, nullptr, 0, buf, sizeof(buf));
|
1058
|
-
gpr_log(GPR_DEBUG, "[xds_client %p] ClusterLoadAssignment: %s",
|
1059
|
-
buf);
|
1196
|
+
gpr_log(GPR_DEBUG, "[xds_client %p] ClusterLoadAssignment: %s",
|
1197
|
+
context.client, buf);
|
1060
1198
|
}
|
1061
1199
|
}
|
1062
1200
|
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1201
|
+
grpc_error_handle RoutePathMatchParse(
|
1202
|
+
const envoy_config_route_v3_RouteMatch* match, XdsApi::Route* route,
|
1203
|
+
bool* ignore_route) {
|
1204
|
+
auto* case_sensitive_ptr =
|
1205
|
+
envoy_config_route_v3_RouteMatch_case_sensitive(match);
|
1206
|
+
bool case_sensitive = true;
|
1207
|
+
if (case_sensitive_ptr != nullptr) {
|
1208
|
+
case_sensitive = google_protobuf_BoolValue_value(case_sensitive_ptr);
|
1069
1209
|
}
|
1210
|
+
StringMatcher::Type type;
|
1211
|
+
std::string match_string;
|
1070
1212
|
if (envoy_config_route_v3_RouteMatch_has_prefix(match)) {
|
1071
1213
|
absl::string_view prefix =
|
1072
1214
|
UpbStringToAbsl(envoy_config_route_v3_RouteMatch_prefix(match));
|
@@ -1091,9 +1233,8 @@ grpc_error* RoutePathMatchParse(const envoy_config_route_v3_RouteMatch* match,
|
|
1091
1233
|
return GRPC_ERROR_NONE;
|
1092
1234
|
}
|
1093
1235
|
}
|
1094
|
-
|
1095
|
-
|
1096
|
-
route->matchers.path_matcher.string_matcher = std::string(prefix);
|
1236
|
+
type = StringMatcher::Type::kPrefix;
|
1237
|
+
match_string = std::string(prefix);
|
1097
1238
|
} else if (envoy_config_route_v3_RouteMatch_has_path(match)) {
|
1098
1239
|
absl::string_view path =
|
1099
1240
|
UpbStringToAbsl(envoy_config_route_v3_RouteMatch_path(match));
|
@@ -1126,102 +1267,99 @@ grpc_error* RoutePathMatchParse(const envoy_config_route_v3_RouteMatch* match,
|
|
1126
1267
|
*ignore_route = true;
|
1127
1268
|
return GRPC_ERROR_NONE;
|
1128
1269
|
}
|
1129
|
-
|
1130
|
-
|
1131
|
-
route->matchers.path_matcher.string_matcher = std::string(path);
|
1270
|
+
type = StringMatcher::Type::kExact;
|
1271
|
+
match_string = std::string(path);
|
1132
1272
|
} else if (envoy_config_route_v3_RouteMatch_has_safe_regex(match)) {
|
1133
1273
|
const envoy_type_matcher_v3_RegexMatcher* regex_matcher =
|
1134
1274
|
envoy_config_route_v3_RouteMatch_safe_regex(match);
|
1135
1275
|
GPR_ASSERT(regex_matcher != nullptr);
|
1136
|
-
|
1276
|
+
type = StringMatcher::Type::kSafeRegex;
|
1277
|
+
match_string = UpbStringToStdString(
|
1137
1278
|
envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher));
|
1138
|
-
RE2::Options options;
|
1139
|
-
options.set_case_sensitive(route->matchers.path_matcher.case_sensitive);
|
1140
|
-
auto regex = absl::make_unique<RE2>(std::move(matcher), options);
|
1141
|
-
if (!regex->ok()) {
|
1142
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1143
|
-
"Invalid regex string specified in path matcher.");
|
1144
|
-
}
|
1145
|
-
route->matchers.path_matcher.type =
|
1146
|
-
XdsApi::Route::Matchers::PathMatcher::PathMatcherType::REGEX;
|
1147
|
-
route->matchers.path_matcher.regex_matcher = std::move(regex);
|
1148
1279
|
} else {
|
1149
1280
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1150
1281
|
"Invalid route path specifier specified.");
|
1151
1282
|
}
|
1283
|
+
absl::StatusOr<StringMatcher> string_matcher =
|
1284
|
+
StringMatcher::Create(type, match_string, case_sensitive);
|
1285
|
+
if (!string_matcher.ok()) {
|
1286
|
+
return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1287
|
+
absl::StrCat("path matcher: ", string_matcher.status().message())
|
1288
|
+
.c_str());
|
1289
|
+
;
|
1290
|
+
}
|
1291
|
+
route->matchers.path_matcher = std::move(string_matcher.value());
|
1152
1292
|
return GRPC_ERROR_NONE;
|
1153
1293
|
}
|
1154
1294
|
|
1155
|
-
|
1295
|
+
grpc_error_handle RouteHeaderMatchersParse(
|
1156
1296
|
const envoy_config_route_v3_RouteMatch* match, XdsApi::Route* route) {
|
1157
1297
|
size_t size;
|
1158
1298
|
const envoy_config_route_v3_HeaderMatcher* const* headers =
|
1159
1299
|
envoy_config_route_v3_RouteMatch_headers(match, &size);
|
1160
1300
|
for (size_t i = 0; i < size; ++i) {
|
1161
1301
|
const envoy_config_route_v3_HeaderMatcher* header = headers[i];
|
1162
|
-
|
1163
|
-
header_matcher.name =
|
1302
|
+
const std::string name =
|
1164
1303
|
UpbStringToStdString(envoy_config_route_v3_HeaderMatcher_name(header));
|
1304
|
+
HeaderMatcher::Type type;
|
1305
|
+
std::string match_string;
|
1306
|
+
int64_t range_start = 0;
|
1307
|
+
int64_t range_end = 0;
|
1308
|
+
bool present_match = false;
|
1165
1309
|
if (envoy_config_route_v3_HeaderMatcher_has_exact_match(header)) {
|
1166
|
-
|
1167
|
-
|
1168
|
-
header_matcher.string_matcher = UpbStringToStdString(
|
1310
|
+
type = HeaderMatcher::Type::kExact;
|
1311
|
+
match_string = UpbStringToStdString(
|
1169
1312
|
envoy_config_route_v3_HeaderMatcher_exact_match(header));
|
1170
1313
|
} else if (envoy_config_route_v3_HeaderMatcher_has_safe_regex_match(
|
1171
1314
|
header)) {
|
1172
1315
|
const envoy_type_matcher_v3_RegexMatcher* regex_matcher =
|
1173
1316
|
envoy_config_route_v3_HeaderMatcher_safe_regex_match(header);
|
1174
1317
|
GPR_ASSERT(regex_matcher != nullptr);
|
1175
|
-
|
1318
|
+
type = HeaderMatcher::Type::kSafeRegex;
|
1319
|
+
match_string = UpbStringToStdString(
|
1176
1320
|
envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher));
|
1177
|
-
std::unique_ptr<RE2> regex = absl::make_unique<RE2>(matcher);
|
1178
|
-
if (!regex->ok()) {
|
1179
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1180
|
-
"Invalid regex string specified in header matcher.");
|
1181
|
-
}
|
1182
|
-
header_matcher.type =
|
1183
|
-
XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::REGEX;
|
1184
|
-
header_matcher.regex_match = std::move(regex);
|
1185
1321
|
} else if (envoy_config_route_v3_HeaderMatcher_has_range_match(header)) {
|
1186
|
-
|
1187
|
-
XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::RANGE;
|
1322
|
+
type = HeaderMatcher::Type::kRange;
|
1188
1323
|
const envoy_type_v3_Int64Range* range_matcher =
|
1189
1324
|
envoy_config_route_v3_HeaderMatcher_range_match(header);
|
1190
|
-
|
1191
|
-
|
1192
|
-
header_matcher.range_end = envoy_type_v3_Int64Range_end(range_matcher);
|
1193
|
-
if (header_matcher.range_end < header_matcher.range_start) {
|
1194
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1195
|
-
"Invalid range header matcher specifier specified: end "
|
1196
|
-
"cannot be smaller than start.");
|
1197
|
-
}
|
1325
|
+
range_start = envoy_type_v3_Int64Range_start(range_matcher);
|
1326
|
+
range_end = envoy_type_v3_Int64Range_end(range_matcher);
|
1198
1327
|
} else if (envoy_config_route_v3_HeaderMatcher_has_present_match(header)) {
|
1199
|
-
|
1200
|
-
|
1201
|
-
header_matcher.present_match =
|
1202
|
-
envoy_config_route_v3_HeaderMatcher_present_match(header);
|
1328
|
+
type = HeaderMatcher::Type::kPresent;
|
1329
|
+
present_match = envoy_config_route_v3_HeaderMatcher_present_match(header);
|
1203
1330
|
} else if (envoy_config_route_v3_HeaderMatcher_has_prefix_match(header)) {
|
1204
|
-
|
1205
|
-
|
1206
|
-
header_matcher.string_matcher = UpbStringToStdString(
|
1331
|
+
type = HeaderMatcher::Type::kPrefix;
|
1332
|
+
match_string = UpbStringToStdString(
|
1207
1333
|
envoy_config_route_v3_HeaderMatcher_prefix_match(header));
|
1208
1334
|
} else if (envoy_config_route_v3_HeaderMatcher_has_suffix_match(header)) {
|
1209
|
-
|
1210
|
-
|
1211
|
-
header_matcher.string_matcher = UpbStringToStdString(
|
1335
|
+
type = HeaderMatcher::Type::kSuffix;
|
1336
|
+
match_string = UpbStringToStdString(
|
1212
1337
|
envoy_config_route_v3_HeaderMatcher_suffix_match(header));
|
1338
|
+
} else if (envoy_config_route_v3_HeaderMatcher_has_contains_match(header)) {
|
1339
|
+
type = HeaderMatcher::Type::kContains;
|
1340
|
+
match_string = UpbStringToStdString(
|
1341
|
+
envoy_config_route_v3_HeaderMatcher_contains_match(header));
|
1213
1342
|
} else {
|
1214
1343
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1215
1344
|
"Invalid route header matcher specified.");
|
1216
1345
|
}
|
1217
|
-
|
1346
|
+
bool invert_match =
|
1218
1347
|
envoy_config_route_v3_HeaderMatcher_invert_match(header);
|
1219
|
-
|
1348
|
+
absl::StatusOr<HeaderMatcher> header_matcher =
|
1349
|
+
HeaderMatcher::Create(name, type, match_string, range_start, range_end,
|
1350
|
+
present_match, invert_match);
|
1351
|
+
if (!header_matcher.ok()) {
|
1352
|
+
return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1353
|
+
absl::StrCat("header matcher: ", header_matcher.status().message())
|
1354
|
+
.c_str());
|
1355
|
+
}
|
1356
|
+
route->matchers.header_matchers.emplace_back(
|
1357
|
+
std::move(header_matcher.value()));
|
1220
1358
|
}
|
1221
1359
|
return GRPC_ERROR_NONE;
|
1222
1360
|
}
|
1223
1361
|
|
1224
|
-
|
1362
|
+
grpc_error_handle RouteRuntimeFractionParse(
|
1225
1363
|
const envoy_config_route_v3_RouteMatch* match, XdsApi::Route* route) {
|
1226
1364
|
const envoy_config_core_v3_RuntimeFractionalPercent* runtime_fraction =
|
1227
1365
|
envoy_config_route_v3_RouteMatch_runtime_fraction(match);
|
@@ -1254,8 +1392,98 @@ grpc_error* RouteRuntimeFractionParse(
|
|
1254
1392
|
return GRPC_ERROR_NONE;
|
1255
1393
|
}
|
1256
1394
|
|
1257
|
-
|
1258
|
-
|
1395
|
+
grpc_error_handle ExtractHttpFilterTypeName(const EncodingContext& context,
|
1396
|
+
const google_protobuf_Any* any,
|
1397
|
+
absl::string_view* filter_type) {
|
1398
|
+
*filter_type = UpbStringToAbsl(google_protobuf_Any_type_url(any));
|
1399
|
+
if (*filter_type == "type.googleapis.com/udpa.type.v1.TypedStruct") {
|
1400
|
+
upb_strview any_value = google_protobuf_Any_value(any);
|
1401
|
+
const auto* typed_struct = udpa_type_v1_TypedStruct_parse(
|
1402
|
+
any_value.data, any_value.size, context.arena);
|
1403
|
+
if (typed_struct == nullptr) {
|
1404
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1405
|
+
"could not parse TypedStruct from filter config");
|
1406
|
+
}
|
1407
|
+
*filter_type =
|
1408
|
+
UpbStringToAbsl(udpa_type_v1_TypedStruct_type_url(typed_struct));
|
1409
|
+
}
|
1410
|
+
*filter_type = absl::StripPrefix(*filter_type, "type.googleapis.com/");
|
1411
|
+
return GRPC_ERROR_NONE;
|
1412
|
+
}
|
1413
|
+
|
1414
|
+
template <typename ParentType, typename EntryType>
|
1415
|
+
grpc_error_handle ParseTypedPerFilterConfig(
|
1416
|
+
const EncodingContext& context, const ParentType* parent,
|
1417
|
+
const EntryType* (*entry_func)(const ParentType*, size_t*),
|
1418
|
+
upb_strview (*key_func)(const EntryType*),
|
1419
|
+
const google_protobuf_Any* (*value_func)(const EntryType*),
|
1420
|
+
XdsApi::TypedPerFilterConfig* typed_per_filter_config) {
|
1421
|
+
size_t filter_it = UPB_MAP_BEGIN;
|
1422
|
+
while (true) {
|
1423
|
+
const auto* filter_entry = entry_func(parent, &filter_it);
|
1424
|
+
if (filter_entry == nullptr) break;
|
1425
|
+
absl::string_view key = UpbStringToAbsl(key_func(filter_entry));
|
1426
|
+
if (key.empty()) {
|
1427
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("empty filter name in map");
|
1428
|
+
}
|
1429
|
+
const google_protobuf_Any* any = value_func(filter_entry);
|
1430
|
+
GPR_ASSERT(any != nullptr);
|
1431
|
+
absl::string_view filter_type =
|
1432
|
+
UpbStringToAbsl(google_protobuf_Any_type_url(any));
|
1433
|
+
if (filter_type.empty()) {
|
1434
|
+
return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1435
|
+
absl::StrCat("no filter config specified for filter name ", key)
|
1436
|
+
.c_str());
|
1437
|
+
}
|
1438
|
+
bool is_optional = false;
|
1439
|
+
if (filter_type ==
|
1440
|
+
"type.googleapis.com/envoy.config.route.v3.FilterConfig") {
|
1441
|
+
upb_strview any_value = google_protobuf_Any_value(any);
|
1442
|
+
const auto* filter_config = envoy_config_route_v3_FilterConfig_parse(
|
1443
|
+
any_value.data, any_value.size, context.arena);
|
1444
|
+
if (filter_config == nullptr) {
|
1445
|
+
return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1446
|
+
absl::StrCat("could not parse FilterConfig wrapper for ", key)
|
1447
|
+
.c_str());
|
1448
|
+
}
|
1449
|
+
is_optional =
|
1450
|
+
envoy_config_route_v3_FilterConfig_is_optional(filter_config);
|
1451
|
+
any = envoy_config_route_v3_FilterConfig_config(filter_config);
|
1452
|
+
if (any == nullptr) {
|
1453
|
+
if (is_optional) continue;
|
1454
|
+
return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1455
|
+
absl::StrCat("no filter config specified for filter name ", key)
|
1456
|
+
.c_str());
|
1457
|
+
}
|
1458
|
+
}
|
1459
|
+
grpc_error_handle error =
|
1460
|
+
ExtractHttpFilterTypeName(context, any, &filter_type);
|
1461
|
+
if (error != GRPC_ERROR_NONE) return error;
|
1462
|
+
const XdsHttpFilterImpl* filter_impl =
|
1463
|
+
XdsHttpFilterRegistry::GetFilterForType(filter_type);
|
1464
|
+
if (filter_impl == nullptr) {
|
1465
|
+
if (is_optional) continue;
|
1466
|
+
return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1467
|
+
absl::StrCat("no filter registered for config type ", filter_type)
|
1468
|
+
.c_str());
|
1469
|
+
}
|
1470
|
+
absl::StatusOr<XdsHttpFilterImpl::FilterConfig> filter_config =
|
1471
|
+
filter_impl->GenerateFilterConfigOverride(
|
1472
|
+
google_protobuf_Any_value(any), context.arena);
|
1473
|
+
if (!filter_config.ok()) {
|
1474
|
+
return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1475
|
+
absl::StrCat("filter config for type ", filter_type,
|
1476
|
+
" failed to parse: ", filter_config.status().ToString())
|
1477
|
+
.c_str());
|
1478
|
+
}
|
1479
|
+
(*typed_per_filter_config)[std::string(key)] = std::move(*filter_config);
|
1480
|
+
}
|
1481
|
+
return GRPC_ERROR_NONE;
|
1482
|
+
}
|
1483
|
+
|
1484
|
+
grpc_error_handle RouteActionParse(const EncodingContext& context,
|
1485
|
+
const envoy_config_route_v3_Route* route_msg,
|
1486
|
+
XdsApi::Route* route, bool* ignore_route) {
|
1259
1487
|
if (!envoy_config_route_v3_Route_has_route(route_msg)) {
|
1260
1488
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1261
1489
|
"No RouteAction found in route.");
|
@@ -1307,6 +1535,17 @@ grpc_error* RouteActionParse(const envoy_config_route_v3_Route* route_msg,
|
|
1307
1535
|
cluster.weight = google_protobuf_UInt32Value_value(weight);
|
1308
1536
|
if (cluster.weight == 0) continue;
|
1309
1537
|
sum_of_weights += cluster.weight;
|
1538
|
+
if (context.use_v3) {
|
1539
|
+
grpc_error_handle error = ParseTypedPerFilterConfig<
|
1540
|
+
envoy_config_route_v3_WeightedCluster_ClusterWeight,
|
1541
|
+
envoy_config_route_v3_WeightedCluster_ClusterWeight_TypedPerFilterConfigEntry>(
|
1542
|
+
context, cluster_weight,
|
1543
|
+
envoy_config_route_v3_WeightedCluster_ClusterWeight_typed_per_filter_config_next,
|
1544
|
+
envoy_config_route_v3_WeightedCluster_ClusterWeight_TypedPerFilterConfigEntry_key,
|
1545
|
+
envoy_config_route_v3_WeightedCluster_ClusterWeight_TypedPerFilterConfigEntry_value,
|
1546
|
+
&cluster.typed_per_filter_config);
|
1547
|
+
if (error != GRPC_ERROR_NONE) return error;
|
1548
|
+
}
|
1310
1549
|
route->weighted_clusters.emplace_back(std::move(cluster));
|
1311
1550
|
}
|
1312
1551
|
if (total_weight != sum_of_weights) {
|
@@ -1321,7 +1560,7 @@ grpc_error* RouteActionParse(const envoy_config_route_v3_Route* route_msg,
|
|
1321
1560
|
// No cluster or weighted_clusters found in RouteAction, ignore this route.
|
1322
1561
|
*ignore_route = true;
|
1323
1562
|
}
|
1324
|
-
if (
|
1563
|
+
if (!*ignore_route) {
|
1325
1564
|
const envoy_config_route_v3_RouteAction_MaxStreamDuration*
|
1326
1565
|
max_stream_duration =
|
1327
1566
|
envoy_config_route_v3_RouteAction_max_stream_duration(route_action);
|
@@ -1342,20 +1581,102 @@ grpc_error* RouteActionParse(const envoy_config_route_v3_Route* route_msg,
|
|
1342
1581
|
}
|
1343
1582
|
}
|
1344
1583
|
}
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1584
|
+
// Get HashPolicy from RouteAction
|
1585
|
+
if (XdsRingHashEnabled()) {
|
1586
|
+
size_t size = 0;
|
1587
|
+
const envoy_config_route_v3_RouteAction_HashPolicy* const* hash_policies =
|
1588
|
+
envoy_config_route_v3_RouteAction_hash_policy(route_action, &size);
|
1589
|
+
for (size_t i = 0; i < size; ++i) {
|
1590
|
+
const envoy_config_route_v3_RouteAction_HashPolicy* hash_policy =
|
1591
|
+
hash_policies[i];
|
1592
|
+
XdsApi::Route::HashPolicy policy;
|
1593
|
+
policy.terminal =
|
1594
|
+
envoy_config_route_v3_RouteAction_HashPolicy_terminal(hash_policy);
|
1595
|
+
const envoy_config_route_v3_RouteAction_HashPolicy_Header* header;
|
1596
|
+
const envoy_config_route_v3_RouteAction_HashPolicy_FilterState*
|
1597
|
+
filter_state;
|
1598
|
+
if ((header = envoy_config_route_v3_RouteAction_HashPolicy_header(
|
1599
|
+
hash_policy)) != nullptr) {
|
1600
|
+
policy.type = XdsApi::Route::HashPolicy::Type::HEADER;
|
1601
|
+
policy.header_name = UpbStringToStdString(
|
1602
|
+
envoy_config_route_v3_RouteAction_HashPolicy_Header_header_name(
|
1603
|
+
header));
|
1604
|
+
const struct envoy_type_matcher_v3_RegexMatchAndSubstitute*
|
1605
|
+
regex_rewrite =
|
1606
|
+
envoy_config_route_v3_RouteAction_HashPolicy_Header_regex_rewrite(
|
1607
|
+
header);
|
1608
|
+
if (regex_rewrite == nullptr) {
|
1609
|
+
gpr_log(
|
1610
|
+
GPR_DEBUG,
|
1611
|
+
"RouteAction HashPolicy contains policy specifier Header with "
|
1612
|
+
"RegexMatchAndSubstitution but Regex is missing");
|
1613
|
+
continue;
|
1614
|
+
}
|
1615
|
+
const envoy_type_matcher_v3_RegexMatcher* regex_matcher =
|
1616
|
+
envoy_type_matcher_v3_RegexMatchAndSubstitute_pattern(
|
1617
|
+
regex_rewrite);
|
1618
|
+
if (regex_matcher == nullptr) {
|
1619
|
+
gpr_log(
|
1620
|
+
GPR_DEBUG,
|
1621
|
+
"RouteAction HashPolicy contains policy specifier Header with "
|
1622
|
+
"RegexMatchAndSubstitution but RegexMatcher pattern is "
|
1623
|
+
"missing");
|
1624
|
+
continue;
|
1625
|
+
}
|
1626
|
+
RE2::Options options;
|
1627
|
+
policy.regex = absl::make_unique<RE2>(
|
1628
|
+
UpbStringToStdString(
|
1629
|
+
envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher)),
|
1630
|
+
options);
|
1631
|
+
if (!policy.regex->ok()) {
|
1632
|
+
gpr_log(
|
1633
|
+
GPR_DEBUG,
|
1634
|
+
"RouteAction HashPolicy contains policy specifier Header with "
|
1635
|
+
"RegexMatchAndSubstitution but RegexMatcher pattern does not "
|
1636
|
+
"compile");
|
1637
|
+
continue;
|
1638
|
+
}
|
1639
|
+
policy.regex_substitution = UpbStringToStdString(
|
1640
|
+
envoy_type_matcher_v3_RegexMatchAndSubstitute_substitution(
|
1641
|
+
regex_rewrite));
|
1642
|
+
} else if ((filter_state =
|
1643
|
+
envoy_config_route_v3_RouteAction_HashPolicy_filter_state(
|
1644
|
+
hash_policy)) != nullptr) {
|
1645
|
+
std::string key = UpbStringToStdString(
|
1646
|
+
envoy_config_route_v3_RouteAction_HashPolicy_FilterState_key(
|
1647
|
+
filter_state));
|
1648
|
+
if (key == "io.grpc.channel_id") {
|
1649
|
+
policy.type = XdsApi::Route::HashPolicy::Type::CHANNEL_ID;
|
1650
|
+
} else {
|
1651
|
+
gpr_log(GPR_DEBUG,
|
1652
|
+
"RouteAction HashPolicy contains policy specifier "
|
1653
|
+
"FilterState but "
|
1654
|
+
"key is not io.grpc.channel_id.");
|
1655
|
+
continue;
|
1656
|
+
}
|
1657
|
+
} else {
|
1658
|
+
gpr_log(
|
1659
|
+
GPR_DEBUG,
|
1660
|
+
"RouteAction HashPolicy contains unsupported policy specifier.");
|
1661
|
+
continue;
|
1662
|
+
}
|
1663
|
+
route->hash_policies.emplace_back(std::move(policy));
|
1664
|
+
}
|
1665
|
+
}
|
1666
|
+
return GRPC_ERROR_NONE;
|
1667
|
+
}
|
1668
|
+
|
1669
|
+
grpc_error_handle RouteConfigParse(
|
1670
|
+
const EncodingContext& context,
|
1671
|
+
const envoy_config_route_v3_RouteConfiguration* route_config,
|
1672
|
+
XdsApi::RdsUpdate* rds_update) {
|
1673
|
+
MaybeLogRouteConfiguration(context, route_config);
|
1674
|
+
// Get the virtual hosts.
|
1675
|
+
size_t num_virtual_hosts;
|
1676
|
+
const envoy_config_route_v3_VirtualHost* const* virtual_hosts =
|
1677
|
+
envoy_config_route_v3_RouteConfiguration_virtual_hosts(
|
1678
|
+
route_config, &num_virtual_hosts);
|
1679
|
+
for (size_t i = 0; i < num_virtual_hosts; ++i) {
|
1359
1680
|
rds_update->virtual_hosts.emplace_back();
|
1360
1681
|
XdsApi::RdsUpdate::VirtualHost& vhost = rds_update->virtual_hosts.back();
|
1361
1682
|
// Parse domains.
|
@@ -1375,6 +1696,18 @@ grpc_error* RouteConfigParse(
|
|
1375
1696
|
if (vhost.domains.empty()) {
|
1376
1697
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("VirtualHost has no domains");
|
1377
1698
|
}
|
1699
|
+
// Parse typed_per_filter_config.
|
1700
|
+
if (context.use_v3) {
|
1701
|
+
grpc_error_handle error = ParseTypedPerFilterConfig<
|
1702
|
+
envoy_config_route_v3_VirtualHost,
|
1703
|
+
envoy_config_route_v3_VirtualHost_TypedPerFilterConfigEntry>(
|
1704
|
+
context, virtual_hosts[i],
|
1705
|
+
envoy_config_route_v3_VirtualHost_typed_per_filter_config_next,
|
1706
|
+
envoy_config_route_v3_VirtualHost_TypedPerFilterConfigEntry_key,
|
1707
|
+
envoy_config_route_v3_VirtualHost_TypedPerFilterConfigEntry_value,
|
1708
|
+
&vhost.typed_per_filter_config);
|
1709
|
+
if (error != GRPC_ERROR_NONE) return error;
|
1710
|
+
}
|
1378
1711
|
// Parse routes.
|
1379
1712
|
size_t num_routes;
|
1380
1713
|
const envoy_config_route_v3_Route* const* routes =
|
@@ -1387,6 +1720,9 @@ grpc_error* RouteConfigParse(
|
|
1387
1720
|
for (size_t j = 0; j < num_routes; ++j) {
|
1388
1721
|
const envoy_config_route_v3_RouteMatch* match =
|
1389
1722
|
envoy_config_route_v3_Route_match(routes[j]);
|
1723
|
+
if (match == nullptr) {
|
1724
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Match can't be null.");
|
1725
|
+
}
|
1390
1726
|
size_t query_parameters_size;
|
1391
1727
|
static_cast<void>(envoy_config_route_v3_RouteMatch_query_parameters(
|
1392
1728
|
match, &query_parameters_size));
|
@@ -1395,16 +1731,28 @@ grpc_error* RouteConfigParse(
|
|
1395
1731
|
}
|
1396
1732
|
XdsApi::Route route;
|
1397
1733
|
bool ignore_route = false;
|
1398
|
-
|
1734
|
+
grpc_error_handle error =
|
1735
|
+
RoutePathMatchParse(match, &route, &ignore_route);
|
1399
1736
|
if (error != GRPC_ERROR_NONE) return error;
|
1400
1737
|
if (ignore_route) continue;
|
1401
1738
|
error = RouteHeaderMatchersParse(match, &route);
|
1402
1739
|
if (error != GRPC_ERROR_NONE) return error;
|
1403
1740
|
error = RouteRuntimeFractionParse(match, &route);
|
1404
1741
|
if (error != GRPC_ERROR_NONE) return error;
|
1405
|
-
error = RouteActionParse(routes[j], &route, &ignore_route);
|
1742
|
+
error = RouteActionParse(context, routes[j], &route, &ignore_route);
|
1406
1743
|
if (error != GRPC_ERROR_NONE) return error;
|
1407
1744
|
if (ignore_route) continue;
|
1745
|
+
if (context.use_v3) {
|
1746
|
+
grpc_error_handle error = ParseTypedPerFilterConfig<
|
1747
|
+
envoy_config_route_v3_Route,
|
1748
|
+
envoy_config_route_v3_Route_TypedPerFilterConfigEntry>(
|
1749
|
+
context, routes[j],
|
1750
|
+
envoy_config_route_v3_Route_typed_per_filter_config_next,
|
1751
|
+
envoy_config_route_v3_Route_TypedPerFilterConfigEntry_key,
|
1752
|
+
envoy_config_route_v3_Route_TypedPerFilterConfigEntry_value,
|
1753
|
+
&route.typed_per_filter_config);
|
1754
|
+
if (error != GRPC_ERROR_NONE) return error;
|
1755
|
+
}
|
1408
1756
|
vhost.routes.emplace_back(std::move(route));
|
1409
1757
|
}
|
1410
1758
|
if (vhost.routes.empty()) {
|
@@ -1414,170 +1762,6 @@ grpc_error* RouteConfigParse(
|
|
1414
1762
|
return GRPC_ERROR_NONE;
|
1415
1763
|
}
|
1416
1764
|
|
1417
|
-
grpc_error* LdsResponseParse(
|
1418
|
-
XdsClient* client, TraceFlag* tracer, upb_symtab* symtab,
|
1419
|
-
const envoy_service_discovery_v3_DiscoveryResponse* response,
|
1420
|
-
const std::set<absl::string_view>& expected_listener_names,
|
1421
|
-
XdsApi::LdsUpdateMap* lds_update_map, upb_arena* arena) {
|
1422
|
-
// Get the resources from the response.
|
1423
|
-
size_t size;
|
1424
|
-
const google_protobuf_Any* const* resources =
|
1425
|
-
envoy_service_discovery_v3_DiscoveryResponse_resources(response, &size);
|
1426
|
-
for (size_t i = 0; i < size; ++i) {
|
1427
|
-
// Check the type_url of the resource.
|
1428
|
-
absl::string_view type_url =
|
1429
|
-
UpbStringToAbsl(google_protobuf_Any_type_url(resources[i]));
|
1430
|
-
if (!IsLds(type_url)) {
|
1431
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resource is not LDS.");
|
1432
|
-
}
|
1433
|
-
// Decode the listener.
|
1434
|
-
const upb_strview encoded_listener =
|
1435
|
-
google_protobuf_Any_value(resources[i]);
|
1436
|
-
const envoy_config_listener_v3_Listener* listener =
|
1437
|
-
envoy_config_listener_v3_Listener_parse(encoded_listener.data,
|
1438
|
-
encoded_listener.size, arena);
|
1439
|
-
if (listener == nullptr) {
|
1440
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode listener.");
|
1441
|
-
}
|
1442
|
-
// Check listener name. Ignore unexpected listeners.
|
1443
|
-
std::string listener_name =
|
1444
|
-
UpbStringToStdString(envoy_config_listener_v3_Listener_name(listener));
|
1445
|
-
if (expected_listener_names.find(listener_name) ==
|
1446
|
-
expected_listener_names.end()) {
|
1447
|
-
continue;
|
1448
|
-
}
|
1449
|
-
// Fail if listener name is duplicated.
|
1450
|
-
if (lds_update_map->find(listener_name) != lds_update_map->end()) {
|
1451
|
-
return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1452
|
-
absl::StrCat("duplicate listener name \"", listener_name, "\"")
|
1453
|
-
.c_str());
|
1454
|
-
}
|
1455
|
-
XdsApi::LdsUpdate& lds_update = (*lds_update_map)[listener_name];
|
1456
|
-
// Get api_listener and decode it to http_connection_manager.
|
1457
|
-
const envoy_config_listener_v3_ApiListener* api_listener =
|
1458
|
-
envoy_config_listener_v3_Listener_api_listener(listener);
|
1459
|
-
if (api_listener == nullptr) {
|
1460
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1461
|
-
"Listener has no ApiListener.");
|
1462
|
-
}
|
1463
|
-
const upb_strview encoded_api_listener = google_protobuf_Any_value(
|
1464
|
-
envoy_config_listener_v3_ApiListener_api_listener(api_listener));
|
1465
|
-
const envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager*
|
1466
|
-
http_connection_manager =
|
1467
|
-
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_parse(
|
1468
|
-
encoded_api_listener.data, encoded_api_listener.size, arena);
|
1469
|
-
if (http_connection_manager == nullptr) {
|
1470
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1471
|
-
"Could not parse HttpConnectionManager config from ApiListener");
|
1472
|
-
}
|
1473
|
-
if (XdsTimeoutEnabled()) {
|
1474
|
-
// Obtain max_stream_duration from Http Protocol Options.
|
1475
|
-
const envoy_config_core_v3_HttpProtocolOptions* options =
|
1476
|
-
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_common_http_protocol_options(
|
1477
|
-
http_connection_manager);
|
1478
|
-
if (options != nullptr) {
|
1479
|
-
const google_protobuf_Duration* duration =
|
1480
|
-
envoy_config_core_v3_HttpProtocolOptions_max_stream_duration(
|
1481
|
-
options);
|
1482
|
-
if (duration != nullptr) {
|
1483
|
-
lds_update.http_max_stream_duration.seconds =
|
1484
|
-
google_protobuf_Duration_seconds(duration);
|
1485
|
-
lds_update.http_max_stream_duration.nanos =
|
1486
|
-
google_protobuf_Duration_nanos(duration);
|
1487
|
-
}
|
1488
|
-
}
|
1489
|
-
}
|
1490
|
-
// Found inlined route_config. Parse it to find the cluster_name.
|
1491
|
-
if (envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_has_route_config(
|
1492
|
-
http_connection_manager)) {
|
1493
|
-
const envoy_config_route_v3_RouteConfiguration* route_config =
|
1494
|
-
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_route_config(
|
1495
|
-
http_connection_manager);
|
1496
|
-
XdsApi::RdsUpdate rds_update;
|
1497
|
-
grpc_error* error =
|
1498
|
-
RouteConfigParse(client, tracer, symtab, route_config, &rds_update);
|
1499
|
-
if (error != GRPC_ERROR_NONE) return error;
|
1500
|
-
lds_update.rds_update = std::move(rds_update);
|
1501
|
-
continue;
|
1502
|
-
}
|
1503
|
-
// Validate that RDS must be used to get the route_config dynamically.
|
1504
|
-
if (!envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_has_rds(
|
1505
|
-
http_connection_manager)) {
|
1506
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1507
|
-
"HttpConnectionManager neither has inlined route_config nor RDS.");
|
1508
|
-
}
|
1509
|
-
const envoy_extensions_filters_network_http_connection_manager_v3_Rds* rds =
|
1510
|
-
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_rds(
|
1511
|
-
http_connection_manager);
|
1512
|
-
// Check that the ConfigSource specifies ADS.
|
1513
|
-
const envoy_config_core_v3_ConfigSource* config_source =
|
1514
|
-
envoy_extensions_filters_network_http_connection_manager_v3_Rds_config_source(
|
1515
|
-
rds);
|
1516
|
-
if (config_source == nullptr) {
|
1517
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1518
|
-
"HttpConnectionManager missing config_source for RDS.");
|
1519
|
-
}
|
1520
|
-
if (!envoy_config_core_v3_ConfigSource_has_ads(config_source)) {
|
1521
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1522
|
-
"HttpConnectionManager ConfigSource for RDS does not specify ADS.");
|
1523
|
-
}
|
1524
|
-
// Get the route_config_name.
|
1525
|
-
lds_update.route_config_name = UpbStringToStdString(
|
1526
|
-
envoy_extensions_filters_network_http_connection_manager_v3_Rds_route_config_name(
|
1527
|
-
rds));
|
1528
|
-
}
|
1529
|
-
return GRPC_ERROR_NONE;
|
1530
|
-
}
|
1531
|
-
|
1532
|
-
grpc_error* RdsResponseParse(
|
1533
|
-
XdsClient* client, TraceFlag* tracer, upb_symtab* symtab,
|
1534
|
-
const envoy_service_discovery_v3_DiscoveryResponse* response,
|
1535
|
-
const std::set<absl::string_view>& expected_route_configuration_names,
|
1536
|
-
XdsApi::RdsUpdateMap* rds_update_map, upb_arena* arena) {
|
1537
|
-
// Get the resources from the response.
|
1538
|
-
size_t size;
|
1539
|
-
const google_protobuf_Any* const* resources =
|
1540
|
-
envoy_service_discovery_v3_DiscoveryResponse_resources(response, &size);
|
1541
|
-
for (size_t i = 0; i < size; ++i) {
|
1542
|
-
// Check the type_url of the resource.
|
1543
|
-
absl::string_view type_url =
|
1544
|
-
UpbStringToAbsl(google_protobuf_Any_type_url(resources[i]));
|
1545
|
-
if (!IsRds(type_url)) {
|
1546
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resource is not RDS.");
|
1547
|
-
}
|
1548
|
-
// Decode the route_config.
|
1549
|
-
const upb_strview encoded_route_config =
|
1550
|
-
google_protobuf_Any_value(resources[i]);
|
1551
|
-
const envoy_config_route_v3_RouteConfiguration* route_config =
|
1552
|
-
envoy_config_route_v3_RouteConfiguration_parse(
|
1553
|
-
encoded_route_config.data, encoded_route_config.size, arena);
|
1554
|
-
if (route_config == nullptr) {
|
1555
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode route_config.");
|
1556
|
-
}
|
1557
|
-
// Check route_config_name. Ignore unexpected route_config.
|
1558
|
-
std::string route_config_name = UpbStringToStdString(
|
1559
|
-
envoy_config_route_v3_RouteConfiguration_name(route_config));
|
1560
|
-
if (expected_route_configuration_names.find(route_config_name) ==
|
1561
|
-
expected_route_configuration_names.end()) {
|
1562
|
-
continue;
|
1563
|
-
}
|
1564
|
-
// Fail if route config name is duplicated.
|
1565
|
-
if (rds_update_map->find(route_config_name) != rds_update_map->end()) {
|
1566
|
-
return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1567
|
-
absl::StrCat("duplicate route config name \"", route_config_name,
|
1568
|
-
"\"")
|
1569
|
-
.c_str());
|
1570
|
-
}
|
1571
|
-
// Parse the route_config.
|
1572
|
-
XdsApi::RdsUpdate& rds_update =
|
1573
|
-
(*rds_update_map)[std::move(route_config_name)];
|
1574
|
-
grpc_error* error =
|
1575
|
-
RouteConfigParse(client, tracer, symtab, route_config, &rds_update);
|
1576
|
-
if (error != GRPC_ERROR_NONE) return error;
|
1577
|
-
}
|
1578
|
-
return GRPC_ERROR_NONE;
|
1579
|
-
}
|
1580
|
-
|
1581
1765
|
XdsApi::CommonTlsContext::CertificateProviderInstance
|
1582
1766
|
CertificateProviderInstanceParse(
|
1583
1767
|
const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance*
|
@@ -1591,11 +1775,11 @@ CertificateProviderInstanceParse(
|
|
1591
1775
|
certificate_provider_instance_proto))};
|
1592
1776
|
}
|
1593
1777
|
|
1594
|
-
|
1778
|
+
grpc_error_handle CommonTlsContextParse(
|
1595
1779
|
const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext*
|
1596
1780
|
common_tls_context_proto,
|
1597
1781
|
XdsApi::CommonTlsContext* common_tls_context) GRPC_MUST_USE_RESULT;
|
1598
|
-
|
1782
|
+
grpc_error_handle CommonTlsContextParse(
|
1599
1783
|
const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext*
|
1600
1784
|
common_tls_context_proto,
|
1601
1785
|
XdsApi::CommonTlsContext* common_tls_context) {
|
@@ -1612,35 +1796,35 @@ grpc_error* CommonTlsContextParse(
|
|
1612
1796
|
envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_match_subject_alt_names(
|
1613
1797
|
default_validation_context, &len);
|
1614
1798
|
for (size_t i = 0; i < len; ++i) {
|
1615
|
-
|
1799
|
+
StringMatcher::Type type;
|
1616
1800
|
std::string matcher;
|
1617
1801
|
if (envoy_type_matcher_v3_StringMatcher_has_exact(
|
1618
1802
|
subject_alt_names_matchers[i])) {
|
1619
|
-
type =
|
1803
|
+
type = StringMatcher::Type::kExact;
|
1620
1804
|
matcher =
|
1621
1805
|
UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_exact(
|
1622
1806
|
subject_alt_names_matchers[i]));
|
1623
1807
|
} else if (envoy_type_matcher_v3_StringMatcher_has_prefix(
|
1624
1808
|
subject_alt_names_matchers[i])) {
|
1625
|
-
type =
|
1809
|
+
type = StringMatcher::Type::kPrefix;
|
1626
1810
|
matcher =
|
1627
1811
|
UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_prefix(
|
1628
1812
|
subject_alt_names_matchers[i]));
|
1629
1813
|
} else if (envoy_type_matcher_v3_StringMatcher_has_suffix(
|
1630
1814
|
subject_alt_names_matchers[i])) {
|
1631
|
-
type =
|
1815
|
+
type = StringMatcher::Type::kSuffix;
|
1632
1816
|
matcher =
|
1633
1817
|
UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_suffix(
|
1634
1818
|
subject_alt_names_matchers[i]));
|
1635
1819
|
} else if (envoy_type_matcher_v3_StringMatcher_has_contains(
|
1636
1820
|
subject_alt_names_matchers[i])) {
|
1637
|
-
type =
|
1821
|
+
type = StringMatcher::Type::kContains;
|
1638
1822
|
matcher =
|
1639
1823
|
UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_contains(
|
1640
1824
|
subject_alt_names_matchers[i]));
|
1641
1825
|
} else if (envoy_type_matcher_v3_StringMatcher_has_safe_regex(
|
1642
1826
|
subject_alt_names_matchers[i])) {
|
1643
|
-
type =
|
1827
|
+
type = StringMatcher::Type::kSafeRegex;
|
1644
1828
|
auto* regex_matcher = envoy_type_matcher_v3_StringMatcher_safe_regex(
|
1645
1829
|
subject_alt_names_matchers[i]);
|
1646
1830
|
matcher = UpbStringToStdString(
|
@@ -1651,20 +1835,22 @@ grpc_error* CommonTlsContextParse(
|
|
1651
1835
|
}
|
1652
1836
|
bool ignore_case = envoy_type_matcher_v3_StringMatcher_ignore_case(
|
1653
1837
|
subject_alt_names_matchers[i]);
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1838
|
+
absl::StatusOr<StringMatcher> string_matcher =
|
1839
|
+
StringMatcher::Create(type, matcher,
|
1840
|
+
/*case_sensitive=*/!ignore_case);
|
1841
|
+
if (!string_matcher.ok()) {
|
1842
|
+
return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1843
|
+
absl::StrCat("string matcher: ",
|
1844
|
+
string_matcher.status().message())
|
1845
|
+
.c_str());
|
1846
|
+
}
|
1847
|
+
if (type == StringMatcher::Type::kSafeRegex && ignore_case) {
|
1848
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1849
|
+
"StringMatcher: ignore_case has no effect for SAFE_REGEX.");
|
1664
1850
|
}
|
1665
1851
|
common_tls_context->combined_validation_context
|
1666
1852
|
.default_validation_context.match_subject_alt_names.push_back(
|
1667
|
-
std::move(string_matcher));
|
1853
|
+
std::move(string_matcher.value()));
|
1668
1854
|
}
|
1669
1855
|
}
|
1670
1856
|
auto* validation_context_certificate_provider_instance =
|
@@ -1688,11 +1874,797 @@ grpc_error* CommonTlsContextParse(
|
|
1688
1874
|
return GRPC_ERROR_NONE;
|
1689
1875
|
}
|
1690
1876
|
|
1691
|
-
|
1692
|
-
|
1877
|
+
grpc_error_handle HttpConnectionManagerParse(
|
1878
|
+
bool is_client, const EncodingContext& context,
|
1879
|
+
const envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager*
|
1880
|
+
http_connection_manager_proto,
|
1881
|
+
bool is_v2,
|
1882
|
+
XdsApi::LdsUpdate::HttpConnectionManager* http_connection_manager) {
|
1883
|
+
MaybeLogHttpConnectionManager(context, http_connection_manager_proto);
|
1884
|
+
// Obtain max_stream_duration from Http Protocol Options.
|
1885
|
+
const envoy_config_core_v3_HttpProtocolOptions* options =
|
1886
|
+
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_common_http_protocol_options(
|
1887
|
+
http_connection_manager_proto);
|
1888
|
+
if (options != nullptr) {
|
1889
|
+
const google_protobuf_Duration* duration =
|
1890
|
+
envoy_config_core_v3_HttpProtocolOptions_max_stream_duration(options);
|
1891
|
+
if (duration != nullptr) {
|
1892
|
+
http_connection_manager->http_max_stream_duration.seconds =
|
1893
|
+
google_protobuf_Duration_seconds(duration);
|
1894
|
+
http_connection_manager->http_max_stream_duration.nanos =
|
1895
|
+
google_protobuf_Duration_nanos(duration);
|
1896
|
+
}
|
1897
|
+
}
|
1898
|
+
// Parse filters.
|
1899
|
+
if (!is_v2) {
|
1900
|
+
size_t num_filters = 0;
|
1901
|
+
const auto* http_filters =
|
1902
|
+
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_http_filters(
|
1903
|
+
http_connection_manager_proto, &num_filters);
|
1904
|
+
std::set<absl::string_view> names_seen;
|
1905
|
+
for (size_t i = 0; i < num_filters; ++i) {
|
1906
|
+
const auto* http_filter = http_filters[i];
|
1907
|
+
absl::string_view name = UpbStringToAbsl(
|
1908
|
+
envoy_extensions_filters_network_http_connection_manager_v3_HttpFilter_name(
|
1909
|
+
http_filter));
|
1910
|
+
if (name.empty()) {
|
1911
|
+
return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1912
|
+
absl::StrCat("empty filter name at index ", i).c_str());
|
1913
|
+
}
|
1914
|
+
if (names_seen.find(name) != names_seen.end()) {
|
1915
|
+
return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1916
|
+
absl::StrCat("duplicate HTTP filter name: ", name).c_str());
|
1917
|
+
}
|
1918
|
+
names_seen.insert(name);
|
1919
|
+
const bool is_optional =
|
1920
|
+
envoy_extensions_filters_network_http_connection_manager_v3_HttpFilter_is_optional(
|
1921
|
+
http_filter);
|
1922
|
+
const google_protobuf_Any* any =
|
1923
|
+
envoy_extensions_filters_network_http_connection_manager_v3_HttpFilter_typed_config(
|
1924
|
+
http_filter);
|
1925
|
+
if (any == nullptr) {
|
1926
|
+
if (is_optional) continue;
|
1927
|
+
return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1928
|
+
absl::StrCat("no filter config specified for filter name ", name)
|
1929
|
+
.c_str());
|
1930
|
+
}
|
1931
|
+
absl::string_view filter_type;
|
1932
|
+
grpc_error_handle error =
|
1933
|
+
ExtractHttpFilterTypeName(context, any, &filter_type);
|
1934
|
+
if (error != GRPC_ERROR_NONE) return error;
|
1935
|
+
const XdsHttpFilterImpl* filter_impl =
|
1936
|
+
XdsHttpFilterRegistry::GetFilterForType(filter_type);
|
1937
|
+
if (filter_impl == nullptr) {
|
1938
|
+
if (is_optional) continue;
|
1939
|
+
return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1940
|
+
absl::StrCat("no filter registered for config type ", filter_type)
|
1941
|
+
.c_str());
|
1942
|
+
}
|
1943
|
+
if ((is_client && !filter_impl->IsSupportedOnClients()) ||
|
1944
|
+
(!is_client && !filter_impl->IsSupportedOnServers())) {
|
1945
|
+
if (is_optional) continue;
|
1946
|
+
return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1947
|
+
absl::StrFormat("Filter %s is not supported on %s", filter_type,
|
1948
|
+
is_client ? "clients" : "servers")
|
1949
|
+
.c_str());
|
1950
|
+
}
|
1951
|
+
absl::StatusOr<XdsHttpFilterImpl::FilterConfig> filter_config =
|
1952
|
+
filter_impl->GenerateFilterConfig(google_protobuf_Any_value(any),
|
1953
|
+
context.arena);
|
1954
|
+
if (!filter_config.ok()) {
|
1955
|
+
return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1956
|
+
absl::StrCat(
|
1957
|
+
"filter config for type ", filter_type,
|
1958
|
+
" failed to parse: ", filter_config.status().ToString())
|
1959
|
+
.c_str());
|
1960
|
+
}
|
1961
|
+
http_connection_manager->http_filters.emplace_back(
|
1962
|
+
XdsApi::LdsUpdate::HttpConnectionManager::HttpFilter{
|
1963
|
+
std::string(name), std::move(*filter_config)});
|
1964
|
+
}
|
1965
|
+
} else {
|
1966
|
+
// If using a v2 config, we just hard-code a list containing only the
|
1967
|
+
// router filter without actually looking at the config. This ensures
|
1968
|
+
// that the right thing happens in the xds resolver without having
|
1969
|
+
// to expose whether the resource we received was v2 or v3.
|
1970
|
+
http_connection_manager->http_filters.emplace_back(
|
1971
|
+
XdsApi::LdsUpdate::HttpConnectionManager::HttpFilter{
|
1972
|
+
"router", {kXdsHttpRouterFilterConfigName, Json()}});
|
1973
|
+
}
|
1974
|
+
if (is_client) {
|
1975
|
+
// Found inlined route_config. Parse it to find the cluster_name.
|
1976
|
+
if (envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_has_route_config(
|
1977
|
+
http_connection_manager_proto)) {
|
1978
|
+
const envoy_config_route_v3_RouteConfiguration* route_config =
|
1979
|
+
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_route_config(
|
1980
|
+
http_connection_manager_proto);
|
1981
|
+
XdsApi::RdsUpdate rds_update;
|
1982
|
+
grpc_error_handle error =
|
1983
|
+
RouteConfigParse(context, route_config, &rds_update);
|
1984
|
+
if (error != GRPC_ERROR_NONE) return error;
|
1985
|
+
http_connection_manager->rds_update = std::move(rds_update);
|
1986
|
+
return GRPC_ERROR_NONE;
|
1987
|
+
}
|
1988
|
+
// Validate that RDS must be used to get the route_config dynamically.
|
1989
|
+
const envoy_extensions_filters_network_http_connection_manager_v3_Rds* rds =
|
1990
|
+
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_rds(
|
1991
|
+
http_connection_manager_proto);
|
1992
|
+
if (rds == nullptr) {
|
1993
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1994
|
+
"HttpConnectionManager neither has inlined route_config nor RDS.");
|
1995
|
+
}
|
1996
|
+
// Check that the ConfigSource specifies ADS.
|
1997
|
+
const envoy_config_core_v3_ConfigSource* config_source =
|
1998
|
+
envoy_extensions_filters_network_http_connection_manager_v3_Rds_config_source(
|
1999
|
+
rds);
|
2000
|
+
if (config_source == nullptr) {
|
2001
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2002
|
+
"HttpConnectionManager missing config_source for RDS.");
|
2003
|
+
}
|
2004
|
+
if (!envoy_config_core_v3_ConfigSource_has_ads(config_source)) {
|
2005
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2006
|
+
"HttpConnectionManager ConfigSource for RDS does not specify ADS.");
|
2007
|
+
}
|
2008
|
+
// Get the route_config_name.
|
2009
|
+
http_connection_manager->route_config_name = UpbStringToStdString(
|
2010
|
+
envoy_extensions_filters_network_http_connection_manager_v3_Rds_route_config_name(
|
2011
|
+
rds));
|
2012
|
+
}
|
2013
|
+
return GRPC_ERROR_NONE;
|
2014
|
+
}
|
2015
|
+
|
2016
|
+
grpc_error_handle LdsResponseParseClient(
|
2017
|
+
const EncodingContext& context,
|
2018
|
+
const envoy_config_listener_v3_ApiListener* api_listener, bool is_v2,
|
2019
|
+
XdsApi::LdsUpdate* lds_update) {
|
2020
|
+
lds_update->type = XdsApi::LdsUpdate::ListenerType::kHttpApiListener;
|
2021
|
+
const upb_strview encoded_api_listener = google_protobuf_Any_value(
|
2022
|
+
envoy_config_listener_v3_ApiListener_api_listener(api_listener));
|
2023
|
+
const auto* http_connection_manager =
|
2024
|
+
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_parse(
|
2025
|
+
encoded_api_listener.data, encoded_api_listener.size, context.arena);
|
2026
|
+
if (http_connection_manager == nullptr) {
|
2027
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2028
|
+
"Could not parse HttpConnectionManager config from ApiListener");
|
2029
|
+
}
|
2030
|
+
return HttpConnectionManagerParse(true /* is_client */, context,
|
2031
|
+
http_connection_manager, is_v2,
|
2032
|
+
&lds_update->http_connection_manager);
|
2033
|
+
}
|
2034
|
+
|
2035
|
+
grpc_error_handle DownstreamTlsContextParse(
|
2036
|
+
const EncodingContext& context,
|
2037
|
+
const envoy_config_core_v3_TransportSocket* transport_socket,
|
2038
|
+
XdsApi::DownstreamTlsContext* downstream_tls_context) {
|
2039
|
+
absl::string_view name = UpbStringToAbsl(
|
2040
|
+
envoy_config_core_v3_TransportSocket_name(transport_socket));
|
2041
|
+
if (name == "envoy.transport_sockets.tls") {
|
2042
|
+
auto* typed_config =
|
2043
|
+
envoy_config_core_v3_TransportSocket_typed_config(transport_socket);
|
2044
|
+
if (typed_config != nullptr) {
|
2045
|
+
const upb_strview encoded_downstream_tls_context =
|
2046
|
+
google_protobuf_Any_value(typed_config);
|
2047
|
+
auto* downstream_tls_context_proto =
|
2048
|
+
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_parse(
|
2049
|
+
encoded_downstream_tls_context.data,
|
2050
|
+
encoded_downstream_tls_context.size, context.arena);
|
2051
|
+
if (downstream_tls_context_proto == nullptr) {
|
2052
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2053
|
+
"Can't decode downstream tls context.");
|
2054
|
+
}
|
2055
|
+
auto* common_tls_context =
|
2056
|
+
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_common_tls_context(
|
2057
|
+
downstream_tls_context_proto);
|
2058
|
+
if (common_tls_context != nullptr) {
|
2059
|
+
grpc_error_handle error = CommonTlsContextParse(
|
2060
|
+
common_tls_context, &downstream_tls_context->common_tls_context);
|
2061
|
+
if (error != GRPC_ERROR_NONE) return error;
|
2062
|
+
}
|
2063
|
+
auto* require_client_certificate =
|
2064
|
+
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_require_client_certificate(
|
2065
|
+
downstream_tls_context_proto);
|
2066
|
+
if (require_client_certificate != nullptr) {
|
2067
|
+
downstream_tls_context->require_client_certificate =
|
2068
|
+
google_protobuf_BoolValue_value(require_client_certificate);
|
2069
|
+
}
|
2070
|
+
}
|
2071
|
+
if (downstream_tls_context->common_tls_context
|
2072
|
+
.tls_certificate_certificate_provider_instance.instance_name
|
2073
|
+
.empty()) {
|
2074
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2075
|
+
"TLS configuration provided but no "
|
2076
|
+
"tls_certificate_certificate_provider_instance found.");
|
2077
|
+
}
|
2078
|
+
}
|
2079
|
+
return GRPC_ERROR_NONE;
|
2080
|
+
}
|
2081
|
+
|
2082
|
+
grpc_error_handle CidrRangeParse(
|
2083
|
+
const envoy_config_core_v3_CidrRange* cidr_range_proto,
|
2084
|
+
XdsApi::LdsUpdate::FilterChainMap::CidrRange* cidr_range) {
|
2085
|
+
std::string address_prefix = UpbStringToStdString(
|
2086
|
+
envoy_config_core_v3_CidrRange_address_prefix(cidr_range_proto));
|
2087
|
+
grpc_error_handle error =
|
2088
|
+
grpc_string_to_sockaddr(&cidr_range->address, address_prefix.c_str(), 0);
|
2089
|
+
if (error != GRPC_ERROR_NONE) return error;
|
2090
|
+
cidr_range->prefix_len = 0;
|
2091
|
+
auto* prefix_len_proto =
|
2092
|
+
envoy_config_core_v3_CidrRange_prefix_len(cidr_range_proto);
|
2093
|
+
if (prefix_len_proto != nullptr) {
|
2094
|
+
cidr_range->prefix_len = std::min(
|
2095
|
+
google_protobuf_UInt32Value_value(prefix_len_proto),
|
2096
|
+
(reinterpret_cast<const grpc_sockaddr*>(cidr_range->address.addr))
|
2097
|
+
->sa_family == GRPC_AF_INET
|
2098
|
+
? uint32_t(32)
|
2099
|
+
: uint32_t(128));
|
2100
|
+
}
|
2101
|
+
// Normalize the network address by masking it with prefix_len
|
2102
|
+
grpc_sockaddr_mask_bits(&cidr_range->address, cidr_range->prefix_len);
|
2103
|
+
return GRPC_ERROR_NONE;
|
2104
|
+
}
|
2105
|
+
|
2106
|
+
grpc_error_handle FilterChainMatchParse(
|
2107
|
+
const envoy_config_listener_v3_FilterChainMatch* filter_chain_match_proto,
|
2108
|
+
FilterChain::FilterChainMatch* filter_chain_match) {
|
2109
|
+
auto* destination_port =
|
2110
|
+
envoy_config_listener_v3_FilterChainMatch_destination_port(
|
2111
|
+
filter_chain_match_proto);
|
2112
|
+
if (destination_port != nullptr) {
|
2113
|
+
filter_chain_match->destination_port =
|
2114
|
+
google_protobuf_UInt32Value_value(destination_port);
|
2115
|
+
}
|
2116
|
+
size_t size = 0;
|
2117
|
+
auto* prefix_ranges = envoy_config_listener_v3_FilterChainMatch_prefix_ranges(
|
2118
|
+
filter_chain_match_proto, &size);
|
2119
|
+
filter_chain_match->prefix_ranges.reserve(size);
|
2120
|
+
for (size_t i = 0; i < size; i++) {
|
2121
|
+
XdsApi::LdsUpdate::FilterChainMap::CidrRange cidr_range;
|
2122
|
+
grpc_error_handle error = CidrRangeParse(prefix_ranges[i], &cidr_range);
|
2123
|
+
if (error != GRPC_ERROR_NONE) return error;
|
2124
|
+
filter_chain_match->prefix_ranges.push_back(cidr_range);
|
2125
|
+
}
|
2126
|
+
filter_chain_match->source_type =
|
2127
|
+
static_cast<XdsApi::LdsUpdate::FilterChainMap::ConnectionSourceType>(
|
2128
|
+
envoy_config_listener_v3_FilterChainMatch_source_type(
|
2129
|
+
filter_chain_match_proto));
|
2130
|
+
auto* source_prefix_ranges =
|
2131
|
+
envoy_config_listener_v3_FilterChainMatch_source_prefix_ranges(
|
2132
|
+
filter_chain_match_proto, &size);
|
2133
|
+
filter_chain_match->source_prefix_ranges.reserve(size);
|
2134
|
+
for (size_t i = 0; i < size; i++) {
|
2135
|
+
XdsApi::LdsUpdate::FilterChainMap::CidrRange cidr_range;
|
2136
|
+
grpc_error_handle error =
|
2137
|
+
CidrRangeParse(source_prefix_ranges[i], &cidr_range);
|
2138
|
+
if (error != GRPC_ERROR_NONE) return error;
|
2139
|
+
filter_chain_match->source_prefix_ranges.push_back(cidr_range);
|
2140
|
+
}
|
2141
|
+
auto* source_ports = envoy_config_listener_v3_FilterChainMatch_source_ports(
|
2142
|
+
filter_chain_match_proto, &size);
|
2143
|
+
filter_chain_match->source_ports.reserve(size);
|
2144
|
+
for (size_t i = 0; i < size; i++) {
|
2145
|
+
filter_chain_match->source_ports.push_back(source_ports[i]);
|
2146
|
+
}
|
2147
|
+
auto* server_names = envoy_config_listener_v3_FilterChainMatch_server_names(
|
2148
|
+
filter_chain_match_proto, &size);
|
2149
|
+
for (size_t i = 0; i < size; i++) {
|
2150
|
+
filter_chain_match->server_names.push_back(
|
2151
|
+
UpbStringToStdString(server_names[i]));
|
2152
|
+
}
|
2153
|
+
filter_chain_match->transport_protocol = UpbStringToStdString(
|
2154
|
+
envoy_config_listener_v3_FilterChainMatch_transport_protocol(
|
2155
|
+
filter_chain_match_proto));
|
2156
|
+
auto* application_protocols =
|
2157
|
+
envoy_config_listener_v3_FilterChainMatch_application_protocols(
|
2158
|
+
filter_chain_match_proto, &size);
|
2159
|
+
for (size_t i = 0; i < size; i++) {
|
2160
|
+
filter_chain_match->application_protocols.push_back(
|
2161
|
+
UpbStringToStdString(application_protocols[i]));
|
2162
|
+
}
|
2163
|
+
return GRPC_ERROR_NONE;
|
2164
|
+
}
|
2165
|
+
|
2166
|
+
grpc_error_handle FilterChainParse(
|
2167
|
+
const EncodingContext& context,
|
2168
|
+
const envoy_config_listener_v3_FilterChain* filter_chain_proto, bool is_v2,
|
2169
|
+
FilterChain* filter_chain) {
|
2170
|
+
grpc_error_handle error = GRPC_ERROR_NONE;
|
2171
|
+
auto* filter_chain_match =
|
2172
|
+
envoy_config_listener_v3_FilterChain_filter_chain_match(
|
2173
|
+
filter_chain_proto);
|
2174
|
+
if (filter_chain_match != nullptr) {
|
2175
|
+
error = FilterChainMatchParse(filter_chain_match,
|
2176
|
+
&filter_chain->filter_chain_match);
|
2177
|
+
if (error != GRPC_ERROR_NONE) return error;
|
2178
|
+
}
|
2179
|
+
// Parse the filters list. Currently we only support HttpConnectionManager.
|
2180
|
+
size_t size = 0;
|
2181
|
+
auto* filters =
|
2182
|
+
envoy_config_listener_v3_FilterChain_filters(filter_chain_proto, &size);
|
2183
|
+
if (size != 1) {
|
2184
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2185
|
+
"FilterChain should have exactly one filter: HttpConnectionManager; no "
|
2186
|
+
"other filter is supported at the moment");
|
2187
|
+
}
|
2188
|
+
auto* typed_config = envoy_config_listener_v3_Filter_typed_config(filters[0]);
|
2189
|
+
if (typed_config == nullptr) {
|
2190
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2191
|
+
"No typed_config found in filter.");
|
2192
|
+
}
|
2193
|
+
absl::string_view type_url =
|
2194
|
+
UpbStringToAbsl(google_protobuf_Any_type_url(typed_config));
|
2195
|
+
if (type_url !=
|
2196
|
+
"type.googleapis.com/"
|
2197
|
+
"envoy.extensions.filters.network.http_connection_manager.v3."
|
2198
|
+
"HttpConnectionManager") {
|
2199
|
+
return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2200
|
+
absl::StrCat("Unsupported filter type ", type_url).c_str());
|
2201
|
+
}
|
2202
|
+
const upb_strview encoded_http_connection_manager =
|
2203
|
+
google_protobuf_Any_value(typed_config);
|
2204
|
+
const auto* http_connection_manager =
|
2205
|
+
envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_parse(
|
2206
|
+
encoded_http_connection_manager.data,
|
2207
|
+
encoded_http_connection_manager.size, context.arena);
|
2208
|
+
if (http_connection_manager == nullptr) {
|
2209
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2210
|
+
"Could not parse HttpConnectionManager config from filter "
|
2211
|
+
"typed_config");
|
2212
|
+
}
|
2213
|
+
filter_chain->filter_chain_data =
|
2214
|
+
std::make_shared<XdsApi::LdsUpdate::FilterChainData>();
|
2215
|
+
error = HttpConnectionManagerParse(
|
2216
|
+
false /* is_client */, context, http_connection_manager, is_v2,
|
2217
|
+
&filter_chain->filter_chain_data->http_connection_manager);
|
2218
|
+
if (error != GRPC_ERROR_NONE) return error;
|
2219
|
+
// Get the DownstreamTlsContext for the filter chain
|
2220
|
+
if (XdsSecurityEnabled()) {
|
2221
|
+
auto* transport_socket =
|
2222
|
+
envoy_config_listener_v3_FilterChain_transport_socket(
|
2223
|
+
filter_chain_proto);
|
2224
|
+
if (transport_socket != nullptr) {
|
2225
|
+
error = DownstreamTlsContextParse(
|
2226
|
+
context, transport_socket,
|
2227
|
+
&filter_chain->filter_chain_data->downstream_tls_context);
|
2228
|
+
}
|
2229
|
+
}
|
2230
|
+
return error;
|
2231
|
+
}
|
2232
|
+
|
2233
|
+
grpc_error_handle AddressParse(
|
2234
|
+
const envoy_config_core_v3_Address* address_proto, std::string* address) {
|
2235
|
+
const auto* socket_address =
|
2236
|
+
envoy_config_core_v3_Address_socket_address(address_proto);
|
2237
|
+
if (socket_address == nullptr) {
|
2238
|
+
return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2239
|
+
"Address does not have socket_address");
|
2240
|
+
}
|
2241
|
+
if (envoy_config_core_v3_SocketAddress_protocol(socket_address) !=
|
2242
|
+
envoy_config_core_v3_SocketAddress_TCP) {
|
2243
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2244
|
+
"SocketAddress protocol is not TCP");
|
2245
|
+
}
|
2246
|
+
uint32_t port = envoy_config_core_v3_SocketAddress_port_value(socket_address);
|
2247
|
+
if (port > 65535) {
|
2248
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Invalid port");
|
2249
|
+
}
|
2250
|
+
*address = JoinHostPort(
|
2251
|
+
UpbStringToAbsl(
|
2252
|
+
envoy_config_core_v3_SocketAddress_address(socket_address)),
|
2253
|
+
port);
|
2254
|
+
return GRPC_ERROR_NONE;
|
2255
|
+
}
|
2256
|
+
|
2257
|
+
// An intermediate map for filter chains that we create to validate the list of
|
2258
|
+
// filter chains received from the control plane and to finally create
|
2259
|
+
// XdsApi::LdsUpdate::FilterChainMap
|
2260
|
+
struct InternalFilterChainMap {
|
2261
|
+
using SourceIpMap =
|
2262
|
+
std::map<std::string, XdsApi::LdsUpdate::FilterChainMap::SourceIp>;
|
2263
|
+
using ConnectionSourceTypesArray = std::array<SourceIpMap, 3>;
|
2264
|
+
struct DestinationIp {
|
2265
|
+
absl::optional<XdsApi::LdsUpdate::FilterChainMap::CidrRange> prefix_range;
|
2266
|
+
bool transport_protocol_raw_buffer_provided = false;
|
2267
|
+
ConnectionSourceTypesArray source_types_array;
|
2268
|
+
};
|
2269
|
+
using DestinationIpMap = std::map<std::string, DestinationIp>;
|
2270
|
+
DestinationIpMap destination_ip_map;
|
2271
|
+
};
|
2272
|
+
|
2273
|
+
grpc_error_handle AddFilterChainDataForSourcePort(
|
2274
|
+
const FilterChain& filter_chain,
|
2275
|
+
XdsApi::LdsUpdate::FilterChainMap::SourcePortsMap* ports_map,
|
2276
|
+
uint32_t port) {
|
2277
|
+
auto insert_result = ports_map->emplace(
|
2278
|
+
port, XdsApi::LdsUpdate::FilterChainMap::FilterChainDataSharedPtr{
|
2279
|
+
filter_chain.filter_chain_data});
|
2280
|
+
if (!insert_result.second) {
|
2281
|
+
return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2282
|
+
absl::StrCat(
|
2283
|
+
"Duplicate matching rules detected when adding filter chain: ",
|
2284
|
+
filter_chain.filter_chain_match.ToString())
|
2285
|
+
.c_str());
|
2286
|
+
}
|
2287
|
+
return GRPC_ERROR_NONE;
|
2288
|
+
}
|
2289
|
+
|
2290
|
+
grpc_error_handle AddFilterChainDataForSourcePorts(
|
2291
|
+
const FilterChain& filter_chain,
|
2292
|
+
XdsApi::LdsUpdate::FilterChainMap::SourcePortsMap* ports_map) {
|
2293
|
+
if (filter_chain.filter_chain_match.source_ports.empty()) {
|
2294
|
+
return AddFilterChainDataForSourcePort(filter_chain, ports_map, 0);
|
2295
|
+
} else {
|
2296
|
+
for (uint32_t port : filter_chain.filter_chain_match.source_ports) {
|
2297
|
+
grpc_error_handle error =
|
2298
|
+
AddFilterChainDataForSourcePort(filter_chain, ports_map, port);
|
2299
|
+
if (error != GRPC_ERROR_NONE) return error;
|
2300
|
+
}
|
2301
|
+
}
|
2302
|
+
return GRPC_ERROR_NONE;
|
2303
|
+
}
|
2304
|
+
|
2305
|
+
grpc_error_handle AddFilterChainDataForSourceIpRange(
|
2306
|
+
const FilterChain& filter_chain,
|
2307
|
+
InternalFilterChainMap::SourceIpMap* source_ip_map) {
|
2308
|
+
if (filter_chain.filter_chain_match.source_prefix_ranges.empty()) {
|
2309
|
+
auto insert_result = source_ip_map->emplace(
|
2310
|
+
"", XdsApi::LdsUpdate::FilterChainMap::SourceIp());
|
2311
|
+
return AddFilterChainDataForSourcePorts(
|
2312
|
+
filter_chain, &insert_result.first->second.ports_map);
|
2313
|
+
} else {
|
2314
|
+
for (const auto& prefix_range :
|
2315
|
+
filter_chain.filter_chain_match.source_prefix_ranges) {
|
2316
|
+
auto insert_result = source_ip_map->emplace(
|
2317
|
+
absl::StrCat(grpc_sockaddr_to_string(&prefix_range.address, false),
|
2318
|
+
"/", prefix_range.prefix_len),
|
2319
|
+
XdsApi::LdsUpdate::FilterChainMap::SourceIp());
|
2320
|
+
if (insert_result.second) {
|
2321
|
+
insert_result.first->second.prefix_range.emplace(prefix_range);
|
2322
|
+
}
|
2323
|
+
grpc_error_handle error = AddFilterChainDataForSourcePorts(
|
2324
|
+
filter_chain, &insert_result.first->second.ports_map);
|
2325
|
+
if (error != GRPC_ERROR_NONE) return error;
|
2326
|
+
}
|
2327
|
+
}
|
2328
|
+
return GRPC_ERROR_NONE;
|
2329
|
+
}
|
2330
|
+
|
2331
|
+
grpc_error_handle AddFilterChainDataForSourceType(
|
2332
|
+
const FilterChain& filter_chain,
|
2333
|
+
InternalFilterChainMap::DestinationIp* destination_ip) {
|
2334
|
+
GPR_ASSERT(static_cast<unsigned int>(
|
2335
|
+
filter_chain.filter_chain_match.source_type) < 3);
|
2336
|
+
return AddFilterChainDataForSourceIpRange(
|
2337
|
+
filter_chain, &destination_ip->source_types_array[static_cast<int>(
|
2338
|
+
filter_chain.filter_chain_match.source_type)]);
|
2339
|
+
}
|
2340
|
+
|
2341
|
+
grpc_error_handle AddFilterChainDataForApplicationProtocols(
|
2342
|
+
const FilterChain& filter_chain,
|
2343
|
+
InternalFilterChainMap::DestinationIp* destination_ip) {
|
2344
|
+
// Only allow filter chains that do not mention application protocols
|
2345
|
+
if (!filter_chain.filter_chain_match.application_protocols.empty()) {
|
2346
|
+
return GRPC_ERROR_NONE;
|
2347
|
+
}
|
2348
|
+
return AddFilterChainDataForSourceType(filter_chain, destination_ip);
|
2349
|
+
}
|
2350
|
+
|
2351
|
+
grpc_error_handle AddFilterChainDataForTransportProtocol(
|
2352
|
+
const FilterChain& filter_chain,
|
2353
|
+
InternalFilterChainMap::DestinationIp* destination_ip) {
|
2354
|
+
const std::string& transport_protocol =
|
2355
|
+
filter_chain.filter_chain_match.transport_protocol;
|
2356
|
+
// Only allow filter chains with no transport protocol or "raw_buffer"
|
2357
|
+
if (!transport_protocol.empty() && transport_protocol != "raw_buffer") {
|
2358
|
+
return GRPC_ERROR_NONE;
|
2359
|
+
}
|
2360
|
+
// If for this configuration, we've already seen filter chains that mention
|
2361
|
+
// the transport protocol as "raw_buffer", we will never match filter chains
|
2362
|
+
// that do not mention it.
|
2363
|
+
if (destination_ip->transport_protocol_raw_buffer_provided &&
|
2364
|
+
transport_protocol.empty()) {
|
2365
|
+
return GRPC_ERROR_NONE;
|
2366
|
+
}
|
2367
|
+
if (!transport_protocol.empty() &&
|
2368
|
+
!destination_ip->transport_protocol_raw_buffer_provided) {
|
2369
|
+
destination_ip->transport_protocol_raw_buffer_provided = true;
|
2370
|
+
// Clear out the previous entries if any since those entries did not mention
|
2371
|
+
// "raw_buffer"
|
2372
|
+
destination_ip->source_types_array =
|
2373
|
+
InternalFilterChainMap::ConnectionSourceTypesArray();
|
2374
|
+
}
|
2375
|
+
return AddFilterChainDataForApplicationProtocols(filter_chain,
|
2376
|
+
destination_ip);
|
2377
|
+
}
|
2378
|
+
|
2379
|
+
grpc_error_handle AddFilterChainDataForServerNames(
|
2380
|
+
const FilterChain& filter_chain,
|
2381
|
+
InternalFilterChainMap::DestinationIp* destination_ip) {
|
2382
|
+
// Don't continue adding filter chains with server names mentioned
|
2383
|
+
if (!filter_chain.filter_chain_match.server_names.empty()) {
|
2384
|
+
return GRPC_ERROR_NONE;
|
2385
|
+
}
|
2386
|
+
return AddFilterChainDataForTransportProtocol(filter_chain, destination_ip);
|
2387
|
+
}
|
2388
|
+
|
2389
|
+
grpc_error_handle AddFilterChainDataForDestinationIpRange(
|
2390
|
+
const FilterChain& filter_chain,
|
2391
|
+
InternalFilterChainMap::DestinationIpMap* destination_ip_map) {
|
2392
|
+
if (filter_chain.filter_chain_match.prefix_ranges.empty()) {
|
2393
|
+
auto insert_result = destination_ip_map->emplace(
|
2394
|
+
"", InternalFilterChainMap::DestinationIp());
|
2395
|
+
return AddFilterChainDataForServerNames(filter_chain,
|
2396
|
+
&insert_result.first->second);
|
2397
|
+
} else {
|
2398
|
+
for (const auto& prefix_range :
|
2399
|
+
filter_chain.filter_chain_match.prefix_ranges) {
|
2400
|
+
auto insert_result = destination_ip_map->emplace(
|
2401
|
+
absl::StrCat(grpc_sockaddr_to_string(&prefix_range.address, false),
|
2402
|
+
"/", prefix_range.prefix_len),
|
2403
|
+
InternalFilterChainMap::DestinationIp());
|
2404
|
+
if (insert_result.second) {
|
2405
|
+
insert_result.first->second.prefix_range.emplace(prefix_range);
|
2406
|
+
}
|
2407
|
+
grpc_error_handle error = AddFilterChainDataForServerNames(
|
2408
|
+
filter_chain, &insert_result.first->second);
|
2409
|
+
if (error != GRPC_ERROR_NONE) return error;
|
2410
|
+
}
|
2411
|
+
}
|
2412
|
+
return GRPC_ERROR_NONE;
|
2413
|
+
}
|
2414
|
+
|
2415
|
+
XdsApi::LdsUpdate::FilterChainMap BuildFromInternalFilterChainMap(
|
2416
|
+
InternalFilterChainMap* internal_filter_chain_map) {
|
2417
|
+
XdsApi::LdsUpdate::FilterChainMap filter_chain_map;
|
2418
|
+
for (auto& destination_ip_pair :
|
2419
|
+
internal_filter_chain_map->destination_ip_map) {
|
2420
|
+
XdsApi::LdsUpdate::FilterChainMap::DestinationIp destination_ip;
|
2421
|
+
destination_ip.prefix_range = destination_ip_pair.second.prefix_range;
|
2422
|
+
for (int i = 0; i < 3; i++) {
|
2423
|
+
auto& source_ip_map = destination_ip_pair.second.source_types_array[i];
|
2424
|
+
for (auto& source_ip_pair : source_ip_map) {
|
2425
|
+
destination_ip.source_types_array[i].push_back(
|
2426
|
+
std::move(source_ip_pair.second));
|
2427
|
+
}
|
2428
|
+
}
|
2429
|
+
filter_chain_map.destination_ip_vector.push_back(std::move(destination_ip));
|
2430
|
+
}
|
2431
|
+
return filter_chain_map;
|
2432
|
+
}
|
2433
|
+
|
2434
|
+
grpc_error_handle BuildFilterChainMap(
|
2435
|
+
const std::vector<FilterChain>& filter_chains,
|
2436
|
+
XdsApi::LdsUpdate::FilterChainMap* filter_chain_map) {
|
2437
|
+
InternalFilterChainMap internal_filter_chain_map;
|
2438
|
+
for (const auto& filter_chain : filter_chains) {
|
2439
|
+
// Discard filter chain entries that specify destination port
|
2440
|
+
if (filter_chain.filter_chain_match.destination_port != 0) continue;
|
2441
|
+
grpc_error_handle error = AddFilterChainDataForDestinationIpRange(
|
2442
|
+
filter_chain, &internal_filter_chain_map.destination_ip_map);
|
2443
|
+
if (error != GRPC_ERROR_NONE) return error;
|
2444
|
+
}
|
2445
|
+
*filter_chain_map =
|
2446
|
+
BuildFromInternalFilterChainMap(&internal_filter_chain_map);
|
2447
|
+
return GRPC_ERROR_NONE;
|
2448
|
+
}
|
2449
|
+
|
2450
|
+
grpc_error_handle LdsResponseParseServer(
|
2451
|
+
const EncodingContext& context,
|
2452
|
+
const envoy_config_listener_v3_Listener* listener, bool is_v2,
|
2453
|
+
XdsApi::LdsUpdate* lds_update) {
|
2454
|
+
lds_update->type = XdsApi::LdsUpdate::ListenerType::kTcpListener;
|
2455
|
+
grpc_error_handle error =
|
2456
|
+
AddressParse(envoy_config_listener_v3_Listener_address(listener),
|
2457
|
+
&lds_update->address);
|
2458
|
+
if (error != GRPC_ERROR_NONE) return error;
|
2459
|
+
const auto* use_original_dst =
|
2460
|
+
envoy_config_listener_v3_Listener_use_original_dst(listener);
|
2461
|
+
if (use_original_dst != nullptr) {
|
2462
|
+
if (google_protobuf_BoolValue_value(use_original_dst)) {
|
2463
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2464
|
+
"Field \'use_original_dst\' is not supported.");
|
2465
|
+
}
|
2466
|
+
}
|
2467
|
+
size_t size = 0;
|
2468
|
+
auto* filter_chains =
|
2469
|
+
envoy_config_listener_v3_Listener_filter_chains(listener, &size);
|
2470
|
+
std::vector<FilterChain> parsed_filter_chains;
|
2471
|
+
parsed_filter_chains.reserve(size);
|
2472
|
+
for (size_t i = 0; i < size; i++) {
|
2473
|
+
FilterChain filter_chain;
|
2474
|
+
error = FilterChainParse(context, filter_chains[i], is_v2, &filter_chain);
|
2475
|
+
if (error != GRPC_ERROR_NONE) return error;
|
2476
|
+
parsed_filter_chains.push_back(std::move(filter_chain));
|
2477
|
+
}
|
2478
|
+
error =
|
2479
|
+
BuildFilterChainMap(parsed_filter_chains, &lds_update->filter_chain_map);
|
2480
|
+
if (error != GRPC_ERROR_NONE) return error;
|
2481
|
+
auto* default_filter_chain =
|
2482
|
+
envoy_config_listener_v3_Listener_default_filter_chain(listener);
|
2483
|
+
if (default_filter_chain != nullptr) {
|
2484
|
+
FilterChain filter_chain;
|
2485
|
+
error =
|
2486
|
+
FilterChainParse(context, default_filter_chain, is_v2, &filter_chain);
|
2487
|
+
if (error != GRPC_ERROR_NONE) return error;
|
2488
|
+
if (filter_chain.filter_chain_data != nullptr) {
|
2489
|
+
lds_update->default_filter_chain =
|
2490
|
+
std::move(*filter_chain.filter_chain_data);
|
2491
|
+
}
|
2492
|
+
}
|
2493
|
+
if (size == 0 && default_filter_chain == nullptr) {
|
2494
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("No filter chain provided.");
|
2495
|
+
}
|
2496
|
+
return GRPC_ERROR_NONE;
|
2497
|
+
}
|
2498
|
+
|
2499
|
+
grpc_error_handle LdsResponseParse(
|
2500
|
+
const EncodingContext& context,
|
2501
|
+
const envoy_service_discovery_v3_DiscoveryResponse* response,
|
2502
|
+
const std::set<absl::string_view>& expected_listener_names,
|
2503
|
+
XdsApi::LdsUpdateMap* lds_update_map,
|
2504
|
+
std::set<std::string>* resource_names_failed) {
|
2505
|
+
std::vector<grpc_error_handle> errors;
|
2506
|
+
// Get the resources from the response.
|
2507
|
+
size_t size;
|
2508
|
+
const google_protobuf_Any* const* resources =
|
2509
|
+
envoy_service_discovery_v3_DiscoveryResponse_resources(response, &size);
|
2510
|
+
for (size_t i = 0; i < size; ++i) {
|
2511
|
+
// Check the type_url of the resource.
|
2512
|
+
absl::string_view type_url =
|
2513
|
+
UpbStringToAbsl(google_protobuf_Any_type_url(resources[i]));
|
2514
|
+
bool is_v2 = false;
|
2515
|
+
if (!IsLds(type_url, &is_v2)) {
|
2516
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2517
|
+
absl::StrCat("resource index ", i, ": Resource is not LDS.")
|
2518
|
+
.c_str()));
|
2519
|
+
continue;
|
2520
|
+
}
|
2521
|
+
// Decode the listener.
|
2522
|
+
const upb_strview encoded_listener =
|
2523
|
+
google_protobuf_Any_value(resources[i]);
|
2524
|
+
const envoy_config_listener_v3_Listener* listener =
|
2525
|
+
envoy_config_listener_v3_Listener_parse(
|
2526
|
+
encoded_listener.data, encoded_listener.size, context.arena);
|
2527
|
+
if (listener == nullptr) {
|
2528
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2529
|
+
absl::StrCat("resource index ", i, ": Can't decode listener.")
|
2530
|
+
.c_str()));
|
2531
|
+
continue;
|
2532
|
+
}
|
2533
|
+
// Check listener name. Ignore unexpected listeners.
|
2534
|
+
std::string listener_name =
|
2535
|
+
UpbStringToStdString(envoy_config_listener_v3_Listener_name(listener));
|
2536
|
+
if (expected_listener_names.find(listener_name) ==
|
2537
|
+
expected_listener_names.end()) {
|
2538
|
+
continue;
|
2539
|
+
}
|
2540
|
+
// Fail if listener name is duplicated.
|
2541
|
+
if (lds_update_map->find(listener_name) != lds_update_map->end()) {
|
2542
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2543
|
+
absl::StrCat("duplicate listener name \"", listener_name, "\"")
|
2544
|
+
.c_str()));
|
2545
|
+
resource_names_failed->insert(listener_name);
|
2546
|
+
continue;
|
2547
|
+
}
|
2548
|
+
// Serialize into JSON and store it in the LdsUpdateMap
|
2549
|
+
XdsApi::LdsResourceData& lds_resource_data =
|
2550
|
+
(*lds_update_map)[listener_name];
|
2551
|
+
XdsApi::LdsUpdate& lds_update = lds_resource_data.resource;
|
2552
|
+
lds_resource_data.serialized_proto = UpbStringToStdString(encoded_listener);
|
2553
|
+
// Check whether it's a client or server listener.
|
2554
|
+
const envoy_config_listener_v3_ApiListener* api_listener =
|
2555
|
+
envoy_config_listener_v3_Listener_api_listener(listener);
|
2556
|
+
const envoy_config_core_v3_Address* address =
|
2557
|
+
envoy_config_listener_v3_Listener_address(listener);
|
2558
|
+
if (api_listener != nullptr && address != nullptr) {
|
2559
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2560
|
+
absl::StrCat(listener_name,
|
2561
|
+
": Listener has both address and ApiListener")
|
2562
|
+
.c_str()));
|
2563
|
+
resource_names_failed->insert(listener_name);
|
2564
|
+
continue;
|
2565
|
+
}
|
2566
|
+
if (api_listener == nullptr && address == nullptr) {
|
2567
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2568
|
+
absl::StrCat(listener_name,
|
2569
|
+
": Listener has neither address nor ApiListener")
|
2570
|
+
.c_str()));
|
2571
|
+
resource_names_failed->insert(listener_name);
|
2572
|
+
continue;
|
2573
|
+
}
|
2574
|
+
grpc_error_handle error = GRPC_ERROR_NONE;
|
2575
|
+
if (api_listener != nullptr) {
|
2576
|
+
error = LdsResponseParseClient(context, api_listener, is_v2, &lds_update);
|
2577
|
+
} else {
|
2578
|
+
error = LdsResponseParseServer(context, listener, is_v2, &lds_update);
|
2579
|
+
}
|
2580
|
+
if (error != GRPC_ERROR_NONE) {
|
2581
|
+
errors.push_back(grpc_error_add_child(
|
2582
|
+
GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2583
|
+
absl::StrCat(listener_name, ": validation error").c_str()),
|
2584
|
+
error));
|
2585
|
+
resource_names_failed->insert(listener_name);
|
2586
|
+
}
|
2587
|
+
}
|
2588
|
+
return GRPC_ERROR_CREATE_FROM_VECTOR("errors parsing LDS response", &errors);
|
2589
|
+
}
|
2590
|
+
|
2591
|
+
grpc_error_handle RdsResponseParse(
|
2592
|
+
const EncodingContext& context,
|
2593
|
+
const envoy_service_discovery_v3_DiscoveryResponse* response,
|
2594
|
+
const std::set<absl::string_view>& expected_route_configuration_names,
|
2595
|
+
XdsApi::RdsUpdateMap* rds_update_map,
|
2596
|
+
std::set<std::string>* resource_names_failed) {
|
2597
|
+
std::vector<grpc_error_handle> errors;
|
2598
|
+
// Get the resources from the response.
|
2599
|
+
size_t size;
|
2600
|
+
const google_protobuf_Any* const* resources =
|
2601
|
+
envoy_service_discovery_v3_DiscoveryResponse_resources(response, &size);
|
2602
|
+
for (size_t i = 0; i < size; ++i) {
|
2603
|
+
// Check the type_url of the resource.
|
2604
|
+
absl::string_view type_url =
|
2605
|
+
UpbStringToAbsl(google_protobuf_Any_type_url(resources[i]));
|
2606
|
+
if (!IsRds(type_url)) {
|
2607
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2608
|
+
absl::StrCat("resource index ", i, ": Resource is not RDS.")
|
2609
|
+
.c_str()));
|
2610
|
+
continue;
|
2611
|
+
}
|
2612
|
+
// Decode the route_config.
|
2613
|
+
const upb_strview encoded_route_config =
|
2614
|
+
google_protobuf_Any_value(resources[i]);
|
2615
|
+
const envoy_config_route_v3_RouteConfiguration* route_config =
|
2616
|
+
envoy_config_route_v3_RouteConfiguration_parse(
|
2617
|
+
encoded_route_config.data, encoded_route_config.size,
|
2618
|
+
context.arena);
|
2619
|
+
if (route_config == nullptr) {
|
2620
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2621
|
+
absl::StrCat("resource index ", i, ": Can't decode route_config.")
|
2622
|
+
.c_str()));
|
2623
|
+
continue;
|
2624
|
+
}
|
2625
|
+
// Check route_config_name. Ignore unexpected route_config.
|
2626
|
+
std::string route_config_name = UpbStringToStdString(
|
2627
|
+
envoy_config_route_v3_RouteConfiguration_name(route_config));
|
2628
|
+
if (expected_route_configuration_names.find(route_config_name) ==
|
2629
|
+
expected_route_configuration_names.end()) {
|
2630
|
+
continue;
|
2631
|
+
}
|
2632
|
+
// Fail if route config name is duplicated.
|
2633
|
+
if (rds_update_map->find(route_config_name) != rds_update_map->end()) {
|
2634
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2635
|
+
absl::StrCat("duplicate route config name \"", route_config_name,
|
2636
|
+
"\"")
|
2637
|
+
.c_str()));
|
2638
|
+
resource_names_failed->insert(route_config_name);
|
2639
|
+
continue;
|
2640
|
+
}
|
2641
|
+
// Serialize into JSON and store it in the RdsUpdateMap
|
2642
|
+
XdsApi::RdsResourceData& rds_resource_data =
|
2643
|
+
(*rds_update_map)[route_config_name];
|
2644
|
+
XdsApi::RdsUpdate& rds_update = rds_resource_data.resource;
|
2645
|
+
rds_resource_data.serialized_proto =
|
2646
|
+
UpbStringToStdString(encoded_route_config);
|
2647
|
+
// Parse the route_config.
|
2648
|
+
grpc_error_handle error =
|
2649
|
+
RouteConfigParse(context, route_config, &rds_update);
|
2650
|
+
if (error != GRPC_ERROR_NONE) {
|
2651
|
+
errors.push_back(grpc_error_add_child(
|
2652
|
+
GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2653
|
+
absl::StrCat(route_config_name, ": validation error").c_str()),
|
2654
|
+
error));
|
2655
|
+
resource_names_failed->insert(route_config_name);
|
2656
|
+
}
|
2657
|
+
}
|
2658
|
+
return GRPC_ERROR_CREATE_FROM_VECTOR("errors parsing RDS response", &errors);
|
2659
|
+
}
|
2660
|
+
|
2661
|
+
grpc_error_handle CdsResponseParse(
|
2662
|
+
const EncodingContext& context,
|
1693
2663
|
const envoy_service_discovery_v3_DiscoveryResponse* response,
|
1694
2664
|
const std::set<absl::string_view>& expected_cluster_names,
|
1695
|
-
XdsApi::CdsUpdateMap* cds_update_map,
|
2665
|
+
XdsApi::CdsUpdateMap* cds_update_map,
|
2666
|
+
std::set<std::string>* resource_names_failed) {
|
2667
|
+
std::vector<grpc_error_handle> errors;
|
1696
2668
|
// Get the resources from the response.
|
1697
2669
|
size_t size;
|
1698
2670
|
const google_protobuf_Any* const* resources =
|
@@ -1703,17 +2675,23 @@ grpc_error* CdsResponseParse(
|
|
1703
2675
|
absl::string_view type_url =
|
1704
2676
|
UpbStringToAbsl(google_protobuf_Any_type_url(resources[i]));
|
1705
2677
|
if (!IsCds(type_url)) {
|
1706
|
-
|
2678
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2679
|
+
absl::StrCat("resource index ", i, ": Resource is not CDS.")
|
2680
|
+
.c_str()));
|
2681
|
+
continue;
|
1707
2682
|
}
|
1708
2683
|
// Decode the cluster.
|
1709
2684
|
const upb_strview encoded_cluster = google_protobuf_Any_value(resources[i]);
|
1710
2685
|
const envoy_config_cluster_v3_Cluster* cluster =
|
1711
|
-
envoy_config_cluster_v3_Cluster_parse(
|
1712
|
-
|
2686
|
+
envoy_config_cluster_v3_Cluster_parse(
|
2687
|
+
encoded_cluster.data, encoded_cluster.size, context.arena);
|
1713
2688
|
if (cluster == nullptr) {
|
1714
|
-
|
2689
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2690
|
+
absl::StrCat("resource index ", i, ": Can't decode cluster.")
|
2691
|
+
.c_str()));
|
2692
|
+
continue;
|
1715
2693
|
}
|
1716
|
-
MaybeLogCluster(
|
2694
|
+
MaybeLogCluster(context, cluster);
|
1717
2695
|
// Ignore unexpected cluster names.
|
1718
2696
|
std::string cluster_name =
|
1719
2697
|
UpbStringToStdString(envoy_config_cluster_v3_Cluster_name(cluster));
|
@@ -1723,41 +2701,194 @@ grpc_error* CdsResponseParse(
|
|
1723
2701
|
}
|
1724
2702
|
// Fail on duplicate resources.
|
1725
2703
|
if (cds_update_map->find(cluster_name) != cds_update_map->end()) {
|
1726
|
-
|
2704
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1727
2705
|
absl::StrCat("duplicate resource name \"", cluster_name, "\"")
|
1728
|
-
.c_str());
|
2706
|
+
.c_str()));
|
2707
|
+
resource_names_failed->insert(cluster_name);
|
2708
|
+
continue;
|
1729
2709
|
}
|
1730
|
-
|
2710
|
+
// Serialize into JSON and store it in the CdsUpdateMap
|
2711
|
+
XdsApi::CdsResourceData& cds_resource_data =
|
2712
|
+
(*cds_update_map)[cluster_name];
|
2713
|
+
XdsApi::CdsUpdate& cds_update = cds_resource_data.resource;
|
2714
|
+
cds_resource_data.serialized_proto = UpbStringToStdString(encoded_cluster);
|
1731
2715
|
// Check the cluster_discovery_type.
|
1732
|
-
if (!envoy_config_cluster_v3_Cluster_has_type(cluster)
|
1733
|
-
|
2716
|
+
if (!envoy_config_cluster_v3_Cluster_has_type(cluster) &&
|
2717
|
+
!envoy_config_cluster_v3_Cluster_has_cluster_type(cluster)) {
|
2718
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2719
|
+
absl::StrCat(cluster_name, ": DiscoveryType not found.").c_str()));
|
2720
|
+
resource_names_failed->insert(cluster_name);
|
2721
|
+
continue;
|
1734
2722
|
}
|
1735
|
-
if (envoy_config_cluster_v3_Cluster_type(cluster)
|
2723
|
+
if (envoy_config_cluster_v3_Cluster_type(cluster) ==
|
1736
2724
|
envoy_config_cluster_v3_Cluster_EDS) {
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
2725
|
+
cds_update.cluster_type = XdsApi::CdsUpdate::ClusterType::EDS;
|
2726
|
+
// Check the EDS config source.
|
2727
|
+
const envoy_config_cluster_v3_Cluster_EdsClusterConfig*
|
2728
|
+
eds_cluster_config =
|
2729
|
+
envoy_config_cluster_v3_Cluster_eds_cluster_config(cluster);
|
2730
|
+
const envoy_config_core_v3_ConfigSource* eds_config =
|
2731
|
+
envoy_config_cluster_v3_Cluster_EdsClusterConfig_eds_config(
|
2732
|
+
eds_cluster_config);
|
2733
|
+
if (!envoy_config_core_v3_ConfigSource_has_ads(eds_config)) {
|
2734
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2735
|
+
absl::StrCat(cluster_name, ": EDS ConfigSource is not ADS.")
|
2736
|
+
.c_str()));
|
2737
|
+
resource_names_failed->insert(cluster_name);
|
2738
|
+
continue;
|
2739
|
+
}
|
2740
|
+
// Record EDS service_name (if any).
|
2741
|
+
upb_strview service_name =
|
2742
|
+
envoy_config_cluster_v3_Cluster_EdsClusterConfig_service_name(
|
2743
|
+
eds_cluster_config);
|
2744
|
+
if (service_name.size != 0) {
|
2745
|
+
cds_update.eds_service_name = UpbStringToStdString(service_name);
|
2746
|
+
}
|
2747
|
+
} else if (!XdsAggregateAndLogicalDnsClusterEnabled()) {
|
2748
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2749
|
+
absl::StrCat(cluster_name, ": DiscoveryType is not valid.").c_str()));
|
2750
|
+
resource_names_failed->insert(cluster_name);
|
2751
|
+
continue;
|
2752
|
+
} else if (envoy_config_cluster_v3_Cluster_type(cluster) ==
|
2753
|
+
envoy_config_cluster_v3_Cluster_LOGICAL_DNS) {
|
2754
|
+
cds_update.cluster_type = XdsApi::CdsUpdate::ClusterType::LOGICAL_DNS;
|
2755
|
+
} else {
|
2756
|
+
if (envoy_config_cluster_v3_Cluster_has_cluster_type(cluster)) {
|
2757
|
+
const envoy_config_cluster_v3_Cluster_CustomClusterType*
|
2758
|
+
custom_cluster_type =
|
2759
|
+
envoy_config_cluster_v3_Cluster_cluster_type(cluster);
|
2760
|
+
upb_strview type_name =
|
2761
|
+
envoy_config_cluster_v3_Cluster_CustomClusterType_name(
|
2762
|
+
custom_cluster_type);
|
2763
|
+
if (UpbStringToAbsl(type_name) == "envoy.clusters.aggregate") {
|
2764
|
+
cds_update.cluster_type = XdsApi::CdsUpdate::ClusterType::AGGREGATE;
|
2765
|
+
// Retrieve aggregate clusters.
|
2766
|
+
const google_protobuf_Any* typed_config =
|
2767
|
+
envoy_config_cluster_v3_Cluster_CustomClusterType_typed_config(
|
2768
|
+
custom_cluster_type);
|
2769
|
+
const upb_strview aggregate_cluster_config_upb_strview =
|
2770
|
+
google_protobuf_Any_value(typed_config);
|
2771
|
+
const envoy_extensions_clusters_aggregate_v3_ClusterConfig*
|
2772
|
+
aggregate_cluster_config =
|
2773
|
+
envoy_extensions_clusters_aggregate_v3_ClusterConfig_parse(
|
2774
|
+
aggregate_cluster_config_upb_strview.data,
|
2775
|
+
aggregate_cluster_config_upb_strview.size, context.arena);
|
2776
|
+
if (aggregate_cluster_config == nullptr) {
|
2777
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2778
|
+
absl::StrCat(cluster_name, ": Can't parse aggregate cluster.")
|
2779
|
+
.c_str()));
|
2780
|
+
resource_names_failed->insert(cluster_name);
|
2781
|
+
continue;
|
2782
|
+
}
|
2783
|
+
size_t size;
|
2784
|
+
const upb_strview* clusters =
|
2785
|
+
envoy_extensions_clusters_aggregate_v3_ClusterConfig_clusters(
|
2786
|
+
aggregate_cluster_config, &size);
|
2787
|
+
for (size_t i = 0; i < size; ++i) {
|
2788
|
+
const upb_strview cluster = clusters[i];
|
2789
|
+
cds_update.prioritized_cluster_names.emplace_back(
|
2790
|
+
UpbStringToStdString(cluster));
|
2791
|
+
}
|
2792
|
+
} else {
|
2793
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2794
|
+
absl::StrCat(cluster_name, ": DiscoveryType is not valid.")
|
2795
|
+
.c_str()));
|
2796
|
+
resource_names_failed->insert(cluster_name);
|
2797
|
+
continue;
|
2798
|
+
}
|
2799
|
+
} else {
|
2800
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2801
|
+
absl::StrCat(cluster_name, ": DiscoveryType is not valid.")
|
2802
|
+
.c_str()));
|
2803
|
+
resource_names_failed->insert(cluster_name);
|
2804
|
+
continue;
|
2805
|
+
}
|
1755
2806
|
}
|
1756
2807
|
// Check the LB policy.
|
1757
|
-
if (envoy_config_cluster_v3_Cluster_lb_policy(cluster)
|
2808
|
+
if (envoy_config_cluster_v3_Cluster_lb_policy(cluster) ==
|
1758
2809
|
envoy_config_cluster_v3_Cluster_ROUND_ROBIN) {
|
1759
|
-
|
1760
|
-
|
2810
|
+
cds_update.lb_policy = "ROUND_ROBIN";
|
2811
|
+
} else if (XdsRingHashEnabled() &&
|
2812
|
+
envoy_config_cluster_v3_Cluster_lb_policy(cluster) ==
|
2813
|
+
envoy_config_cluster_v3_Cluster_RING_HASH) {
|
2814
|
+
cds_update.lb_policy = "RING_HASH";
|
2815
|
+
// Record ring hash lb config
|
2816
|
+
auto* ring_hash_config =
|
2817
|
+
envoy_config_cluster_v3_Cluster_ring_hash_lb_config(cluster);
|
2818
|
+
if (ring_hash_config == nullptr) {
|
2819
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2820
|
+
absl::StrCat(cluster_name,
|
2821
|
+
": ring hash lb config required but not present.")
|
2822
|
+
.c_str()));
|
2823
|
+
resource_names_failed->insert(cluster_name);
|
2824
|
+
continue;
|
2825
|
+
}
|
2826
|
+
const google_protobuf_UInt64Value* max_ring_size =
|
2827
|
+
envoy_config_cluster_v3_Cluster_RingHashLbConfig_maximum_ring_size(
|
2828
|
+
ring_hash_config);
|
2829
|
+
if (max_ring_size != nullptr) {
|
2830
|
+
cds_update.max_ring_size =
|
2831
|
+
google_protobuf_UInt64Value_value(max_ring_size);
|
2832
|
+
if (cds_update.max_ring_size > 8388608 ||
|
2833
|
+
cds_update.max_ring_size == 0) {
|
2834
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2835
|
+
absl::StrCat(
|
2836
|
+
cluster_name,
|
2837
|
+
": max_ring_size is not in the range of 1 to 8388608.")
|
2838
|
+
.c_str()));
|
2839
|
+
resource_names_failed->insert(cluster_name);
|
2840
|
+
continue;
|
2841
|
+
}
|
2842
|
+
}
|
2843
|
+
const google_protobuf_UInt64Value* min_ring_size =
|
2844
|
+
envoy_config_cluster_v3_Cluster_RingHashLbConfig_minimum_ring_size(
|
2845
|
+
ring_hash_config);
|
2846
|
+
if (min_ring_size != nullptr) {
|
2847
|
+
cds_update.min_ring_size =
|
2848
|
+
google_protobuf_UInt64Value_value(min_ring_size);
|
2849
|
+
if (cds_update.min_ring_size > 8388608 ||
|
2850
|
+
cds_update.min_ring_size == 0) {
|
2851
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2852
|
+
absl::StrCat(
|
2853
|
+
cluster_name,
|
2854
|
+
": min_ring_size is not in the range of 1 to 8388608.")
|
2855
|
+
.c_str()));
|
2856
|
+
resource_names_failed->insert(cluster_name);
|
2857
|
+
continue;
|
2858
|
+
}
|
2859
|
+
if (cds_update.min_ring_size > cds_update.max_ring_size) {
|
2860
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2861
|
+
absl::StrCat(
|
2862
|
+
cluster_name,
|
2863
|
+
": min_ring_size cannot be greater than max_ring_size.")
|
2864
|
+
.c_str()));
|
2865
|
+
resource_names_failed->insert(cluster_name);
|
2866
|
+
continue;
|
2867
|
+
}
|
2868
|
+
}
|
2869
|
+
if (envoy_config_cluster_v3_Cluster_RingHashLbConfig_hash_function(
|
2870
|
+
ring_hash_config) ==
|
2871
|
+
envoy_config_cluster_v3_Cluster_RingHashLbConfig_XX_HASH) {
|
2872
|
+
cds_update.hash_function = XdsApi::CdsUpdate::HashFunction::XX_HASH;
|
2873
|
+
} else if (
|
2874
|
+
envoy_config_cluster_v3_Cluster_RingHashLbConfig_hash_function(
|
2875
|
+
ring_hash_config) ==
|
2876
|
+
envoy_config_cluster_v3_Cluster_RingHashLbConfig_MURMUR_HASH_2) {
|
2877
|
+
cds_update.hash_function =
|
2878
|
+
XdsApi::CdsUpdate::HashFunction::MURMUR_HASH_2;
|
2879
|
+
} else {
|
2880
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2881
|
+
absl::StrCat(cluster_name,
|
2882
|
+
": ring hash lb config has invalid hash function.")
|
2883
|
+
.c_str()));
|
2884
|
+
resource_names_failed->insert(cluster_name);
|
2885
|
+
continue;
|
2886
|
+
}
|
2887
|
+
} else {
|
2888
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2889
|
+
absl::StrCat(cluster_name, ": LB policy is not supported.").c_str()));
|
2890
|
+
resource_names_failed->insert(cluster_name);
|
2891
|
+
continue;
|
1761
2892
|
}
|
1762
2893
|
if (XdsSecurityEnabled()) {
|
1763
2894
|
// Record Upstream tls context
|
@@ -1776,26 +2907,43 @@ grpc_error* CdsResponseParse(
|
|
1776
2907
|
auto* upstream_tls_context =
|
1777
2908
|
envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_parse(
|
1778
2909
|
encoded_upstream_tls_context.data,
|
1779
|
-
encoded_upstream_tls_context.size, arena);
|
2910
|
+
encoded_upstream_tls_context.size, context.arena);
|
1780
2911
|
if (upstream_tls_context == nullptr) {
|
1781
|
-
|
1782
|
-
|
2912
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2913
|
+
absl::StrCat(cluster_name,
|
2914
|
+
": Can't decode upstream tls context.")
|
2915
|
+
.c_str()));
|
2916
|
+
resource_names_failed->insert(cluster_name);
|
2917
|
+
continue;
|
1783
2918
|
}
|
1784
2919
|
auto* common_tls_context =
|
1785
2920
|
envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_common_tls_context(
|
1786
2921
|
upstream_tls_context);
|
1787
2922
|
if (common_tls_context != nullptr) {
|
1788
|
-
|
2923
|
+
grpc_error_handle error = CommonTlsContextParse(
|
1789
2924
|
common_tls_context, &cds_update.common_tls_context);
|
1790
|
-
if (error != GRPC_ERROR_NONE)
|
2925
|
+
if (error != GRPC_ERROR_NONE) {
|
2926
|
+
errors.push_back(grpc_error_add_child(
|
2927
|
+
GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2928
|
+
absl::StrCat(cluster_name, ": error in TLS context")
|
2929
|
+
.c_str()),
|
2930
|
+
error));
|
2931
|
+
resource_names_failed->insert(cluster_name);
|
2932
|
+
continue;
|
2933
|
+
}
|
1791
2934
|
}
|
1792
2935
|
}
|
1793
2936
|
if (cds_update.common_tls_context.combined_validation_context
|
1794
2937
|
.validation_context_certificate_provider_instance
|
1795
2938
|
.instance_name.empty()) {
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
2939
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2940
|
+
absl::StrCat(cluster_name,
|
2941
|
+
"TLS configuration provided but no "
|
2942
|
+
"validation_context_certificate_provider_instance "
|
2943
|
+
"found.")
|
2944
|
+
.c_str()));
|
2945
|
+
resource_names_failed->insert(cluster_name);
|
2946
|
+
continue;
|
1799
2947
|
}
|
1800
2948
|
}
|
1801
2949
|
}
|
@@ -1805,8 +2953,11 @@ grpc_error* CdsResponseParse(
|
|
1805
2953
|
envoy_config_cluster_v3_Cluster_lrs_server(cluster);
|
1806
2954
|
if (lrs_server != nullptr) {
|
1807
2955
|
if (!envoy_config_core_v3_ConfigSource_has_self(lrs_server)) {
|
1808
|
-
|
1809
|
-
"LRS ConfigSource is not self.")
|
2956
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
2957
|
+
absl::StrCat(cluster_name, ": LRS ConfigSource is not self.")
|
2958
|
+
.c_str()));
|
2959
|
+
resource_names_failed->insert(cluster_name);
|
2960
|
+
continue;
|
1810
2961
|
}
|
1811
2962
|
cds_update.lrs_load_reporting_server_name.emplace("");
|
1812
2963
|
}
|
@@ -1837,10 +2988,10 @@ grpc_error* CdsResponseParse(
|
|
1837
2988
|
}
|
1838
2989
|
}
|
1839
2990
|
}
|
1840
|
-
return
|
2991
|
+
return GRPC_ERROR_CREATE_FROM_VECTOR("errors parsing CDS response", &errors);
|
1841
2992
|
}
|
1842
2993
|
|
1843
|
-
|
2994
|
+
grpc_error_handle ServerAddressParseAndAppend(
|
1844
2995
|
const envoy_config_endpoint_v3_LbEndpoint* lb_endpoint,
|
1845
2996
|
ServerAddressList* list) {
|
1846
2997
|
// If health_status is not HEALTHY or UNKNOWN, skip this endpoint.
|
@@ -1865,13 +3016,15 @@ grpc_error* ServerAddressParseAndAppend(
|
|
1865
3016
|
}
|
1866
3017
|
// Populate grpc_resolved_address.
|
1867
3018
|
grpc_resolved_address addr;
|
1868
|
-
|
3019
|
+
grpc_error_handle error =
|
3020
|
+
grpc_string_to_sockaddr(&addr, address_str.c_str(), port);
|
3021
|
+
if (error != GRPC_ERROR_NONE) return error;
|
1869
3022
|
// Append the address to the list.
|
1870
3023
|
list->emplace_back(addr, nullptr);
|
1871
3024
|
return GRPC_ERROR_NONE;
|
1872
3025
|
}
|
1873
3026
|
|
1874
|
-
|
3027
|
+
grpc_error_handle LocalityParse(
|
1875
3028
|
const envoy_config_endpoint_v3_LocalityLbEndpoints* locality_lb_endpoints,
|
1876
3029
|
XdsApi::EdsUpdate::Priority::Locality* output_locality, size_t* priority) {
|
1877
3030
|
// Parse LB weight.
|
@@ -1888,6 +3041,9 @@ grpc_error* LocalityParse(
|
|
1888
3041
|
const envoy_config_core_v3_Locality* locality =
|
1889
3042
|
envoy_config_endpoint_v3_LocalityLbEndpoints_locality(
|
1890
3043
|
locality_lb_endpoints);
|
3044
|
+
if (locality == nullptr) {
|
3045
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty locality.");
|
3046
|
+
}
|
1891
3047
|
std::string region =
|
1892
3048
|
UpbStringToStdString(envoy_config_core_v3_Locality_region(locality));
|
1893
3049
|
std::string zone =
|
@@ -1902,7 +3058,7 @@ grpc_error* LocalityParse(
|
|
1902
3058
|
envoy_config_endpoint_v3_LocalityLbEndpoints_lb_endpoints(
|
1903
3059
|
locality_lb_endpoints, &size);
|
1904
3060
|
for (size_t i = 0; i < size; ++i) {
|
1905
|
-
|
3061
|
+
grpc_error_handle error = ServerAddressParseAndAppend(
|
1906
3062
|
lb_endpoints[i], &output_locality->endpoints);
|
1907
3063
|
if (error != GRPC_ERROR_NONE) return error;
|
1908
3064
|
}
|
@@ -1912,7 +3068,7 @@ grpc_error* LocalityParse(
|
|
1912
3068
|
return GRPC_ERROR_NONE;
|
1913
3069
|
}
|
1914
3070
|
|
1915
|
-
|
3071
|
+
grpc_error_handle DropParseAndAppend(
|
1916
3072
|
const envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload*
|
1917
3073
|
drop_overload,
|
1918
3074
|
XdsApi::EdsUpdate::DropConfig* drop_config) {
|
@@ -1951,11 +3107,13 @@ grpc_error* DropParseAndAppend(
|
|
1951
3107
|
return GRPC_ERROR_NONE;
|
1952
3108
|
}
|
1953
3109
|
|
1954
|
-
|
1955
|
-
|
3110
|
+
grpc_error_handle EdsResponseParse(
|
3111
|
+
const EncodingContext& context,
|
1956
3112
|
const envoy_service_discovery_v3_DiscoveryResponse* response,
|
1957
3113
|
const std::set<absl::string_view>& expected_eds_service_names,
|
1958
|
-
XdsApi::EdsUpdateMap* eds_update_map,
|
3114
|
+
XdsApi::EdsUpdateMap* eds_update_map,
|
3115
|
+
std::set<std::string>* resource_names_failed) {
|
3116
|
+
std::vector<grpc_error_handle> errors;
|
1959
3117
|
// Get the resources from the response.
|
1960
3118
|
size_t size;
|
1961
3119
|
const google_protobuf_Any* const* resources =
|
@@ -1965,7 +3123,10 @@ grpc_error* EdsResponseParse(
|
|
1965
3123
|
absl::string_view type_url =
|
1966
3124
|
UpbStringToAbsl(google_protobuf_Any_type_url(resources[i]));
|
1967
3125
|
if (!IsEds(type_url)) {
|
1968
|
-
|
3126
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
3127
|
+
absl::StrCat("resource index ", i, ": Resource is not EDS.")
|
3128
|
+
.c_str()));
|
3129
|
+
continue;
|
1969
3130
|
}
|
1970
3131
|
// Get the cluster_load_assignment.
|
1971
3132
|
upb_strview encoded_cluster_load_assignment =
|
@@ -1973,13 +3134,15 @@ grpc_error* EdsResponseParse(
|
|
1973
3134
|
envoy_config_endpoint_v3_ClusterLoadAssignment* cluster_load_assignment =
|
1974
3135
|
envoy_config_endpoint_v3_ClusterLoadAssignment_parse(
|
1975
3136
|
encoded_cluster_load_assignment.data,
|
1976
|
-
encoded_cluster_load_assignment.size, arena);
|
3137
|
+
encoded_cluster_load_assignment.size, context.arena);
|
1977
3138
|
if (cluster_load_assignment == nullptr) {
|
1978
|
-
|
1979
|
-
"
|
3139
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
3140
|
+
absl::StrCat("resource index ", i,
|
3141
|
+
": Can't parse cluster_load_assignment.")
|
3142
|
+
.c_str()));
|
3143
|
+
continue;
|
1980
3144
|
}
|
1981
|
-
MaybeLogClusterLoadAssignment(
|
1982
|
-
cluster_load_assignment);
|
3145
|
+
MaybeLogClusterLoadAssignment(context, cluster_load_assignment);
|
1983
3146
|
// Check the EDS service name. Ignore unexpected names.
|
1984
3147
|
std::string eds_service_name = UpbStringToStdString(
|
1985
3148
|
envoy_config_endpoint_v3_ClusterLoadAssignment_cluster_name(
|
@@ -1990,22 +3153,29 @@ grpc_error* EdsResponseParse(
|
|
1990
3153
|
}
|
1991
3154
|
// Fail on duplicate resources.
|
1992
3155
|
if (eds_update_map->find(eds_service_name) != eds_update_map->end()) {
|
1993
|
-
|
3156
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1994
3157
|
absl::StrCat("duplicate resource name \"", eds_service_name, "\"")
|
1995
|
-
.c_str());
|
3158
|
+
.c_str()));
|
3159
|
+
resource_names_failed->insert(eds_service_name);
|
3160
|
+
continue;
|
1996
3161
|
}
|
1997
|
-
|
1998
|
-
|
3162
|
+
// Serialize into JSON and store it in the EdsUpdateMap
|
3163
|
+
XdsApi::EdsResourceData& eds_resource_data =
|
3164
|
+
(*eds_update_map)[eds_service_name];
|
3165
|
+
XdsApi::EdsUpdate& eds_update = eds_resource_data.resource;
|
3166
|
+
eds_resource_data.serialized_proto =
|
3167
|
+
UpbStringToStdString(encoded_cluster_load_assignment);
|
1999
3168
|
// Get the endpoints.
|
2000
3169
|
size_t locality_size;
|
2001
3170
|
const envoy_config_endpoint_v3_LocalityLbEndpoints* const* endpoints =
|
2002
3171
|
envoy_config_endpoint_v3_ClusterLoadAssignment_endpoints(
|
2003
3172
|
cluster_load_assignment, &locality_size);
|
3173
|
+
grpc_error_handle error = GRPC_ERROR_NONE;
|
2004
3174
|
for (size_t j = 0; j < locality_size; ++j) {
|
2005
3175
|
size_t priority;
|
2006
3176
|
XdsApi::EdsUpdate::Priority::Locality locality;
|
2007
|
-
|
2008
|
-
if (error != GRPC_ERROR_NONE)
|
3177
|
+
error = LocalityParse(endpoints[j], &locality, &priority);
|
3178
|
+
if (error != GRPC_ERROR_NONE) break;
|
2009
3179
|
// Filter out locality with weight 0.
|
2010
3180
|
if (locality.lb_weight == 0) continue;
|
2011
3181
|
// Make sure prorities is big enough. Note that they might not
|
@@ -2016,10 +3186,21 @@ grpc_error* EdsResponseParse(
|
|
2016
3186
|
eds_update.priorities[priority].localities.emplace(locality.name.get(),
|
2017
3187
|
std::move(locality));
|
2018
3188
|
}
|
3189
|
+
if (error != GRPC_ERROR_NONE) {
|
3190
|
+
errors.push_back(grpc_error_add_child(
|
3191
|
+
GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
3192
|
+
absl::StrCat(eds_service_name, ": locality validation error")
|
3193
|
+
.c_str()),
|
3194
|
+
error));
|
3195
|
+
resource_names_failed->insert(eds_service_name);
|
3196
|
+
continue;
|
3197
|
+
}
|
2019
3198
|
for (const auto& priority : eds_update.priorities) {
|
2020
3199
|
if (priority.localities.empty()) {
|
2021
|
-
|
2022
|
-
"
|
3200
|
+
errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
3201
|
+
absl::StrCat(eds_service_name, ": sparse priority list").c_str()));
|
3202
|
+
resource_names_failed->insert(eds_service_name);
|
3203
|
+
continue;
|
2023
3204
|
}
|
2024
3205
|
}
|
2025
3206
|
// Get the drop config.
|
@@ -2034,13 +3215,22 @@ grpc_error* EdsResponseParse(
|
|
2034
3215
|
envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_drop_overloads(
|
2035
3216
|
policy, &drop_size);
|
2036
3217
|
for (size_t j = 0; j < drop_size; ++j) {
|
2037
|
-
|
3218
|
+
error =
|
2038
3219
|
DropParseAndAppend(drop_overload[j], eds_update.drop_config.get());
|
2039
|
-
if (error != GRPC_ERROR_NONE)
|
3220
|
+
if (error != GRPC_ERROR_NONE) break;
|
3221
|
+
}
|
3222
|
+
if (error != GRPC_ERROR_NONE) {
|
3223
|
+
errors.push_back(grpc_error_add_child(
|
3224
|
+
GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
3225
|
+
absl::StrCat(eds_service_name, ": drop config validation error")
|
3226
|
+
.c_str()),
|
3227
|
+
error));
|
3228
|
+
resource_names_failed->insert(eds_service_name);
|
3229
|
+
continue;
|
2040
3230
|
}
|
2041
3231
|
}
|
2042
3232
|
}
|
2043
|
-
return
|
3233
|
+
return GRPC_ERROR_CREATE_FROM_VECTOR("errors parsing EDS response", &errors);
|
2044
3234
|
}
|
2045
3235
|
|
2046
3236
|
std::string TypeUrlInternalToExternal(absl::string_view type_url) {
|
@@ -2056,16 +3246,27 @@ std::string TypeUrlInternalToExternal(absl::string_view type_url) {
|
|
2056
3246
|
return std::string(type_url);
|
2057
3247
|
}
|
2058
3248
|
|
3249
|
+
template <typename UpdateMap>
|
3250
|
+
void MoveUpdatesToFailedSet(UpdateMap* update_map,
|
3251
|
+
std::set<std::string>* resource_names_failed) {
|
3252
|
+
for (const auto& p : *update_map) {
|
3253
|
+
resource_names_failed->insert(p.first);
|
3254
|
+
}
|
3255
|
+
update_map->clear();
|
3256
|
+
}
|
3257
|
+
|
2059
3258
|
} // namespace
|
2060
3259
|
|
2061
3260
|
XdsApi::AdsParseResult XdsApi::ParseAdsResponse(
|
2062
|
-
const grpc_slice& encoded_response,
|
3261
|
+
const XdsBootstrap::XdsServer& server, const grpc_slice& encoded_response,
|
2063
3262
|
const std::set<absl::string_view>& expected_listener_names,
|
2064
3263
|
const std::set<absl::string_view>& expected_route_configuration_names,
|
2065
3264
|
const std::set<absl::string_view>& expected_cluster_names,
|
2066
3265
|
const std::set<absl::string_view>& expected_eds_service_names) {
|
2067
3266
|
AdsParseResult result;
|
2068
3267
|
upb::Arena arena;
|
3268
|
+
const EncodingContext context = {client_, tracer_, symtab_.ptr(), arena.ptr(),
|
3269
|
+
server.ShouldUseV3()};
|
2069
3270
|
// Decode the response.
|
2070
3271
|
const envoy_service_discovery_v3_DiscoveryResponse* response =
|
2071
3272
|
envoy_service_discovery_v3_DiscoveryResponse_parse(
|
@@ -2077,7 +3278,7 @@ XdsApi::AdsParseResult XdsApi::ParseAdsResponse(
|
|
2077
3278
|
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode DiscoveryResponse.");
|
2078
3279
|
return result;
|
2079
3280
|
}
|
2080
|
-
MaybeLogDiscoveryResponse(
|
3281
|
+
MaybeLogDiscoveryResponse(context, response);
|
2081
3282
|
// Record the type_url, the version_info, and the nonce of the response.
|
2082
3283
|
result.type_url = TypeUrlInternalToExternal(UpbStringToAbsl(
|
2083
3284
|
envoy_service_discovery_v3_DiscoveryResponse_type_url(response)));
|
@@ -2087,22 +3288,37 @@ XdsApi::AdsParseResult XdsApi::ParseAdsResponse(
|
|
2087
3288
|
envoy_service_discovery_v3_DiscoveryResponse_nonce(response));
|
2088
3289
|
// Parse the response according to the resource type.
|
2089
3290
|
if (IsLds(result.type_url)) {
|
2090
|
-
result.parse_error =
|
2091
|
-
|
2092
|
-
|
3291
|
+
result.parse_error =
|
3292
|
+
LdsResponseParse(context, response, expected_listener_names,
|
3293
|
+
&result.lds_update_map, &result.resource_names_failed);
|
3294
|
+
if (result.parse_error != GRPC_ERROR_NONE) {
|
3295
|
+
MoveUpdatesToFailedSet(&result.lds_update_map,
|
3296
|
+
&result.resource_names_failed);
|
3297
|
+
}
|
2093
3298
|
} else if (IsRds(result.type_url)) {
|
2094
3299
|
result.parse_error =
|
2095
|
-
RdsResponseParse(
|
2096
|
-
|
2097
|
-
|
3300
|
+
RdsResponseParse(context, response, expected_route_configuration_names,
|
3301
|
+
&result.rds_update_map, &result.resource_names_failed);
|
3302
|
+
if (result.parse_error != GRPC_ERROR_NONE) {
|
3303
|
+
MoveUpdatesToFailedSet(&result.rds_update_map,
|
3304
|
+
&result.resource_names_failed);
|
3305
|
+
}
|
2098
3306
|
} else if (IsCds(result.type_url)) {
|
2099
|
-
result.parse_error =
|
2100
|
-
|
2101
|
-
|
3307
|
+
result.parse_error =
|
3308
|
+
CdsResponseParse(context, response, expected_cluster_names,
|
3309
|
+
&result.cds_update_map, &result.resource_names_failed);
|
3310
|
+
if (result.parse_error != GRPC_ERROR_NONE) {
|
3311
|
+
MoveUpdatesToFailedSet(&result.cds_update_map,
|
3312
|
+
&result.resource_names_failed);
|
3313
|
+
}
|
2102
3314
|
} else if (IsEds(result.type_url)) {
|
2103
|
-
result.parse_error =
|
2104
|
-
|
2105
|
-
|
3315
|
+
result.parse_error =
|
3316
|
+
EdsResponseParse(context, response, expected_eds_service_names,
|
3317
|
+
&result.eds_update_map, &result.resource_names_failed);
|
3318
|
+
if (result.parse_error != GRPC_ERROR_NONE) {
|
3319
|
+
MoveUpdatesToFailedSet(&result.eds_update_map,
|
3320
|
+
&result.resource_names_failed);
|
3321
|
+
}
|
2106
3322
|
}
|
2107
3323
|
return result;
|
2108
3324
|
}
|
@@ -2110,25 +3326,25 @@ XdsApi::AdsParseResult XdsApi::ParseAdsResponse(
|
|
2110
3326
|
namespace {
|
2111
3327
|
|
2112
3328
|
void MaybeLogLrsRequest(
|
2113
|
-
|
3329
|
+
const EncodingContext& context,
|
2114
3330
|
const envoy_service_load_stats_v3_LoadStatsRequest* request) {
|
2115
|
-
if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
|
3331
|
+
if (GRPC_TRACE_FLAG_ENABLED(*context.tracer) &&
|
2116
3332
|
gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
|
2117
3333
|
const upb_msgdef* msg_type =
|
2118
|
-
envoy_service_load_stats_v3_LoadStatsRequest_getmsgdef(symtab);
|
3334
|
+
envoy_service_load_stats_v3_LoadStatsRequest_getmsgdef(context.symtab);
|
2119
3335
|
char buf[10240];
|
2120
3336
|
upb_text_encode(request, msg_type, nullptr, 0, buf, sizeof(buf));
|
2121
|
-
gpr_log(GPR_DEBUG, "[xds_client %p] constructed LRS request: %s",
|
2122
|
-
buf);
|
3337
|
+
gpr_log(GPR_DEBUG, "[xds_client %p] constructed LRS request: %s",
|
3338
|
+
context.client, buf);
|
2123
3339
|
}
|
2124
3340
|
}
|
2125
3341
|
|
2126
3342
|
grpc_slice SerializeLrsRequest(
|
2127
|
-
const
|
2128
|
-
|
3343
|
+
const EncodingContext& context,
|
3344
|
+
const envoy_service_load_stats_v3_LoadStatsRequest* request) {
|
2129
3345
|
size_t output_length;
|
2130
3346
|
char* output = envoy_service_load_stats_v3_LoadStatsRequest_serialize(
|
2131
|
-
request, arena, &output_length);
|
3347
|
+
request, context.arena, &output_length);
|
2132
3348
|
return grpc_slice_from_copied_buffer(output, output_length);
|
2133
3349
|
}
|
2134
3350
|
|
@@ -2137,6 +3353,8 @@ grpc_slice SerializeLrsRequest(
|
|
2137
3353
|
grpc_slice XdsApi::CreateLrsInitialRequest(
|
2138
3354
|
const XdsBootstrap::XdsServer& server) {
|
2139
3355
|
upb::Arena arena;
|
3356
|
+
const EncodingContext context = {client_, tracer_, symtab_.ptr(), arena.ptr(),
|
3357
|
+
server.ShouldUseV3()};
|
2140
3358
|
// Create a request.
|
2141
3359
|
envoy_service_load_stats_v3_LoadStatsRequest* request =
|
2142
3360
|
envoy_service_load_stats_v3_LoadStatsRequest_new(arena.ptr());
|
@@ -2144,25 +3362,25 @@ grpc_slice XdsApi::CreateLrsInitialRequest(
|
|
2144
3362
|
envoy_config_core_v3_Node* node_msg =
|
2145
3363
|
envoy_service_load_stats_v3_LoadStatsRequest_mutable_node(request,
|
2146
3364
|
arena.ptr());
|
2147
|
-
PopulateNode(
|
2148
|
-
user_agent_name_, node_msg);
|
3365
|
+
PopulateNode(context, node_, build_version_, user_agent_name_, node_msg);
|
2149
3366
|
envoy_config_core_v3_Node_add_client_features(
|
2150
3367
|
node_msg, upb_strview_makez("envoy.lrs.supports_send_all_clusters"),
|
2151
3368
|
arena.ptr());
|
2152
|
-
MaybeLogLrsRequest(
|
2153
|
-
return SerializeLrsRequest(
|
3369
|
+
MaybeLogLrsRequest(context, request);
|
3370
|
+
return SerializeLrsRequest(context, request);
|
2154
3371
|
}
|
2155
3372
|
|
2156
3373
|
namespace {
|
2157
3374
|
|
2158
3375
|
void LocalityStatsPopulate(
|
3376
|
+
const EncodingContext& context,
|
2159
3377
|
envoy_config_endpoint_v3_UpstreamLocalityStats* output,
|
2160
3378
|
const XdsLocalityName& locality_name,
|
2161
|
-
const XdsClusterLocalityStats::Snapshot& snapshot
|
3379
|
+
const XdsClusterLocalityStats::Snapshot& snapshot) {
|
2162
3380
|
// Set locality.
|
2163
3381
|
envoy_config_core_v3_Locality* locality =
|
2164
|
-
envoy_config_endpoint_v3_UpstreamLocalityStats_mutable_locality(
|
2165
|
-
|
3382
|
+
envoy_config_endpoint_v3_UpstreamLocalityStats_mutable_locality(
|
3383
|
+
output, context.arena);
|
2166
3384
|
if (!locality_name.region().empty()) {
|
2167
3385
|
envoy_config_core_v3_Locality_set_region(
|
2168
3386
|
locality, StdStringToUpbString(locality_name.region()));
|
@@ -2190,7 +3408,7 @@ void LocalityStatsPopulate(
|
|
2190
3408
|
const XdsClusterLocalityStats::BackendMetric& metric_value = p.second;
|
2191
3409
|
envoy_config_endpoint_v3_EndpointLoadMetricStats* load_metric =
|
2192
3410
|
envoy_config_endpoint_v3_UpstreamLocalityStats_add_load_metric_stats(
|
2193
|
-
output, arena);
|
3411
|
+
output, context.arena);
|
2194
3412
|
envoy_config_endpoint_v3_EndpointLoadMetricStats_set_metric_name(
|
2195
3413
|
load_metric, StdStringToUpbString(metric_name));
|
2196
3414
|
envoy_config_endpoint_v3_EndpointLoadMetricStats_set_num_requests_finished_with_metric(
|
@@ -2205,6 +3423,8 @@ void LocalityStatsPopulate(
|
|
2205
3423
|
grpc_slice XdsApi::CreateLrsRequest(
|
2206
3424
|
ClusterLoadReportMap cluster_load_report_map) {
|
2207
3425
|
upb::Arena arena;
|
3426
|
+
const EncodingContext context = {client_, tracer_, symtab_.ptr(), arena.ptr(),
|
3427
|
+
false};
|
2208
3428
|
// Create a request.
|
2209
3429
|
envoy_service_load_stats_v3_LoadStatsRequest* request =
|
2210
3430
|
envoy_service_load_stats_v3_LoadStatsRequest_new(arena.ptr());
|
@@ -2231,8 +3451,7 @@ grpc_slice XdsApi::CreateLrsRequest(
|
|
2231
3451
|
envoy_config_endpoint_v3_UpstreamLocalityStats* locality_stats =
|
2232
3452
|
envoy_config_endpoint_v3_ClusterStats_add_upstream_locality_stats(
|
2233
3453
|
cluster_stats, arena.ptr());
|
2234
|
-
LocalityStatsPopulate(locality_stats, locality_name, snapshot
|
2235
|
-
arena.ptr());
|
3454
|
+
LocalityStatsPopulate(context, locality_stats, locality_name, snapshot);
|
2236
3455
|
}
|
2237
3456
|
// Add dropped requests.
|
2238
3457
|
uint64_t total_dropped_requests = 0;
|
@@ -2261,14 +3480,14 @@ grpc_slice XdsApi::CreateLrsRequest(
|
|
2261
3480
|
google_protobuf_Duration_set_seconds(load_report_interval, timespec.tv_sec);
|
2262
3481
|
google_protobuf_Duration_set_nanos(load_report_interval, timespec.tv_nsec);
|
2263
3482
|
}
|
2264
|
-
MaybeLogLrsRequest(
|
2265
|
-
return SerializeLrsRequest(
|
3483
|
+
MaybeLogLrsRequest(context, request);
|
3484
|
+
return SerializeLrsRequest(context, request);
|
2266
3485
|
}
|
2267
3486
|
|
2268
|
-
|
2269
|
-
|
2270
|
-
|
2271
|
-
|
3487
|
+
grpc_error_handle XdsApi::ParseLrsResponse(
|
3488
|
+
const grpc_slice& encoded_response, bool* send_all_clusters,
|
3489
|
+
std::set<std::string>* cluster_names,
|
3490
|
+
grpc_millis* load_reporting_interval) {
|
2272
3491
|
upb::Arena arena;
|
2273
3492
|
// Decode the response.
|
2274
3493
|
const envoy_service_load_stats_v3_LoadStatsResponse* decoded_response =
|
@@ -2305,4 +3524,276 @@ grpc_error* XdsApi::ParseLrsResponse(const grpc_slice& encoded_response,
|
|
2305
3524
|
return GRPC_ERROR_NONE;
|
2306
3525
|
}
|
2307
3526
|
|
3527
|
+
namespace {
|
3528
|
+
google_protobuf_Timestamp* GrpcMillisToTimestamp(const EncodingContext& context,
|
3529
|
+
grpc_millis value) {
|
3530
|
+
google_protobuf_Timestamp* timestamp =
|
3531
|
+
google_protobuf_Timestamp_new(context.arena);
|
3532
|
+
gpr_timespec timespec = grpc_millis_to_timespec(value, GPR_CLOCK_REALTIME);
|
3533
|
+
google_protobuf_Timestamp_set_seconds(timestamp, timespec.tv_sec);
|
3534
|
+
google_protobuf_Timestamp_set_nanos(timestamp, timespec.tv_nsec);
|
3535
|
+
return timestamp;
|
3536
|
+
}
|
3537
|
+
|
3538
|
+
envoy_admin_v3_UpdateFailureState* CreateUpdateFailureStateUpb(
|
3539
|
+
const EncodingContext& context,
|
3540
|
+
const XdsApi::ResourceMetadata* resource_metadata) {
|
3541
|
+
auto* update_failure_state =
|
3542
|
+
envoy_admin_v3_UpdateFailureState_new(context.arena);
|
3543
|
+
envoy_admin_v3_UpdateFailureState_set_details(
|
3544
|
+
update_failure_state,
|
3545
|
+
StdStringToUpbString(resource_metadata->failed_details));
|
3546
|
+
envoy_admin_v3_UpdateFailureState_set_version_info(
|
3547
|
+
update_failure_state,
|
3548
|
+
StdStringToUpbString(resource_metadata->failed_version));
|
3549
|
+
envoy_admin_v3_UpdateFailureState_set_last_update_attempt(
|
3550
|
+
update_failure_state,
|
3551
|
+
GrpcMillisToTimestamp(context, resource_metadata->failed_update_time));
|
3552
|
+
return update_failure_state;
|
3553
|
+
}
|
3554
|
+
|
3555
|
+
void DumpLdsConfig(const EncodingContext& context,
|
3556
|
+
const XdsApi::ResourceTypeMetadata& resource_type_metadata,
|
3557
|
+
envoy_service_status_v3_PerXdsConfig* per_xds_config) {
|
3558
|
+
upb_strview kLdsTypeUrlUpb = upb_strview_makez(XdsApi::kLdsTypeUrl);
|
3559
|
+
auto* listener_config_dump =
|
3560
|
+
envoy_service_status_v3_PerXdsConfig_mutable_listener_config(
|
3561
|
+
per_xds_config, context.arena);
|
3562
|
+
envoy_admin_v3_ListenersConfigDump_set_version_info(
|
3563
|
+
listener_config_dump,
|
3564
|
+
StdStringToUpbString(resource_type_metadata.version));
|
3565
|
+
for (auto& p : resource_type_metadata.resource_metadata_map) {
|
3566
|
+
absl::string_view name = p.first;
|
3567
|
+
const XdsApi::ResourceMetadata* meta = p.second;
|
3568
|
+
const upb_strview name_upb = StdStringToUpbString(name);
|
3569
|
+
auto* dynamic_listener =
|
3570
|
+
envoy_admin_v3_ListenersConfigDump_add_dynamic_listeners(
|
3571
|
+
listener_config_dump, context.arena);
|
3572
|
+
envoy_admin_v3_ListenersConfigDump_DynamicListener_set_name(
|
3573
|
+
dynamic_listener, name_upb);
|
3574
|
+
envoy_admin_v3_ListenersConfigDump_DynamicListener_set_client_status(
|
3575
|
+
dynamic_listener, meta->client_status);
|
3576
|
+
if (!meta->serialized_proto.empty()) {
|
3577
|
+
// Set in-effective listeners
|
3578
|
+
auto* dynamic_listener_state =
|
3579
|
+
envoy_admin_v3_ListenersConfigDump_DynamicListener_mutable_active_state(
|
3580
|
+
dynamic_listener, context.arena);
|
3581
|
+
envoy_admin_v3_ListenersConfigDump_DynamicListenerState_set_version_info(
|
3582
|
+
dynamic_listener_state, StdStringToUpbString(meta->version));
|
3583
|
+
envoy_admin_v3_ListenersConfigDump_DynamicListenerState_set_last_updated(
|
3584
|
+
dynamic_listener_state,
|
3585
|
+
GrpcMillisToTimestamp(context, meta->update_time));
|
3586
|
+
auto* listener_any =
|
3587
|
+
envoy_admin_v3_ListenersConfigDump_DynamicListenerState_mutable_listener(
|
3588
|
+
dynamic_listener_state, context.arena);
|
3589
|
+
google_protobuf_Any_set_type_url(listener_any, kLdsTypeUrlUpb);
|
3590
|
+
google_protobuf_Any_set_value(
|
3591
|
+
listener_any, StdStringToUpbString(meta->serialized_proto));
|
3592
|
+
}
|
3593
|
+
if (meta->client_status == XdsApi::ResourceMetadata::NACKED) {
|
3594
|
+
// Set error_state if NACKED
|
3595
|
+
envoy_admin_v3_ListenersConfigDump_DynamicListener_set_error_state(
|
3596
|
+
dynamic_listener, CreateUpdateFailureStateUpb(context, meta));
|
3597
|
+
}
|
3598
|
+
}
|
3599
|
+
}
|
3600
|
+
|
3601
|
+
void DumpRdsConfig(const EncodingContext& context,
|
3602
|
+
const XdsApi::ResourceTypeMetadata& resource_type_metadata,
|
3603
|
+
envoy_service_status_v3_PerXdsConfig* per_xds_config) {
|
3604
|
+
upb_strview kRdsTypeUrlUpb = upb_strview_makez(XdsApi::kRdsTypeUrl);
|
3605
|
+
auto* route_config_dump =
|
3606
|
+
envoy_service_status_v3_PerXdsConfig_mutable_route_config(per_xds_config,
|
3607
|
+
context.arena);
|
3608
|
+
for (auto& p : resource_type_metadata.resource_metadata_map) {
|
3609
|
+
absl::string_view name = p.first;
|
3610
|
+
const XdsApi::ResourceMetadata* meta = p.second;
|
3611
|
+
const upb_strview name_upb = StdStringToUpbString(name);
|
3612
|
+
auto* dynamic_route_config =
|
3613
|
+
envoy_admin_v3_RoutesConfigDump_add_dynamic_route_configs(
|
3614
|
+
route_config_dump, context.arena);
|
3615
|
+
envoy_admin_v3_RoutesConfigDump_DynamicRouteConfig_set_client_status(
|
3616
|
+
dynamic_route_config, meta->client_status);
|
3617
|
+
auto* route_config_any =
|
3618
|
+
envoy_admin_v3_RoutesConfigDump_DynamicRouteConfig_mutable_route_config(
|
3619
|
+
dynamic_route_config, context.arena);
|
3620
|
+
if (!meta->serialized_proto.empty()) {
|
3621
|
+
// Set in-effective route configs
|
3622
|
+
envoy_admin_v3_RoutesConfigDump_DynamicRouteConfig_set_version_info(
|
3623
|
+
dynamic_route_config, StdStringToUpbString(meta->version));
|
3624
|
+
envoy_admin_v3_RoutesConfigDump_DynamicRouteConfig_set_last_updated(
|
3625
|
+
dynamic_route_config,
|
3626
|
+
GrpcMillisToTimestamp(context, meta->update_time));
|
3627
|
+
google_protobuf_Any_set_type_url(route_config_any, kRdsTypeUrlUpb);
|
3628
|
+
google_protobuf_Any_set_value(
|
3629
|
+
route_config_any, StdStringToUpbString(meta->serialized_proto));
|
3630
|
+
} else {
|
3631
|
+
// If there isn't a working route config, we still need to print the
|
3632
|
+
// name.
|
3633
|
+
auto* route_config =
|
3634
|
+
envoy_config_route_v3_RouteConfiguration_new(context.arena);
|
3635
|
+
envoy_config_route_v3_RouteConfiguration_set_name(route_config, name_upb);
|
3636
|
+
size_t length;
|
3637
|
+
char* bytes = envoy_config_route_v3_RouteConfiguration_serialize(
|
3638
|
+
route_config, context.arena, &length);
|
3639
|
+
google_protobuf_Any_set_type_url(route_config_any, kRdsTypeUrlUpb);
|
3640
|
+
google_protobuf_Any_set_value(route_config_any,
|
3641
|
+
upb_strview_make(bytes, length));
|
3642
|
+
}
|
3643
|
+
if (meta->client_status == XdsApi::ResourceMetadata::NACKED) {
|
3644
|
+
// Set error_state if NACKED
|
3645
|
+
envoy_admin_v3_RoutesConfigDump_DynamicRouteConfig_set_error_state(
|
3646
|
+
dynamic_route_config, CreateUpdateFailureStateUpb(context, meta));
|
3647
|
+
}
|
3648
|
+
}
|
3649
|
+
}
|
3650
|
+
|
3651
|
+
void DumpCdsConfig(const EncodingContext& context,
|
3652
|
+
const XdsApi::ResourceTypeMetadata& resource_type_metadata,
|
3653
|
+
envoy_service_status_v3_PerXdsConfig* per_xds_config) {
|
3654
|
+
upb_strview kCdsTypeUrlUpb = upb_strview_makez(XdsApi::kCdsTypeUrl);
|
3655
|
+
auto* cluster_config_dump =
|
3656
|
+
envoy_service_status_v3_PerXdsConfig_mutable_cluster_config(
|
3657
|
+
per_xds_config, context.arena);
|
3658
|
+
envoy_admin_v3_ClustersConfigDump_set_version_info(
|
3659
|
+
cluster_config_dump,
|
3660
|
+
StdStringToUpbString(resource_type_metadata.version));
|
3661
|
+
for (auto& p : resource_type_metadata.resource_metadata_map) {
|
3662
|
+
absl::string_view name = p.first;
|
3663
|
+
const XdsApi::ResourceMetadata* meta = p.second;
|
3664
|
+
const upb_strview name_upb = StdStringToUpbString(name);
|
3665
|
+
auto* dynamic_cluster =
|
3666
|
+
envoy_admin_v3_ClustersConfigDump_add_dynamic_active_clusters(
|
3667
|
+
cluster_config_dump, context.arena);
|
3668
|
+
envoy_admin_v3_ClustersConfigDump_DynamicCluster_set_client_status(
|
3669
|
+
dynamic_cluster, meta->client_status);
|
3670
|
+
auto* cluster_any =
|
3671
|
+
envoy_admin_v3_ClustersConfigDump_DynamicCluster_mutable_cluster(
|
3672
|
+
dynamic_cluster, context.arena);
|
3673
|
+
if (!meta->serialized_proto.empty()) {
|
3674
|
+
// Set in-effective clusters
|
3675
|
+
envoy_admin_v3_ClustersConfigDump_DynamicCluster_set_version_info(
|
3676
|
+
dynamic_cluster, StdStringToUpbString(meta->version));
|
3677
|
+
envoy_admin_v3_ClustersConfigDump_DynamicCluster_set_last_updated(
|
3678
|
+
dynamic_cluster, GrpcMillisToTimestamp(context, meta->update_time));
|
3679
|
+
google_protobuf_Any_set_type_url(cluster_any, kCdsTypeUrlUpb);
|
3680
|
+
google_protobuf_Any_set_value(
|
3681
|
+
cluster_any, StdStringToUpbString(meta->serialized_proto));
|
3682
|
+
} else {
|
3683
|
+
// If there isn't a working cluster, we still need to print the name.
|
3684
|
+
auto* cluster = envoy_config_cluster_v3_Cluster_new(context.arena);
|
3685
|
+
envoy_config_cluster_v3_Cluster_set_name(cluster, name_upb);
|
3686
|
+
size_t length;
|
3687
|
+
char* bytes = envoy_config_cluster_v3_Cluster_serialize(
|
3688
|
+
cluster, context.arena, &length);
|
3689
|
+
google_protobuf_Any_set_type_url(cluster_any, kCdsTypeUrlUpb);
|
3690
|
+
google_protobuf_Any_set_value(cluster_any,
|
3691
|
+
upb_strview_make(bytes, length));
|
3692
|
+
}
|
3693
|
+
if (meta->client_status == XdsApi::ResourceMetadata::NACKED) {
|
3694
|
+
// Set error_state if NACKED
|
3695
|
+
envoy_admin_v3_ClustersConfigDump_DynamicCluster_set_error_state(
|
3696
|
+
dynamic_cluster, CreateUpdateFailureStateUpb(context, meta));
|
3697
|
+
}
|
3698
|
+
}
|
3699
|
+
}
|
3700
|
+
|
3701
|
+
void DumpEdsConfig(const EncodingContext& context,
|
3702
|
+
const XdsApi::ResourceTypeMetadata& resource_type_metadata,
|
3703
|
+
envoy_service_status_v3_PerXdsConfig* per_xds_config) {
|
3704
|
+
upb_strview kEdsTypeUrlUpb = upb_strview_makez(XdsApi::kEdsTypeUrl);
|
3705
|
+
auto* endpoint_config_dump =
|
3706
|
+
envoy_service_status_v3_PerXdsConfig_mutable_endpoint_config(
|
3707
|
+
per_xds_config, context.arena);
|
3708
|
+
for (auto& p : resource_type_metadata.resource_metadata_map) {
|
3709
|
+
absl::string_view name = p.first;
|
3710
|
+
const XdsApi::ResourceMetadata* meta = p.second;
|
3711
|
+
const upb_strview name_upb = StdStringToUpbString(name);
|
3712
|
+
auto* dynamic_endpoint =
|
3713
|
+
envoy_admin_v3_EndpointsConfigDump_add_dynamic_endpoint_configs(
|
3714
|
+
endpoint_config_dump, context.arena);
|
3715
|
+
envoy_admin_v3_EndpointsConfigDump_DynamicEndpointConfig_set_client_status(
|
3716
|
+
dynamic_endpoint, meta->client_status);
|
3717
|
+
auto* endpoint_any =
|
3718
|
+
envoy_admin_v3_EndpointsConfigDump_DynamicEndpointConfig_mutable_endpoint_config(
|
3719
|
+
dynamic_endpoint, context.arena);
|
3720
|
+
if (!meta->serialized_proto.empty()) {
|
3721
|
+
// Set in-effective endpoints
|
3722
|
+
envoy_admin_v3_EndpointsConfigDump_DynamicEndpointConfig_set_version_info(
|
3723
|
+
dynamic_endpoint, StdStringToUpbString(meta->version));
|
3724
|
+
envoy_admin_v3_EndpointsConfigDump_DynamicEndpointConfig_set_last_updated(
|
3725
|
+
dynamic_endpoint, GrpcMillisToTimestamp(context, meta->update_time));
|
3726
|
+
google_protobuf_Any_set_type_url(endpoint_any, kEdsTypeUrlUpb);
|
3727
|
+
google_protobuf_Any_set_value(
|
3728
|
+
endpoint_any, StdStringToUpbString(meta->serialized_proto));
|
3729
|
+
} else {
|
3730
|
+
// If there isn't a working endpoint, we still need to print the name.
|
3731
|
+
auto* cluster_load_assignment =
|
3732
|
+
envoy_config_endpoint_v3_ClusterLoadAssignment_new(context.arena);
|
3733
|
+
envoy_config_endpoint_v3_ClusterLoadAssignment_set_cluster_name(
|
3734
|
+
cluster_load_assignment, name_upb);
|
3735
|
+
size_t length;
|
3736
|
+
char* bytes = envoy_config_endpoint_v3_ClusterLoadAssignment_serialize(
|
3737
|
+
cluster_load_assignment, context.arena, &length);
|
3738
|
+
google_protobuf_Any_set_type_url(endpoint_any, kEdsTypeUrlUpb);
|
3739
|
+
google_protobuf_Any_set_value(endpoint_any,
|
3740
|
+
upb_strview_make(bytes, length));
|
3741
|
+
}
|
3742
|
+
if (meta->client_status == XdsApi::ResourceMetadata::NACKED) {
|
3743
|
+
// Set error_state if NACKED
|
3744
|
+
envoy_admin_v3_EndpointsConfigDump_DynamicEndpointConfig_set_error_state(
|
3745
|
+
dynamic_endpoint, CreateUpdateFailureStateUpb(context, meta));
|
3746
|
+
}
|
3747
|
+
}
|
3748
|
+
}
|
3749
|
+
|
3750
|
+
} // namespace
|
3751
|
+
|
3752
|
+
std::string XdsApi::AssembleClientConfig(
|
3753
|
+
const ResourceTypeMetadataMap& resource_type_metadata_map) {
|
3754
|
+
upb::Arena arena;
|
3755
|
+
// Create the ClientConfig for resource metadata from XdsClient
|
3756
|
+
auto* client_config = envoy_service_status_v3_ClientConfig_new(arena.ptr());
|
3757
|
+
// Fill-in the node information
|
3758
|
+
auto* node = envoy_service_status_v3_ClientConfig_mutable_node(client_config,
|
3759
|
+
arena.ptr());
|
3760
|
+
const EncodingContext context = {client_, tracer_, symtab_.ptr(), arena.ptr(),
|
3761
|
+
true};
|
3762
|
+
PopulateNode(context, node_, build_version_, user_agent_name_, node);
|
3763
|
+
// Dump each xDS-type config into PerXdsConfig
|
3764
|
+
for (auto& p : resource_type_metadata_map) {
|
3765
|
+
absl::string_view type_url = p.first;
|
3766
|
+
const ResourceTypeMetadata& resource_type_metadata = p.second;
|
3767
|
+
if (type_url == kLdsTypeUrl) {
|
3768
|
+
auto* per_xds_config =
|
3769
|
+
envoy_service_status_v3_ClientConfig_add_xds_config(client_config,
|
3770
|
+
context.arena);
|
3771
|
+
DumpLdsConfig(context, resource_type_metadata, per_xds_config);
|
3772
|
+
} else if (type_url == kRdsTypeUrl) {
|
3773
|
+
auto* per_xds_config =
|
3774
|
+
envoy_service_status_v3_ClientConfig_add_xds_config(client_config,
|
3775
|
+
context.arena);
|
3776
|
+
DumpRdsConfig(context, resource_type_metadata, per_xds_config);
|
3777
|
+
} else if (type_url == kCdsTypeUrl) {
|
3778
|
+
auto* per_xds_config =
|
3779
|
+
envoy_service_status_v3_ClientConfig_add_xds_config(client_config,
|
3780
|
+
context.arena);
|
3781
|
+
DumpCdsConfig(context, resource_type_metadata, per_xds_config);
|
3782
|
+
} else if (type_url == kEdsTypeUrl) {
|
3783
|
+
auto* per_xds_config =
|
3784
|
+
envoy_service_status_v3_ClientConfig_add_xds_config(client_config,
|
3785
|
+
context.arena);
|
3786
|
+
DumpEdsConfig(context, resource_type_metadata, per_xds_config);
|
3787
|
+
} else {
|
3788
|
+
gpr_log(GPR_ERROR, "invalid type_url %s", std::string(type_url).c_str());
|
3789
|
+
return "";
|
3790
|
+
}
|
3791
|
+
}
|
3792
|
+
// Serialize the upb message to bytes
|
3793
|
+
size_t output_length;
|
3794
|
+
char* output = envoy_service_status_v3_ClientConfig_serialize(
|
3795
|
+
client_config, arena.ptr(), &output_length);
|
3796
|
+
return std::string(output, output_length);
|
3797
|
+
}
|
3798
|
+
|
2308
3799
|
} // namespace grpc_core
|