grpc 1.53.0 → 1.53.1

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.

Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +4 -2
  3. data/include/grpc/impl/grpc_types.h +11 -2
  4. data/src/core/ext/filters/client_channel/http_proxy.cc +1 -1
  5. data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +1 -1
  6. data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +12 -8
  7. data/src/core/ext/transport/chttp2/transport/bin_encoder.h +5 -1
  8. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +33 -2
  9. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +118 -222
  10. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +295 -113
  11. data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc +2 -0
  12. data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.h +2 -0
  13. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +466 -273
  14. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +7 -3
  15. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +14 -12
  16. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +9 -1
  17. data/src/core/ext/transport/chttp2/transport/internal.h +2 -0
  18. data/src/core/ext/transport/chttp2/transport/parsing.cc +6 -0
  19. data/src/core/lib/backoff/random_early_detection.cc +31 -0
  20. data/src/core/lib/backoff/random_early_detection.h +59 -0
  21. data/src/core/lib/iomgr/endpoint_pair.h +2 -2
  22. data/src/core/lib/iomgr/endpoint_pair_posix.cc +2 -2
  23. data/src/core/lib/iomgr/endpoint_pair_windows.cc +1 -1
  24. data/src/core/lib/surface/validate_metadata.cc +43 -42
  25. data/src/core/lib/surface/validate_metadata.h +9 -0
  26. data/src/core/lib/transport/metadata_batch.cc +4 -4
  27. data/src/core/lib/transport/metadata_batch.h +153 -15
  28. data/src/core/lib/transport/parsed_metadata.h +19 -9
  29. data/src/ruby/lib/grpc/version.rb +1 -1
  30. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4837576e9ebd29efff84e3790780b00cac54cb40b9189034e566a5383853536f
4
- data.tar.gz: 72f8914c2cede10965aa0d4f4f0283bc2fa6212e7edb194c3192f3bd3c3d7f41
3
+ metadata.gz: a379c4ca9a7aaaba1fc0daf741ff674124622bf473dc48ecc8c786ba7a9246a5
4
+ data.tar.gz: 87ad7e100be1406e6b5d928d9f6af684dd0f2d5bb9fc7c9b5a15ab0fed668cc8
5
5
  SHA512:
6
- metadata.gz: aba6fbfdcfafdb992473f7206ce0f1a8fb1d681af13e67ddf500034d1005b794997d1d11ecd0b7e198cccc70de0d4363432be068299faba3e12a5ad8c9791240
7
- data.tar.gz: ab9f41385d08750b44ef638c471cc9394e39f3a8ba1cf2a0aef997ba6ca03b1058081ad06c24586804f36a60a11534fc609498b0c8af8fd7d0f5de67ccf00cd3
6
+ metadata.gz: 8022d820669d96ad0669842e80a0e8cc316fdd77f0c3843e1ab8bb899ed9ea829baecf08e31c81d0bb64c55ba6afe98c8ae693d46bdeeb83f7b7f6dbe25628dc
7
+ data.tar.gz: eda257dbc42d4e994f67f7efacdf8c63078808b22e1adc92ec05a5ebdd1490fc1c49b87b6e88e32954dff09dacf53deb1c5517acbc00ddd8356de2200a0ad247
data/Makefile CHANGED
@@ -411,8 +411,8 @@ Q = @
411
411
  endif
412
412
 
413
413
  CORE_VERSION = 30.1.0
414
- CPP_VERSION = 1.53.0
415
- CSHARP_VERSION = 2.53.0
414
+ CPP_VERSION = 1.53.1
415
+ CSHARP_VERSION = 2.53.1
416
416
 
417
417
  CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
418
418
  CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
@@ -1403,6 +1403,7 @@ LIBGRPC_SRC = \
1403
1403
  src/core/lib/address_utils/parse_address.cc \
1404
1404
  src/core/lib/address_utils/sockaddr_utils.cc \
1405
1405
  src/core/lib/backoff/backoff.cc \
1406
+ src/core/lib/backoff/random_early_detection.cc \
1406
1407
  src/core/lib/channel/channel_args.cc \
1407
1408
  src/core/lib/channel/channel_args_preconditioning.cc \
