grpc 1.82.0 → 1.83.0.pre1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +8 -5
  3. data/etc/roots.pem +10400 -3855
  4. data/include/grpc/grpc_audit_logging.h +2 -2
  5. data/include/grpc/grpc_security_constants.h +2 -0
  6. data/include/grpc/impl/channel_arg_names.h +23 -0
  7. data/src/core/call/call_filters.h +19 -3
  8. data/src/core/call/call_spine.h +4 -4
  9. data/src/core/call/client_call.cc +1 -1
  10. data/src/core/call/metadata.cc +7 -2
  11. data/src/core/call/server_call.cc +13 -3
  12. data/src/core/call/server_call.h +5 -3
  13. data/src/core/client_channel/backup_poller.cc +2 -17
  14. data/src/core/client_channel/client_channel.cc +17 -14
  15. data/src/core/client_channel/client_channel.h +3 -1
  16. data/src/core/client_channel/client_channel_filter.cc +11 -13
  17. data/src/core/client_channel/client_channel_service_config.cc +5 -13
  18. data/src/core/client_channel/direct_channel.cc +5 -1
  19. data/src/core/client_channel/direct_channel.h +3 -1
  20. data/src/core/config/experiment_env_var.cc +30 -0
  21. data/src/core/config/experiment_env_var.h +26 -0
  22. data/src/core/credentials/call/regional_access_boundary_fetcher.cc +6 -6
  23. data/src/core/credentials/transport/ssl/ssl_security_connector.cc +14 -2
  24. data/src/core/credentials/transport/tls/grpc_tls_certificate_selector.cc +172 -0
  25. data/src/core/credentials/transport/tls/grpc_tls_certificate_selector.h +103 -0
  26. data/src/core/credentials/transport/tls/load_system_roots_fallback.cc +3 -2
  27. data/src/core/credentials/transport/tls/load_system_roots_supported.cc +10 -3
  28. data/src/core/credentials/transport/tls/tls_security_connector.cc +14 -2
  29. data/src/core/credentials/transport/xds/xds_credentials.cc +4 -12
  30. data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +2 -1
  31. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +19 -13
  32. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +11 -9
  33. data/src/core/ext/transport/chttp2/transport/flow_control.cc +2 -2
  34. data/src/core/ext/transport/chttp2/transport/flow_control.h +3 -2
  35. data/src/core/ext/transport/chttp2/transport/frame.cc +58 -1
  36. data/src/core/ext/transport/chttp2/transport/frame.h +13 -1
  37. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +2 -4
  38. data/src/core/ext/transport/chttp2/transport/frame_security.cc +10 -1
  39. data/src/core/ext/transport/chttp2/transport/frame_security.h +2 -1
  40. data/src/core/ext/transport/chttp2/transport/goaway.cc +11 -1
  41. data/src/core/ext/transport/chttp2/transport/goaway.h +17 -1
  42. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +9 -0
  43. data/src/core/ext/transport/chttp2/transport/http2_client_transport.cc +117 -276
  44. data/src/core/ext/transport/chttp2/transport/http2_client_transport.h +44 -17
  45. data/src/core/ext/transport/chttp2/transport/http2_server_transport.cc +382 -496
  46. data/src/core/ext/transport/chttp2/transport/http2_server_transport.h +75 -77
  47. data/src/core/ext/transport/chttp2/transport/http2_settings.cc +1 -1
  48. data/src/core/ext/transport/chttp2/transport/http2_settings.h +30 -11
  49. data/src/core/ext/transport/chttp2/transport/http2_settings_promises.h +24 -9
  50. data/src/core/ext/transport/chttp2/transport/http2_transport.cc +26 -0
  51. data/src/core/ext/transport/chttp2/transport/http2_transport.h +2 -0
  52. data/src/core/ext/transport/chttp2/transport/internal.h +4 -0
  53. data/src/core/ext/transport/chttp2/transport/parsing.cc +3 -2
  54. data/src/core/ext/transport/chttp2/transport/ping_promise.cc +1 -1
  55. data/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc +4 -10
  56. data/src/core/ext/transport/chttp2/transport/read_context.h +62 -20
  57. data/src/core/ext/transport/chttp2/transport/security_frame.h +1 -0
  58. data/src/core/ext/transport/chttp2/transport/stream.h +271 -120
  59. data/src/core/ext/transport/chttp2/transport/stream_data_queue.h +77 -61
  60. data/src/core/handshaker/security/secure_endpoint.cc +0 -13
  61. data/src/core/lib/channel/promise_based_filter.cc +77 -3
  62. data/src/core/lib/channel/promise_based_filter.h +238 -184
  63. data/src/core/lib/event_engine/extensions/receive_coalescing_extension.h +0 -4
  64. data/src/core/lib/event_engine/extensions/tcp_trace.h +1 -1
  65. data/src/core/lib/event_engine/posix_engine/posix_engine.cc +2 -12
  66. data/src/core/lib/event_engine/shim.cc +2 -16
  67. data/src/core/lib/event_engine/shim.h +0 -4
  68. data/src/core/lib/experiments/experiments.cc +51 -102
  69. data/src/core/lib/experiments/experiments.h +37 -59
  70. data/src/core/lib/iomgr/error.cc +3 -73
  71. data/src/core/lib/iomgr/error.h +8 -6
  72. data/src/core/lib/iomgr/error_cfstream.cc +1 -2
  73. data/src/core/lib/iomgr/ev_epoll1_linux.cc +2 -6
  74. data/src/core/lib/iomgr/ev_poll_posix.cc +2 -6
  75. data/src/core/lib/iomgr/tcp_posix.cc +2 -6
  76. data/src/core/lib/security/authorization/audit_logging.cc +2 -2
  77. data/src/core/lib/security/authorization/audit_logging.h +3 -3
  78. data/src/core/lib/security/authorization/grpc_authorization_engine.cc +11 -13
  79. data/src/core/lib/security/authorization/grpc_authorization_engine.h +1 -1
  80. data/src/core/lib/security/authorization/matchers.cc +20 -20
  81. data/src/core/lib/security/authorization/matchers.h +15 -16
  82. data/src/core/lib/security/authorization/rbac_policy.h +1 -1
  83. data/src/core/lib/security/authorization/stdout_logger.cc +3 -3
  84. data/src/core/lib/security/authorization/stdout_logger.h +6 -5
  85. data/src/core/lib/surface/call.cc +0 -8
  86. data/src/core/lib/surface/call.h +2 -0
  87. data/src/core/lib/surface/channel.cc +21 -2
  88. data/src/core/lib/surface/channel.h +14 -6
  89. data/src/core/lib/surface/filter_stack_call.cc +10 -29
  90. data/src/core/lib/surface/legacy_channel.cc +7 -7
  91. data/src/core/lib/surface/legacy_channel.h +3 -1
  92. data/src/core/lib/surface/version.cc +2 -2
  93. data/src/core/lib/transport/bdp_estimator.cc +13 -13
  94. data/src/core/lib/transport/bdp_estimator.h +9 -5
  95. data/src/core/lib/transport/error_utils.cc +26 -138
  96. data/src/core/lib/transport/promise_endpoint.h +2 -4
  97. data/src/core/load_balancing/grpclb/grpclb.cc +2 -1
  98. data/src/core/load_balancing/pick_first/pick_first.cc +33 -2
  99. data/src/core/load_balancing/pick_first/pick_first.h +6 -0
  100. data/src/core/load_balancing/ring_hash/ring_hash.cc +3 -10
  101. data/src/core/load_balancing/rls/rls.cc +2 -1
  102. data/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc +2 -7
  103. data/src/core/load_balancing/xds/cds.cc +80 -56
  104. data/src/core/load_balancing/xds/cds.h +21 -0
  105. data/src/core/mitigation_engine/mitigation.h +53 -0
  106. data/src/core/mitigation_engine/mitigation_provider.h +62 -0
  107. data/src/core/resolver/dns/dns_resolver_plugin.cc +1 -6
  108. data/src/core/resolver/xds/xds_resolver.cc +14 -11
  109. data/src/core/server/server.h +1 -4
  110. data/src/core/server/server_config_selector.h +5 -4
  111. data/src/core/server/server_config_selector_filter.cc +67 -80
  112. data/src/core/server/xds_server_config_fetcher.cc +681 -692
  113. data/src/core/server/xds_server_config_fetcher_legacy.cc +15 -12
  114. data/src/core/telemetry/call_tracer.cc +49 -2
  115. data/src/core/telemetry/call_tracer.h +1 -0
  116. data/src/core/telemetry/tcp_tracer.h +38 -0
  117. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +1 -1
  118. data/src/core/tsi/ssl_telemetry_utils.cc +343 -0
  119. data/src/core/tsi/ssl_telemetry_utils.h +74 -0
  120. data/src/core/tsi/ssl_transport_security.cc +577 -301
  121. data/src/core/tsi/ssl_transport_security.h +22 -6
  122. data/src/core/tsi/ssl_transport_security_utils.cc +2 -0
  123. data/src/core/tsi/transport_security.h +7 -0
  124. data/src/core/util/http_client/httpcli.cc +1 -4
  125. data/src/core/util/http_client/httpcli_security_connector.cc +2 -1
  126. data/src/core/util/status_helper.cc +71 -192
  127. data/src/core/util/status_helper.h +16 -21
  128. data/src/core/xds/grpc/file_watcher_certificate_provider_factory.cc +2 -11
  129. data/src/core/xds/grpc/xds_bootstrap_grpc.cc +2 -7
  130. data/src/core/xds/grpc/xds_cluster_parser.cc +5 -16
  131. data/src/core/xds/grpc/xds_common_types.cc +94 -38
  132. data/src/core/xds/grpc/xds_common_types.h +33 -18
  133. data/src/core/xds/grpc/xds_common_types_parser.cc +168 -100
  134. data/src/core/xds/grpc/xds_common_types_parser.h +18 -1
  135. data/src/core/xds/grpc/xds_endpoint_parser.cc +6 -17
  136. data/src/core/xds/grpc/xds_http_filter_registry.cc +2 -10
  137. data/src/core/xds/grpc/xds_http_rbac_filter.cc +3 -12
  138. data/src/core/xds/grpc/xds_metadata_parser.cc +0 -2
  139. data/src/core/xds/grpc/xds_route_config_parser.cc +7 -11
  140. data/src/core/xds/grpc/xds_routing.cc +113 -82
  141. data/src/core/xds/grpc/xds_routing.h +70 -20
  142. data/src/core/xds/grpc/xds_server_grpc.cc +22 -13
  143. data/src/core/xds/grpc/xds_server_grpc.h +16 -2
  144. data/src/core/xds/grpc/xds_server_grpc_interface.h +10 -0
  145. data/src/core/xds/grpc/xds_transport_grpc.cc +123 -18
  146. data/src/core/xds/grpc/xds_transport_grpc.h +28 -4
  147. data/src/core/xds/xds_client/lrs_client.cc +3 -7
  148. data/src/core/xds/xds_client/xds_bootstrap.cc +4 -16
  149. data/src/core/xds/xds_client/xds_client.cc +2 -15
  150. data/src/core/xds/xds_client/xds_transport.h +3 -0
  151. data/src/ruby/lib/grpc/version.rb +1 -1
  152. data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +1 -1
  153. metadata +9 -1
