grpc 1.26.0 → 1.27.0.pre1
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 +1654 -1519
- data/etc/roots.pem +44 -0
- data/include/grpc/grpc_security.h +37 -15
- data/include/grpc/grpc_security_constants.h +27 -0
- data/include/grpc/impl/codegen/grpc_types.h +14 -0
- data/include/grpc/impl/codegen/port_platform.h +1 -1
- data/src/core/ext/filters/client_channel/client_channel.cc +0 -20
- data/src/core/ext/filters/client_channel/http_proxy.cc +4 -4
- data/src/core/ext/filters/client_channel/lb_policy.cc +4 -3
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +191 -201
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +89 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +40 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +3 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +88 -121
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +28 -57
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +0 -7
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +8 -9
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +53 -34
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +18 -5
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +24 -19
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +2 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +4 -2
- data/src/core/ext/filters/client_channel/server_address.cc +6 -9
- data/src/core/ext/filters/client_channel/server_address.h +3 -10
- data/src/core/ext/filters/client_channel/xds/xds_api.cc +394 -150
- data/src/core/ext/filters/client_channel/xds/xds_api.h +75 -35
- data/src/core/ext/filters/client_channel/xds/xds_bootstrap.cc +59 -22
- data/src/core/ext/filters/client_channel/xds/xds_bootstrap.h +13 -9
- data/src/core/ext/filters/client_channel/xds/xds_channel_secure.cc +8 -6
- data/src/core/ext/filters/client_channel/xds/xds_client.cc +456 -175
- data/src/core/ext/filters/client_channel/xds/xds_client.h +33 -21
- data/src/core/ext/filters/client_channel/xds/xds_client_stats.cc +5 -8
- data/src/core/ext/filters/client_channel/xds/xds_client_stats.h +18 -24
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +2 -2
- data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c +13 -5
- data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h +34 -0
- data/src/core/lib/channel/channelz.h +11 -1
- data/src/core/lib/gpr/time_precise.cc +1 -1
- data/src/core/lib/gprpp/optional.h +26 -0
- data/src/core/lib/gprpp/string_view.h +14 -10
- data/src/core/lib/iomgr/executor.cc +1 -1
- data/src/core/lib/iomgr/fork_posix.cc +4 -0
- data/src/core/lib/iomgr/poller/eventmanager_libuv.cc +87 -0
- data/src/core/lib/iomgr/poller/eventmanager_libuv.h +88 -0
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +14 -0
- data/src/core/lib/iomgr/socket_utils_posix.h +12 -0
- data/src/core/lib/iomgr/tcp_custom.h +3 -0
- data/src/core/lib/iomgr/tcp_posix.cc +607 -56
- data/src/core/lib/iomgr/tcp_server_custom.cc +15 -2
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +8 -0
- data/src/core/lib/json/json.h +11 -1
- data/src/core/lib/json/json_reader.cc +206 -28
- data/src/core/lib/json/json_writer.cc +111 -24
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +7 -0
- data/src/core/lib/security/credentials/composite/composite_credentials.h +5 -1
- data/src/core/lib/security/credentials/credentials.h +10 -1
- data/src/core/lib/security/credentials/fake/fake_credentials.h +2 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -1
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +6 -4
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -1
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +20 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +8 -0
- data/src/core/lib/security/credentials/tls/{spiffe_credentials.cc → tls_credentials.cc} +23 -24
- data/src/core/lib/security/credentials/tls/{spiffe_credentials.h → tls_credentials.h} +9 -9
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +13 -0
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +22 -2
- data/src/core/lib/security/security_connector/load_system_roots_fallback.cc +2 -2
- data/src/core/lib/security/security_connector/load_system_roots_linux.cc +2 -2
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +30 -3
- data/src/core/lib/security/security_connector/ssl_utils.cc +45 -3
- data/src/core/lib/security/security_connector/ssl_utils.h +12 -0
- data/src/core/lib/security/security_connector/tls/{spiffe_security_connector.cc → tls_security_connector.cc} +82 -69
- data/src/core/lib/security/security_connector/tls/{spiffe_security_connector.h → tls_security_connector.h} +17 -18
- data/src/core/lib/security/transport/client_auth_filter.cc +33 -0
- data/src/core/lib/surface/completion_queue.cc +22 -1
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +11 -1
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +1 -1
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +3 -3
- data/src/core/tsi/fake_transport_security.cc +7 -3
- data/src/core/tsi/fake_transport_security.h +2 -0
- data/src/core/tsi/ssl_transport_security.cc +144 -8
- data/src/core/tsi/ssl_transport_security.h +15 -1
- data/src/core/tsi/transport_security.cc +13 -0
- data/src/core/tsi/transport_security_grpc.cc +2 -2
- data/src/core/tsi/transport_security_grpc.h +2 -2
- data/src/core/tsi/transport_security_interface.h +12 -0
- data/src/ruby/bin/math_pb.rb +5 -5
- data/src/ruby/ext/grpc/rb_call_credentials.c +4 -1
- 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/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/v1/health_pb.rb +3 -3
- data/src/ruby/pb/src/proto/grpc/testing/empty_pb.rb +1 -1
- data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +23 -13
- data/third_party/abseil-cpp/absl/algorithm/algorithm.h +159 -0
- data/third_party/abseil-cpp/absl/base/attributes.h +609 -0
- data/third_party/abseil-cpp/absl/base/call_once.h +226 -0
- data/third_party/abseil-cpp/absl/base/casts.h +184 -0
- data/third_party/abseil-cpp/absl/base/config.h +622 -0
- data/third_party/abseil-cpp/absl/base/const_init.h +76 -0
- data/third_party/abseil-cpp/absl/base/dynamic_annotations.cc +129 -0
- data/third_party/abseil-cpp/absl/base/dynamic_annotations.h +389 -0
- data/third_party/abseil-cpp/absl/base/internal/atomic_hook.h +179 -0
- data/third_party/abseil-cpp/absl/base/internal/bits.h +218 -0
- data/third_party/abseil-cpp/absl/base/internal/cycleclock.cc +107 -0
- data/third_party/abseil-cpp/absl/base/internal/cycleclock.h +94 -0
- data/third_party/abseil-cpp/absl/base/internal/endian.h +266 -0
- data/third_party/abseil-cpp/absl/base/internal/hide_ptr.h +51 -0
- data/third_party/abseil-cpp/absl/base/internal/identity.h +37 -0
- data/third_party/abseil-cpp/absl/base/internal/inline_variable.h +107 -0
- data/third_party/abseil-cpp/absl/base/internal/invoke.h +187 -0
- data/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h +107 -0
- data/third_party/abseil-cpp/absl/base/internal/per_thread_tls.h +52 -0
- data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +237 -0
- data/third_party/abseil-cpp/absl/base/internal/raw_logging.h +179 -0
- data/third_party/abseil-cpp/absl/base/internal/scheduling_mode.h +58 -0
- data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +233 -0
- data/third_party/abseil-cpp/absl/base/internal/spinlock.h +243 -0
- data/third_party/abseil-cpp/absl/base/internal/spinlock_akaros.inc +35 -0
- data/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc +67 -0
- data/third_party/abseil-cpp/absl/base/internal/spinlock_posix.inc +46 -0
- data/third_party/abseil-cpp/absl/base/internal/spinlock_wait.cc +81 -0
- data/third_party/abseil-cpp/absl/base/internal/spinlock_wait.h +93 -0
- data/third_party/abseil-cpp/absl/base/internal/spinlock_win32.inc +37 -0
- data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +414 -0
- data/third_party/abseil-cpp/absl/base/internal/sysinfo.h +66 -0
- data/third_party/abseil-cpp/absl/base/internal/thread_annotations.h +271 -0
- data/third_party/abseil-cpp/absl/base/internal/thread_identity.cc +140 -0
- data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +250 -0
- data/third_party/abseil-cpp/absl/base/internal/throw_delegate.cc +108 -0
- data/third_party/abseil-cpp/absl/base/internal/throw_delegate.h +75 -0
- data/third_party/abseil-cpp/absl/base/internal/tsan_mutex_interface.h +66 -0
- data/third_party/abseil-cpp/absl/base/internal/unaligned_access.h +158 -0
- data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +103 -0
- data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h +124 -0
- data/third_party/abseil-cpp/absl/base/log_severity.cc +27 -0
- data/third_party/abseil-cpp/absl/base/log_severity.h +121 -0
- data/third_party/abseil-cpp/absl/base/macros.h +220 -0
- data/third_party/abseil-cpp/absl/base/optimization.h +181 -0
- data/third_party/abseil-cpp/absl/base/options.h +214 -0
- data/third_party/abseil-cpp/absl/base/policy_checks.h +111 -0
- data/third_party/abseil-cpp/absl/base/port.h +26 -0
- data/third_party/abseil-cpp/absl/base/thread_annotations.h +280 -0
- data/third_party/abseil-cpp/absl/container/inlined_vector.h +848 -0
- data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +265 -0
- data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +892 -0
- data/third_party/abseil-cpp/absl/memory/memory.h +695 -0
- data/third_party/abseil-cpp/absl/meta/type_traits.h +759 -0
- data/third_party/abseil-cpp/absl/numeric/int128.cc +404 -0
- data/third_party/abseil-cpp/absl/numeric/int128.h +1091 -0
- data/third_party/abseil-cpp/absl/numeric/int128_have_intrinsic.inc +302 -0
- data/third_party/abseil-cpp/absl/numeric/int128_no_intrinsic.inc +308 -0
- data/third_party/abseil-cpp/absl/strings/ascii.cc +200 -0
- data/third_party/abseil-cpp/absl/strings/ascii.h +241 -0
- data/third_party/abseil-cpp/absl/strings/charconv.cc +985 -0
- data/third_party/abseil-cpp/absl/strings/charconv.h +119 -0
- data/third_party/abseil-cpp/absl/strings/escaping.cc +949 -0
- data/third_party/abseil-cpp/absl/strings/escaping.h +164 -0
- data/third_party/abseil-cpp/absl/strings/internal/char_map.h +156 -0
- data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc +359 -0
- data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.h +421 -0
- data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc +504 -0
- data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.h +99 -0
- data/third_party/abseil-cpp/absl/strings/internal/escaping.cc +180 -0
- data/third_party/abseil-cpp/absl/strings/internal/escaping.h +58 -0
- data/third_party/abseil-cpp/absl/strings/internal/memutil.cc +112 -0
- data/third_party/abseil-cpp/absl/strings/internal/memutil.h +148 -0
- data/third_party/abseil-cpp/absl/strings/internal/ostringstream.cc +36 -0
- data/third_party/abseil-cpp/absl/strings/internal/ostringstream.h +89 -0
- data/third_party/abseil-cpp/absl/strings/internal/resize_uninitialized.h +73 -0
- data/third_party/abseil-cpp/absl/strings/internal/stl_type_traits.h +248 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h +314 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +455 -0
- data/third_party/abseil-cpp/absl/strings/internal/utf8.cc +53 -0
- data/third_party/abseil-cpp/absl/strings/internal/utf8.h +50 -0
- data/third_party/abseil-cpp/absl/strings/match.cc +40 -0
- data/third_party/abseil-cpp/absl/strings/match.h +90 -0
- data/third_party/abseil-cpp/absl/strings/numbers.cc +916 -0
- data/third_party/abseil-cpp/absl/strings/numbers.h +263 -0
- data/third_party/abseil-cpp/absl/strings/str_cat.cc +246 -0
- data/third_party/abseil-cpp/absl/strings/str_cat.h +408 -0
- data/third_party/abseil-cpp/absl/strings/str_join.h +293 -0
- data/third_party/abseil-cpp/absl/strings/str_replace.cc +82 -0
- data/third_party/abseil-cpp/absl/strings/str_replace.h +219 -0
- data/third_party/abseil-cpp/absl/strings/str_split.cc +139 -0
- data/third_party/abseil-cpp/absl/strings/str_split.h +513 -0
- data/third_party/abseil-cpp/absl/strings/string_view.cc +235 -0
- data/third_party/abseil-cpp/absl/strings/string_view.h +615 -0
- data/third_party/abseil-cpp/absl/strings/strip.h +91 -0
- data/third_party/abseil-cpp/absl/strings/substitute.cc +171 -0
- data/third_party/abseil-cpp/absl/strings/substitute.h +693 -0
- data/third_party/abseil-cpp/absl/types/bad_optional_access.cc +48 -0
- data/third_party/abseil-cpp/absl/types/bad_optional_access.h +78 -0
- data/third_party/abseil-cpp/absl/types/internal/optional.h +396 -0
- data/third_party/abseil-cpp/absl/types/internal/span.h +128 -0
- data/third_party/abseil-cpp/absl/types/optional.h +776 -0
- data/third_party/abseil-cpp/absl/types/span.h +713 -0
- data/third_party/abseil-cpp/absl/utility/utility.h +350 -0
- data/third_party/upb/upb/decode.c +4 -0
- data/third_party/upb/upb/port.c +0 -1
- data/third_party/upb/upb/port_def.inc +1 -3
- data/third_party/upb/upb/table.c +2 -1
- metadata +147 -43
- data/src/core/lib/json/json_common.h +0 -34
- data/src/core/lib/json/json_reader.h +0 -146
- data/src/core/lib/json/json_string.cc +0 -367
- data/src/core/lib/json/json_writer.h +0 -84
data/etc/roots.pem
CHANGED
@@ -4598,3 +4598,47 @@ L5/ndtFhKvshuzHQqp9HpLIiyhY6UFfEW0NnxWViA0kB60PZ2Pierc+xYw5F9KBa
|
|
4598
4598
|
LJstxabArahH9CdMOA0uG0k7UvToiIMrVCjU8jVStDKDYmlkDJGcn5fqdBb9HxEG
|
4599
4599
|
mpv0
|
4600
4600
|
-----END CERTIFICATE-----
|
4601
|
+
|
4602
|
+
# Issuer: CN=Entrust Root Certification Authority - G4 O=Entrust, Inc. OU=See www.entrust.net/legal-terms/(c) 2015 Entrust, Inc. - for authorized use only
|
4603
|
+
# Subject: CN=Entrust Root Certification Authority - G4 O=Entrust, Inc. OU=See www.entrust.net/legal-terms/(c) 2015 Entrust, Inc. - for authorized use only
|
4604
|
+
# Label: "Entrust Root Certification Authority - G4"
|
4605
|
+
# Serial: 289383649854506086828220374796556676440
|
4606
|
+
# MD5 Fingerprint: 89:53:f1:83:23:b7:7c:8e:05:f1:8c:71:38:4e:1f:88
|
4607
|
+
# SHA1 Fingerprint: 14:88:4e:86:26:37:b0:26:af:59:62:5c:40:77:ec:35:29:ba:96:01
|
4608
|
+
# SHA256 Fingerprint: db:35:17:d1:f6:73:2a:2d:5a:b9:7c:53:3e:c7:07:79:ee:32:70:a6:2f:b4:ac:42:38:37:24:60:e6:f0:1e:88
|
4609
|
+
-----BEGIN CERTIFICATE-----
|
4610
|
+
MIIGSzCCBDOgAwIBAgIRANm1Q3+vqTkPAAAAAFVlrVgwDQYJKoZIhvcNAQELBQAw
|
4611
|
+
gb4xCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQL
|
4612
|
+
Ex9TZWUgd3d3LmVudHJ1c3QubmV0L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykg
|
4613
|
+
MjAxNSBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxMjAw
|
4614
|
+
BgNVBAMTKUVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEc0
|
4615
|
+
MB4XDTE1MDUyNzExMTExNloXDTM3MTIyNzExNDExNlowgb4xCzAJBgNVBAYTAlVT
|
4616
|
+
MRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1
|
4617
|
+
c3QubmV0L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxNSBFbnRydXN0LCBJ
|
4618
|
+
bmMuIC0gZm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxMjAwBgNVBAMTKUVudHJ1c3Qg
|
4619
|
+
Um9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEc0MIICIjANBgkqhkiG9w0B
|
4620
|
+
AQEFAAOCAg8AMIICCgKCAgEAsewsQu7i0TD/pZJH4i3DumSXbcr3DbVZwbPLqGgZ
|
4621
|
+
2K+EbTBwXX7zLtJTmeH+H17ZSK9dE43b/2MzTdMAArzE+NEGCJR5WIoV3imz/f3E
|
4622
|
+
T+iq4qA7ec2/a0My3dl0ELn39GjUu9CH1apLiipvKgS1sqbHoHrmSKvS0VnM1n4j
|
4623
|
+
5pds8ELl3FFLFUHtSUrJ3hCX1nbB76W1NhSXNdh4IjVS70O92yfbYVaCNNzLiGAM
|
4624
|
+
C1rlLAHGVK/XqsEQe9IFWrhAnoanw5CGAlZSCXqc0ieCU0plUmr1POeo8pyvi73T
|
4625
|
+
DtTUXm6Hnmo9RR3RXRv06QqsYJn7ibT/mCzPfB3pAqoEmh643IhuJbNsZvc8kPNX
|
4626
|
+
wbMv9W3y+8qh+CmdRouzavbmZwe+LGcKKh9asj5XxNMhIWNlUpEbsZmOeX7m640A
|
4627
|
+
2Vqq6nPopIICR5b+W45UYaPrL0swsIsjdXJ8ITzI9vF01Bx7owVV7rtNOzK+mndm
|
4628
|
+
nqxpkCIHH2E6lr7lmk/MBTwoWdPBDFSoWWG9yHJM6Nyfh3+9nEg2XpWjDrk4JFX8
|
4629
|
+
dWbrAuMINClKxuMrLzOg2qOGpRKX/YAr2hRC45K9PvJdXmd0LhyIRyk0X+IyqJwl
|
4630
|
+
N4y6mACXi0mWHv0liqzc2thddG5msP9E36EYxr5ILzeUePiVSj9/E15dWf10hkNj
|
4631
|
+
c0kCAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYD
|
4632
|
+
VR0OBBYEFJ84xFYjwznooHFs6FRM5Og6sb9nMA0GCSqGSIb3DQEBCwUAA4ICAQAS
|
4633
|
+
5UKme4sPDORGpbZgQIeMJX6tuGguW8ZAdjwD+MlZ9POrYs4QjbRaZIxowLByQzTS
|
4634
|
+
Gwv2LFPSypBLhmb8qoMi9IsabyZIrHZ3CL/FmFz0Jomee8O5ZDIBf9PD3Vht7LGr
|
4635
|
+
hFV0d4QEJ1JrhkzO3bll/9bGXp+aEJlLdWr+aumXIOTkdnrG0CSqkM0gkLpHZPt/
|
4636
|
+
B7NTeLUKYvJzQ85BK4FqLoUWlFPUa19yIqtRLULVAJyZv967lDtX/Zr1hstWO1uI
|
4637
|
+
AeV8KEsD+UmDfLJ/fOPtjqF/YFOOVZ1QNBIPt5d7bIdKROf1beyAN/BYGW5KaHbw
|
4638
|
+
H5Lk6rWS02FREAutp9lfx1/cH6NcjKF+m7ee01ZvZl4HliDtC3T7Zk6LERXpgUl+
|
4639
|
+
b7DUUH8i119lAg2m9IUe2K4GS0qn0jFmwvjO5QimpAKWRGhXxNUzzxkvFMSUHHuk
|
4640
|
+
2fCfDrGA4tGeEWSpiBE6doLlYsKA2KSD7ZPvfC+QsDJMlhVoSFLUmQjAJOgc47Ol
|
4641
|
+
IQ6SwJAfzyBfyjs4x7dtOvPmRLgOMWuIjnDrnBdSqEGULoe256YSxXXfW8AKbnuk
|
4642
|
+
5F6G+TaU33fD6Q3AOfF5u0aOq0NZJ7cguyPpVkAh7DE9ZapD8j3fcEThuk0mEDuY
|
4643
|
+
n/PIjhs4ViFqUZPTkcpG2om3PVODLAgfi49T3f+sHw==
|
4644
|
+
-----END CERTIFICATE-----
|
@@ -132,7 +132,8 @@ GRPCAPI void grpc_channel_credentials_release(grpc_channel_credentials* creds);
|
|
132
132
|
|
133
133
|
/** Creates default credentials to connect to a google gRPC service.
|
134
134
|
WARNING: Do NOT use this credentials to connect to a non-google service as
|
135
|
-
this could result in an oauth2 token leak.
|
135
|
+
this could result in an oauth2 token leak. The security level of the
|
136
|
+
resulting connection is GRPC_PRIVACY_AND_INTEGRITY. */
|
136
137
|
GRPCAPI grpc_channel_credentials* grpc_google_default_credentials_create(void);
|
137
138
|
|
138
139
|
/** Callback for getting the SSL roots override from the application.
|
@@ -208,6 +209,7 @@ typedef struct {
|
|
208
209
|
/** Deprecated in favor of grpc_ssl_server_credentials_create_ex. It will be
|
209
210
|
removed after all of its call sites are migrated to
|
210
211
|
grpc_ssl_server_credentials_create_ex. Creates an SSL credentials object.
|
212
|
+
The security level of the resulting connection is GRPC_PRIVACY_AND_INTEGRITY.
|
211
213
|
- pem_root_certs is the NULL-terminated string containing the PEM encoding
|
212
214
|
of the server root certificates. If this parameter is NULL, the
|
213
215
|
implementation will first try to dereference the file pointed by the
|
@@ -239,6 +241,7 @@ GRPCAPI grpc_channel_credentials* grpc_ssl_credentials_create(
|
|
239
241
|
const verify_peer_options* verify_options, void* reserved);
|
240
242
|
|
241
243
|
/* Creates an SSL credentials object.
|
244
|
+
The security level of the resulting connection is GRPC_PRIVACY_AND_INTEGRITY.
|
242
245
|
- pem_root_certs is the NULL-terminated string containing the PEM encoding
|
243
246
|
of the server root certificates. If this parameter is NULL, the
|
244
247
|
implementation will first try to dereference the file pointed by the
|
@@ -281,7 +284,8 @@ typedef struct grpc_call_credentials grpc_call_credentials;
|
|
281
284
|
The creator of the credentials object is responsible for its release. */
|
282
285
|
GRPCAPI void grpc_call_credentials_release(grpc_call_credentials* creds);
|
283
286
|
|
284
|
-
/** Creates a composite channel credentials object.
|
287
|
+
/** Creates a composite channel credentials object. The security level of
|
288
|
+
* resulting connection is determined by channel_creds. */
|
285
289
|
GRPCAPI grpc_channel_credentials* grpc_composite_channel_credentials_create(
|
286
290
|
grpc_channel_credentials* channel_creds, grpc_call_credentials* call_creds,
|
287
291
|
void* reserved);
|
@@ -431,9 +435,11 @@ typedef struct {
|
|
431
435
|
const char* type;
|
432
436
|
} grpc_metadata_credentials_plugin;
|
433
437
|
|
434
|
-
/** Creates a credentials object from a plugin
|
438
|
+
/** Creates a credentials object from a plugin with a specified minimum security
|
439
|
+
* level. */
|
435
440
|
GRPCAPI grpc_call_credentials* grpc_metadata_credentials_create_from_plugin(
|
436
|
-
grpc_metadata_credentials_plugin plugin,
|
441
|
+
grpc_metadata_credentials_plugin plugin,
|
442
|
+
grpc_security_level min_security_level, void* reserved);
|
437
443
|
|
438
444
|
/** --- Secure channel creation. --- */
|
439
445
|
|
@@ -653,8 +659,9 @@ GRPCAPI void grpc_alts_credentials_options_destroy(
|
|
653
659
|
grpc_alts_credentials_options* options);
|
654
660
|
|
655
661
|
/**
|
656
|
-
* This method creates an ALTS channel credential object.
|
657
|
-
*
|
662
|
+
* This method creates an ALTS channel credential object. The security
|
663
|
+
* level of the resulting connection is GRPC_PRIVACY_AND_INTEGRITY.
|
664
|
+
* It is used for experimental purpose for now and subject to change.
|
658
665
|
*
|
659
666
|
* - options: grpc ALTS credentials options instance for client.
|
660
667
|
*
|
@@ -677,8 +684,10 @@ GRPCAPI grpc_server_credentials* grpc_alts_server_credentials_create(
|
|
677
684
|
/** --- Local channel/server credentials --- **/
|
678
685
|
|
679
686
|
/**
|
680
|
-
* This method creates a local channel credential object.
|
681
|
-
*
|
687
|
+
* This method creates a local channel credential object. The security level
|
688
|
+
* of the resulting connection is GRPC_PRIVACY_AND_INTEGRITY for UDS and
|
689
|
+
* GRPC_SECURITY_NONE for LOCAL_TCP. It is used for experimental purpose
|
690
|
+
* for now and subject to change.
|
682
691
|
*
|
683
692
|
* - type: local connection type
|
684
693
|
*
|
@@ -698,7 +707,7 @@ GRPCAPI grpc_channel_credentials* grpc_local_credentials_create(
|
|
698
707
|
GRPCAPI grpc_server_credentials* grpc_local_server_credentials_create(
|
699
708
|
grpc_local_connect_type type);
|
700
709
|
|
701
|
-
/** ---
|
710
|
+
/** --- TLS channel/server credentials ---
|
702
711
|
* It is used for experimental purpose for now and subject to change. */
|
703
712
|
|
704
713
|
/** Config for TLS key materials. It is used for
|
@@ -731,6 +740,19 @@ GRPCAPI int grpc_tls_credentials_options_set_cert_request_type(
|
|
731
740
|
grpc_tls_credentials_options* options,
|
732
741
|
grpc_ssl_client_certificate_request_type type);
|
733
742
|
|
743
|
+
/** Set grpc_tls_server_verification_option field in credentials options
|
744
|
+
with the provided server_verification_option. options should not be NULL.
|
745
|
+
This should be called only on the client side.
|
746
|
+
If grpc_tls_server_verification_option is not
|
747
|
+
GRPC_TLS_SERVER_VERIFICATION, use of a customer server
|
748
|
+
authorization check (grpc_tls_server_authorization_check_config)
|
749
|
+
will be mandatory.
|
750
|
+
It returns 1 on success and 0 on failure. It is used for
|
751
|
+
experimental purpose for now and subject to change. */
|
752
|
+
GRPCAPI int grpc_tls_credentials_options_set_server_verification_option(
|
753
|
+
grpc_tls_credentials_options* options,
|
754
|
+
grpc_tls_server_verification_option server_verification_option);
|
755
|
+
|
734
756
|
/** Set grpc_tls_key_materials_config field in credentials options
|
735
757
|
with the provided config struct whose ownership is transferred.
|
736
758
|
Both parameters should not be NULL.
|
@@ -902,6 +924,7 @@ struct grpc_tls_server_authorization_check_arg {
|
|
902
924
|
int success;
|
903
925
|
const char* target_name;
|
904
926
|
const char* peer_cert;
|
927
|
+
const char* peer_cert_full_chain;
|
905
928
|
grpc_status_code status;
|
906
929
|
const char* error_details;
|
907
930
|
grpc_tls_server_authorization_check_config* config;
|
@@ -938,11 +961,10 @@ grpc_tls_server_authorization_check_config_create(
|
|
938
961
|
grpc_tls_server_authorization_check_arg* arg),
|
939
962
|
void (*destruct)(void* config_user_data));
|
940
963
|
|
941
|
-
/** --- SPIFFE channel/server credentials --- **/
|
942
|
-
|
943
964
|
/**
|
944
|
-
* This method creates a TLS
|
945
|
-
* It takes ownership of the options parameter.
|
965
|
+
* This method creates a TLS channel credential object.
|
966
|
+
* It takes ownership of the options parameter. The security level
|
967
|
+
* of the resulting connection is GRPC_PRIVACY_AND_INTEGRITY.
|
946
968
|
*
|
947
969
|
* - options: grpc TLS credentials options instance.
|
948
970
|
*
|
@@ -952,7 +974,7 @@ grpc_tls_server_authorization_check_config_create(
|
|
952
974
|
* to change.
|
953
975
|
*/
|
954
976
|
|
955
|
-
grpc_channel_credentials*
|
977
|
+
grpc_channel_credentials* grpc_tls_credentials_create(
|
956
978
|
grpc_tls_credentials_options* options);
|
957
979
|
|
958
980
|
/**
|
@@ -966,7 +988,7 @@ grpc_channel_credentials* grpc_tls_spiffe_credentials_create(
|
|
966
988
|
* It is used for experimental purpose for now and subject
|
967
989
|
* to change.
|
968
990
|
*/
|
969
|
-
grpc_server_credentials*
|
991
|
+
grpc_server_credentials* grpc_tls_server_credentials_create(
|
970
992
|
grpc_tls_credentials_options* options);
|
971
993
|
|
972
994
|
#ifdef __cplusplus
|
@@ -29,7 +29,9 @@ extern "C" {
|
|
29
29
|
#define GRPC_X509_CN_PROPERTY_NAME "x509_common_name"
|
30
30
|
#define GRPC_X509_SAN_PROPERTY_NAME "x509_subject_alternative_name"
|
31
31
|
#define GRPC_X509_PEM_CERT_PROPERTY_NAME "x509_pem_cert"
|
32
|
+
#define GRPC_X509_PEM_CERT_CHAIN_PROPERTY_NAME "x509_pem_cert_chain"
|
32
33
|
#define GRPC_SSL_SESSION_REUSED_PROPERTY "ssl_session_reused"
|
34
|
+
#define GRPC_TRANSPORT_SECURITY_LEVEL_PROPERTY_NAME "security_level"
|
33
35
|
|
34
36
|
/** Environment variable that points to the default SSL roots file. This file
|
35
37
|
must be a PEM encoded file with all the roots such as the one that can be
|
@@ -105,6 +107,31 @@ typedef enum {
|
|
105
107
|
GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY
|
106
108
|
} grpc_ssl_client_certificate_request_type;
|
107
109
|
|
110
|
+
/* Security levels of grpc transport security. It represents an inherent
|
111
|
+
* property of a backend connection and is determined by a channel credential
|
112
|
+
* used to create the connection. */
|
113
|
+
typedef enum {
|
114
|
+
GRPC_SECURITY_MIN,
|
115
|
+
GRPC_SECURITY_NONE = GRPC_SECURITY_MIN,
|
116
|
+
GRPC_INTEGRITY_ONLY,
|
117
|
+
GRPC_PRIVACY_AND_INTEGRITY,
|
118
|
+
GRPC_SECURITY_MAX = GRPC_PRIVACY_AND_INTEGRITY,
|
119
|
+
} grpc_security_level;
|
120
|
+
|
121
|
+
typedef enum {
|
122
|
+
/** Default option: performs server certificate verification and hostname
|
123
|
+
verification. */
|
124
|
+
GRPC_TLS_SERVER_VERIFICATION,
|
125
|
+
/** Performs server certificate verification, but skips hostname verification
|
126
|
+
Client is responsible for verifying server's identity via
|
127
|
+
server authorization check callback. */
|
128
|
+
GRPC_TLS_SKIP_HOSTNAME_VERIFICATION,
|
129
|
+
/** Skips both server certificate and hostname verification.
|
130
|
+
Client is responsible for verifying server's identity and
|
131
|
+
server's certificate via server authorization check callback. */
|
132
|
+
GRPC_TLS_SKIP_ALL_SERVER_VERIFICATION
|
133
|
+
} grpc_tls_server_verification_option;
|
134
|
+
|
108
135
|
/**
|
109
136
|
* Type of local connections for which local channel/server credentials will be
|
110
137
|
* applied. It supports UDS and local TCP connections.
|
@@ -323,6 +323,20 @@ typedef struct {
|
|
323
323
|
"grpc.experimental.tcp_min_read_chunk_size"
|
324
324
|
#define GRPC_ARG_TCP_MAX_READ_CHUNK_SIZE \
|
325
325
|
"grpc.experimental.tcp_max_read_chunk_size"
|
326
|
+
/* TCP TX Zerocopy enable state: zero is disabled, non-zero is enabled. By
|
327
|
+
default, it is disabled. */
|
328
|
+
#define GRPC_ARG_TCP_TX_ZEROCOPY_ENABLED \
|
329
|
+
"grpc.experimental.tcp_tx_zerocopy_enabled"
|
330
|
+
/* TCP TX Zerocopy send threshold: only zerocopy if >= this many bytes sent. By
|
331
|
+
default, this is set to 16KB. */
|
332
|
+
#define GRPC_ARG_TCP_TX_ZEROCOPY_SEND_BYTES_THRESHOLD \
|
333
|
+
"grpc.experimental.tcp_tx_zerocopy_send_bytes_threshold"
|
334
|
+
/* TCP TX Zerocopy max simultaneous sends: limit for maximum number of pending
|
335
|
+
calls to tcp_write() using zerocopy. A tcp_write() is considered pending
|
336
|
+
until the kernel performs the zerocopy-done callback for all sendmsg() calls
|
337
|
+
issued by the tcp_write(). By default, this is set to 4. */
|
338
|
+
#define GRPC_ARG_TCP_TX_ZEROCOPY_MAX_SIMULT_SENDS \
|
339
|
+
"grpc.experimental.tcp_tx_zerocopy_max_simultaneous_sends"
|
326
340
|
/* Timeout in milliseconds to use for calls to the grpclb load balancer.
|
327
341
|
If 0 or unset, the balancer calls will have no deadline. */
|
328
342
|
#define GRPC_ARG_GRPCLB_CALL_TIMEOUT_MS "grpc.grpclb_call_timeout_ms"
|
@@ -1638,26 +1638,6 @@ void ChannelData::ProcessLbPolicy(
|
|
1638
1638
|
grpc_channel_args_find(resolver_result.args, GRPC_ARG_LB_POLICY_NAME);
|
1639
1639
|
local_policy_name = grpc_channel_arg_get_string(channel_arg);
|
1640
1640
|
}
|
1641
|
-
// Special case: If at least one balancer address is present, we use
|
1642
|
-
// the grpclb policy, regardless of what the resolver has returned.
|
1643
|
-
bool found_balancer_address = false;
|
1644
|
-
for (size_t i = 0; i < resolver_result.addresses.size(); ++i) {
|
1645
|
-
const ServerAddress& address = resolver_result.addresses[i];
|
1646
|
-
if (address.IsBalancer()) {
|
1647
|
-
found_balancer_address = true;
|
1648
|
-
break;
|
1649
|
-
}
|
1650
|
-
}
|
1651
|
-
if (found_balancer_address) {
|
1652
|
-
if (local_policy_name != nullptr &&
|
1653
|
-
strcmp(local_policy_name, "grpclb") != 0) {
|
1654
|
-
gpr_log(GPR_INFO,
|
1655
|
-
"resolver requested LB policy %s but provided at least one "
|
1656
|
-
"balancer address -- forcing use of grpclb LB policy",
|
1657
|
-
local_policy_name);
|
1658
|
-
}
|
1659
|
-
local_policy_name = "grpclb";
|
1660
|
-
}
|
1661
1641
|
// Use pick_first if nothing was specified and we didn't select grpclb
|
1662
1642
|
// above.
|
1663
1643
|
lb_policy_name->reset(gpr_strdup(
|
@@ -187,10 +187,10 @@ class HttpProxyMapper : public ProxyMapperInterface {
|
|
187
187
|
return false;
|
188
188
|
}
|
189
189
|
|
190
|
-
bool MapAddress(const grpc_resolved_address& address
|
191
|
-
const grpc_channel_args* args
|
192
|
-
grpc_resolved_address** new_address
|
193
|
-
grpc_channel_args** new_args) override {
|
190
|
+
bool MapAddress(const grpc_resolved_address& /*address*/,
|
191
|
+
const grpc_channel_args* /*args*/,
|
192
|
+
grpc_resolved_address** /*new_address*/,
|
193
|
+
grpc_channel_args** /*new_args*/) override {
|
194
194
|
return false;
|
195
195
|
}
|
196
196
|
};
|
@@ -44,7 +44,7 @@ LoadBalancingPolicy::~LoadBalancingPolicy() {
|
|
44
44
|
|
45
45
|
void LoadBalancingPolicy::Orphan() {
|
46
46
|
ShutdownLocked();
|
47
|
-
Unref();
|
47
|
+
Unref(DEBUG_LOCATION, "Orphan");
|
48
48
|
}
|
49
49
|
|
50
50
|
//
|
@@ -104,7 +104,8 @@ LoadBalancingPolicy::PickResult LoadBalancingPolicy::QueuePicker::Pick(
|
|
104
104
|
// ExitIdleLocked().
|
105
105
|
if (!exit_idle_called_) {
|
106
106
|
exit_idle_called_ = true;
|
107
|
-
|
107
|
+
// Ref held by closure.
|
108
|
+
parent_->Ref(DEBUG_LOCATION, "QueuePicker::CallExitIdle").release();
|
108
109
|
parent_->combiner()->Run(
|
109
110
|
GRPC_CLOSURE_CREATE(&CallExitIdle, parent_.get(), nullptr),
|
110
111
|
GRPC_ERROR_NONE);
|
@@ -118,7 +119,7 @@ void LoadBalancingPolicy::QueuePicker::CallExitIdle(void* arg,
|
|
118
119
|
grpc_error* /*error*/) {
|
119
120
|
LoadBalancingPolicy* parent = static_cast<LoadBalancingPolicy*>(arg);
|
120
121
|
parent->ExitIdleLocked();
|
121
|
-
parent->Unref();
|
122
|
+
parent->Unref(DEBUG_LOCATION, "QueuePicker::CallExitIdle");
|
122
123
|
}
|
123
124
|
|
124
125
|
//
|
@@ -73,6 +73,7 @@
|
|
73
73
|
#include "src/core/ext/filters/client_channel/client_channel.h"
|
74
74
|
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h"
|
75
75
|
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h"
|
76
|
+
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h"
|
76
77
|
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h"
|
77
78
|
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h"
|
78
79
|
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h"
|
@@ -172,8 +173,6 @@ class GrpcLb : public LoadBalancingPolicy {
|
|
172
173
|
void ScheduleNextClientLoadReportLocked();
|
173
174
|
void SendClientLoadReportLocked();
|
174
175
|
|
175
|
-
static bool LoadReportCountersAreZero(grpc_grpclb_request* request);
|
176
|
-
|
177
176
|
static void MaybeSendClientLoadReport(void* arg, grpc_error* error);
|
178
177
|
static void ClientLoadReportDone(void* arg, grpc_error* error);
|
179
178
|
static void OnInitialRequestSent(void* arg, grpc_error* error);
|
@@ -227,14 +226,12 @@ class GrpcLb : public LoadBalancingPolicy {
|
|
227
226
|
class Serverlist : public RefCounted<Serverlist> {
|
228
227
|
public:
|
229
228
|
// Takes ownership of serverlist.
|
230
|
-
explicit Serverlist(
|
231
|
-
: serverlist_(serverlist) {}
|
232
|
-
|
233
|
-
~Serverlist() { grpc_grpclb_destroy_serverlist(serverlist_); }
|
229
|
+
explicit Serverlist(std::vector<GrpcLbServer> serverlist)
|
230
|
+
: serverlist_(std::move(serverlist)) {}
|
234
231
|
|
235
232
|
bool operator==(const Serverlist& other) const;
|
236
233
|
|
237
|
-
const
|
234
|
+
const std::vector<GrpcLbServer>& serverlist() const { return serverlist_; }
|
238
235
|
|
239
236
|
// Returns a text representation suitable for logging.
|
240
237
|
grpc_core::UniquePtr<char> AsText() const;
|
@@ -257,7 +254,7 @@ class GrpcLb : public LoadBalancingPolicy {
|
|
257
254
|
const char* ShouldDrop();
|
258
255
|
|
259
256
|
private:
|
260
|
-
|
257
|
+
std::vector<GrpcLbServer> serverlist_;
|
261
258
|
|
262
259
|
// Guarded by the channel's data plane combiner, NOT the control
|
263
260
|
// plane combiner. It should not be accessed by anything but the
|
@@ -404,28 +401,26 @@ class GrpcLb : public LoadBalancingPolicy {
|
|
404
401
|
//
|
405
402
|
|
406
403
|
bool GrpcLb::Serverlist::operator==(const Serverlist& other) const {
|
407
|
-
return
|
404
|
+
return serverlist_ == other.serverlist_;
|
408
405
|
}
|
409
406
|
|
410
|
-
void ParseServer(const
|
411
|
-
grpc_resolved_address* addr) {
|
407
|
+
void ParseServer(const GrpcLbServer& server, grpc_resolved_address* addr) {
|
412
408
|
memset(addr, 0, sizeof(*addr));
|
413
|
-
if (server
|
414
|
-
const uint16_t netorder_port = grpc_htons((uint16_t)server
|
409
|
+
if (server.drop) return;
|
410
|
+
const uint16_t netorder_port = grpc_htons((uint16_t)server.port);
|
415
411
|
/* the addresses are given in binary format (a in(6)_addr struct) in
|
416
412
|
* server->ip_address.bytes. */
|
417
|
-
|
418
|
-
if (ip.size == 4) {
|
413
|
+
if (server.ip_size == 4) {
|
419
414
|
addr->len = static_cast<socklen_t>(sizeof(grpc_sockaddr_in));
|
420
415
|
grpc_sockaddr_in* addr4 = reinterpret_cast<grpc_sockaddr_in*>(&addr->addr);
|
421
416
|
addr4->sin_family = GRPC_AF_INET;
|
422
|
-
memcpy(&addr4->sin_addr,
|
417
|
+
memcpy(&addr4->sin_addr, server.ip_addr, server.ip_size);
|
423
418
|
addr4->sin_port = netorder_port;
|
424
|
-
} else if (
|
419
|
+
} else if (server.ip_size == 16) {
|
425
420
|
addr->len = static_cast<socklen_t>(sizeof(grpc_sockaddr_in6));
|
426
421
|
grpc_sockaddr_in6* addr6 = (grpc_sockaddr_in6*)&addr->addr;
|
427
422
|
addr6->sin6_family = GRPC_AF_INET6;
|
428
|
-
memcpy(&addr6->sin6_addr,
|
423
|
+
memcpy(&addr6->sin6_addr, server.ip_addr, server.ip_size);
|
429
424
|
addr6->sin6_port = netorder_port;
|
430
425
|
}
|
431
426
|
}
|
@@ -433,10 +428,10 @@ void ParseServer(const grpc_grpclb_server* server,
|
|
433
428
|
grpc_core::UniquePtr<char> GrpcLb::Serverlist::AsText() const {
|
434
429
|
gpr_strvec entries;
|
435
430
|
gpr_strvec_init(&entries);
|
436
|
-
for (size_t i = 0; i < serverlist_
|
437
|
-
const
|
431
|
+
for (size_t i = 0; i < serverlist_.size(); ++i) {
|
432
|
+
const GrpcLbServer& server = serverlist_[i];
|
438
433
|
char* ipport;
|
439
|
-
if (server
|
434
|
+
if (server.drop) {
|
440
435
|
ipport = gpr_strdup("(drop)");
|
441
436
|
} else {
|
442
437
|
grpc_resolved_address addr;
|
@@ -445,7 +440,7 @@ grpc_core::UniquePtr<char> GrpcLb::Serverlist::AsText() const {
|
|
445
440
|
}
|
446
441
|
char* entry;
|
447
442
|
gpr_asprintf(&entry, " %" PRIuPTR ": %s token=%s\n", i, ipport,
|
448
|
-
server
|
443
|
+
server.load_balance_token);
|
449
444
|
gpr_free(ipport);
|
450
445
|
gpr_strvec_add(&entries, entry);
|
451
446
|
}
|
@@ -492,23 +487,22 @@ const grpc_arg_pointer_vtable lb_token_arg_vtable = {
|
|
492
487
|
const grpc_arg_pointer_vtable client_stats_arg_vtable = {
|
493
488
|
client_stats_copy, client_stats_destroy, equal_cmp};
|
494
489
|
|
495
|
-
bool IsServerValid(const
|
496
|
-
if (server
|
497
|
-
|
498
|
-
if (GPR_UNLIKELY(server->port >> 16 != 0)) {
|
490
|
+
bool IsServerValid(const GrpcLbServer& server, size_t idx, bool log) {
|
491
|
+
if (server.drop) return false;
|
492
|
+
if (GPR_UNLIKELY(server.port >> 16 != 0)) {
|
499
493
|
if (log) {
|
500
494
|
gpr_log(GPR_ERROR,
|
501
495
|
"Invalid port '%d' at index %lu of serverlist. Ignoring.",
|
502
|
-
server
|
496
|
+
server.port, (unsigned long)idx);
|
503
497
|
}
|
504
498
|
return false;
|
505
499
|
}
|
506
|
-
if (GPR_UNLIKELY(
|
500
|
+
if (GPR_UNLIKELY(server.ip_size != 4 && server.ip_size != 16)) {
|
507
501
|
if (log) {
|
508
502
|
gpr_log(GPR_ERROR,
|
509
503
|
"Expected IP to be 4 or 16 bytes, got %d at index %lu of "
|
510
504
|
"serverlist. Ignoring",
|
511
|
-
|
505
|
+
server.ip_size, (unsigned long)idx);
|
512
506
|
}
|
513
507
|
return false;
|
514
508
|
}
|
@@ -519,20 +513,20 @@ bool IsServerValid(const grpc_grpclb_server* server, size_t idx, bool log) {
|
|
519
513
|
ServerAddressList GrpcLb::Serverlist::GetServerAddressList(
|
520
514
|
GrpcLbClientStats* client_stats) const {
|
521
515
|
ServerAddressList addresses;
|
522
|
-
for (size_t i = 0; i < serverlist_
|
523
|
-
const
|
524
|
-
if (!IsServerValid(
|
516
|
+
for (size_t i = 0; i < serverlist_.size(); ++i) {
|
517
|
+
const GrpcLbServer& server = serverlist_[i];
|
518
|
+
if (!IsServerValid(server, i, false)) continue;
|
525
519
|
// Address processing.
|
526
520
|
grpc_resolved_address addr;
|
527
521
|
ParseServer(server, &addr);
|
528
522
|
// LB token processing.
|
529
|
-
char lb_token[GPR_ARRAY_SIZE(server
|
530
|
-
if (server
|
523
|
+
char lb_token[GPR_ARRAY_SIZE(server.load_balance_token) + 1];
|
524
|
+
if (server.load_balance_token[0] != 0) {
|
531
525
|
const size_t lb_token_max_length =
|
532
|
-
GPR_ARRAY_SIZE(server
|
526
|
+
GPR_ARRAY_SIZE(server.load_balance_token);
|
533
527
|
const size_t lb_token_length =
|
534
|
-
strnlen(server
|
535
|
-
memcpy(lb_token, server
|
528
|
+
strnlen(server.load_balance_token, lb_token_max_length);
|
529
|
+
memcpy(lb_token, server.load_balance_token, lb_token_length);
|
536
530
|
lb_token[lb_token_length] = '\0';
|
537
531
|
} else {
|
538
532
|
char* uri = grpc_sockaddr_to_uri(&addr);
|
@@ -561,18 +555,18 @@ ServerAddressList GrpcLb::Serverlist::GetServerAddressList(
|
|
561
555
|
}
|
562
556
|
|
563
557
|
bool GrpcLb::Serverlist::ContainsAllDropEntries() const {
|
564
|
-
if (serverlist_
|
565
|
-
for (
|
566
|
-
if (!
|
558
|
+
if (serverlist_.empty()) return false;
|
559
|
+
for (const GrpcLbServer& server : serverlist_) {
|
560
|
+
if (!server.drop) return false;
|
567
561
|
}
|
568
562
|
return true;
|
569
563
|
}
|
570
564
|
|
571
565
|
const char* GrpcLb::Serverlist::ShouldDrop() {
|
572
|
-
if (serverlist_
|
573
|
-
|
574
|
-
drop_index_ = (drop_index_ + 1) % serverlist_
|
575
|
-
return server
|
566
|
+
if (serverlist_.empty()) return nullptr;
|
567
|
+
GrpcLbServer& server = serverlist_[drop_index_];
|
568
|
+
drop_index_ = (drop_index_ + 1) % serverlist_.size();
|
569
|
+
return server.drop ? server.load_balance_token : nullptr;
|
576
570
|
}
|
577
571
|
|
578
572
|
//
|
@@ -782,10 +776,8 @@ GrpcLb::BalancerCallState::BalancerCallState(
|
|
782
776
|
nullptr, deadline, nullptr);
|
783
777
|
// Init the LB call request payload.
|
784
778
|
upb::Arena arena;
|
785
|
-
grpc_grpclb_request* request =
|
786
|
-
grpc_grpclb_request_create(grpclb_policy()->server_name_, arena.ptr());
|
787
779
|
grpc_slice request_payload_slice =
|
788
|
-
|
780
|
+
GrpcLbRequestCreate(grpclb_policy()->server_name_, arena.ptr());
|
789
781
|
send_message_payload_ =
|
790
782
|
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
|
791
783
|
grpc_slice_unref_internal(request_payload_slice);
|
@@ -936,33 +928,24 @@ void GrpcLb::BalancerCallState::MaybeSendClientLoadReportLocked(
|
|
936
928
|
}
|
937
929
|
}
|
938
930
|
|
939
|
-
bool GrpcLb::BalancerCallState::LoadReportCountersAreZero(
|
940
|
-
grpc_grpclb_request* request) {
|
941
|
-
const grpc_lb_v1_ClientStats* cstats =
|
942
|
-
grpc_lb_v1_LoadBalanceRequest_client_stats(request);
|
943
|
-
if (cstats == nullptr) {
|
944
|
-
return true;
|
945
|
-
}
|
946
|
-
size_t drop_count;
|
947
|
-
grpc_lb_v1_ClientStats_calls_finished_with_drop(cstats, &drop_count);
|
948
|
-
return grpc_lb_v1_ClientStats_num_calls_started(cstats) == 0 &&
|
949
|
-
grpc_lb_v1_ClientStats_num_calls_finished(cstats) == 0 &&
|
950
|
-
grpc_lb_v1_ClientStats_num_calls_finished_with_client_failed_to_send(
|
951
|
-
cstats) == 0 &&
|
952
|
-
grpc_lb_v1_ClientStats_num_calls_finished_known_received(cstats) ==
|
953
|
-
0 &&
|
954
|
-
drop_count == 0;
|
955
|
-
}
|
956
|
-
|
957
931
|
void GrpcLb::BalancerCallState::SendClientLoadReportLocked() {
|
958
932
|
// Construct message payload.
|
959
933
|
GPR_ASSERT(send_message_payload_ == nullptr);
|
960
|
-
|
961
|
-
|
962
|
-
|
934
|
+
// Get snapshot of stats.
|
935
|
+
int64_t num_calls_started;
|
936
|
+
int64_t num_calls_finished;
|
937
|
+
int64_t num_calls_finished_with_client_failed_to_send;
|
938
|
+
int64_t num_calls_finished_known_received;
|
939
|
+
std::unique_ptr<GrpcLbClientStats::DroppedCallCounts> drop_token_counts;
|
940
|
+
client_stats_->Get(&num_calls_started, &num_calls_finished,
|
941
|
+
&num_calls_finished_with_client_failed_to_send,
|
942
|
+
&num_calls_finished_known_received, &drop_token_counts);
|
963
943
|
// Skip client load report if the counters were all zero in the last
|
964
944
|
// report and they are still zero in this one.
|
965
|
-
if (
|
945
|
+
if (num_calls_started == 0 && num_calls_finished == 0 &&
|
946
|
+
num_calls_finished_with_client_failed_to_send == 0 &&
|
947
|
+
num_calls_finished_known_received == 0 &&
|
948
|
+
(drop_token_counts == nullptr || drop_token_counts->size() == 0)) {
|
966
949
|
if (last_client_load_report_counters_were_zero_) {
|
967
950
|
ScheduleNextClientLoadReportLocked();
|
968
951
|
return;
|
@@ -971,8 +954,12 @@ void GrpcLb::BalancerCallState::SendClientLoadReportLocked() {
|
|
971
954
|
} else {
|
972
955
|
last_client_load_report_counters_were_zero_ = false;
|
973
956
|
}
|
974
|
-
|
975
|
-
|
957
|
+
// Populate load report.
|
958
|
+
upb::Arena arena;
|
959
|
+
grpc_slice request_payload_slice = GrpcLbLoadReportRequestCreate(
|
960
|
+
num_calls_started, num_calls_finished,
|
961
|
+
num_calls_finished_with_client_failed_to_send,
|
962
|
+
num_calls_finished_known_received, drop_token_counts.get(), arena.ptr());
|
976
963
|
send_message_payload_ =
|
977
964
|
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
|
978
965
|
grpc_slice_unref_internal(request_payload_slice);
|
@@ -1064,107 +1051,10 @@ void GrpcLb::BalancerCallState::OnBalancerMessageReceivedLocked(
|
|
1064
1051
|
grpc_byte_buffer_reader_destroy(&bbr);
|
1065
1052
|
grpc_byte_buffer_destroy(lb_calld->recv_message_payload_);
|
1066
1053
|
lb_calld->recv_message_payload_ = nullptr;
|
1067
|
-
|
1068
|
-
grpc_grpclb_serverlist* serverlist;
|
1054
|
+
GrpcLbResponse response;
|
1069
1055
|
upb::Arena arena;
|
1070
|
-
if (!
|
1071
|
-
(
|
1072
|
-
response_slice, arena.ptr())) != nullptr) {
|
1073
|
-
// Have NOT seen initial response, look for initial response.
|
1074
|
-
const google_protobuf_Duration* client_stats_report_interval =
|
1075
|
-
grpc_lb_v1_InitialLoadBalanceResponse_client_stats_report_interval(
|
1076
|
-
initial_response);
|
1077
|
-
if (client_stats_report_interval != nullptr) {
|
1078
|
-
lb_calld->client_stats_report_interval_ =
|
1079
|
-
GPR_MAX(GPR_MS_PER_SEC,
|
1080
|
-
grpc_grpclb_duration_to_millis(client_stats_report_interval));
|
1081
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) {
|
1082
|
-
gpr_log(GPR_INFO,
|
1083
|
-
"[grpclb %p] lb_calld=%p: Received initial LB response "
|
1084
|
-
"message; client load reporting interval = %" PRId64
|
1085
|
-
" milliseconds",
|
1086
|
-
grpclb_policy, lb_calld,
|
1087
|
-
lb_calld->client_stats_report_interval_);
|
1088
|
-
}
|
1089
|
-
} else if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) {
|
1090
|
-
gpr_log(GPR_INFO,
|
1091
|
-
"[grpclb %p] lb_calld=%p: Received initial LB response message; "
|
1092
|
-
"client load reporting NOT enabled",
|
1093
|
-
grpclb_policy, lb_calld);
|
1094
|
-
}
|
1095
|
-
lb_calld->seen_initial_response_ = true;
|
1096
|
-
} else if ((serverlist = grpc_grpclb_response_parse_serverlist(
|
1097
|
-
response_slice)) != nullptr) {
|
1098
|
-
// Have seen initial response, look for serverlist.
|
1099
|
-
GPR_ASSERT(lb_calld->lb_call_ != nullptr);
|
1100
|
-
auto serverlist_wrapper = MakeRefCounted<Serverlist>(serverlist);
|
1101
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) {
|
1102
|
-
grpc_core::UniquePtr<char> serverlist_text = serverlist_wrapper->AsText();
|
1103
|
-
gpr_log(GPR_INFO,
|
1104
|
-
"[grpclb %p] lb_calld=%p: Serverlist with %" PRIuPTR
|
1105
|
-
" servers received:\n%s",
|
1106
|
-
grpclb_policy, lb_calld, serverlist->num_servers,
|
1107
|
-
serverlist_text.get());
|
1108
|
-
}
|
1109
|
-
lb_calld->seen_serverlist_ = true;
|
1110
|
-
// Start sending client load report only after we start using the
|
1111
|
-
// serverlist returned from the current LB call.
|
1112
|
-
if (lb_calld->client_stats_report_interval_ > 0 &&
|
1113
|
-
lb_calld->client_stats_ == nullptr) {
|
1114
|
-
lb_calld->client_stats_ = MakeRefCounted<GrpcLbClientStats>();
|
1115
|
-
// Ref held by callback.
|
1116
|
-
lb_calld->Ref(DEBUG_LOCATION, "client_load_report").release();
|
1117
|
-
lb_calld->ScheduleNextClientLoadReportLocked();
|
1118
|
-
}
|
1119
|
-
// Check if the serverlist differs from the previous one.
|
1120
|
-
if (grpclb_policy->serverlist_ != nullptr &&
|
1121
|
-
*grpclb_policy->serverlist_ == *serverlist_wrapper) {
|
1122
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) {
|
1123
|
-
gpr_log(GPR_INFO,
|
1124
|
-
"[grpclb %p] lb_calld=%p: Incoming server list identical to "
|
1125
|
-
"current, ignoring.",
|
1126
|
-
grpclb_policy, lb_calld);
|
1127
|
-
}
|
1128
|
-
} else { // New serverlist.
|
1129
|
-
// Dispose of the fallback.
|
1130
|
-
// TODO(roth): Ideally, we should stay in fallback mode until we
|
1131
|
-
// know that we can reach at least one of the backends in the new
|
1132
|
-
// serverlist. Unfortunately, we can't do that, since we need to
|
1133
|
-
// send the new addresses to the child policy in order to determine
|
1134
|
-
// if they are reachable, and if we don't exit fallback mode now,
|
1135
|
-
// CreateOrUpdateChildPolicyLocked() will use the fallback
|
1136
|
-
// addresses instead of the addresses from the new serverlist.
|
1137
|
-
// However, if we can't reach any of the servers in the new
|
1138
|
-
// serverlist, then the child policy will never switch away from
|
1139
|
-
// the fallback addresses, but the grpclb policy will still think
|
1140
|
-
// that we're not in fallback mode, which means that we won't send
|
1141
|
-
// updates to the child policy when the fallback addresses are
|
1142
|
-
// updated by the resolver. This is sub-optimal, but the only way
|
1143
|
-
// to fix it is to maintain a completely separate child policy for
|
1144
|
-
// fallback mode, and that's more work than we want to put into
|
1145
|
-
// the grpclb implementation at this point, since we're deprecating
|
1146
|
-
// it in favor of the xds policy. We will implement this the
|
1147
|
-
// right way in the xds policy instead.
|
1148
|
-
if (grpclb_policy->fallback_mode_) {
|
1149
|
-
gpr_log(GPR_INFO,
|
1150
|
-
"[grpclb %p] Received response from balancer; exiting "
|
1151
|
-
"fallback mode",
|
1152
|
-
grpclb_policy);
|
1153
|
-
grpclb_policy->fallback_mode_ = false;
|
1154
|
-
}
|
1155
|
-
if (grpclb_policy->fallback_at_startup_checks_pending_) {
|
1156
|
-
grpclb_policy->fallback_at_startup_checks_pending_ = false;
|
1157
|
-
grpc_timer_cancel(&grpclb_policy->lb_fallback_timer_);
|
1158
|
-
grpclb_policy->CancelBalancerChannelConnectivityWatchLocked();
|
1159
|
-
}
|
1160
|
-
// Update the serverlist in the GrpcLb instance. This serverlist
|
1161
|
-
// instance will be destroyed either upon the next update or when the
|
1162
|
-
// GrpcLb instance is destroyed.
|
1163
|
-
grpclb_policy->serverlist_ = std::move(serverlist_wrapper);
|
1164
|
-
grpclb_policy->CreateOrUpdateChildPolicyLocked();
|
1165
|
-
}
|
1166
|
-
} else {
|
1167
|
-
// No valid initial response or serverlist found.
|
1056
|
+
if (!GrpcLbResponseParse(response_slice, arena.ptr(), &response) ||
|
1057
|
+
(response.type == response.INITIAL && lb_calld->seen_initial_response_)) {
|
1168
1058
|
char* response_slice_str =
|
1169
1059
|
grpc_dump_slice(response_slice, GPR_DUMP_ASCII | GPR_DUMP_HEX);
|
1170
1060
|
gpr_log(GPR_ERROR,
|
@@ -1172,6 +1062,122 @@ void GrpcLb::BalancerCallState::OnBalancerMessageReceivedLocked(
|
|
1172
1062
|
"Ignoring.",
|
1173
1063
|
grpclb_policy, lb_calld, response_slice_str);
|
1174
1064
|
gpr_free(response_slice_str);
|
1065
|
+
} else {
|
1066
|
+
switch (response.type) {
|
1067
|
+
case response.INITIAL: {
|
1068
|
+
if (response.client_stats_report_interval != 0) {
|
1069
|
+
lb_calld->client_stats_report_interval_ =
|
1070
|
+
GPR_MAX(GPR_MS_PER_SEC, response.client_stats_report_interval);
|
1071
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) {
|
1072
|
+
gpr_log(GPR_INFO,
|
1073
|
+
"[grpclb %p] lb_calld=%p: Received initial LB response "
|
1074
|
+
"message; client load reporting interval = %" PRId64
|
1075
|
+
" milliseconds",
|
1076
|
+
grpclb_policy, lb_calld,
|
1077
|
+
lb_calld->client_stats_report_interval_);
|
1078
|
+
}
|
1079
|
+
} else if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) {
|
1080
|
+
gpr_log(GPR_INFO,
|
1081
|
+
"[grpclb %p] lb_calld=%p: Received initial LB response "
|
1082
|
+
"message; client load reporting NOT enabled",
|
1083
|
+
grpclb_policy, lb_calld);
|
1084
|
+
}
|
1085
|
+
lb_calld->seen_initial_response_ = true;
|
1086
|
+
break;
|
1087
|
+
}
|
1088
|
+
case response.SERVERLIST: {
|
1089
|
+
GPR_ASSERT(lb_calld->lb_call_ != nullptr);
|
1090
|
+
auto serverlist_wrapper =
|
1091
|
+
MakeRefCounted<Serverlist>(std::move(response.serverlist));
|
1092
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) {
|
1093
|
+
grpc_core::UniquePtr<char> serverlist_text =
|
1094
|
+
serverlist_wrapper->AsText();
|
1095
|
+
gpr_log(GPR_INFO,
|
1096
|
+
"[grpclb %p] lb_calld=%p: Serverlist with %" PRIuPTR
|
1097
|
+
" servers received:\n%s",
|
1098
|
+
grpclb_policy, lb_calld,
|
1099
|
+
serverlist_wrapper->serverlist().size(),
|
1100
|
+
serverlist_text.get());
|
1101
|
+
}
|
1102
|
+
lb_calld->seen_serverlist_ = true;
|
1103
|
+
// Start sending client load report only after we start using the
|
1104
|
+
// serverlist returned from the current LB call.
|
1105
|
+
if (lb_calld->client_stats_report_interval_ > 0 &&
|
1106
|
+
lb_calld->client_stats_ == nullptr) {
|
1107
|
+
lb_calld->client_stats_ = MakeRefCounted<GrpcLbClientStats>();
|
1108
|
+
// Ref held by callback.
|
1109
|
+
lb_calld->Ref(DEBUG_LOCATION, "client_load_report").release();
|
1110
|
+
lb_calld->ScheduleNextClientLoadReportLocked();
|
1111
|
+
}
|
1112
|
+
// Check if the serverlist differs from the previous one.
|
1113
|
+
if (grpclb_policy->serverlist_ != nullptr &&
|
1114
|
+
*grpclb_policy->serverlist_ == *serverlist_wrapper) {
|
1115
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) {
|
1116
|
+
gpr_log(GPR_INFO,
|
1117
|
+
"[grpclb %p] lb_calld=%p: Incoming server list identical "
|
1118
|
+
"to current, ignoring.",
|
1119
|
+
grpclb_policy, lb_calld);
|
1120
|
+
}
|
1121
|
+
} else { // New serverlist.
|
1122
|
+
// Dispose of the fallback.
|
1123
|
+
// TODO(roth): Ideally, we should stay in fallback mode until we
|
1124
|
+
// know that we can reach at least one of the backends in the new
|
1125
|
+
// serverlist. Unfortunately, we can't do that, since we need to
|
1126
|
+
// send the new addresses to the child policy in order to determine
|
1127
|
+
// if they are reachable, and if we don't exit fallback mode now,
|
1128
|
+
// CreateOrUpdateChildPolicyLocked() will use the fallback
|
1129
|
+
// addresses instead of the addresses from the new serverlist.
|
1130
|
+
// However, if we can't reach any of the servers in the new
|
1131
|
+
// serverlist, then the child policy will never switch away from
|
1132
|
+
// the fallback addresses, but the grpclb policy will still think
|
1133
|
+
// that we're not in fallback mode, which means that we won't send
|
1134
|
+
// updates to the child policy when the fallback addresses are
|
1135
|
+
// updated by the resolver. This is sub-optimal, but the only way
|
1136
|
+
// to fix it is to maintain a completely separate child policy for
|
1137
|
+
// fallback mode, and that's more work than we want to put into
|
1138
|
+
// the grpclb implementation at this point, since we're deprecating
|
1139
|
+
// it in favor of the xds policy. We will implement this the
|
1140
|
+
// right way in the xds policy instead.
|
1141
|
+
if (grpclb_policy->fallback_mode_) {
|
1142
|
+
gpr_log(GPR_INFO,
|
1143
|
+
"[grpclb %p] Received response from balancer; exiting "
|
1144
|
+
"fallback mode",
|
1145
|
+
grpclb_policy);
|
1146
|
+
grpclb_policy->fallback_mode_ = false;
|
1147
|
+
}
|
1148
|
+
if (grpclb_policy->fallback_at_startup_checks_pending_) {
|
1149
|
+
grpclb_policy->fallback_at_startup_checks_pending_ = false;
|
1150
|
+
grpc_timer_cancel(&grpclb_policy->lb_fallback_timer_);
|
1151
|
+
grpclb_policy->CancelBalancerChannelConnectivityWatchLocked();
|
1152
|
+
}
|
1153
|
+
// Update the serverlist in the GrpcLb instance. This serverlist
|
1154
|
+
// instance will be destroyed either upon the next update or when the
|
1155
|
+
// GrpcLb instance is destroyed.
|
1156
|
+
grpclb_policy->serverlist_ = std::move(serverlist_wrapper);
|
1157
|
+
grpclb_policy->CreateOrUpdateChildPolicyLocked();
|
1158
|
+
}
|
1159
|
+
break;
|
1160
|
+
}
|
1161
|
+
case response.FALLBACK: {
|
1162
|
+
if (!grpclb_policy->fallback_mode_) {
|
1163
|
+
gpr_log(GPR_INFO,
|
1164
|
+
"[grpclb %p] Entering fallback mode as requested by balancer",
|
1165
|
+
grpclb_policy);
|
1166
|
+
if (grpclb_policy->fallback_at_startup_checks_pending_) {
|
1167
|
+
grpclb_policy->fallback_at_startup_checks_pending_ = false;
|
1168
|
+
grpc_timer_cancel(&grpclb_policy->lb_fallback_timer_);
|
1169
|
+
grpclb_policy->CancelBalancerChannelConnectivityWatchLocked();
|
1170
|
+
}
|
1171
|
+
grpclb_policy->fallback_mode_ = true;
|
1172
|
+
grpclb_policy->CreateOrUpdateChildPolicyLocked();
|
1173
|
+
// Reset serverlist, so that if the balancer exits fallback
|
1174
|
+
// mode by sending the same serverlist we were previously
|
1175
|
+
// using, we don't incorrectly ignore it as a duplicate.
|
1176
|
+
grpclb_policy->serverlist_.reset();
|
1177
|
+
}
|
1178
|
+
break;
|
1179
|
+
}
|
1180
|
+
}
|
1175
1181
|
}
|
1176
1182
|
grpc_slice_unref_internal(response_slice);
|
1177
1183
|
if (!grpclb_policy->shutting_down_) {
|
@@ -1262,25 +1268,11 @@ void GrpcLb::BalancerCallState::OnBalancerStatusReceivedLocked(
|
|
1262
1268
|
// helper code for creating balancer channel
|
1263
1269
|
//
|
1264
1270
|
|
1265
|
-
ServerAddressList ExtractBalancerAddresses(const
|
1266
|
-
ServerAddressList
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
// recursively use the grpclb policy in the channel used to talk to
|
1271
|
-
// the balancers. Note that we do NOT strip out the balancer_name
|
1272
|
-
// channel arg, since we need that to set the authority correctly
|
1273
|
-
// to talk to the balancers.
|
1274
|
-
static const char* args_to_remove[] = {
|
1275
|
-
GRPC_ARG_ADDRESS_IS_BALANCER,
|
1276
|
-
};
|
1277
|
-
balancer_addresses.emplace_back(
|
1278
|
-
addresses[i].address(),
|
1279
|
-
grpc_channel_args_copy_and_remove(addresses[i].args(), args_to_remove,
|
1280
|
-
GPR_ARRAY_SIZE(args_to_remove)));
|
1281
|
-
}
|
1282
|
-
}
|
1283
|
-
return balancer_addresses;
|
1271
|
+
ServerAddressList ExtractBalancerAddresses(const grpc_channel_args& args) {
|
1272
|
+
const ServerAddressList* addresses =
|
1273
|
+
FindGrpclbBalancerAddressesInChannelArgs(args);
|
1274
|
+
if (addresses != nullptr) return *addresses;
|
1275
|
+
return ServerAddressList();
|
1284
1276
|
}
|
1285
1277
|
|
1286
1278
|
/* Returns the channel args for the LB channel, used to create a bidirectional
|
@@ -1486,27 +1478,25 @@ void GrpcLb::UpdateLocked(UpdateArgs args) {
|
|
1486
1478
|
// helpers for UpdateLocked()
|
1487
1479
|
//
|
1488
1480
|
|
1489
|
-
|
1490
|
-
|
1481
|
+
ServerAddressList AddNullLbTokenToAddresses(
|
1482
|
+
const ServerAddressList& addresses) {
|
1491
1483
|
static const char* lb_token = "";
|
1492
1484
|
grpc_arg arg = grpc_channel_arg_pointer_create(
|
1493
1485
|
const_cast<char*>(GRPC_ARG_GRPCLB_ADDRESS_LB_TOKEN),
|
1494
1486
|
const_cast<char*>(lb_token), &lb_token_arg_vtable);
|
1495
|
-
ServerAddressList
|
1487
|
+
ServerAddressList addresses_out;
|
1496
1488
|
for (size_t i = 0; i < addresses.size(); ++i) {
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
grpc_channel_args_copy_and_add(addresses[i].args(), &arg, 1));
|
1501
|
-
}
|
1489
|
+
addresses_out.emplace_back(
|
1490
|
+
addresses[i].address(),
|
1491
|
+
grpc_channel_args_copy_and_add(addresses[i].args(), &arg, 1));
|
1502
1492
|
}
|
1503
|
-
return
|
1493
|
+
return addresses_out;
|
1504
1494
|
}
|
1505
1495
|
|
1506
1496
|
void GrpcLb::ProcessAddressesAndChannelArgsLocked(
|
1507
1497
|
const ServerAddressList& addresses, const grpc_channel_args& args) {
|
1508
1498
|
// Update fallback address list.
|
1509
|
-
fallback_backend_addresses_ =
|
1499
|
+
fallback_backend_addresses_ = AddNullLbTokenToAddresses(addresses);
|
1510
1500
|
// Make sure that GRPC_ARG_LB_POLICY_NAME is set in channel args,
|
1511
1501
|
// since we use this to trigger the client_load_reporting filter.
|
1512
1502
|
static const char* args_to_remove[] = {GRPC_ARG_LB_POLICY_NAME};
|
@@ -1516,7 +1506,7 @@ void GrpcLb::ProcessAddressesAndChannelArgsLocked(
|
|
1516
1506
|
args_ = grpc_channel_args_copy_and_add_and_remove(
|
1517
1507
|
&args, args_to_remove, GPR_ARRAY_SIZE(args_to_remove), &new_arg, 1);
|
1518
1508
|
// Construct args for balancer channel.
|
1519
|
-
ServerAddressList balancer_addresses = ExtractBalancerAddresses(
|
1509
|
+
ServerAddressList balancer_addresses = ExtractBalancerAddresses(args);
|
1520
1510
|
grpc_channel_args* lb_channel_args = BuildBalancerChannelArgs(
|
1521
1511
|
balancer_addresses, response_generator_.get(), &args);
|
1522
1512
|
// Create balancer channel if needed.
|