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.

Files changed (221) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +65 -37
  3. data/include/grpc/grpc.h +15 -1
  4. data/include/grpc/impl/codegen/port_platform.h +2 -0
  5. data/src/core/ext/filters/client_channel/client_channel.cc +327 -305
  6. data/src/core/ext/filters/client_channel/client_channel_factory.h +2 -1
  7. data/src/core/ext/filters/client_channel/config_selector.h +8 -0
  8. data/src/core/ext/filters/client_channel/dynamic_filters.cc +9 -4
  9. data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +24 -142
  10. data/src/core/ext/filters/client_channel/global_subchannel_pool.h +15 -10
  11. data/src/core/ext/filters/client_channel/lb_policy.cc +3 -0
  12. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +23 -0
  13. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +27 -0
  14. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +7 -22
  15. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +1 -1
  16. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +2 -2
  17. data/src/core/ext/filters/client_channel/local_subchannel_pool.cc +27 -67
  18. data/src/core/ext/filters/client_channel/local_subchannel_pool.h +10 -9
  19. data/src/core/ext/filters/client_channel/resolver.cc +3 -0
  20. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +2 -2
  21. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +3 -1
  22. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +5 -9
  23. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +18 -3
  24. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +295 -91
  25. data/src/core/ext/filters/client_channel/server_address.cc +3 -0
  26. data/src/core/ext/filters/client_channel/subchannel.cc +69 -146
  27. data/src/core/ext/filters/client_channel/subchannel.h +63 -95
  28. data/src/core/ext/filters/client_channel/subchannel_pool_interface.cc +16 -2
  29. data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +10 -8
  30. data/src/core/ext/filters/client_idle/client_idle_filter.cc +1 -1
  31. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +495 -0
  32. data/src/core/ext/filters/fault_injection/fault_injection_filter.h +39 -0
  33. data/src/core/ext/filters/fault_injection/service_config_parser.cc +189 -0
  34. data/src/core/ext/filters/fault_injection/service_config_parser.h +85 -0
  35. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +1 -1
  36. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +1 -1
  37. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +3 -2
  38. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +1 -1
  39. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +3 -2
  40. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +457 -170
  41. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +1 -1
  42. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +39 -7
  43. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +12 -1
  44. data/src/core/ext/transport/chttp2/transport/frame_data.cc +5 -1
  45. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +1 -1
  46. data/src/core/ext/transport/chttp2/transport/internal.h +1 -0
  47. data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.c +406 -0
  48. data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.h +1459 -0
  49. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c +350 -0
  50. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.h +1348 -0
  51. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +6 -0
  52. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +25 -0
  53. data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.c +144 -0
  54. data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.h +488 -0
  55. data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.c +141 -0
  56. data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.h +452 -0
  57. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +15 -0
  58. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +44 -0
  59. data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.c +79 -0
  60. data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.h +268 -0
  61. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c +78 -0
  62. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.h +281 -0
  63. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +41 -0
  64. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +113 -0
  65. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +6 -5
  66. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +13 -9
  67. data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.c +93 -0
  68. data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.h +323 -0
  69. data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.c +36 -0
  70. data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.h +90 -0
  71. data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.c +46 -0
  72. data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.h +124 -0
  73. data/src/core/ext/upb-generated/udpa/type/v1/typed_struct.upb.c +33 -0
  74. data/src/core/ext/upb-generated/udpa/type/v1/typed_struct.upb.h +77 -0
  75. data/src/core/ext/upbdefs-generated/envoy/admin/v3/config_dump.upbdefs.c +354 -0
  76. data/src/core/ext/upbdefs-generated/envoy/admin/v3/config_dump.upbdefs.h +140 -0
  77. data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.c +383 -0
  78. data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.h +115 -0
  79. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +10 -7
  80. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.h +5 -0
  81. data/src/core/ext/upbdefs-generated/envoy/config/metrics/v3/stats.upbdefs.c +141 -0
  82. data/src/core/ext/upbdefs-generated/envoy/config/metrics/v3/stats.upbdefs.h +70 -0
  83. data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.c +141 -0
  84. data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.h +70 -0
  85. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +13 -7
  86. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.h +5 -0
  87. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/common/fault/v3/fault.upbdefs.c +102 -0
  88. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/common/fault/v3/fault.upbdefs.h +55 -0
  89. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.c +120 -0
  90. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.h +45 -0
  91. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.c +76 -0
  92. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.h +35 -0
  93. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +21 -20
  94. data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.c +130 -0
  95. data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.h +50 -0
  96. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/node.upbdefs.c +56 -0
  97. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/node.upbdefs.h +35 -0
  98. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/struct.upbdefs.c +63 -0
  99. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/struct.upbdefs.h +40 -0
  100. data/src/core/ext/upbdefs-generated/udpa/type/v1/typed_struct.upbdefs.c +44 -0
  101. data/src/core/ext/upbdefs-generated/udpa/type/v1/typed_struct.upbdefs.h +35 -0
  102. data/src/core/ext/xds/xds_api.cc +1591 -279
  103. data/src/core/ext/xds/xds_api.h +279 -39
  104. data/src/core/ext/xds/xds_bootstrap.cc +21 -5
  105. data/src/core/ext/xds/xds_bootstrap.h +5 -1
  106. data/src/core/ext/xds/xds_client.cc +168 -23
  107. data/src/core/ext/xds/xds_client.h +26 -0
  108. data/src/core/ext/xds/xds_client_stats.h +2 -2
  109. data/src/core/ext/xds/xds_http_fault_filter.cc +226 -0
  110. data/src/core/ext/xds/xds_http_fault_filter.h +63 -0
  111. data/src/core/ext/xds/xds_http_filters.cc +114 -0
  112. data/src/core/ext/xds/xds_http_filters.h +130 -0
  113. data/src/core/ext/xds/xds_server_config_fetcher.cc +391 -126
  114. data/src/core/lib/channel/channel_stack.cc +12 -0
  115. data/src/core/lib/channel/channel_stack.h +7 -0
  116. data/src/core/lib/channel/channelz.cc +92 -4
  117. data/src/core/lib/channel/channelz.h +30 -1
  118. data/src/core/lib/channel/channelz_registry.cc +14 -0
  119. data/src/core/lib/channel/handshaker.cc +0 -39
  120. data/src/core/lib/channel/handshaker.h +0 -17
  121. data/src/core/lib/channel/status_util.cc +12 -2
  122. data/src/core/lib/channel/status_util.h +5 -0
  123. data/src/core/lib/gpr/sync_abseil.cc +3 -6
  124. data/src/core/lib/gpr/sync_windows.cc +2 -2
  125. data/src/core/lib/gprpp/atomic.h +3 -3
  126. data/src/core/lib/gprpp/dual_ref_counted.h +3 -3
  127. data/src/core/lib/gprpp/ref_counted_ptr.h +2 -0
  128. data/src/core/lib/gprpp/thd.h +1 -1
  129. data/src/core/lib/iomgr/buffer_list.h +1 -1
  130. data/src/core/lib/iomgr/cfstream_handle.cc +2 -2
  131. data/src/core/lib/iomgr/error.h +1 -1
  132. data/src/core/lib/iomgr/ev_apple.cc +1 -1
  133. data/src/core/lib/iomgr/ev_epoll1_linux.cc +3 -3
  134. data/src/core/lib/iomgr/ev_posix.cc +3 -3
  135. data/src/core/lib/iomgr/exec_ctx.cc +6 -2
  136. data/src/core/lib/iomgr/resource_quota.cc +1 -1
  137. data/src/core/lib/iomgr/sockaddr_utils.cc +120 -0
  138. data/src/core/lib/iomgr/sockaddr_utils.h +25 -0
  139. data/src/core/lib/iomgr/tcp_posix.cc +1 -4
  140. data/src/core/lib/iomgr/tcp_uv.cc +2 -2
  141. data/src/core/lib/iomgr/timer_generic.cc +2 -2
  142. data/src/core/lib/iomgr/timer_manager.cc +1 -1
  143. data/src/core/lib/iomgr/wakeup_fd_nospecial.cc +1 -1
  144. data/src/core/lib/{security/authorization → matchers}/matchers.cc +8 -8
  145. data/src/core/lib/{security/authorization → matchers}/matchers.h +14 -12
  146. data/src/core/lib/security/security_connector/ssl_utils.cc +6 -4
  147. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +6 -0
  148. data/src/core/lib/security/transport/security_handshaker.cc +32 -2
  149. data/src/core/lib/slice/slice_intern.cc +6 -7
  150. data/src/core/lib/surface/channel.h +3 -3
  151. data/src/core/lib/surface/completion_queue.cc +1 -1
  152. data/src/core/lib/surface/lame_client.cc +38 -19
  153. data/src/core/lib/surface/lame_client.h +4 -3
  154. data/src/core/lib/surface/server.cc +40 -33
  155. data/src/core/lib/surface/server.h +74 -15
  156. data/src/core/lib/surface/version.cc +1 -1
  157. data/src/core/lib/transport/metadata_batch.cc +27 -0
  158. data/src/core/lib/transport/metadata_batch.h +14 -0
  159. data/src/core/plugin_registry/grpc_plugin_registry.cc +6 -0
  160. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +1 -4
  161. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +1 -1
  162. data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +1 -3
  163. data/src/core/tsi/fake_transport_security.cc +10 -1
  164. data/src/ruby/ext/grpc/extconf.rb +9 -1
  165. data/src/ruby/ext/grpc/rb_channel.c +10 -1
  166. data/src/ruby/ext/grpc/rb_channel_credentials.c +11 -1
  167. data/src/ruby/ext/grpc/rb_channel_credentials.h +4 -0
  168. data/src/ruby/ext/grpc/rb_compression_options.c +1 -1
  169. data/src/ruby/ext/grpc/rb_enable_cpp.cc +1 -1
  170. data/src/ruby/ext/grpc/rb_grpc.c +4 -0
  171. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
  172. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +4 -1
  173. data/src/ruby/ext/grpc/rb_server.c +13 -1
  174. data/src/ruby/ext/grpc/rb_server_credentials.c +19 -3
  175. data/src/ruby/ext/grpc/rb_server_credentials.h +4 -0
  176. data/src/ruby/ext/grpc/rb_xds_channel_credentials.c +215 -0
  177. data/src/ruby/ext/grpc/rb_xds_channel_credentials.h +35 -0
  178. data/src/ruby/ext/grpc/rb_xds_server_credentials.c +169 -0
  179. data/src/ruby/ext/grpc/rb_xds_server_credentials.h +35 -0
  180. data/src/ruby/lib/grpc/generic/client_stub.rb +4 -2
  181. data/src/ruby/lib/grpc/version.rb +1 -1
  182. data/src/ruby/spec/call_spec.rb +1 -1
  183. data/src/ruby/spec/channel_credentials_spec.rb +32 -0
  184. data/src/ruby/spec/channel_spec.rb +17 -6
  185. data/src/ruby/spec/client_auth_spec.rb +27 -1
  186. data/src/ruby/spec/errors_spec.rb +1 -1
  187. data/src/ruby/spec/generic/active_call_spec.rb +2 -2
  188. data/src/ruby/spec/generic/client_stub_spec.rb +4 -4
  189. data/src/ruby/spec/generic/rpc_server_spec.rb +1 -1
  190. data/src/ruby/spec/server_credentials_spec.rb +25 -0
  191. data/src/ruby/spec/server_spec.rb +22 -0
  192. data/third_party/boringssl-with-bazel/err_data.c +255 -255
  193. data/third_party/boringssl-with-bazel/src/crypto/cpu-arm-linux.c +11 -2
  194. data/third_party/boringssl-with-bazel/src/crypto/cpu-arm.c +3 -3
  195. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/cipher.c +21 -13
  196. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +7 -5
  197. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +0 -28
  198. data/third_party/boringssl-with-bazel/src/crypto/x509/x_attrib.c +22 -17
  199. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +3 -1
  200. data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +4 -0
  201. data/third_party/boringssl-with-bazel/src/include/openssl/cpu.h +22 -32
  202. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +25 -9
  203. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +0 -1
  204. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +33 -19
  205. data/third_party/xxhash/xxhash.h +5443 -0
  206. metadata +93 -49
  207. data/src/core/lib/security/authorization/authorization_engine.cc +0 -177
  208. data/src/core/lib/security/authorization/authorization_engine.h +0 -84
  209. data/src/core/lib/security/authorization/evaluate_args.cc +0 -148
  210. data/src/core/lib/security/authorization/evaluate_args.h +0 -59
  211. data/src/core/lib/security/authorization/mock_cel/activation.h +0 -57
  212. data/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h +0 -44
  213. data/src/core/lib/security/authorization/mock_cel/cel_expression.h +0 -69
  214. data/src/core/lib/security/authorization/mock_cel/cel_value.h +0 -99
  215. data/src/core/lib/security/authorization/mock_cel/evaluator_core.h +0 -67
  216. data/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h +0 -57
  217. data/third_party/abseil-cpp/absl/container/flat_hash_set.h +0 -504
  218. data/third_party/upb/upb/json_decode.c +0 -1443
  219. data/third_party/upb/upb/json_decode.h +0 -23
  220. data/third_party/upb/upb/json_encode.c +0 -713
  221. data/third_party/upb/upb/json_encode.h +0 -36