@@ -43,6 +43,7 @@
43
43
 
44
44
  namespace grpc_core {
45
45
  namespace http2 {
46
+ constexpr uint32_t kCurrentCycleMaxResetStreams = 1024u;
46
47
 
47
48
  class ReadLoopPauseRestart {
48
49
  public:
@@ -52,19 +53,14 @@ class ReadLoopPauseRestart {
52
53
  ReadLoopPauseRestart(ReadLoopPauseRestart&&) = delete;
53
54
  ReadLoopPauseRestart& operator=(ReadLoopPauseRestart&&) = delete;
54
55
 
55
- // Signals that the read loop should pause. If it's already paused, this is a
56
+ // Signals that the ReadLoop should pause. If it's already paused, this is a
56
57
  // no-op.
57
- void SetPauseReadLoop() {
58
- // TODO(tjagtap) [PH2][P2][Settings] Plumb with when we receive urgent
59
- // settings. Example - initial window size 0 is urgent because it indicates
60
- // extreme memory pressure on the server.
61
- should_pause_read_loop_ = true;
62
- }
58
+ void SetPauseReadLoop() { should_pause_read_loop_ = true; }
63
59
 
64
60
  // If SetPauseReadLoop() was called, this returns Pending and
65
61
  // registers a waker that will be woken by WakeReadLoop().
66
- // If the read loop does not need to be paused, this returns OkStatus.
67
- // This should be polled by the read loop to yield control when requested.
62
+ // If the ReadLoop does not need to be paused, this returns OkStatus.
63
+ // This should be polled by the ReadLoop to yield control when requested.
68
64
  Poll<absl::Status> MaybePauseReadLoop() {
69
65
  if (should_pause_read_loop_) {
70
66
  read_loop_waker_ = GetContext<Activity>()->MakeNonOwningWaker();
@@ -173,10 +169,12 @@ class IncomingMetadataState {
173
169
  class ReadContext {
174
170
  public:
175
171
  explicit ReadContext(const uint32_t max_new_streams_per_read_cycle,
176
- const PromiseEndpoint& endpoint, const bool is_client)
172
+ const PromiseEndpoint& endpoint, const bool is_client,
173
+ const uint32_t max_security_frame_size)
177
174
  : max_new_streams_per_read_cycle_(max_new_streams_per_read_cycle),
178
175
  peer_string_(GetPeerString(endpoint)),
179
176
  is_client_(is_client),
177
+ max_security_frame_size_(max_security_frame_size),
180
178
  header_assembler_(is_client) {
181
179
  GRPC_DCHECK(max_new_streams_per_read_cycle > 0u)
182
180
  << "0 is invalid, because we will never be able to create a stream.";
@@ -282,8 +280,23 @@ class ReadContext {
282
280
  /*last_stream_id=*/last_stream_id,
283
281
  /*is_client=*/is_client_,
284
282
  /*is_first_settings_processed=*/is_first_settings_processed,
285
- /*tracker=*/tracker_);
283
+ /*tracker=*/tracker_,
284
+ /*max_security_frame_size=*/max_security_frame_size_);
285
+ }
286
+
287
+ // Called when we are closing a stream.
288
+ void OnResetFrameEnqueued(const uint32_t reset_stream_error_code) {
289
+ // TODO(tjagtap) [PH2][P1] Call this when we reject streams because of
290
+ // MAX_CONCURRENT_STREAMS limit.
291
+ if (reset_stream_error_code != 0u) {
292
+ IncrementInducedFrames();
293
+ }
286
294
  }
295
+ void OnSettingsFrameReceived() { IncrementInducedFrames(); }
296
+ void OnPingFrameReceived() { IncrementInducedFrames(); }
297
+
298
+ // Called when we read a RST_STREAM frame from the peer.
299
+ void OnResetFrameReceived() { IncrementResetStreamFrames(); }
287
300
 
288
301
  // Called when a HEADER frame is received.
289
302
  void UpdateState(const Http2HeaderFrame& frame,
@@ -349,7 +362,21 @@ class ReadContext {
349
362
  //////////////////////////////////////////////////////////////////////////////
350
363
  // ReadLoopPauseRestart wrapper functions.
351
364
 
352
- void SetPauseReadLoop() { read_loop_manager_.SetPauseReadLoop(); }
365
+ // A note on stalling the ReadLoop:
366
+ // We have intentionally decided against stalling the ReadLoop when receiving
367
+ // one SETTINGS frame or one PING frame because we have anyway capped the
368
+ // number of iterations of the ReadLoop. And so as long as the endpoint Read
369
+ // in the ReadLoop is resolving immediately, we are ok to delay sending
370
+ // SETTINGS ACK, PING ACK and applying the settings. We will only stall the
371
+ // ReadLoop if certain per cycle limits are exceeded.
372
+ // We are also not going to stall the ReadLoop on any urgent setting being
373
+ // received because we have our ReadLoop capped at a max number of iterations,
374
+ // and applying those new settings a little later is ok.
375
+
376
+ void SetPauseReadLoop() {
377
+ ResetReadCycleCounters();
378
+ read_loop_manager_.SetPauseReadLoop();
379
+ }
353
380
 
354
381
  Poll<absl::Status> MaybePauseReadLoop() {
355
382
  return read_loop_manager_.MaybePauseReadLoop();
@@ -396,37 +423,51 @@ class ReadContext {
396
423
  void ResetReadCycleCounters() {
397
424
  current_cycle_read_count_ = 0u;
398
425
  current_cycle_bytes_read_ = 0u;
426
+ current_cycle_num_induced_frames_ = 0u;
399
427
  current_cycle_num_new_streams_ = 0u;
428
+ current_cycle_num_reset_streams_ = 0u;
400
429
  }
401
430
  void IncrementIncomingStreams() {
402
431
  ++current_cycle_num_new_streams_;
403
432
  if (current_cycle_num_new_streams_ >= max_new_streams_per_read_cycle_) {
404
- read_loop_manager_.SetPauseReadLoop();
405
- ResetReadCycleCounters();
433
+ SetPauseReadLoop();
406
434
  }
407
435
  }
408
436
  void IncrementReadCycleCounters(const uint32_t payload_length) {
409
437
  current_cycle_bytes_read_ += kFrameHeaderSize + payload_length;
410
438
  ++current_cycle_read_count_;
411
439
  if (current_cycle_read_count_ >= kMaxFramesReadPerReadCycle) {
412
- read_loop_manager_.SetPauseReadLoop();
413
- ResetReadCycleCounters();
440
+ SetPauseReadLoop();
441
+ }
442
+ }
443
+ void IncrementInducedFrames() {
444
+ ++current_cycle_num_induced_frames_;
445
+ if (current_cycle_num_induced_frames_ >=
446
+ GrpcErrors::kDefaultMaxPendingInducedFrames) {
447
+ SetPauseReadLoop();
448
+ }
449
+ }
450
+ void IncrementResetStreamFrames() {
451
+ ++current_cycle_num_reset_streams_;
452
+ if (current_cycle_num_reset_streams_ >= kCurrentCycleMaxResetStreams) {
453
+ SetPauseReadLoop();
414
454
  }
415
455
  }
416
-
417
456
  // Counters to track total bytes and frames read per cycle.
418
- // Checked against limits to pause the read loop when maxed out.
457
+ // Checked against limits to pause the ReadLoop when maxed out.
419
458
  // This yields execution to prevent starvation of other transport tasks.
420
459
  // As per RFC 9113, HTTP/2 frame sizes can vary significantly.
421
460
  // Some frames are very large, while others are extremely small.
422
- // We stall the read loop based only on current_cycle_read_count_.
461
+ // We stall the ReadLoop based only on current_cycle_read_count_.
423
462
  // We measure current_cycle_bytes_read_ just for telemetry. We are not
424
- // stalling the read loop based on the number of bytes read right now because
463
+ // stalling the ReadLoop based on the number of bytes read right now because
425
464
  // we think that current_cycle_read_count_ would be sufficient for now.
426
465
  uint64_t current_cycle_bytes_read_ = 0u;
427
466
  uint16_t current_cycle_read_count_ = 0u;
467
+ uint32_t current_cycle_num_induced_frames_ = 0u;
428
468
 
429
469
  uint32_t current_cycle_num_new_streams_ = 0u;
470
+ uint32_t current_cycle_num_reset_streams_ = 0u;
430
471
  // Unlike other limits, this cannot be a constexpr because it is set per
431
472
  // transport via a ChannelArg named "grpc.http2.max_requests_per_read".
432
473
  const uint32_t max_new_streams_per_read_cycle_;
@@ -436,6 +477,7 @@ class ReadContext {
436
477
  const Slice peer_string_;
437
478
  const bool is_client_;
438
479
 
480
+ const uint32_t max_security_frame_size_;
439
481
  uint32_t max_header_list_size_soft_limit_ =
440
482
  DEFAULT_MAX_HEADER_LIST_SIZE_SOFT_LIMIT;
441
483
  HPackParser parser_;
@@ -197,6 +197,7 @@ class SecurityFrameHandler final : public RefCounted<SecurityFrameHandler> {
197
197
  {
198
198
  MutexLock lock(&mutex_);
199
199
  GRPC_DCHECK(payload_.Length() != 0);
200
+ GRPC_DCHECK(payload_.Length() <= GrpcErrors::kMaxSecurityFrameSize);
200
201
  GRPC_HTTP2_SECURITY_FRAME_DLOG
201
202
  << "SecurityFrameHandler::MaybeAppendSecurityFrame Write Frame "
202
203
  "Length "