1408
1409
  src/core/lib/channel/channel_stack.cc \
@@ -1943,6 +1944,7 @@ LIBGRPC_UNSECURE_SRC = \
1943
1944
  src/core/lib/address_utils/parse_address.cc \
1944
1945
  src/core/lib/address_utils/sockaddr_utils.cc \
1945
1946
  src/core/lib/backoff/backoff.cc \
1947
+ src/core/lib/backoff/random_early_detection.cc \
1946
1948
  src/core/lib/channel/channel_args.cc \
1947
1949
  src/core/lib/channel/channel_args_preconditioning.cc \
1948
1950
  src/core/lib/channel/channel_stack.cc \
@@ -293,9 +293,18 @@ typedef struct {
293
293
  * protector.
294
294
  */
295
295
  #define GRPC_ARG_TSI_MAX_FRAME_SIZE "grpc.tsi.max_frame_size"
296
- /** Maximum metadata size, in bytes. Note this limit applies to the max sum of
297
- all metadata key-value entries in a batch of headers. */
296
+ /** Maximum metadata size (soft limit), in bytes. Note this limit applies to the
297
+ max sum of all metadata key-value entries in a batch of headers. Some random
298
+ sample of requests between this limit and
299
+ `GRPC_ARG_ABSOLUTE_MAX_METADATA_SIZE` will be rejected. Defaults to maximum
300
+ of 8 KB and `GRPC_ARG_ABSOLUTE_MAX_METADATA_SIZE` * 0.8 (if set).
301
+ */
298
302
  #define GRPC_ARG_MAX_METADATA_SIZE "grpc.max_metadata_size"
303
+ /** Maximum metadata size (hard limit), in bytes. Note this limit applies to the
304
+ max sum of all metadata key-value entries in a batch of headers. All requests
305
+ exceeding this limit will be rejected. Defaults to maximum of 16 KB and
306
+ `GRPC_ARG_MAX_METADATA_SIZE` * 1.25 (if set). */
307
+ #define GRPC_ARG_ABSOLUTE_MAX_METADATA_SIZE "grpc.absolute_max_metadata_size"
299
308
  /** If non-zero, allow the use of SO_REUSEPORT if it's available (default 1) */
300
309
  #define GRPC_ARG_ALLOW_REUSEPORT "grpc.so_reuseport"
301
310
  /** If non-zero, a pointer to a buffer pool (a pointer of type
@@ -76,7 +76,7 @@ absl::optional<std::string> GetHttpProxyServer(
76
76
  if (!uri_str.has_value()) uri_str = GetEnv("https_proxy");
77
77
  if (!uri_str.has_value()) uri_str = GetEnv("http_proxy");
78
78
  if (!uri_str.has_value()) return absl::nullopt;
79
- // an emtpy value means "don't use proxy"
79
+ // an empty value means "don't use proxy"
80
80
  if (uri_str->empty()) return absl::nullopt;
81
81
  uri = URI::Parse(*uri_str);
82
82
  if (!uri.ok() || uri->authority().empty()) {
@@ -116,7 +116,7 @@ constexpr absl::string_view kRls = "rls_experimental";
116
116
  const char kGrpc[] = "grpc";
117
117
  const char* kRlsRequestPath = "/grpc.lookup.v1.RouteLookupService/RouteLookup";
118
118
  const char* kFakeTargetFieldValue = "fake_target_field_value";
119
- const char* kRlsHeaderKey = "X-Google-RLS-Data";
119
+ const char* kRlsHeaderKey = "x-google-rls-data";
120
120
 
121
121
  const Duration kDefaultLookupServiceTimeout = Duration::Seconds(10);
122
122
  const Duration kMaxMaxAge = Duration::Minutes(5);
@@ -149,7 +149,8 @@ static void enc_flush_some(huff_out* out) {
149
149
  }
150
150
  }
151
151
 
152
- static void enc_add2(huff_out* out, uint8_t a, uint8_t b) {
152
+ static void enc_add2(huff_out* out, uint8_t a, uint8_t b, uint32_t* wire_size) {
153
+ *wire_size += 2;
153
154
  b64_huff_sym sa = huff_alphabet[a];
154
155
  b64_huff_sym sb = huff_alphabet[b];
155
156
  out->temp = (out->temp << (sa.length + sb.length)) |
@@ -159,7 +160,8 @@ static void enc_add2(huff_out* out, uint8_t a, uint8_t b) {
159
160
  enc_flush_some(out);
160
161
  }
161
162
 
162
- static void enc_add1(huff_out* out, uint8_t a) {
163
+ static void enc_add1(huff_out* out, uint8_t a, uint32_t* wire_size) {
164
+ *wire_size += 1;
163
165
  b64_huff_sym sa = huff_alphabet[a];
164
166
  out->temp = (out->temp << sa.length) | sa.bits;
165
167
  out->temp_length += sa.length;
@@ -167,7 +169,7 @@ static void enc_add1(huff_out* out, uint8_t a) {
167
169
  }
168
170
 
169
171
  grpc_slice grpc_chttp2_base64_encode_and_huffman_compress(
170
- const grpc_slice& input) {
172
+ const grpc_slice& input, uint32_t* wire_size) {
171
173
  size_t input_length = GRPC_SLICE_LENGTH(input);
172
174
  size_t input_triplets = input_length / 3;
173
175
  size_t tail_case = input_length % 3;
@@ -183,16 +185,17 @@ grpc_slice grpc_chttp2_base64_encode_and_huffman_compress(
183
185
  out.temp = 0;
184
186
  out.temp_length = 0;
185
187
  out.out = start_out;
188
+ *wire_size = 0;
186
189
 
187
190
  // encode full triplets
188
191
  for (i = 0; i < input_triplets; i++) {
189
192
  const uint8_t low_to_high = static_cast<uint8_t>((in[0] & 0x3) << 4);
190
193
  const uint8_t high_to_low = in[1] >> 4;
191
- enc_add2(&out, in[0] >> 2, low_to_high | high_to_low);
194
+ enc_add2(&out, in[0] >> 2, low_to_high | high_to_low, wire_size);
192
195
 
193
196
  const uint8_t a = static_cast<uint8_t>((in[1] & 0xf) << 2);
194
197
  const uint8_t b = (in[2] >> 6);
195
- enc_add2(&out, a | b, in[2] & 0x3f);
198
+ enc_add2(&out, a | b, in[2] & 0x3f, wire_size);
196
199
  in += 3;
197
200
  }
198
201
 
@@ -201,14 +204,15 @@ grpc_slice grpc_chttp2_base64_encode_and_huffman_compress(
201
204
  case 0:
202
205
  break;
203
206
  case 1:
204
- enc_add2(&out, in[0] >> 2, static_cast<uint8_t>((in[0] & 0x3) << 4));
207
+ enc_add2(&out, in[0] >> 2, static_cast<uint8_t>((in[0] & 0x3) << 4),
208
+ wire_size);
205
209
  in += 1;
206
210
  break;
207
211
  case 2: {
208
212
  const uint8_t low_to_high = static_cast<uint8_t>((in[0] & 0x3) << 4);
209
213
  const uint8_t high_to_low = in[1] >> 4;
210
- enc_add2(&out, in[0] >> 2, low_to_high | high_to_low);
211
- enc_add1(&out, static_cast<uint8_t>((in[1] & 0xf) << 2));
214
+ enc_add2(&out, in[0] >> 2, low_to_high | high_to_low, wire_size);
215
+ enc_add1(&out, static_cast<uint8_t>((in[1] & 0xf) << 2), wire_size);
212
216
  in += 2;
213
217
  break;
214
218
  }
@@ -21,6 +21,8 @@
21
21
 
22
22
  #include <grpc/support/port_platform.h>
23
23
 
24
+ #include <stdint.h>
25
+
24
26
  #include <grpc/slice.h>
25
27
 
26
28
  // base64 encode a slice. Returns a new slice, does not take ownership of the
@@ -36,7 +38,9 @@ grpc_slice grpc_chttp2_huffman_compress(const grpc_slice& input);
36
38
  // grpc_slice y = grpc_chttp2_huffman_compress(x);
37
39
  // grpc_core::CSliceUnref( x);
38
40
  // return y;
41
+ // *wire_size is the length of the base64 encoded string prior to huffman
42
+ // compression (as is needed for hpack table math)
39
43
  grpc_slice grpc_chttp2_base64_encode_and_huffman_compress(
40
- const grpc_slice& input);
44
+ const grpc_slice& input, uint32_t* wire_size);
41
45
 
42
46
  #endif // GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_ENCODER_H
@@ -96,7 +96,8 @@
96
96
  #define DEFAULT_CONNECTION_WINDOW_TARGET (1024 * 1024)
97
97
  #define MAX_WINDOW 0x7fffffffu
98
98
  #define MAX_WRITE_BUFFER_SIZE (64 * 1024 * 1024)
99
- #define DEFAULT_MAX_HEADER_LIST_SIZE (8 * 1024)
99
+ #define DEFAULT_MAX_HEADER_LIST_SIZE (16 * 1024)
100
+ #define DEFAULT_MAX_HEADER_LIST_SIZE_SOFT_LIMIT (8 * 1024)
100
101
 
101
102
  #define DEFAULT_CLIENT_KEEPALIVE_TIME_MS INT_MAX
102
103
  #define DEFAULT_CLIENT_KEEPALIVE_TIMEOUT_MS 20000 // 20 seconds
@@ -348,6 +349,21 @@ static void read_channel_args(grpc_chttp2_transport* t,
348
349
  .GetObjectRef<grpc_core::channelz::SocketNode::Security>());
349
350
  }
350
351
 
352
+ const int soft_limit =
353
+ channel_args.GetInt(GRPC_ARG_MAX_METADATA_SIZE).value_or(-1);
354
+ if (soft_limit < 0) {
355
+ // Set soft limit to 0.8 * hard limit if this is larger than
356
+ // `DEFAULT_MAX_HEADER_LIST_SIZE_SOFT_LIMIT` and
357
+ // `GRPC_ARG_MAX_METADATA_SIZE` is not set.
358
+ t->max_header_list_size_soft_limit = std::max(
359
+ DEFAULT_MAX_HEADER_LIST_SIZE_SOFT_LIMIT,
360
+ static_cast<int>(
361
+ 0.8 * channel_args.GetInt(GRPC_ARG_ABSOLUTE_MAX_METADATA_SIZE)
362
+ .value_or(-1)));
363
+ } else {
364
+ t->max_header_list_size_soft_limit = soft_limit;
365
+ }
366
+
351
367
  static const struct {
352
368
  absl::string_view channel_arg_name;
353
369
  grpc_chttp2_setting_id setting_id;
@@ -367,7 +383,7 @@ static void read_channel_args(grpc_chttp2_transport* t,
367
383
  0,
368
384
  INT32_MAX,
369
385
  {true, true}},
370
- {GRPC_ARG_MAX_METADATA_SIZE,
386
+ {GRPC_ARG_ABSOLUTE_MAX_METADATA_SIZE,
371
387
  GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE,
372
388
  -1,
373
389
  0,
@@ -400,6 +416,21 @@ static void read_channel_args(grpc_chttp2_transport* t,
400
416
  if (value >= 0) {
401
417
  queue_setting_update(t, setting.setting_id,
402
418
  grpc_core::Clamp(value, setting.min, setting.max));
419
+ } else if (setting.setting_id ==
420
+ GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE) {
421
+ // Set value to 1.25 * soft limit if this is larger than
422
+ // `DEFAULT_MAX_HEADER_LIST_SIZE` and
423
+ // `GRPC_ARG_ABSOLUTE_MAX_METADATA_SIZE` is not set.
424
+ const int soft_limit = channel_args.GetInt(GRPC_ARG_MAX_METADATA_SIZE)
425
+ .value_or(setting.default_value);
426
+ const int value = (soft_limit < (INT_MAX / 1.25))
427
+ ? static_cast<int>(soft_limit * 1.25)
428
+ : soft_limit;
429
+ if (value > DEFAULT_MAX_HEADER_LIST_SIZE) {
430
+ queue_setting_update(
431
+ t, setting.setting_id,
432
+ grpc_core::Clamp(value, setting.min, setting.max));
433
+ }
403
434
  }
404
435
  } else if (channel_args.Contains(setting.channel_arg_name)) {
405
436
  gpr_log(GPR_DEBUG, "%s is not available on %s",