@@ -33,10 +33,12 @@
33
33
 
34
34
  #include <grpc/slice_buffer.h>
35
35
 
36
+ #include "envoy/admin/v3/config_dump.upb.h"
36
37
  #include "src/core/ext/filters/client_channel/server_address.h"
37
38
  #include "src/core/ext/xds/xds_bootstrap.h"
38
39
  #include "src/core/ext/xds/xds_client_stats.h"
39
- #include "src/core/lib/security/authorization/matchers.h"
40
+ #include "src/core/ext/xds/xds_http_filters.h"
41
+ #include "src/core/lib/matchers/matchers.h"
40
42
 
41
43
  namespace grpc_core {
42
44
 
@@ -58,13 +60,16 @@ class XdsApi {
58
60
  int64_t seconds = 0;
59
61
  int32_t nanos = 0;
60
62
  bool operator==(const Duration& other) const {
61
- return (seconds == other.seconds && nanos == other.nanos);
63
+ return seconds == other.seconds && nanos == other.nanos;
62
64
  }
63
65
  std::string ToString() const {
64
66
  return absl::StrFormat("Duration seconds: %ld, nanos %d", seconds, nanos);
65
67
  }
66
68
  };
67
69
 
70
+ using TypedPerFilterConfig =
71
+ std::map<std::string, XdsHttpFilterImpl::FilterConfig>;
72
+
68
73
  // TODO(donnadionne): When we can use absl::variant<>, consider using that
69
74
  // for: PathMatcher, HeaderMatcher, cluster_name and weighted_clusters
70
75
  struct Route {
@@ -75,14 +80,38 @@ class XdsApi {
75
80
  absl::optional<uint32_t> fraction_per_million;
76
81
 
77
82
  bool operator==(const Matchers& other) const {
78
- return (path_matcher == other.path_matcher &&
79
- header_matchers == other.header_matchers &&
80
- fraction_per_million == other.fraction_per_million);
83
+ return path_matcher == other.path_matcher &&
84
+ header_matchers == other.header_matchers &&
85
+ fraction_per_million == other.fraction_per_million;
81
86
  }
82
87
  std::string ToString() const;
83
88
  };
84
89
 
90
+ struct HashPolicy {
91
+ enum Type { HEADER, CHANNEL_ID };
92
+ Type type;
93
+ bool terminal = false;
94
+ // Fields used for type HEADER.
95
+ std::string header_name;
96
+ std::unique_ptr<RE2> regex = nullptr;
97
+ std::string regex_substitution;
98
+
99
+ HashPolicy() {}
100
+
101
+ // Copyable.
102
+ HashPolicy(const HashPolicy& other);
103
+ HashPolicy& operator=(const HashPolicy& other);
104
+
105
+ // Moveable.
106
+ HashPolicy(HashPolicy&& other) noexcept;
107
+ HashPolicy& operator=(HashPolicy&& other) noexcept;
108
+
109
+ bool operator==(const HashPolicy& other) const;
110
+ std::string ToString() const;
111
+ };
112
+
85
113
  Matchers matchers;
114
+ std::vector<HashPolicy> hash_policies;
86
115
 
87
116
  // Action for this route.
88
117
  // TODO(roth): When we can use absl::variant<>, consider using that
@@ -91,8 +120,11 @@ class XdsApi {
91
120
  struct ClusterWeight {
92
121
  std::string name;
93
122
  uint32_t weight;
123
+ TypedPerFilterConfig typed_per_filter_config;
124
+
94
125
  bool operator==(const ClusterWeight& other) const {
95
- return (name == other.name && weight == other.weight);
126
+ return name == other.name && weight == other.weight &&
127
+ typed_per_filter_config == other.typed_per_filter_config;
96
128
  }
97
129
  std::string ToString() const;
98
130
  };
@@ -103,11 +135,13 @@ class XdsApi {
103
135
  // not set.
104
136
  absl::optional<Duration> max_stream_duration;
105
137
 
138
+ TypedPerFilterConfig typed_per_filter_config;
139
+
106
140
  bool operator==(const Route& other) const {
107
- return (matchers == other.matchers &&
108
- cluster_name == other.cluster_name &&
109
- weighted_clusters == other.weighted_clusters &&
110
- max_stream_duration == other.max_stream_duration);
141
+ return matchers == other.matchers && cluster_name == other.cluster_name &&
142
+ weighted_clusters == other.weighted_clusters &&
143
+ max_stream_duration == other.max_stream_duration &&
144
+ typed_per_filter_config == other.typed_per_filter_config;
111
145
  }
112
146
  std::string ToString() const;
113
147
  };
@@ -116,9 +150,11 @@ class XdsApi {
116
150
  struct VirtualHost {
117
151
  std::vector<std::string> domains;
118
152
  std::vector<Route> routes;
153
+ TypedPerFilterConfig typed_per_filter_config;
119
154
 
120
155
  bool operator==(const VirtualHost& other) const {
121
- return domains == other.domains && routes == other.routes;
156
+ return domains == other.domains && routes == other.routes &&
157
+ typed_per_filter_config == other.typed_per_filter_config;
122
158
  }
123
159
  };
124
160
 
@@ -204,29 +240,157 @@ class XdsApi {
204
240
  kTcpListener = 0,
205
241
  kHttpApiListener,
206
242
  } type;
207
- DownstreamTlsContext downstream_tls_context;
208
- // The name to use in the RDS request.
209
- std::string route_config_name;
210
- // Storing the Http Connection Manager Common Http Protocol Option
211
- // max_stream_duration
212
- Duration http_max_stream_duration;
213
- // The RouteConfiguration to use for this listener.
214
- // Present only if it is inlined in the LDS response.
215
- absl::optional<RdsUpdate> rds_update;
243
+
244
+ struct HttpConnectionManager {
245
+ // The name to use in the RDS request.
246
+ std::string route_config_name;
247
+ // Storing the Http Connection Manager Common Http Protocol Option
248
+ // max_stream_duration
249
+ Duration http_max_stream_duration;
250
+ // The RouteConfiguration to use for this listener.
251
+ // Present only if it is inlined in the LDS response.
252
+ absl::optional<RdsUpdate> rds_update;
253
+
254
+ struct HttpFilter {
255
+ std::string name;
256
+ XdsHttpFilterImpl::FilterConfig config;
257
+
258
+ bool operator==(const HttpFilter& other) const {
259
+ return name == other.name && config == other.config;
260
+ }
261
+
262
+ std::string ToString() const;
263
+ };
264
+ std::vector<HttpFilter> http_filters;
265
+
266
+ bool operator==(const HttpConnectionManager& other) const {
267
+ return route_config_name == other.route_config_name &&
268
+ http_max_stream_duration == other.http_max_stream_duration &&
269
+ rds_update == other.rds_update &&
270
+ http_filters == other.http_filters;
271
+ }
272
+
273
+ std::string ToString() const;
274
+ };
275
+
276
+ // Populated for type=kHttpApiListener.
277
+ HttpConnectionManager http_connection_manager;
278
+
279
+ // Populated for type=kTcpListener.
280
+ // host:port listening_address set when type is kTcpListener
281
+ std::string address;
282
+
283
+ struct FilterChainData {
284
+ DownstreamTlsContext downstream_tls_context;
285
+ // This is in principle the filter list.
286
+ // We currently require exactly one filter, which is the HCM.
287
+ HttpConnectionManager http_connection_manager;
288
+
289
+ bool operator==(const FilterChainData& other) const {
290
+ return downstream_tls_context == other.downstream_tls_context &&
291
+ http_connection_manager == other.http_connection_manager;
292
+ }
293
+
294
+ std::string ToString() const;
295
+ } filter_chain_data;
296
+
297
+ // A multi-level map used to determine which filter chain to use for a given
298
+ // incoming connection. Determining the right filter chain for a given
299
+ // connection checks the following properties, in order:
300
+ // - destination port (never matched, so not present in map)
301
+ // - destination IP address
302
+ // - server name (never matched, so not present in map)
303
+ // - transport protocol (allows only "raw_buffer" or unset, prefers the
304
+ // former, so only one of those two types is present in map)
305
+ // - application protocol (never matched, so not present in map)
306
+ // - connection source type (any, local or external)
307
+ // - source IP address
308
+ // - source port
309
+ // https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/listener/v3/listener_components.proto#config-listener-v3-filterchainmatch
310
+ // for more details
311
+ struct FilterChainMap {
312
+ struct FilterChainDataSharedPtr {
313
+ std::shared_ptr<FilterChainData> data;
314
+ bool operator==(const FilterChainDataSharedPtr& other) const {
315
+ return *data == *other.data;
316
+ }
317
+ };
318
+ struct CidrRange {
319
+ grpc_resolved_address address;
320
+ uint32_t prefix_len;
321
+
322
+ bool operator==(const CidrRange& other) const {
323
+ return memcmp(&address, &other.address, sizeof(address)) == 0 &&
324
+ prefix_len == other.prefix_len;
325
+ }
326
+
327
+ std::string ToString() const;
328
+ };
329
+ using SourcePortsMap = std::map<uint16_t, FilterChainDataSharedPtr>;
330
+ struct SourceIp {
331
+ absl::optional<CidrRange> prefix_range;
332
+ SourcePortsMap ports_map;
333
+
334
+ bool operator==(const SourceIp& other) const {
335
+ return prefix_range == other.prefix_range &&
336
+ ports_map == other.ports_map;
337
+ }
338
+ };
339
+ using SourceIpVector = std::vector<SourceIp>;
340
+ enum class ConnectionSourceType {
341
+ kAny = 0,
342
+ kSameIpOrLoopback,
343
+ kExternal
344
+ };
345
+ using ConnectionSourceTypesArray = std::array<SourceIpVector, 3>;
346
+ struct DestinationIp {
347
+ absl::optional<CidrRange> prefix_range;
348
+ // We always fail match on server name, so those filter chains are not
349
+ // included here.
350
+ ConnectionSourceTypesArray source_types_array;
351
+
352
+ bool operator==(const DestinationIp& other) const {
353
+ return prefix_range == other.prefix_range &&
354
+ source_types_array == other.source_types_array;
355
+ }
356
+ };
357
+ // We always fail match on destination ports map
358
+ using DestinationIpVector = std::vector<DestinationIp>;
359
+ DestinationIpVector destination_ip_vector;
360
+
361
+ bool operator==(const FilterChainMap& other) const {
362
+ return destination_ip_vector == other.destination_ip_vector;
363
+ }
364
+
365
+ std::string ToString() const;
366
+ } filter_chain_map;
367
+
368
+ absl::optional<FilterChainData> default_filter_chain;
216
369
 
217
370
  bool operator==(const LdsUpdate& other) const {
218
- return downstream_tls_context == other.downstream_tls_context &&
219
- route_config_name == other.route_config_name &&
220
- rds_update == other.rds_update &&
221
- http_max_stream_duration == other.http_max_stream_duration;
371
+ return http_connection_manager == other.http_connection_manager &&
372
+ address == other.address &&
373
+ filter_chain_map == other.filter_chain_map &&
374
+ default_filter_chain == other.default_filter_chain;
222
375
  }
223
376
 
224
377
  std::string ToString() const;
225
378
  };
226
379
 
227
- using LdsUpdateMap = std::map<std::string /*server_name*/, LdsUpdate>;
380
+ struct LdsResourceData {
381
+ LdsUpdate resource;
382
+ std::string serialized_proto;
383
+ };
228
384
 
229
- using RdsUpdateMap = std::map<std::string /*route_config_name*/, RdsUpdate>;
385
+ using LdsUpdateMap = std::map<std::string /*server_name*/, LdsResourceData>;
386
+
387
+ struct RdsResourceData {
388
+ RdsUpdate resource;
389
+ std::string serialized_proto;
390
+ };
391
+
392
+ using RdsUpdateMap =
393
+ std::map<std::string /*route_config_name*/, RdsResourceData>;
230
394
 
231
395
  struct CdsUpdate {
232
396
  enum ClusterType { EDS, LOGICAL_DNS, AGGREGATE };
@@ -269,7 +433,12 @@ class XdsApi {
269
433
  std::string ToString() const;
270
434
  };
271
435
 
272
- using CdsUpdateMap = std::map<std::string /*cluster_name*/, CdsUpdate>;
436
+ struct CdsResourceData {
437
+ CdsUpdate resource;
438
+ std::string serialized_proto;
439
+ };
440
+
441
+ using CdsUpdateMap = std::map<std::string /*cluster_name*/, CdsResourceData>;
273
442
 
274
443
  struct EdsUpdate {
275
444
  struct Priority {
@@ -353,7 +522,13 @@ class XdsApi {
353
522
  std::string ToString() const;
354
523
  };
355
524
 
356
- using EdsUpdateMap = std::map<std::string /*eds_service_name*/, EdsUpdate>;
525
+ struct EdsResourceData {
526
+ EdsUpdate resource;
527
+ std::string serialized_proto;
528
+ };
529
+
530
+ using EdsUpdateMap =
531
+ std::map<std::string /*eds_service_name*/, EdsResourceData>;
357
532
 
358
533
  struct ClusterLoadReport {
359
534
  XdsClusterDropStats::Snapshot dropped_requests;
@@ -366,18 +541,66 @@ class XdsApi {
366
541
  std::pair<std::string /*cluster_name*/, std::string /*eds_service_name*/>,
367
542
  ClusterLoadReport>;
368
543
 
369
- XdsApi(XdsClient* client, TraceFlag* tracer, const XdsBootstrap::Node* node);
544
+ // The metadata of the xDS resource; used by the xDS config dump.
545
+ struct ResourceMetadata {
546
+ // Resource status from the view of a xDS client, which tells the
547
+ // synchronization status between the xDS client and the xDS server.
548
+ enum ClientResourceStatus {
549
+ // Client requested this resource but hasn't received any update from
550
+ // management server. The client will not fail requests, but will queue
551
+ // them
552
+ // until update arrives or the client times out waiting for the resource.
553
+ REQUESTED = 1,
554
+ // This resource has been requested by the client but has either not been
555
+ // delivered by the server or was previously delivered by the server and
556
+ // then subsequently removed from resources provided by the server.
557
+ DOES_NOT_EXIST,
558
+ // Client received this resource and replied with ACK.
559
+ ACKED,
560
+ // Client received this resource and replied with NACK.
561
+ NACKED
562
+ };
370
563
 
371
- // Creates an ADS request.
372
- // Takes ownership of \a error.
373
- grpc_slice CreateAdsRequest(const XdsBootstrap::XdsServer& server,
374
- const std::string& type_url,
375
- const std::set<absl::string_view>& resource_names,
376
- const std::string& version,
377
- const std::string& nonce, grpc_error* error,
378
- bool populate_node);
564
+ // The client status of this resource.
565
+ ClientResourceStatus client_status = REQUESTED;
566
+ // The serialized bytes of the last successfully updated raw xDS resource.
567
+ std::string serialized_proto;
568
+ // The timestamp when the resource was last successfully updated.
569
+ grpc_millis update_time = 0;
570
+ // The last successfully updated version of the resource.
571
+ std::string version;
572
+ // The rejected version string of the last failed update attempt.
573
+ std::string failed_version;
574
+ // Details about the last failed update attempt.
575
+ std::string failed_details;
576
+ // Timestamp of the last failed update attempt.
577
+ grpc_millis failed_update_time = 0;
578
+ };
579
+ using ResourceMetadataMap =
580
+ std::map<absl::string_view /*resource_name*/, const ResourceMetadata*>;
581
+ struct ResourceTypeMetadata {
582
+ absl::string_view version;
583
+ ResourceMetadataMap resource_metadata_map;
584
+ };
585
+ using ResourceTypeMetadataMap =
586
+ std::map<absl::string_view /*type_url*/, ResourceTypeMetadata>;
587
+ static_assert(static_cast<ResourceMetadata::ClientResourceStatus>(
588
+ envoy_admin_v3_REQUESTED) ==
589
+ ResourceMetadata::ClientResourceStatus::REQUESTED,
590
+ "");
591
+ static_assert(static_cast<ResourceMetadata::ClientResourceStatus>(
592
+ envoy_admin_v3_DOES_NOT_EXIST) ==
593
+ ResourceMetadata::ClientResourceStatus::DOES_NOT_EXIST,
594
+ "");
595
+ static_assert(static_cast<ResourceMetadata::ClientResourceStatus>(
596
+ envoy_admin_v3_ACKED) ==
597
+ ResourceMetadata::ClientResourceStatus::ACKED,
598
+ "");
599
+ static_assert(static_cast<ResourceMetadata::ClientResourceStatus>(
600
+ envoy_admin_v3_NACKED) ==
601
+ ResourceMetadata::ClientResourceStatus::NACKED,
602
+ "");
379
603
 
380
- // Parses an ADS response.
381
604
  // If the response can't be parsed at the top level, the resulting
382
605
  // type_url will be empty.
383
606
  // If there is any other type of validation error, the parse_error
@@ -396,8 +619,21 @@ class XdsApi {
396
619
  EdsUpdateMap eds_update_map;
397
620
  std::set<std::string> resource_names_failed;
398
621
  };
622
+
623
+ XdsApi(XdsClient* client, TraceFlag* tracer, const XdsBootstrap::Node* node);
624
+
625
+ // Creates an ADS request.
626
+ // Takes ownership of \a error.
627
+ grpc_slice CreateAdsRequest(const XdsBootstrap::XdsServer& server,
628
+ const std::string& type_url,
629
+ const std::set<absl::string_view>& resource_names,
630
+ const std::string& version,
631
+ const std::string& nonce, grpc_error* error,
632
+ bool populate_node);
633
+
634
+ // Parses an ADS response.
399
635
  AdsParseResult ParseAdsResponse(
400
- const grpc_slice& encoded_response,
636
+ const XdsBootstrap::XdsServer& server, const grpc_slice& encoded_response,
401
637
  const std::set<absl::string_view>& expected_listener_names,
402
638
  const std::set<absl::string_view>& expected_route_configuration_names,
403
639
  const std::set<absl::string_view>& expected_cluster_names,
@@ -417,6 +653,10 @@ class XdsApi {
417
653
  std::set<std::string>* cluster_names,
418
654
  grpc_millis* load_reporting_interval);
419
655
 
656
+ // Assemble the client config proto message and return the serialized result.
657
+ std::string AssembleClientConfig(
658
+ const ResourceTypeMetadataMap& resource_type_metadata_map);
659
+
420
660
  private:
421
661
  XdsClient* client_;
422
662
  TraceFlag* tracer_;
@@ -93,13 +93,14 @@ std::string BootstrapString(const XdsBootstrap& bootstrap) {
93
93
  " locality={\n"
94
94
  " region=\"%s\",\n"
95
95
  " zone=\"%s\",\n"
96
- " subzone=\"%s\"\n"
96
+ " sub_zone=\"%s\"\n"
97
97
  " },\n"
98
98
  " metadata=%s,\n"
99
99
  "},\n",
100
100
  bootstrap.node()->id, bootstrap.node()->cluster,
101
101
  bootstrap.node()->locality_region, bootstrap.node()->locality_zone,
102
- bootstrap.node()->locality_subzone, bootstrap.node()->metadata.Dump()));
102
+ bootstrap.node()->locality_sub_zone,
103
+ bootstrap.node()->metadata.Dump()));
103
104
  }
104
105
  parts.push_back(absl::StrFormat(
105
106
  "servers=[\n"
@@ -118,6 +119,11 @@ std::string BootstrapString(const XdsBootstrap& bootstrap) {
118
119
  absl::StrJoin(bootstrap.server().server_features, ", "), "],\n"));
119
120
  }
120
121
  parts.push_back(" }\n],\n");
122
+ if (!bootstrap.server_listener_resource_name_template().empty()) {
123
+ parts.push_back(
124
+ absl::StrFormat("server_listener_resource_name_template=\"%s\",\n",
125
+ bootstrap.server_listener_resource_name_template()));
126
+ }
121
127
  parts.push_back("certificate_providers={\n");
122
128
  for (const auto& entry : bootstrap.certificate_providers()) {
123
129
  parts.push_back(
@@ -232,6 +238,16 @@ XdsBootstrap::XdsBootstrap(Json json, grpc_error** error) {
232
238
  if (parse_error != GRPC_ERROR_NONE) error_list.push_back(parse_error);
233
239
  }
234
240
  }
241
+ it = json.mutable_object()->find("server_listener_resource_name_template");
242
+ if (it != json.mutable_object()->end()) {
243
+ if (it->second.type() != Json::Type::STRING) {
244
+ error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
245
+ "\"server_listener_resource_name_template\" field is not a string"));
246
+ } else {
247
+ server_listener_resource_name_template_ =
248
+ std::move(*it->second.mutable_string_value());
249
+ }
250
+ }
235
251
  if (XdsSecurityEnabled()) {
236
252
  it = json.mutable_object()->find("certificate_providers");
237
253
  if (it != json.mutable_object()->end()) {
@@ -455,13 +471,13 @@ grpc_error* XdsBootstrap::ParseLocality(Json* json) {
455
471
  node_->locality_zone = std::move(*it->second.mutable_string_value());
456
472
  }
457
473
  }
458
- it = json->mutable_object()->find("subzone");
474
+ it = json->mutable_object()->find("sub_zone");
459
475
  if (it != json->mutable_object()->end()) {
460
476
  if (it->second.type() != Json::Type::STRING) {
461
477
  error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
462
- "\"subzone\" field is not a string"));
478
+ "\"sub_zone\" field is not a string"));
463
479
  } else {
464
- node_->locality_subzone = std::move(*it->second.mutable_string_value());
480
+ node_->locality_sub_zone = std::move(*it->second.mutable_string_value());
465
481
  }
466
482
  }
467
483
  return GRPC_ERROR_CREATE_FROM_VECTOR("errors parsing \"locality\" object",