grpc 1.36.0 → 1.37.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 +65 -37
- data/include/grpc/grpc.h +15 -1
- data/include/grpc/impl/codegen/port_platform.h +2 -0
- data/src/core/ext/filters/client_channel/client_channel.cc +327 -305
- data/src/core/ext/filters/client_channel/client_channel_factory.h +2 -1
- data/src/core/ext/filters/client_channel/config_selector.h +8 -0
- data/src/core/ext/filters/client_channel/dynamic_filters.cc +9 -4
- 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/lb_policy.cc +3 -0
- 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/xds/xds_cluster_impl.cc +7 -22
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +2 -2
- 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 +3 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +3 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +5 -9
- data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +18 -3
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +295 -91
- data/src/core/ext/filters/client_channel/server_address.cc +3 -0
- data/src/core/ext/filters/client_channel/subchannel.cc +69 -146
- data/src/core/ext/filters/client_channel/subchannel.h +63 -95
- 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 +1 -1
- data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +495 -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/workarounds/workaround_cronet_compression_filter.cc +1 -1
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +1 -1
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +3 -2
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +1 -1
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +3 -2
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +457 -170
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +39 -7
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +12 -1
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +5 -1
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/internal.h +1 -0
- 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/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/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/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_components.upb.c +15 -0
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +44 -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 +6 -5
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +13 -9
- 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/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/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/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/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/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/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_components.upbdefs.c +13 -7
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.h +5 -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 +21 -20
- 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/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/xds/xds_api.cc +1591 -279
- data/src/core/ext/xds/xds_api.h +279 -39
- data/src/core/ext/xds/xds_bootstrap.cc +21 -5
- data/src/core/ext/xds/xds_bootstrap.h +5 -1
- data/src/core/ext/xds/xds_client.cc +168 -23
- data/src/core/ext/xds/xds_client.h +26 -0
- data/src/core/ext/xds/xds_client_stats.h +2 -2
- 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 +391 -126
- data/src/core/lib/channel/channel_stack.cc +12 -0
- data/src/core/lib/channel/channel_stack.h +7 -0
- data/src/core/lib/channel/channelz.cc +92 -4
- data/src/core/lib/channel/channelz.h +30 -1
- data/src/core/lib/channel/channelz_registry.cc +14 -0
- data/src/core/lib/channel/handshaker.cc +0 -39
- data/src/core/lib/channel/handshaker.h +0 -17
- data/src/core/lib/channel/status_util.cc +12 -2
- data/src/core/lib/channel/status_util.h +5 -0
- 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/ref_counted_ptr.h +2 -0
- data/src/core/lib/gprpp/thd.h +1 -1
- data/src/core/lib/iomgr/buffer_list.h +1 -1
- data/src/core/lib/iomgr/cfstream_handle.cc +2 -2
- data/src/core/lib/iomgr/error.h +1 -1
- data/src/core/lib/iomgr/ev_apple.cc +1 -1
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +3 -3
- data/src/core/lib/iomgr/ev_posix.cc +3 -3
- data/src/core/lib/iomgr/exec_ctx.cc +6 -2
- data/src/core/lib/iomgr/resource_quota.cc +1 -1
- data/src/core/lib/iomgr/sockaddr_utils.cc +120 -0
- data/src/core/lib/iomgr/sockaddr_utils.h +25 -0
- data/src/core/lib/iomgr/tcp_posix.cc +1 -4
- data/src/core/lib/iomgr/tcp_uv.cc +2 -2
- data/src/core/lib/iomgr/timer_generic.cc +2 -2
- data/src/core/lib/iomgr/timer_manager.cc +1 -1
- data/src/core/lib/iomgr/wakeup_fd_nospecial.cc +1 -1
- data/src/core/lib/{security/authorization → matchers}/matchers.cc +8 -8
- data/src/core/lib/{security/authorization → matchers}/matchers.h +14 -12
- data/src/core/lib/security/security_connector/ssl_utils.cc +6 -4
- data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +6 -0
- data/src/core/lib/security/transport/security_handshaker.cc +32 -2
- data/src/core/lib/slice/slice_intern.cc +6 -7
- data/src/core/lib/surface/channel.h +3 -3
- data/src/core/lib/surface/completion_queue.cc +1 -1
- data/src/core/lib/surface/lame_client.cc +38 -19
- data/src/core/lib/surface/lame_client.h +4 -3
- data/src/core/lib/surface/server.cc +40 -33
- data/src/core/lib/surface/server.h +74 -15
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/lib/transport/metadata_batch.cc +27 -0
- data/src/core/lib/transport/metadata_batch.h +14 -0
- data/src/core/plugin_registry/grpc_plugin_registry.cc +6 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +1 -4
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +1 -1
- data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +1 -3
- data/src/core/tsi/fake_transport_security.cc +10 -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/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/boringssl-with-bazel/err_data.c +255 -255
- 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/fipsmodule/cipher/cipher.c +21 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +7 -5
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +0 -28
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_attrib.c +22 -17
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +3 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +4 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/cpu.h +22 -32
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +25 -9
- data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +0 -1
- data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +33 -19
- data/third_party/xxhash/xxhash.h +5443 -0
- metadata +93 -49
- 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 -99
- 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/container/flat_hash_set.h +0 -504
- 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
@@ -81,6 +81,18 @@ grpc_channel_element* grpc_channel_stack_last_element(
|
|
81
81
|
return grpc_channel_stack_element(channel_stack, channel_stack->count - 1);
|
82
82
|
}
|
83
83
|
|
84
|
+
size_t grpc_channel_stack_filter_instance_number(
|
85
|
+
grpc_channel_stack* channel_stack, grpc_channel_element* elem) {
|
86
|
+
size_t num_found = 0;
|
87
|
+
for (size_t i = 0; i < channel_stack->count; ++i) {
|
88
|
+
grpc_channel_element* element =
|
89
|
+
grpc_channel_stack_element(channel_stack, i);
|
90
|
+
if (element == elem) break;
|
91
|
+
if (element->filter == elem->filter) ++num_found;
|
92
|
+
}
|
93
|
+
return num_found;
|
94
|
+
}
|
95
|
+
|
84
96
|
grpc_call_element* grpc_call_stack_element(grpc_call_stack* call_stack,
|
85
97
|
size_t index) {
|
86
98
|
return CALL_ELEMS_FROM_STACK(call_stack) + index;
|
@@ -204,6 +204,13 @@ grpc_channel_element* grpc_channel_stack_element(grpc_channel_stack* stack,
|
|
204
204
|
/* Get the last channel element in a channel stack */
|
205
205
|
grpc_channel_element* grpc_channel_stack_last_element(
|
206
206
|
grpc_channel_stack* stack);
|
207
|
+
|
208
|
+
// A utility function for a filter to determine how many other instances
|
209
|
+
// of the same filter exist above it in the same stack. Intended to be
|
210
|
+
// used in the filter's init_channel_elem() method.
|
211
|
+
size_t grpc_channel_stack_filter_instance_number(
|
212
|
+
grpc_channel_stack* channel_stack, grpc_channel_element* elem);
|
213
|
+
|
207
214
|
/* Get a call stack element given a call stack and an index */
|
208
215
|
grpc_call_element* grpc_call_stack_element(grpc_call_stack* stack, size_t i);
|
209
216
|
|
@@ -19,7 +19,10 @@
|
|
19
19
|
#include <grpc/impl/codegen/port_platform.h>
|
20
20
|
|
21
21
|
#include "src/core/lib/channel/channelz.h"
|
22
|
+
#include "src/core/lib/iomgr/resolve_address.h"
|
23
|
+
#include "src/core/lib/iomgr/sockaddr_utils.h"
|
22
24
|
|
25
|
+
#include "absl/strings/escaping.h"
|
23
26
|
#include "absl/strings/strip.h"
|
24
27
|
|
25
28
|
#include <grpc/grpc.h>
|
@@ -336,6 +339,83 @@ Json ServerNode::RenderJson() {
|
|
336
339
|
return object;
|
337
340
|
}
|
338
341
|
|
342
|
+
//
|
343
|
+
// SocketNode::Security::Tls
|
344
|
+
//
|
345
|
+
|
346
|
+
Json SocketNode::Security::Tls::RenderJson() {
|
347
|
+
Json::Object data;
|
348
|
+
if (type == NameType::kStandardName) {
|
349
|
+
data["standard_name"] = name;
|
350
|
+
} else if (type == NameType::kOtherName) {
|
351
|
+
data["other_name"] = name;
|
352
|
+
}
|
353
|
+
if (!local_certificate.empty()) {
|
354
|
+
data["local_certificate"] = absl::Base64Escape(local_certificate);
|
355
|
+
}
|
356
|
+
if (!remote_certificate.empty()) {
|
357
|
+
data["remote_certificate"] = absl::Base64Escape(remote_certificate);
|
358
|
+
}
|
359
|
+
return data;
|
360
|
+
}
|
361
|
+
|
362
|
+
//
|
363
|
+
// SocketNode::Security
|
364
|
+
//
|
365
|
+
|
366
|
+
Json SocketNode::Security::RenderJson() {
|
367
|
+
Json::Object data;
|
368
|
+
switch (type) {
|
369
|
+
case ModelType::kUnset:
|
370
|
+
break;
|
371
|
+
case ModelType::kTls:
|
372
|
+
if (tls) {
|
373
|
+
data["tls"] = tls->RenderJson();
|
374
|
+
}
|
375
|
+
break;
|
376
|
+
case ModelType::kOther:
|
377
|
+
if (other) {
|
378
|
+
data["other"] = *other;
|
379
|
+
}
|
380
|
+
break;
|
381
|
+
}
|
382
|
+
return data;
|
383
|
+
}
|
384
|
+
|
385
|
+
namespace {
|
386
|
+
|
387
|
+
void* SecurityArgCopy(void* p) {
|
388
|
+
SocketNode::Security* xds_certificate_provider =
|
389
|
+
static_cast<SocketNode::Security*>(p);
|
390
|
+
return xds_certificate_provider->Ref().release();
|
391
|
+
}
|
392
|
+
|
393
|
+
void SecurityArgDestroy(void* p) {
|
394
|
+
SocketNode::Security* xds_certificate_provider =
|
395
|
+
static_cast<SocketNode::Security*>(p);
|
396
|
+
xds_certificate_provider->Unref();
|
397
|
+
}
|
398
|
+
|
399
|
+
int SecurityArgCmp(void* p, void* q) { return GPR_ICMP(p, q); }
|
400
|
+
|
401
|
+
const grpc_arg_pointer_vtable kChannelArgVtable = {
|
402
|
+
SecurityArgCopy, SecurityArgDestroy, SecurityArgCmp};
|
403
|
+
|
404
|
+
} // namespace
|
405
|
+
|
406
|
+
grpc_arg SocketNode::Security::MakeChannelArg() const {
|
407
|
+
return grpc_channel_arg_pointer_create(
|
408
|
+
const_cast<char*>(GRPC_ARG_CHANNELZ_SECURITY),
|
409
|
+
const_cast<SocketNode::Security*>(this), &kChannelArgVtable);
|
410
|
+
}
|
411
|
+
|
412
|
+
RefCountedPtr<SocketNode::Security> SocketNode::Security::GetFromChannelArgs(
|
413
|
+
const grpc_channel_args* args) {
|
414
|
+
Security* security = grpc_channel_args_find_pointer<Security>(
|
415
|
+
args, GRPC_ARG_CHANNELZ_SECURITY);
|
416
|
+
return security != nullptr ? security->Ref() : nullptr;
|
417
|
+
}
|
418
|
+
|
339
419
|
//
|
340
420
|
// SocketNode
|
341
421
|
//
|
@@ -356,12 +436,14 @@ void PopulateSocketAddressJson(Json::Object* json, const char* name,
|
|
356
436
|
if (!port.empty()) {
|
357
437
|
port_num = atoi(port.data());
|
358
438
|
}
|
359
|
-
|
439
|
+
grpc_resolved_address resolved_host;
|
440
|
+
grpc_string_to_sockaddr(&resolved_host, host.c_str(), port_num);
|
441
|
+
std::string packed_host = grpc_sockaddr_get_packed_host(&resolved_host);
|
442
|
+
std::string b64_host = absl::Base64Escape(packed_host);
|
360
443
|
data["tcpip_address"] = Json::Object{
|
361
444
|
{"port", port_num},
|
362
445
|
{"ip_address", b64_host},
|
363
446
|
};
|
364
|
-
gpr_free(b64_host);
|
365
447
|
} else if (uri.ok() && uri->scheme() == "unix") {
|
366
448
|
data["uds_address"] = Json::Object{
|
367
449
|
{"filename", uri->path()},
|
@@ -376,10 +458,12 @@ void PopulateSocketAddressJson(Json::Object* json, const char* name,
|
|
376
458
|
|
377
459
|
} // namespace
|
378
460
|
|
379
|
-
SocketNode::SocketNode(std::string local, std::string remote, std::string name
|
461
|
+
SocketNode::SocketNode(std::string local, std::string remote, std::string name,
|
462
|
+
RefCountedPtr<Security> security)
|
380
463
|
: BaseNode(EntityType::kSocket, std::move(name)),
|
381
464
|
local_(std::move(local)),
|
382
|
-
remote_(std::move(remote))
|
465
|
+
remote_(std::move(remote)),
|
466
|
+
security_(std::move(security)) {}
|
383
467
|
|
384
468
|
void SocketNode::RecordStreamStartedFromLocal() {
|
385
469
|
streams_started_.FetchAdd(1, MemoryOrder::RELAXED);
|
@@ -467,6 +551,10 @@ Json SocketNode::RenderJson() {
|
|
467
551
|
}},
|
468
552
|
{"data", std::move(data)},
|
469
553
|
};
|
554
|
+
if (security_ != nullptr &&
|
555
|
+
security_->type != SocketNode::Security::ModelType::kUnset) {
|
556
|
+
object["security"] = security_->RenderJson();
|
557
|
+
}
|
470
558
|
PopulateSocketAddressJson(&object, "remote", remote_.c_str());
|
471
559
|
PopulateSocketAddressJson(&object, "local", local_.c_str());
|
472
560
|
return object;
|
@@ -27,6 +27,7 @@
|
|
27
27
|
#include <string>
|
28
28
|
|
29
29
|
#include "absl/container/inlined_vector.h"
|
30
|
+
#include "absl/types/optional.h"
|
30
31
|
|
31
32
|
#include "src/core/lib/channel/channel_trace.h"
|
32
33
|
#include "src/core/lib/gpr/time_precise.h"
|
@@ -268,10 +269,37 @@ class ServerNode : public BaseNode {
|
|
268
269
|
std::map<intptr_t, RefCountedPtr<ListenSocketNode>> child_listen_sockets_;
|
269
270
|
};
|
270
271
|
|
272
|
+
#define GRPC_ARG_CHANNELZ_SECURITY "grpc.internal.channelz_security"
|
273
|
+
|
271
274
|
// Handles channelz bookkeeping for sockets
|
272
275
|
class SocketNode : public BaseNode {
|
273
276
|
public:
|
274
|
-
|
277
|
+
struct Security : public RefCounted<Security> {
|
278
|
+
struct Tls {
|
279
|
+
enum class NameType { kUnset = 0, kStandardName = 1, kOtherName = 2 };
|
280
|
+
NameType type = NameType::kUnset;
|
281
|
+
// Holds the value of standard_name or other_names if type is not kUnset.
|
282
|
+
std::string name;
|
283
|
+
std::string local_certificate;
|
284
|
+
std::string remote_certificate;
|
285
|
+
|
286
|
+
Json RenderJson();
|
287
|
+
};
|
288
|
+
enum class ModelType { kUnset = 0, kTls = 1, kOther = 2 };
|
289
|
+
ModelType type = ModelType::kUnset;
|
290
|
+
absl::optional<Tls> tls;
|
291
|
+
absl::optional<Json> other;
|
292
|
+
|
293
|
+
Json RenderJson();
|
294
|
+
|
295
|
+
grpc_arg MakeChannelArg() const;
|
296
|
+
|
297
|
+
static RefCountedPtr<Security> GetFromChannelArgs(
|
298
|
+
const grpc_channel_args* args);
|
299
|
+
};
|
300
|
+
|
301
|
+
SocketNode(std::string local, std::string remote, std::string name,
|
302
|
+
RefCountedPtr<Security> security);
|
275
303
|
~SocketNode() override {}
|
276
304
|
|
277
305
|
Json RenderJson() override;
|
@@ -305,6 +333,7 @@ class SocketNode : public BaseNode {
|
|
305
333
|
Atomic<gpr_cycle_counter> last_message_received_cycle_{0};
|
306
334
|
std::string local_;
|
307
335
|
std::string remote_;
|
336
|
+
RefCountedPtr<Security> const security_;
|
308
337
|
};
|
309
338
|
|
310
339
|
// Handles channelz bookkeeping for listen sockets
|
@@ -181,18 +181,24 @@ void ChannelzRegistry::InternalLogAllEntities() {
|
|
181
181
|
} // namespace grpc_core
|
182
182
|
|
183
183
|
char* grpc_channelz_get_top_channels(intptr_t start_channel_id) {
|
184
|
+
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
|
185
|
+
grpc_core::ExecCtx exec_ctx;
|
184
186
|
return gpr_strdup(
|
185
187
|
grpc_core::channelz::ChannelzRegistry::GetTopChannels(start_channel_id)
|
186
188
|
.c_str());
|
187
189
|
}
|
188
190
|
|
189
191
|
char* grpc_channelz_get_servers(intptr_t start_server_id) {
|
192
|
+
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
|
193
|
+
grpc_core::ExecCtx exec_ctx;
|
190
194
|
return gpr_strdup(
|
191
195
|
grpc_core::channelz::ChannelzRegistry::GetServers(start_server_id)
|
192
196
|
.c_str());
|
193
197
|
}
|
194
198
|
|
195
199
|
char* grpc_channelz_get_server(intptr_t server_id) {
|
200
|
+
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
|
201
|
+
grpc_core::ExecCtx exec_ctx;
|
196
202
|
grpc_core::RefCountedPtr<grpc_core::channelz::BaseNode> server_node =
|
197
203
|
grpc_core::channelz::ChannelzRegistry::Get(server_id);
|
198
204
|
if (server_node == nullptr ||
|
@@ -209,6 +215,8 @@ char* grpc_channelz_get_server(intptr_t server_id) {
|
|
209
215
|
char* grpc_channelz_get_server_sockets(intptr_t server_id,
|
210
216
|
intptr_t start_socket_id,
|
211
217
|
intptr_t max_results) {
|
218
|
+
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
|
219
|
+
grpc_core::ExecCtx exec_ctx;
|
212
220
|
// Validate inputs before handing them of to the renderer.
|
213
221
|
grpc_core::RefCountedPtr<grpc_core::channelz::BaseNode> base_node =
|
214
222
|
grpc_core::channelz::ChannelzRegistry::Get(server_id);
|
@@ -226,6 +234,8 @@ char* grpc_channelz_get_server_sockets(intptr_t server_id,
|
|
226
234
|
}
|
227
235
|
|
228
236
|
char* grpc_channelz_get_channel(intptr_t channel_id) {
|
237
|
+
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
|
238
|
+
grpc_core::ExecCtx exec_ctx;
|
229
239
|
grpc_core::RefCountedPtr<grpc_core::channelz::BaseNode> channel_node =
|
230
240
|
grpc_core::channelz::ChannelzRegistry::Get(channel_id);
|
231
241
|
if (channel_node == nullptr ||
|
@@ -242,6 +252,8 @@ char* grpc_channelz_get_channel(intptr_t channel_id) {
|
|
242
252
|
}
|
243
253
|
|
244
254
|
char* grpc_channelz_get_subchannel(intptr_t subchannel_id) {
|
255
|
+
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
|
256
|
+
grpc_core::ExecCtx exec_ctx;
|
245
257
|
grpc_core::RefCountedPtr<grpc_core::channelz::BaseNode> subchannel_node =
|
246
258
|
grpc_core::channelz::ChannelzRegistry::Get(subchannel_id);
|
247
259
|
if (subchannel_node == nullptr ||
|
@@ -256,6 +268,8 @@ char* grpc_channelz_get_subchannel(intptr_t subchannel_id) {
|
|
256
268
|
}
|
257
269
|
|
258
270
|
char* grpc_channelz_get_socket(intptr_t socket_id) {
|
271
|
+
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
|
272
|
+
grpc_core::ExecCtx exec_ctx;
|
259
273
|
grpc_core::RefCountedPtr<grpc_core::channelz::BaseNode> socket_node =
|
260
274
|
grpc_core::channelz::ChannelzRegistry::Get(socket_id);
|
261
275
|
if (socket_node == nullptr ||
|
@@ -55,44 +55,6 @@ std::string HandshakerArgsString(HandshakerArgs* args) {
|
|
55
55
|
|
56
56
|
HandshakeManager::HandshakeManager() {}
|
57
57
|
|
58
|
-
/// Add \a mgr to the server side list of all pending handshake managers, the
|
59
|
-
/// list starts with \a *head.
|
60
|
-
// Not thread-safe. Caller needs to synchronize.
|
61
|
-
void HandshakeManager::AddToPendingMgrList(HandshakeManager** head) {
|
62
|
-
GPR_ASSERT(prev_ == nullptr);
|
63
|
-
GPR_ASSERT(next_ == nullptr);
|
64
|
-
next_ = *head;
|
65
|
-
if (*head) {
|
66
|
-
(*head)->prev_ = this;
|
67
|
-
}
|
68
|
-
*head = this;
|
69
|
-
}
|
70
|
-
|
71
|
-
/// Remove \a mgr from the server side list of all pending handshake managers.
|
72
|
-
// Not thread-safe. Caller needs to synchronize.
|
73
|
-
void HandshakeManager::RemoveFromPendingMgrList(HandshakeManager** head) {
|
74
|
-
if (next_ != nullptr) {
|
75
|
-
next_->prev_ = prev_;
|
76
|
-
}
|
77
|
-
if (prev_ != nullptr) {
|
78
|
-
prev_->next_ = next_;
|
79
|
-
} else {
|
80
|
-
GPR_ASSERT(*head == this);
|
81
|
-
*head = next_;
|
82
|
-
}
|
83
|
-
}
|
84
|
-
|
85
|
-
/// Shutdown all pending handshake managers starting at head on the server
|
86
|
-
/// side. Not thread-safe. Caller needs to synchronize.
|
87
|
-
void HandshakeManager::ShutdownAllPending(grpc_error* why) {
|
88
|
-
auto* head = this;
|
89
|
-
while (head != nullptr) {
|
90
|
-
head->Shutdown(GRPC_ERROR_REF(why));
|
91
|
-
head = head->next_;
|
92
|
-
}
|
93
|
-
GRPC_ERROR_UNREF(why);
|
94
|
-
}
|
95
|
-
|
96
58
|
void HandshakeManager::Add(RefCountedPtr<Handshaker> handshaker) {
|
97
59
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_handshaker_trace)) {
|
98
60
|
gpr_log(
|
@@ -213,7 +175,6 @@ void HandshakeManager::DoHandshake(grpc_endpoint* endpoint,
|
|
213
175
|
{
|
214
176
|
MutexLock lock(&mu_);
|
215
177
|
GPR_ASSERT(index_ == 0);
|
216
|
-
GPR_ASSERT(!is_shutdown_);
|
217
178
|
// Construct handshaker args. These will be passed through all
|
218
179
|
// handshakers and eventually be freed by the on_handshake_done callback.
|
219
180
|
args_.endpoint = endpoint;
|
@@ -94,19 +94,6 @@ class HandshakeManager : public RefCounted<HandshakeManager> {
|
|
94
94
|
HandshakeManager();
|
95
95
|
~HandshakeManager() override;
|
96
96
|
|
97
|
-
/// Add \a mgr to the server side list of all pending handshake managers, the
|
98
|
-
/// list starts with \a *head.
|
99
|
-
// Not thread-safe. Caller needs to synchronize.
|
100
|
-
void AddToPendingMgrList(HandshakeManager** head);
|
101
|
-
|
102
|
-
/// Remove \a mgr from the server side list of all pending handshake managers.
|
103
|
-
// Not thread-safe. Caller needs to synchronize.
|
104
|
-
void RemoveFromPendingMgrList(HandshakeManager** head);
|
105
|
-
|
106
|
-
/// Shutdown all pending handshake managers starting at head on the server
|
107
|
-
/// side. Not thread-safe. Caller needs to synchronize.
|
108
|
-
void ShutdownAllPending(grpc_error* why);
|
109
|
-
|
110
97
|
/// Adds a handshaker to the handshake manager.
|
111
98
|
/// Takes ownership of \a handshaker.
|
112
99
|
void Add(RefCountedPtr<Handshaker> handshaker);
|
@@ -161,10 +148,6 @@ class HandshakeManager : public RefCounted<HandshakeManager> {
|
|
161
148
|
grpc_closure on_handshake_done_;
|
162
149
|
// Handshaker args.
|
163
150
|
HandshakerArgs args_;
|
164
|
-
// Links to the previous and next managers in a list of all pending handshakes
|
165
|
-
// Used at server side only.
|
166
|
-
HandshakeManager* prev_ = nullptr;
|
167
|
-
HandshakeManager* next_ = nullptr;
|
168
151
|
};
|
169
152
|
|
170
153
|
} // namespace grpc_core
|
@@ -75,8 +75,6 @@ const char* grpc_status_code_to_string(grpc_status_code status) {
|
|
75
75
|
return "ALREADY_EXISTS";
|
76
76
|
case GRPC_STATUS_PERMISSION_DENIED:
|
77
77
|
return "PERMISSION_DENIED";
|
78
|
-
case GRPC_STATUS_UNAUTHENTICATED:
|
79
|
-
return "UNAUTHENTICATED";
|
80
78
|
case GRPC_STATUS_RESOURCE_EXHAUSTED:
|
81
79
|
return "RESOURCE_EXHAUSTED";
|
82
80
|
case GRPC_STATUS_FAILED_PRECONDITION:
|
@@ -93,7 +91,19 @@ const char* grpc_status_code_to_string(grpc_status_code status) {
|
|
93
91
|
return "UNAVAILABLE";
|
94
92
|
case GRPC_STATUS_DATA_LOSS:
|
95
93
|
return "DATA_LOSS";
|
94
|
+
case GRPC_STATUS_UNAUTHENTICATED:
|
95
|
+
return "UNAUTHENTICATED";
|
96
96
|
default:
|
97
97
|
return "UNKNOWN";
|
98
98
|
}
|
99
99
|
}
|
100
|
+
|
101
|
+
bool grpc_status_code_from_int(int status_int, grpc_status_code* status) {
|
102
|
+
// The range of status code enum is [0, 16], 0 is OK, 16 is UNAUTHENTICATED.
|
103
|
+
if (status_int < GRPC_STATUS_OK || status_int > GRPC_STATUS_UNAUTHENTICATED) {
|
104
|
+
*status = GRPC_STATUS_UNKNOWN;
|
105
|
+
return false;
|
106
|
+
}
|
107
|
+
*status = static_cast<grpc_status_code>(status_int);
|
108
|
+
return true;
|
109
|
+
}
|
@@ -34,6 +34,11 @@ bool grpc_status_code_from_string(const char* status_str,
|
|
34
34
|
/// Returns the string form of \a status, or "UNKNOWN" if invalid.
|
35
35
|
const char* grpc_status_code_to_string(grpc_status_code status);
|
36
36
|
|
37
|
+
// Converts an int to grpc_status_code. If the int is not a valid status code,
|
38
|
+
// sets the code to GRPC_STATUS_UNKNOWN and returns false. Otherwise, returns
|
39
|
+
// true.
|
40
|
+
bool grpc_status_code_from_int(int status_int, grpc_status_code* status);
|
41
|
+
|
37
42
|
namespace grpc_core {
|
38
43
|
namespace internal {
|
39
44
|
|
@@ -62,8 +62,7 @@ void gpr_mu_unlock(gpr_mu* mu) ABSL_NO_THREAD_SAFETY_ANALYSIS {
|
|
62
62
|
|
63
63
|
int gpr_mu_trylock(gpr_mu* mu) {
|
64
64
|
GPR_TIMER_SCOPE("gpr_mu_trylock", 0);
|
65
|
-
|
66
|
-
return ret;
|
65
|
+
return reinterpret_cast<absl::Mutex*>(mu)->TryLock();
|
67
66
|
}
|
68
67
|
|
69
68
|
/*----------------------------------------*/
|
@@ -89,10 +88,8 @@ int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, gpr_timespec abs_deadline) {
|
|
89
88
|
abs_deadline = gpr_convert_clock_type(abs_deadline, GPR_CLOCK_REALTIME);
|
90
89
|
timespec ts = {static_cast<decltype(ts.tv_sec)>(abs_deadline.tv_sec),
|
91
90
|
static_cast<decltype(ts.tv_nsec)>(abs_deadline.tv_nsec)};
|
92
|
-
|
93
|
-
|
94
|
-
absl::TimeFromTimespec(ts)) == true;
|
95
|
-
return ret;
|
91
|
+
return reinterpret_cast<absl::CondVar*>(cv)->WaitWithDeadline(
|
92
|
+
reinterpret_cast<absl::Mutex*>(mu), absl::TimeFromTimespec(ts));
|
96
93
|
}
|
97
94
|
|
98
95
|
void gpr_cv_signal(gpr_cv* cv) {
|
@@ -100,7 +100,7 @@ void gpr_cv_broadcast(gpr_cv* cv) { WakeAllConditionVariable(cv); }
|
|
100
100
|
|
101
101
|
/*----------------------------------------*/
|
102
102
|
|
103
|
-
static void*
|
103
|
+
static void* phony;
|
104
104
|
struct run_once_func_arg {
|
105
105
|
void (*init_function)(void);
|
106
106
|
};
|
@@ -113,7 +113,7 @@ static BOOL CALLBACK run_once_func(gpr_once* once, void* v, void** pv) {
|
|
113
113
|
void gpr_once_init(gpr_once* once, void (*init_function)(void)) {
|
114
114
|
struct run_once_func_arg arg;
|
115
115
|
arg.init_function = init_function;
|
116
|
-
InitOnceExecuteOnce(once, run_once_func, &arg, &
|
116
|
+
InitOnceExecuteOnce(once, run_once_func, &arg, &phony);
|
117
117
|
}
|
118
118
|
|
119
119
|
#endif /* defined(GPR_WINDOWS) && !defined(GPR_ABSEIL_SYNC) && \
|