grpc 1.43.1 → 1.44.0.pre2

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 (382) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +84 -64
  3. data/include/grpc/grpc_security.h +10 -0
  4. data/include/grpc/impl/codegen/compression_types.h +0 -2
  5. data/include/grpc/impl/codegen/grpc_types.h +6 -0
  6. data/src/core/ext/filters/client_channel/backend_metric.h +1 -1
  7. data/src/core/ext/filters/client_channel/client_channel.cc +62 -68
  8. data/src/core/ext/filters/client_channel/client_channel.h +8 -8
  9. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +1 -1
  10. data/src/core/ext/filters/client_channel/config_selector.h +4 -4
  11. data/src/core/ext/filters/client_channel/dynamic_filters.h +1 -1
  12. data/src/core/ext/filters/client_channel/health/health_check_client.cc +16 -14
  13. data/src/core/ext/filters/client_channel/health/health_check_client.h +3 -3
  14. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +1 -1
  15. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +4 -3
  16. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +6 -5
  17. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +3 -7
  18. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +31 -32
  19. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +0 -7
  20. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +1 -1
  21. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +1 -1
  22. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +1 -1
  23. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +43 -29
  24. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +6 -2
  25. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +120 -68
  26. data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +60 -48
  27. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +62 -61
  28. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +16 -11
  29. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +11 -5
  30. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +19 -15
  31. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +1 -1
  32. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +14 -12
  33. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +3 -2
  34. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +50 -105
  35. data/src/core/ext/filters/client_channel/lb_policy.cc +15 -14
  36. data/src/core/ext/filters/client_channel/lb_policy.h +19 -3
  37. data/src/core/ext/filters/client_channel/resolver/binder/binder_resolver.cc +3 -3
  38. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +207 -81
  39. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +22 -12
  40. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +19 -15
  41. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +23 -38
  42. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +118 -207
  43. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +25 -32
  44. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +1 -1
  45. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +82 -73
  46. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +10 -10
  47. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +2 -1
  48. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +2 -5
  49. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +5 -5
  50. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +157 -67
  51. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +1 -1
  52. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +2 -2
  53. data/src/core/ext/filters/client_channel/retry_filter.cc +37 -64
  54. data/src/core/ext/filters/client_channel/retry_service_config.cc +1 -1
  55. data/src/core/ext/filters/client_channel/retry_service_config.h +1 -1
  56. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +1 -1
  57. data/src/core/ext/filters/client_channel/subchannel.cc +12 -16
  58. data/src/core/ext/filters/client_channel/subchannel.h +2 -3
  59. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +37 -48
  60. data/src/core/ext/filters/fault_injection/service_config_parser.cc +6 -8
  61. data/src/core/ext/filters/fault_injection/service_config_parser.h +1 -1
  62. data/src/core/ext/filters/http/client/http_client_filter.cc +51 -122
  63. data/src/core/ext/filters/http/client_authority_filter.cc +8 -24
  64. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +42 -140
  65. data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +5 -25
  66. data/src/core/ext/filters/http/server/http_server_filter.cc +50 -135
  67. data/src/core/ext/filters/message_size/message_size_filter.cc +1 -1
  68. data/src/core/ext/filters/message_size/message_size_filter.h +1 -1
  69. data/src/core/ext/filters/rbac/rbac_filter.cc +157 -0
  70. data/src/core/ext/filters/rbac/rbac_filter.h +74 -0
  71. data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +605 -0
  72. data/src/core/ext/filters/rbac/rbac_service_config_parser.h +70 -0
  73. data/src/core/ext/filters/server_config_selector/server_config_selector.h +3 -2
  74. data/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc +11 -6
  75. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +1 -1
  76. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +1 -1
  77. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +89 -29
  78. data/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +0 -1
  79. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +45 -186
  80. data/src/core/ext/transport/chttp2/transport/frame_data.cc +0 -1
  81. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +341 -279
  82. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +69 -159
  83. data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc +1 -1
  84. data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.h +2 -0
  85. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +19 -32
  86. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +0 -1
  87. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +94 -1
  88. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +2 -24
  89. data/src/core/ext/transport/chttp2/transport/internal.h +0 -33
  90. data/src/core/ext/transport/chttp2/transport/parsing.cc +0 -6
  91. data/src/core/ext/transport/chttp2/transport/writing.cc +47 -116
  92. data/src/core/ext/transport/inproc/inproc_plugin.cc +0 -4
  93. data/src/core/ext/transport/inproc/inproc_transport.cc +11 -63
  94. data/src/core/ext/transport/inproc/inproc_transport.h +0 -3
  95. data/src/core/ext/upb-generated/envoy/extensions/filters/http/rbac/v3/rbac.upb.c +61 -0
  96. data/src/core/ext/upb-generated/envoy/extensions/filters/http/rbac/v3/rbac.upb.h +146 -0
  97. data/src/core/ext/upbdefs-generated/envoy/config/rbac/v3/rbac.upbdefs.c +188 -0
  98. data/src/core/ext/upbdefs-generated/envoy/config/rbac/v3/rbac.upbdefs.h +70 -0
  99. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/rbac/v3/rbac.upbdefs.c +56 -0
  100. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/rbac/v3/rbac.upbdefs.h +40 -0
  101. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/checked.upbdefs.c +154 -0
  102. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/checked.upbdefs.h +95 -0
  103. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/eval.upbdefs.c +58 -0
  104. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/eval.upbdefs.h +55 -0
  105. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/explain.upbdefs.c +44 -0
  106. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/explain.upbdefs.h +40 -0
  107. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/syntax.upbdefs.c +153 -0
  108. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/syntax.upbdefs.h +100 -0
  109. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/value.upbdefs.c +75 -0
  110. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/value.upbdefs.h +55 -0
  111. data/src/core/ext/xds/upb_utils.h +65 -0
  112. data/src/core/ext/xds/xds_api.cc +81 -3458
  113. data/src/core/ext/xds/xds_api.h +56 -611
  114. data/src/core/ext/xds/xds_bootstrap.cc +189 -125
  115. data/src/core/ext/xds/xds_bootstrap.h +20 -15
  116. data/src/core/ext/xds/xds_certificate_provider.h +1 -0
  117. data/src/core/ext/xds/xds_channel_creds.cc +108 -0
  118. data/src/core/ext/xds/xds_channel_creds.h +50 -0
  119. data/src/core/ext/xds/xds_client.cc +584 -994
  120. data/src/core/ext/xds/xds_client.h +78 -135
  121. data/src/core/ext/xds/xds_cluster.cc +451 -0
  122. data/src/core/ext/xds/xds_cluster.h +111 -0
  123. data/src/core/ext/xds/xds_common_types.cc +388 -0
  124. data/src/core/ext/xds/xds_common_types.h +110 -0
  125. data/src/core/ext/xds/xds_endpoint.cc +364 -0
  126. data/src/core/ext/xds/xds_endpoint.h +135 -0
  127. data/src/core/ext/xds/xds_http_filters.cc +5 -0
  128. data/src/core/ext/xds/xds_http_rbac_filter.cc +563 -0
  129. data/src/core/ext/xds/xds_http_rbac_filter.h +54 -0
  130. data/src/core/ext/xds/xds_listener.cc +1036 -0
  131. data/src/core/ext/xds/xds_listener.h +220 -0
  132. data/src/core/ext/{transport/chttp2/transport/hpack_utils.h → xds/xds_resource_type.cc} +12 -9
  133. data/src/core/ext/xds/xds_resource_type.h +98 -0
  134. data/src/core/ext/xds/xds_resource_type_impl.h +87 -0
  135. data/src/core/ext/xds/xds_route_config.cc +993 -0
  136. data/src/core/ext/xds/xds_route_config.h +215 -0
  137. data/src/core/ext/xds/xds_routing.cc +11 -8
  138. data/src/core/ext/xds/xds_routing.h +8 -5
  139. data/src/core/ext/xds/xds_server_config_fetcher.cc +159 -99
  140. data/src/core/lib/address_utils/parse_address.cc +20 -0
  141. data/src/core/lib/address_utils/parse_address.h +5 -0
  142. data/src/core/lib/address_utils/sockaddr_utils.cc +33 -36
  143. data/src/core/lib/address_utils/sockaddr_utils.h +1 -16
  144. data/src/core/lib/backoff/backoff.cc +4 -30
  145. data/src/core/lib/backoff/backoff.h +3 -3
  146. data/src/core/lib/channel/channel_args.cc +0 -1
  147. data/src/core/lib/channel/channel_stack.cc +8 -0
  148. data/src/core/lib/channel/channel_stack.h +1 -1
  149. data/src/core/lib/channel/channel_stack_builder.cc +5 -9
  150. data/src/core/lib/channel/channel_stack_builder.h +4 -7
  151. data/src/core/lib/channel/channelz.cc +1 -0
  152. data/src/core/lib/compression/compression.cc +19 -111
  153. data/src/core/lib/compression/compression_internal.cc +142 -202
  154. data/src/core/lib/compression/compression_internal.h +64 -69
  155. data/src/core/lib/compression/message_compress.cc +11 -11
  156. data/src/core/lib/compression/message_compress.h +2 -2
  157. data/src/core/lib/gpr/useful.h +4 -0
  158. data/src/core/lib/gprpp/bitset.h +7 -0
  159. data/src/core/lib/gprpp/chunked_vector.h +45 -3
  160. data/src/core/lib/gprpp/status_helper.cc +20 -28
  161. data/src/core/lib/gprpp/status_helper.h +6 -19
  162. data/src/core/lib/gprpp/table.h +11 -0
  163. data/src/core/lib/http/httpcli.cc +37 -46
  164. data/src/core/lib/http/httpcli.h +3 -15
  165. data/src/core/lib/iomgr/call_combiner.cc +15 -4
  166. data/src/core/lib/iomgr/closure.h +29 -9
  167. data/src/core/lib/iomgr/combiner.cc +25 -3
  168. data/src/core/lib/iomgr/error.cc +2 -0
  169. data/src/core/lib/iomgr/error.h +3 -0
  170. data/src/core/lib/iomgr/event_engine/iomgr.cc +3 -2
  171. data/src/core/lib/iomgr/event_engine/resolved_address_internal.cc +6 -0
  172. data/src/core/lib/iomgr/event_engine/resolved_address_internal.h +2 -0
  173. data/src/core/lib/iomgr/event_engine/resolver.cc +66 -48
  174. data/src/core/lib/iomgr/event_engine/resolver.h +56 -0
  175. data/src/core/lib/iomgr/exec_ctx.cc +22 -9
  176. data/src/core/lib/iomgr/executor.cc +10 -1
  177. data/src/core/lib/iomgr/fork_posix.cc +3 -2
  178. data/src/core/lib/iomgr/iomgr_custom.cc +4 -1
  179. data/src/core/lib/iomgr/iomgr_posix.cc +2 -2
  180. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +2 -2
  181. data/src/core/lib/iomgr/iomgr_windows.cc +2 -2
  182. data/src/core/lib/iomgr/port.h +2 -2
  183. data/src/core/lib/iomgr/resolve_address.cc +5 -24
  184. data/src/core/lib/iomgr/resolve_address.h +47 -44
  185. data/src/core/lib/iomgr/resolve_address_custom.cc +131 -109
  186. data/src/core/lib/iomgr/resolve_address_custom.h +101 -19
  187. data/src/core/lib/iomgr/resolve_address_impl.h +59 -0
  188. data/src/core/lib/iomgr/resolve_address_posix.cc +82 -66
  189. data/src/core/lib/iomgr/resolve_address_posix.h +47 -0
  190. data/src/core/lib/iomgr/resolve_address_windows.cc +93 -74
  191. data/src/core/lib/iomgr/resolve_address_windows.h +47 -0
  192. data/src/core/lib/iomgr/resolved_address.h +39 -0
  193. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +1 -0
  194. data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +1 -0
  195. data/src/core/lib/iomgr/unix_sockets_posix.cc +22 -34
  196. data/src/core/lib/iomgr/unix_sockets_posix.h +4 -7
  197. data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +6 -15
  198. data/src/core/lib/matchers/matchers.cc +1 -1
  199. data/src/core/lib/promise/activity.h +49 -20
  200. data/src/core/lib/promise/detail/status.h +5 -0
  201. data/src/core/{ext/filters/client_channel → lib/resolver}/resolver.cc +17 -25
  202. data/src/core/{ext/filters/client_channel → lib/resolver}/resolver.h +43 -44
  203. data/src/core/{ext/filters/client_channel → lib/resolver}/resolver_factory.h +10 -5
  204. data/src/core/{ext/filters/client_channel → lib/resolver}/resolver_registry.cc +3 -2
  205. data/src/core/{ext/filters/client_channel → lib/resolver}/resolver_registry.h +4 -5
  206. data/src/core/{ext/filters/client_channel → lib/resolver}/server_address.cc +1 -1
  207. data/src/core/{ext/filters/client_channel → lib/resolver}/server_address.h +4 -4
  208. data/src/core/lib/resource_quota/api.h +0 -1
  209. data/src/core/lib/{gprpp → resource_quota}/arena.cc +16 -13
  210. data/src/core/lib/{gprpp → resource_quota}/arena.h +24 -13
  211. data/src/core/lib/security/authorization/evaluate_args.cc +30 -15
  212. data/src/core/lib/security/authorization/evaluate_args.h +1 -0
  213. data/src/core/lib/security/authorization/grpc_authorization_engine.cc +60 -0
  214. data/src/core/lib/security/authorization/grpc_authorization_engine.h +62 -0
  215. data/src/core/lib/security/authorization/matchers.cc +227 -0
  216. data/src/core/lib/security/authorization/matchers.h +211 -0
  217. data/src/core/lib/security/authorization/rbac_policy.cc +442 -0
  218. data/src/core/lib/security/authorization/rbac_policy.h +170 -0
  219. data/src/core/lib/security/context/security_context.cc +4 -2
  220. data/src/core/lib/security/context/security_context.h +1 -1
  221. data/src/core/lib/security/credentials/composite/composite_credentials.cc +5 -5
  222. data/src/core/lib/security/credentials/composite/composite_credentials.h +4 -3
  223. data/src/core/lib/security/credentials/credentials.h +10 -20
  224. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +6 -9
  225. data/src/core/lib/security/credentials/external/external_account_credentials.cc +7 -9
  226. data/src/core/lib/security/credentials/external/external_account_credentials.h +2 -7
  227. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +2 -3
  228. data/src/core/lib/security/credentials/fake/fake_credentials.cc +5 -4
  229. data/src/core/lib/security/credentials/fake/fake_credentials.h +8 -7
  230. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +2 -5
  231. data/src/core/lib/security/credentials/iam/iam_credentials.cc +16 -19
  232. data/src/core/lib/security/credentials/iam/iam_credentials.h +6 -5
  233. data/src/core/lib/security/credentials/jwt/json_token.cc +4 -6
  234. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +16 -28
  235. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +8 -8
  236. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +6 -13
  237. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +44 -57
  238. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +13 -15
  239. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +6 -7
  240. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +5 -4
  241. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +1 -10
  242. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +6 -0
  243. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +7 -0
  244. data/src/core/lib/security/credentials/xds/xds_credentials.h +1 -1
  245. data/src/core/lib/security/security_connector/security_connector.cc +0 -4
  246. data/src/core/lib/security/security_connector/security_connector.h +5 -1
  247. data/src/core/lib/security/security_connector/ssl_utils.cc +14 -24
  248. data/src/core/lib/security/security_connector/ssl_utils.h +5 -14
  249. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +2 -3
  250. data/src/core/lib/security/transport/auth_filters.h +7 -0
  251. data/src/core/lib/security/transport/client_auth_filter.cc +53 -33
  252. data/src/core/lib/security/transport/server_auth_filter.cc +40 -35
  253. data/src/core/{ext → lib}/service_config/service_config.cc +2 -2
  254. data/src/core/{ext → lib}/service_config/service_config.h +4 -4
  255. data/src/core/{ext → lib}/service_config/service_config_call_data.h +5 -5
  256. data/src/core/{ext → lib}/service_config/service_config_parser.cc +1 -1
  257. data/src/core/{ext → lib}/service_config/service_config_parser.h +3 -3
  258. data/src/core/lib/slice/slice.cc +3 -1
  259. data/src/core/lib/slice/slice.h +43 -13
  260. data/src/core/lib/slice/slice_intern.cc +3 -101
  261. data/src/core/lib/slice/slice_internal.h +1 -2
  262. data/src/core/lib/slice/slice_refcount.h +4 -13
  263. data/src/core/lib/slice/slice_refcount_base.h +0 -16
  264. data/src/core/lib/surface/call.cc +140 -382
  265. data/src/core/lib/surface/call.h +4 -4
  266. data/src/core/lib/surface/channel.cc +42 -44
  267. data/src/core/lib/surface/channel.h +4 -4
  268. data/src/core/lib/surface/init.cc +0 -2
  269. data/src/core/lib/surface/lame_client.cc +0 -1
  270. data/src/core/lib/surface/server.cc +12 -29
  271. data/src/core/lib/surface/server.h +2 -2
  272. data/src/core/lib/surface/version.cc +2 -2
  273. data/src/core/lib/transport/error_utils.h +14 -0
  274. data/src/core/lib/transport/metadata_batch.h +799 -717
  275. data/src/core/lib/transport/parsed_metadata.cc +2 -0
  276. data/src/core/lib/transport/parsed_metadata.h +95 -92
  277. data/src/core/lib/transport/timeout_encoding.cc +200 -66
  278. data/src/core/lib/transport/timeout_encoding.h +40 -10
  279. data/src/core/lib/transport/transport.h +1 -1
  280. data/src/core/lib/transport/transport_op_string.cc +6 -39
  281. data/src/core/lib/uri/uri_parser.cc +223 -53
  282. data/src/core/lib/uri/uri_parser.h +36 -23
  283. data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -3
  284. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +1 -1
  285. data/src/core/tsi/ssl/session_cache/ssl_session.h +2 -4
  286. data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +3 -5
  287. data/src/core/tsi/ssl_transport_security.cc +53 -13
  288. data/src/core/tsi/ssl_transport_security.h +18 -6
  289. data/src/ruby/ext/grpc/extconf.rb +10 -3
  290. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
  291. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +3 -0
  292. data/src/ruby/lib/grpc/version.rb +1 -1
  293. data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +2 -1
  294. data/third_party/abseil-cpp/absl/base/internal/fast_type_id.h +48 -0
  295. data/third_party/abseil-cpp/absl/random/bernoulli_distribution.h +200 -0
  296. data/third_party/abseil-cpp/absl/random/beta_distribution.h +427 -0
  297. data/third_party/abseil-cpp/absl/random/discrete_distribution.cc +98 -0
  298. data/third_party/abseil-cpp/absl/random/discrete_distribution.h +247 -0
  299. data/third_party/abseil-cpp/absl/random/distributions.h +452 -0
  300. data/third_party/abseil-cpp/absl/random/exponential_distribution.h +165 -0
  301. data/third_party/abseil-cpp/absl/random/gaussian_distribution.cc +104 -0
  302. data/third_party/abseil-cpp/absl/random/gaussian_distribution.h +275 -0
  303. data/third_party/abseil-cpp/absl/random/internal/distribution_caller.h +92 -0
  304. data/third_party/abseil-cpp/absl/random/internal/fast_uniform_bits.h +268 -0
  305. data/third_party/abseil-cpp/absl/random/internal/fastmath.h +57 -0
  306. data/third_party/abseil-cpp/absl/random/internal/generate_real.h +144 -0
  307. data/third_party/abseil-cpp/absl/random/internal/iostream_state_saver.h +245 -0
  308. data/third_party/abseil-cpp/absl/random/internal/nonsecure_base.h +150 -0
  309. data/third_party/abseil-cpp/absl/random/internal/pcg_engine.h +308 -0
  310. data/third_party/abseil-cpp/absl/random/internal/platform.h +171 -0
  311. data/third_party/abseil-cpp/absl/random/internal/pool_urbg.cc +253 -0
  312. data/third_party/abseil-cpp/absl/random/internal/pool_urbg.h +131 -0
  313. data/third_party/abseil-cpp/absl/random/internal/randen.cc +91 -0
  314. data/third_party/abseil-cpp/absl/random/internal/randen.h +102 -0
  315. data/third_party/abseil-cpp/absl/random/internal/randen_detect.cc +221 -0
  316. data/third_party/abseil-cpp/absl/random/internal/randen_detect.h +33 -0
  317. data/third_party/abseil-cpp/absl/random/internal/randen_engine.h +239 -0
  318. data/third_party/abseil-cpp/absl/random/internal/randen_hwaes.cc +526 -0
  319. data/third_party/abseil-cpp/absl/random/internal/randen_hwaes.h +50 -0
  320. data/third_party/abseil-cpp/absl/random/internal/randen_round_keys.cc +462 -0
  321. data/third_party/abseil-cpp/absl/random/internal/randen_slow.cc +471 -0
  322. data/third_party/abseil-cpp/absl/random/internal/randen_slow.h +40 -0
  323. data/third_party/abseil-cpp/absl/random/internal/randen_traits.h +88 -0
  324. data/third_party/abseil-cpp/absl/random/internal/salted_seed_seq.h +167 -0
  325. data/third_party/abseil-cpp/absl/random/internal/seed_material.cc +267 -0
  326. data/third_party/abseil-cpp/absl/random/internal/seed_material.h +104 -0
  327. data/third_party/abseil-cpp/absl/random/internal/traits.h +101 -0
  328. data/third_party/abseil-cpp/absl/random/internal/uniform_helper.h +244 -0
  329. data/third_party/abseil-cpp/absl/random/internal/wide_multiply.h +111 -0
  330. data/third_party/abseil-cpp/absl/random/log_uniform_int_distribution.h +257 -0
  331. data/third_party/abseil-cpp/absl/random/poisson_distribution.h +258 -0
  332. data/third_party/abseil-cpp/absl/random/random.h +189 -0
  333. data/third_party/abseil-cpp/absl/random/seed_gen_exception.cc +46 -0
  334. data/third_party/abseil-cpp/absl/random/seed_gen_exception.h +55 -0
  335. data/third_party/abseil-cpp/absl/random/seed_sequences.cc +29 -0
  336. data/third_party/abseil-cpp/absl/random/seed_sequences.h +110 -0
  337. data/third_party/abseil-cpp/absl/random/uniform_int_distribution.h +275 -0
  338. data/third_party/abseil-cpp/absl/random/uniform_real_distribution.h +202 -0
  339. data/third_party/abseil-cpp/absl/random/zipf_distribution.h +271 -0
  340. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +1 -0
  341. data/third_party/boringssl-with-bazel/src/crypto/base64/base64.c +13 -0
  342. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +21 -0
  343. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/cipher.c +12 -0
  344. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +1 -2
  345. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +2 -2
  346. data/third_party/boringssl-with-bazel/src/crypto/mem.c +1 -1
  347. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7.c +29 -0
  348. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/internal.h +0 -1
  349. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8.c +1 -1
  350. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +1 -1
  351. data/third_party/boringssl-with-bazel/src/include/openssl/base64.h +8 -0
  352. data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +13 -1
  353. data/third_party/boringssl-with-bazel/src/include/openssl/dsa.h +10 -0
  354. data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +1 -1
  355. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +9 -4
  356. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs8.h +6 -1
  357. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +23 -2
  358. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +4 -0
  359. data/third_party/xxhash/xxhash.h +607 -352
  360. metadata +149 -77
  361. data/src/core/ext/transport/chttp2/transport/hpack_encoder_index.h +0 -107
  362. data/src/core/ext/transport/chttp2/transport/hpack_utils.cc +0 -46
  363. data/src/core/ext/transport/chttp2/transport/popularity_count.h +0 -60
  364. data/src/core/lib/compression/algorithm_metadata.h +0 -62
  365. data/src/core/lib/compression/compression_args.cc +0 -140
  366. data/src/core/lib/compression/compression_args.h +0 -58
  367. data/src/core/lib/compression/stream_compression.cc +0 -81
  368. data/src/core/lib/compression/stream_compression.h +0 -117
  369. data/src/core/lib/compression/stream_compression_gzip.cc +0 -231
  370. data/src/core/lib/compression/stream_compression_gzip.h +0 -28
  371. data/src/core/lib/compression/stream_compression_identity.cc +0 -91
  372. data/src/core/lib/compression/stream_compression_identity.h +0 -29
  373. data/src/core/lib/security/credentials/credentials_metadata.cc +0 -61
  374. data/src/core/lib/slice/static_slice.cc +0 -377
  375. data/src/core/lib/slice/static_slice.h +0 -300
  376. data/src/core/lib/transport/metadata.cc +0 -714
  377. data/src/core/lib/transport/metadata.h +0 -449
  378. data/src/core/lib/transport/metadata_batch.cc +0 -99
  379. data/src/core/lib/transport/static_metadata.cc +0 -1032
  380. data/src/core/lib/transport/static_metadata.h +0 -322
  381. data/src/core/lib/transport/status_metadata.cc +0 -63
  382. data/src/core/lib/transport/status_metadata.h +0 -48
@@ -60,6 +60,7 @@ struct grpc_tls_credentials_options
60
60
  const std::string& root_cert_name() { return root_cert_name_; }
61
61
  bool watch_identity_pair() { return watch_identity_pair_; }
62
62
  const std::string& identity_cert_name() { return identity_cert_name_; }
63
+ const std::string& crl_directory() { return crl_directory_; }
63
64
 
64
65
  // Setters for member fields.
65
66
  void set_cert_request_type(
@@ -112,6 +113,11 @@ struct grpc_tls_credentials_options
112
113
  identity_cert_name_ = std::move(identity_cert_name);
113
114
  }
114
115
 
116
+ // gRPC will enforce CRLs on all handshakes from all hashed CRL files inside
117
+ // of the crl_directory. If not set, an empty string will be used, which will
118
+ // not enable CRL checking. Only supported for OpenSSL version > 1.1.
119
+ void set_crl_directory(std::string path) { crl_directory_ = std::move(path); }
120
+
115
121
  private:
116
122
  grpc_ssl_client_certificate_request_type cert_request_type_ =
117
123
  GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE;
@@ -125,6 +131,7 @@ struct grpc_tls_credentials_options
125
131
  std::string root_cert_name_;
126
132
  bool watch_identity_pair_ = false;
127
133
  std::string identity_cert_name_;
134
+ std::string crl_directory_;
128
135
  };
129
136
 
130
137
  #endif // GRPC_CORE_LIB_SECURITY_CREDENTIALS_TLS_GRPC_TLS_CREDENTIALS_OPTIONS_H
@@ -23,7 +23,7 @@
23
23
 
24
24
  #include <grpc/grpc_security.h>
25
25
 
26
- #include "src/core/ext/xds/xds_api.h"
26
+ #include "src/core/lib/matchers/matchers.h"
27
27
  #include "src/core/lib/security/credentials/credentials.h"
28
28
 
29
29
  namespace grpc_core {
@@ -25,15 +25,11 @@
25
25
  #include <grpc/support/log.h>
26
26
  #include <grpc/support/string_util.h>
27
27
 
28
- #include "src/core/ext/transport/chttp2/alpn/alpn.h"
29
28
  #include "src/core/lib/channel/channel_args.h"
30
29
  #include "src/core/lib/channel/handshaker.h"
31
30
  #include "src/core/lib/gpr/string.h"
32
- #include "src/core/lib/gprpp/host_port.h"
33
- #include "src/core/lib/iomgr/load_file.h"
34
31
  #include "src/core/lib/security/context/security_context.h"
35
32
  #include "src/core/lib/security/credentials/credentials.h"
36
- #include "src/core/lib/security/security_connector/load_system_roots.h"
37
33
  #include "src/core/lib/security/security_connector/security_connector.h"
38
34
  #include "src/core/lib/security/transport/security_handshaker.h"
39
35
 
@@ -30,11 +30,15 @@
30
30
  #include "src/core/lib/iomgr/endpoint.h"
31
31
  #include "src/core/lib/iomgr/pollset.h"
32
32
  #include "src/core/lib/iomgr/tcp_server.h"
33
- #include "src/core/tsi/ssl_transport_security.h"
34
33
  #include "src/core/tsi/transport_security_interface.h"
35
34
 
36
35
  extern grpc_core::DebugOnlyTraceFlag grpc_trace_security_connector_refcount;
37
36
 
37
+ /* --- URL schemes. --- */
38
+
39
+ #define GRPC_SSL_URL_SCHEME "https"
40
+ #define GRPC_FAKE_SECURITY_URL_SCHEME "http+fake_security"
41
+
38
42
  typedef enum { GRPC_SECURITY_OK = 0, GRPC_SECURITY_ERROR } grpc_security_status;
39
43
 
40
44
  /* --- security_connector object. ---
@@ -92,30 +92,6 @@ const char* grpc_get_ssl_cipher_suites(void) {
92
92
  return cipher_suites;
93
93
  }
94
94
 
95
- grpc_security_level grpc_tsi_security_level_string_to_enum(
96
- const char* security_level) {
97
- if (strcmp(security_level, "TSI_INTEGRITY_ONLY") == 0) {
98
- return GRPC_INTEGRITY_ONLY;
99
- } else if (strcmp(security_level, "TSI_PRIVACY_AND_INTEGRITY") == 0) {
100
- return GRPC_PRIVACY_AND_INTEGRITY;
101
- }
102
- return GRPC_SECURITY_NONE;
103
- }
104
-
105
- const char* grpc_security_level_to_string(grpc_security_level security_level) {
106
- if (security_level == GRPC_PRIVACY_AND_INTEGRITY) {
107
- return "GRPC_PRIVACY_AND_INTEGRITY";
108
- } else if (security_level == GRPC_INTEGRITY_ONLY) {
109
- return "GRPC_INTEGRITY_ONLY";
110
- }
111
- return "GRPC_SECURITY_NONE";
112
- }
113
-
114
- bool grpc_check_security_level(grpc_security_level channel_level,
115
- grpc_security_level call_cred_level) {
116
- return static_cast<int>(channel_level) >= static_cast<int>(call_cred_level);
117
- }
118
-
119
95
  tsi_client_certificate_request_type
120
96
  grpc_get_tsi_client_certificate_request_type(
121
97
  grpc_ssl_client_certificate_request_type grpc_request_type) {
@@ -179,6 +155,16 @@ grpc_error_handle grpc_ssl_check_peer_name(absl::string_view peer_name,
179
155
  return GRPC_ERROR_NONE;
180
156
  }
181
157
 
158
+ void grpc_tsi_ssl_pem_key_cert_pairs_destroy(tsi_ssl_pem_key_cert_pair* kp,
159
+ size_t num_key_cert_pairs) {
160
+ if (kp == nullptr) return;
161
+ for (size_t i = 0; i < num_key_cert_pairs; i++) {
162
+ gpr_free(const_cast<char*>(kp[i].private_key));
163
+ gpr_free(const_cast<char*>(kp[i].cert_chain));
164
+ }
165
+ gpr_free(kp);
166
+ }
167
+
182
168
  bool grpc_ssl_check_call_host(absl::string_view host,
183
169
  absl::string_view target_name,
184
170
  absl::string_view overridden_target_name,
@@ -423,6 +409,7 @@ grpc_security_status grpc_ssl_tsi_client_handshaker_factory_init(
423
409
  tsi_ssl_pem_key_cert_pair* pem_key_cert_pair, const char* pem_root_certs,
424
410
  bool skip_server_certificate_verification, tsi_tls_version min_tls_version,
425
411
  tsi_tls_version max_tls_version, tsi_ssl_session_cache* ssl_session_cache,
412
+ const char* crl_directory,
426
413
  tsi_ssl_client_handshaker_factory** handshaker_factory) {
427
414
  const char* root_certs;
428
415
  const tsi_ssl_root_certs_store* root_store;
@@ -459,6 +446,7 @@ grpc_security_status grpc_ssl_tsi_client_handshaker_factory_init(
459
446
  skip_server_certificate_verification;
460
447
  options.min_tls_version = min_tls_version;
461
448
  options.max_tls_version = max_tls_version;
449
+ options.crl_directory = crl_directory;
462
450
  const tsi_result result =
463
451
  tsi_create_ssl_client_handshaker_factory_with_options(&options,
464
452
  handshaker_factory);
@@ -476,6 +464,7 @@ grpc_security_status grpc_ssl_tsi_server_handshaker_factory_init(
476
464
  const char* pem_root_certs,
477
465
  grpc_ssl_client_certificate_request_type client_certificate_request,
478
466
  tsi_tls_version min_tls_version, tsi_tls_version max_tls_version,
467
+ const char* crl_directory,
479
468
  tsi_ssl_server_handshaker_factory** handshaker_factory) {
480
469
  size_t num_alpn_protocols = 0;
481
470
  const char** alpn_protocol_strings =
@@ -491,6 +480,7 @@ grpc_security_status grpc_ssl_tsi_server_handshaker_factory_init(
491
480
  options.num_alpn_protocols = static_cast<uint16_t>(num_alpn_protocols);
492
481
  options.min_tls_version = min_tls_version;
493
482
  options.max_tls_version = max_tls_version;
483
+ options.crl_directory = crl_directory;
494
484
  const tsi_result result =
495
485
  tsi_create_ssl_server_handshaker_factory_with_options(&options,
496
486
  handshaker_factory);
@@ -40,9 +40,6 @@
40
40
 
41
41
  /* --- Util --- */
42
42
 
43
- /* --- URL schemes. --- */
44
- #define GRPC_SSL_URL_SCHEME "https"
45
-
46
43
  /* Check ALPN information returned from SSL handshakes. */
47
44
  grpc_error_handle grpc_ssl_check_alpn(const tsi_peer* peer);
48
45
 
@@ -69,20 +66,9 @@ tsi_client_certificate_request_type
69
66
  grpc_get_tsi_client_certificate_request_type(
70
67
  grpc_ssl_client_certificate_request_type grpc_request_type);
71
68
 
72
- /* Map tsi_security_level string to grpc_security_level enum. */
73
- grpc_security_level grpc_tsi_security_level_string_to_enum(
74
- const char* security_level);
75
-
76
69
  /* Map grpc_tls_version to tsi_tls_version. */
77
70
  tsi_tls_version grpc_get_tsi_tls_version(grpc_tls_version tls_version);
78
71
 
79
- /* Map grpc_security_level enum to a string. */
80
- const char* grpc_security_level_to_string(grpc_security_level security_level);
81
-
82
- /* Check security level of channel and call credential.*/
83
- bool grpc_check_security_level(grpc_security_level channel_level,
84
- grpc_security_level call_cred_level);
85
-
86
72
  /* Return an array of strings containing alpn protocols. */
87
73
  const char** grpc_fill_alpn_protocol_strings(size_t* num_alpn_protocols);
88
74
 
@@ -91,6 +77,7 @@ grpc_security_status grpc_ssl_tsi_client_handshaker_factory_init(
91
77
  tsi_ssl_pem_key_cert_pair* key_cert_pair, const char* pem_root_certs,
92
78
  bool skip_server_certificate_verification, tsi_tls_version min_tls_version,
93
79
  tsi_tls_version max_tls_version, tsi_ssl_session_cache* ssl_session_cache,
80
+ const char* crl_directory,
94
81
  tsi_ssl_client_handshaker_factory** handshaker_factory);
95
82
 
96
83
  grpc_security_status grpc_ssl_tsi_server_handshaker_factory_init(
@@ -98,8 +85,12 @@ grpc_security_status grpc_ssl_tsi_server_handshaker_factory_init(
98
85
  const char* pem_root_certs,
99
86
  grpc_ssl_client_certificate_request_type client_certificate_request,
100
87
  tsi_tls_version min_tls_version, tsi_tls_version max_tls_version,
88
+ const char* crl_directory,
101
89
  tsi_ssl_server_handshaker_factory** handshaker_factory);
102
90
 
91
+ /* Free the memory occupied by key cert pairs. */
92
+ void grpc_tsi_ssl_pem_key_cert_pairs_destroy(tsi_ssl_pem_key_cert_pair* kp,
93
+ size_t num_key_cert_pairs);
103
94
  /* Exposed for testing only. */
104
95
  grpc_core::RefCountedPtr<grpc_auth_context> grpc_ssl_peer_to_auth_context(
105
96
  const tsi_peer* peer, const char* transport_security_type);
@@ -34,7 +34,6 @@
34
34
  #include <grpc/support/string_util.h>
35
35
 
36
36
  #include "src/core/lib/gprpp/host_port.h"
37
- #include "src/core/lib/security/credentials/ssl/ssl_credentials.h"
38
37
  #include "src/core/lib/security/credentials/tls/tls_credentials.h"
39
38
  #include "src/core/lib/security/security_connector/ssl_utils.h"
40
39
  #include "src/core/lib/security/transport/security_handshaker.h"
@@ -538,7 +537,7 @@ TlsChannelSecurityConnector::UpdateHandshakerFactoryLocked() {
538
537
  skip_server_certificate_verification,
539
538
  grpc_get_tsi_tls_version(options_->min_tls_version()),
540
539
  grpc_get_tsi_tls_version(options_->max_tls_version()), ssl_session_cache_,
541
- &client_handshaker_factory_);
540
+ options_->crl_directory().c_str(), &client_handshaker_factory_);
542
541
  /* Free memory. */
543
542
  if (pem_key_cert_pair != nullptr) {
544
543
  grpc_tsi_ssl_pem_key_cert_pairs_destroy(pem_key_cert_pair, 1);
@@ -806,7 +805,7 @@ TlsServerSecurityConnector::UpdateHandshakerFactoryLocked() {
806
805
  options_->cert_request_type(),
807
806
  grpc_get_tsi_tls_version(options_->min_tls_version()),
808
807
  grpc_get_tsi_tls_version(options_->max_tls_version()),
809
- &server_handshaker_factory_);
808
+ options_->crl_directory().c_str(), &server_handshaker_factory_);
810
809
  /* Free memory. */
811
810
  grpc_tsi_ssl_pem_key_cert_pairs_destroy(pem_key_cert_pairs,
812
811
  num_key_cert_pairs);
@@ -33,4 +33,11 @@ void grpc_auth_metadata_context_build(
33
33
  const grpc_slice& call_method, grpc_auth_context* auth_context,
34
34
  grpc_auth_metadata_context* auth_md_context);
35
35
 
36
+ // Exposed for testing purposes only.
37
+ // Check if the channel's security level is higher or equal to
38
+ // that of call credentials to make a decision whether the transfer
39
+ // of call credentials should be allowed or not.
40
+ bool grpc_check_security_level(grpc_security_level channel_level,
41
+ grpc_security_level call_cred_level);
42
+
36
43
  #endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_AUTH_FILTERS_H */
@@ -30,16 +30,15 @@
30
30
 
31
31
  #include "src/core/lib/channel/channel_stack.h"
32
32
  #include "src/core/lib/gpr/string.h"
33
+ #include "src/core/lib/iomgr/error.h"
33
34
  #include "src/core/lib/profiling/timers.h"
34
35
  #include "src/core/lib/security/context/security_context.h"
35
36
  #include "src/core/lib/security/credentials/credentials.h"
36
37
  #include "src/core/lib/security/security_connector/security_connector.h"
37
- #include "src/core/lib/security/security_connector/ssl_utils.h"
38
38
  #include "src/core/lib/security/transport/auth_filters.h"
39
39
  #include "src/core/lib/slice/slice_internal.h"
40
40
  #include "src/core/lib/slice/slice_string_helpers.h"
41
41
  #include "src/core/lib/surface/call.h"
42
- #include "src/core/lib/transport/static_metadata.h"
43
42
 
44
43
  #define MAX_CREDENTIALS_METADATA_COUNT 4
45
44
 
@@ -65,6 +64,9 @@ struct channel_data {
65
64
  struct call_data {
66
65
  call_data(grpc_call_element* elem, const grpc_call_element_args& args)
67
66
  : owning_call(args.call_stack), call_combiner(args.call_combiner) {
67
+ host.Init();
68
+ method.Init();
69
+ md_array.Init();
68
70
  channel_data* chand = static_cast<channel_data*>(elem->channel_data);
69
71
  GPR_ASSERT(args.context != nullptr);
70
72
  if (args.context[GRPC_CONTEXT_SECURITY].value == nullptr) {
@@ -87,25 +89,24 @@ struct call_data {
87
89
  // fields will be accessed after calling dtor, and msan correctly complains
88
90
  // that the memory is not initialized.
89
91
  void destroy() {
90
- grpc_credentials_mdelem_array_destroy(&md_array);
92
+ md_array.Destroy();
91
93
  creds.reset();
92
- grpc_slice_unref_internal(host);
93
- grpc_slice_unref_internal(method);
94
94
  grpc_auth_metadata_context_reset(&auth_md_context);
95
+ host.Destroy();
96
+ method.Destroy();
95
97
  }
96
98
 
97
99
  grpc_call_stack* owning_call;
98
100
  grpc_core::CallCombiner* call_combiner;
99
101
  grpc_core::RefCountedPtr<grpc_call_credentials> creds;
100
- grpc_slice host = grpc_empty_slice();
101
- grpc_slice method = grpc_empty_slice();
102
+ grpc_core::ManualConstructor<grpc_core::Slice> host;
103
+ grpc_core::ManualConstructor<grpc_core::Slice> method;
102
104
  /* pollset{_set} bound to this call; if we need to make external
103
105
  network requests, they should be done under a pollset added to this
104
106
  pollset_set so that work can progress when this call wants work to progress
105
107
  */
106
108
  grpc_polling_entity* pollent = nullptr;
107
- grpc_credentials_mdelem_array md_array;
108
- grpc_linked_mdelem md_links[MAX_CREDENTIALS_METADATA_COUNT] = {};
109
+ grpc_core::ManualConstructor<grpc_core::CredentialsMetadataArray> md_array;
109
110
  grpc_auth_metadata_context auth_md_context =
110
111
  grpc_auth_metadata_context(); // Zero-initialize the C struct.
111
112
  grpc_closure async_result_closure;
@@ -163,17 +164,20 @@ static void on_credentials_metadata(void* arg, grpc_error_handle input_error) {
163
164
  grpc_auth_metadata_context_reset(&calld->auth_md_context);
164
165
  grpc_error_handle error = GRPC_ERROR_REF(input_error);
165
166
  if (error == GRPC_ERROR_NONE) {
166
- GPR_ASSERT(calld->md_array.size <= MAX_CREDENTIALS_METADATA_COUNT);
167
+ GPR_ASSERT(calld->md_array->size() <= MAX_CREDENTIALS_METADATA_COUNT);
167
168
  GPR_ASSERT(batch->send_initial_metadata);
168
169
  grpc_metadata_batch* mdb =
169
170
  batch->payload->send_initial_metadata.send_initial_metadata;
170
- for (size_t i = 0; i < calld->md_array.size; ++i) {
171
- add_error(&error, grpc_metadata_batch_add_tail(
172
- mdb, &calld->md_links[i],
173
- GRPC_MDELEM_REF(calld->md_array.md[i])));
171
+ for (const auto& md : *calld->md_array) {
172
+ mdb->Append(
173
+ md.first.as_string_view(), md.second.Ref(),
174
+ [&](absl::string_view error_message, const grpc_core::Slice& value) {
175
+ add_error(&error, GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrCat(
176
+ "on_credentials_metadata: ", error_message,
177
+ ": ", md.first.as_string_view(), ": ",
178
+ value.as_string_view())));
179
+ });
174
180
  }
175
- }
176
- if (error == GRPC_ERROR_NONE) {
177
181
  grpc_call_next_op(elem, batch);
178
182
  } else {
179
183
  error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS,
@@ -228,12 +232,27 @@ static void cancel_get_request_metadata(void* arg, grpc_error_handle error) {
228
232
  grpc_call_element* elem = static_cast<grpc_call_element*>(arg);
229
233
  call_data* calld = static_cast<call_data*>(elem->call_data);
230
234
  if (error != GRPC_ERROR_NONE) {
231
- calld->creds->cancel_get_request_metadata(&calld->md_array,
235
+ calld->creds->cancel_get_request_metadata(&*calld->md_array,
232
236
  GRPC_ERROR_REF(error));
233
237
  }
234
238
  GRPC_CALL_STACK_UNREF(calld->owning_call, "cancel_get_request_metadata");
235
239
  }
236
240
 
241
+ static grpc_security_level convert_security_level_string_to_enum(
242
+ const char* security_level) {
243
+ if (strcmp(security_level, "TSI_INTEGRITY_ONLY") == 0) {
244
+ return GRPC_INTEGRITY_ONLY;
245
+ } else if (strcmp(security_level, "TSI_PRIVACY_AND_INTEGRITY") == 0) {
246
+ return GRPC_PRIVACY_AND_INTEGRITY;
247
+ }
248
+ return GRPC_SECURITY_NONE;
249
+ }
250
+
251
+ bool grpc_check_security_level(grpc_security_level channel_level,
252
+ grpc_security_level call_cred_level) {
253
+ return static_cast<int>(channel_level) >= static_cast<int>(call_cred_level);
254
+ }
255
+
237
256
  static void send_security_metadata(grpc_call_element* elem,
238
257
  grpc_transport_stream_op_batch* batch) {
239
258
  call_data* calld = static_cast<call_data*>(elem->call_data);
@@ -289,7 +308,7 @@ static void send_security_metadata(grpc_call_element* elem,
289
308
  grpc_security_level call_cred_security_level =
290
309
  calld->creds->min_security_level();
291
310
  int is_security_level_ok = grpc_check_security_level(
292
- grpc_tsi_security_level_string_to_enum(prop->value),
311
+ convert_security_level_string_to_enum(prop->value),
293
312
  call_cred_security_level);
294
313
  if (!is_security_level_ok) {
295
314
  grpc_transport_stream_op_batch_finish_with_failure(
@@ -304,8 +323,9 @@ static void send_security_metadata(grpc_call_element* elem,
304
323
  }
305
324
 
306
325
  grpc_auth_metadata_context_build(
307
- chand->security_connector->url_scheme(), calld->host, calld->method,
308
- chand->auth_context.get(), &calld->auth_md_context);
326
+ chand->security_connector->url_scheme(), calld->host->c_slice(),
327
+ calld->method->c_slice(), chand->auth_context.get(),
328
+ &calld->auth_md_context);
309
329
 
310
330
  GPR_ASSERT(calld->pollent != nullptr);
311
331
  GRPC_CALL_STACK_REF(calld->owning_call, "get_request_metadata");
@@ -313,7 +333,7 @@ static void send_security_metadata(grpc_call_element* elem,
313
333
  batch, grpc_schedule_on_exec_ctx);
314
334
  grpc_error_handle error = GRPC_ERROR_NONE;
315
335
  if (calld->creds->get_request_metadata(
316
- calld->pollent, calld->auth_md_context, &calld->md_array,
336
+ calld->pollent, calld->auth_md_context, &*calld->md_array,
317
337
  &calld->async_result_closure, &error)) {
318
338
  // Synchronous return; invoke on_credentials_metadata() directly.
319
339
  on_credentials_metadata(batch, error);
@@ -340,11 +360,11 @@ static void on_host_checked(void* arg, grpc_error_handle error) {
340
360
  } else {
341
361
  grpc_transport_stream_op_batch_finish_with_failure(
342
362
  batch,
343
- grpc_error_set_int(
344
- GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrCat(
345
- "Invalid host ", grpc_core::StringViewFromSlice(calld->host),
346
- " set in :authority metadata.")),
347
- GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAUTHENTICATED),
363
+ grpc_error_set_int(GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrCat(
364
+ "Invalid host ", calld->host->as_string_view(),
365
+ " set in :authority metadata.")),
366
+ GRPC_ERROR_INT_GRPC_STATUS,
367
+ GRPC_STATUS_UNAUTHENTICATED),
348
368
  calld->call_combiner);
349
369
  }
350
370
  GRPC_CALL_STACK_UNREF(calld->owning_call, "check_call_host");
@@ -372,18 +392,18 @@ static void client_auth_start_transport_stream_op_batch(
372
392
  if (batch->send_initial_metadata) {
373
393
  grpc_metadata_batch* metadata =
374
394
  batch->payload->send_initial_metadata.send_initial_metadata;
375
- if (metadata->legacy_index()->named.path != nullptr) {
376
- calld->method = grpc_slice_ref_internal(
377
- GRPC_MDVALUE(metadata->legacy_index()->named.path->md));
395
+ if (metadata->get_pointer(grpc_core::HttpPathMetadata()) != nullptr) {
396
+ *calld->method =
397
+ metadata->get_pointer(grpc_core::HttpPathMetadata())->Ref();
378
398
  }
379
- if (metadata->legacy_index()->named.authority != nullptr) {
380
- calld->host = grpc_slice_ref_internal(
381
- GRPC_MDVALUE(metadata->legacy_index()->named.authority->md));
399
+ if (metadata->get_pointer(grpc_core::HttpAuthorityMetadata()) != nullptr) {
400
+ *calld->host =
401
+ metadata->get_pointer(grpc_core::HttpAuthorityMetadata())->Ref();
382
402
  batch->handler_private.extra_arg = elem;
383
403
  GRPC_CALL_STACK_REF(calld->owning_call, "check_call_host");
384
404
  GRPC_CLOSURE_INIT(&calld->async_result_closure, on_host_checked, batch,
385
405
  grpc_schedule_on_exec_ctx);
386
- absl::string_view call_host(grpc_core::StringViewFromSlice(calld->host));
406
+ absl::string_view call_host = calld->host->as_string_view();
387
407
  grpc_error_handle error = GRPC_ERROR_NONE;
388
408
  if (chand->security_connector->check_call_host(
389
409
  call_host, chand->auth_context.get(),
@@ -86,49 +86,55 @@ struct call_data {
86
86
  grpc_error_handle recv_trailing_metadata_error;
87
87
  bool seen_recv_trailing_metadata_ready = false;
88
88
  grpc_metadata_array md;
89
- const grpc_metadata* consumed_md;
90
- size_t num_consumed_md;
91
89
  grpc_closure cancel_closure;
92
90
  gpr_atm state = STATE_INIT; // async_state
93
91
  };
94
92
 
93
+ class ArrayEncoder {
94
+ public:
95
+ explicit ArrayEncoder(grpc_metadata_array* result) : result_(result) {}
96
+
97
+ void Encode(const grpc_core::Slice& key, const grpc_core::Slice& value) {
98
+ Append(key.Ref(), value.Ref());
99
+ }
100
+
101
+ template <typename Which>
102
+ void Encode(Which, const typename Which::ValueType& value) {
103
+ Append(grpc_core::Slice(
104
+ grpc_core::StaticSlice::FromStaticString(Which::key())),
105
+ grpc_core::Slice(Which::Encode(value)));
106
+ }
107
+
108
+ void Encode(grpc_core::HttpMethodMetadata,
109
+ const typename grpc_core::HttpMethodMetadata::ValueType&) {}
110
+
111
+ private:
112
+ void Append(grpc_core::Slice key, grpc_core::Slice value) {
113
+ if (result_->count == result_->capacity) {
114
+ result_->capacity =
115
+ std::max(result_->capacity + 8, result_->capacity * 2);
116
+ result_->metadata = static_cast<grpc_metadata*>(gpr_realloc(
117
+ result_->metadata, result_->capacity * sizeof(grpc_metadata)));
118
+ }
119
+ auto* usr_md = &result_->metadata[result_->count++];
120
+ usr_md->key = key.TakeCSlice();
121
+ usr_md->value = value.TakeCSlice();
122
+ }
123
+
124
+ grpc_metadata_array* result_;
125
+ };
126
+
95
127
  } // namespace
96
128
 
97
129
  static grpc_metadata_array metadata_batch_to_md_array(
98
130
  const grpc_metadata_batch* batch) {
99
131
  grpc_metadata_array result;
100
132
  grpc_metadata_array_init(&result);
101
- batch->ForEach([&](grpc_mdelem md) {
102
- grpc_metadata* usr_md = nullptr;
103
- grpc_slice key = GRPC_MDKEY(md);
104
- grpc_slice value = GRPC_MDVALUE(md);
105
- if (result.count == result.capacity) {
106
- result.capacity = std::max(result.capacity + 8, result.capacity * 2);
107
- result.metadata = static_cast<grpc_metadata*>(gpr_realloc(
108
- result.metadata, result.capacity * sizeof(grpc_metadata)));
109
- }
110
- usr_md = &result.metadata[result.count++];
111
- usr_md->key = grpc_slice_ref_internal(key);
112
- usr_md->value = grpc_slice_ref_internal(value);
113
- });
133
+ ArrayEncoder encoder(&result);
134
+ batch->Encode(&encoder);
114
135
  return result;
115
136
  }
116
137
 
117
- static grpc_filtered_mdelem remove_consumed_md(void* user_data,
118
- grpc_mdelem md) {
119
- grpc_call_element* elem = static_cast<grpc_call_element*>(user_data);
120
- call_data* calld = static_cast<call_data*>(elem->call_data);
121
- size_t i;
122
- for (i = 0; i < calld->num_consumed_md; i++) {
123
- const grpc_metadata* consumed_md = &calld->consumed_md[i];
124
- if (grpc_slice_eq(GRPC_MDKEY(md), consumed_md->key) &&
125
- grpc_slice_eq(GRPC_MDVALUE(md), consumed_md->value)) {
126
- return GRPC_FILTERED_REMOVE();
127
- }
128
- }
129
- return GRPC_FILTERED_MDELEM(md);
130
- }
131
-
132
138
  static void on_md_processing_done_inner(grpc_call_element* elem,
133
139
  const grpc_metadata* consumed_md,
134
140
  size_t num_consumed_md,
@@ -144,11 +150,10 @@ static void on_md_processing_done_inner(grpc_call_element* elem,
144
150
  "Ignoring...");
145
151
  }
146
152
  if (error == GRPC_ERROR_NONE) {
147
- calld->consumed_md = consumed_md;
148
- calld->num_consumed_md = num_consumed_md;
149
- error = grpc_metadata_batch_filter(
150
- batch->payload->recv_initial_metadata.recv_initial_metadata,
151
- remove_consumed_md, elem, "Response metadata filtering error");
153
+ for (size_t i = 0; i < num_consumed_md; i++) {
154
+ batch->payload->recv_initial_metadata.recv_initial_metadata->Remove(
155
+ grpc_core::StringViewFromSlice(consumed_md[i].key));
156
+ }
152
157
  }
153
158
  calld->recv_initial_metadata_error = GRPC_ERROR_REF(error);
154
159
  grpc_closure* closure = calld->original_recv_initial_metadata_ready;
@@ -16,7 +16,7 @@
16
16
 
17
17
  #include <grpc/support/port_platform.h>
18
18
 
19
- #include "src/core/ext/service_config/service_config.h"
19
+ #include "src/core/lib/service_config/service_config.h"
20
20
 
21
21
  #include <string>
22
22
 
@@ -24,8 +24,8 @@
24
24
 
25
25
  #include <grpc/support/log.h>
26
26
 
27
- #include "src/core/ext/service_config/service_config_parser.h"
28
27
  #include "src/core/lib/json/json.h"
28
+ #include "src/core/lib/service_config/service_config_parser.h"
29
29
  #include "src/core/lib/slice/slice_internal.h"
30
30
 
31
31
  namespace grpc_core {
@@ -14,8 +14,8 @@
14
14
  // limitations under the License.
15
15
  //
16
16
 
17
- #ifndef GRPC_CORE_EXT_SERVICE_CONFIG_SERVICE_CONFIG_H
18
- #define GRPC_CORE_EXT_SERVICE_CONFIG_SERVICE_CONFIG_H
17
+ #ifndef GRPC_CORE_LIB_SERVICE_CONFIG_SERVICE_CONFIG_H
18
+ #define GRPC_CORE_LIB_SERVICE_CONFIG_SERVICE_CONFIG_H
19
19
 
20
20
  #include <grpc/support/port_platform.h>
21
21
 
@@ -26,11 +26,11 @@
26
26
  #include <grpc/impl/codegen/grpc_types.h>
27
27
  #include <grpc/support/string_util.h>
28
28
 
29
- #include "src/core/ext/service_config/service_config_parser.h"
30
29
  #include "src/core/lib/gprpp/ref_counted.h"
31
30
  #include "src/core/lib/gprpp/ref_counted_ptr.h"
32
31
  #include "src/core/lib/iomgr/error.h"
33
32
  #include "src/core/lib/json/json.h"
33
+ #include "src/core/lib/service_config/service_config_parser.h"
34
34
  #include "src/core/lib/slice/slice_internal.h"
35
35
 
36
36
  // The main purpose of the code here is to parse the service config in
@@ -124,4 +124,4 @@ class ServiceConfig : public RefCounted<ServiceConfig> {
124
124
 
125
125
  } // namespace grpc_core
126
126
 
127
- #endif /* GRPC_CORE_EXT_SERVICE_CONFIG_SERVICE_CONFIG_H */
127
+ #endif /* GRPC_CORE_LIB_SERVICE_CONFIG_SERVICE_CONFIG_H */
@@ -14,8 +14,8 @@
14
14
  // limitations under the License.
15
15
  //
16
16
 
17
- #ifndef GRPC_CORE_EXT_SERVICE_CONFIG_SERVICE_CONFIG_CALL_DATA_H
18
- #define GRPC_CORE_EXT_SERVICE_CONFIG_SERVICE_CONFIG_CALL_DATA_H
17
+ #ifndef GRPC_CORE_LIB_SERVICE_CONFIG_SERVICE_CONFIG_CALL_DATA_H
18
+ #define GRPC_CORE_LIB_SERVICE_CONFIG_SERVICE_CONFIG_CALL_DATA_H
19
19
 
20
20
  #include <grpc/support/port_platform.h>
21
21
 
@@ -23,10 +23,10 @@
23
23
 
24
24
  #include "absl/strings/string_view.h"
25
25
 
26
- #include "src/core/ext/service_config/service_config.h"
27
- #include "src/core/ext/service_config/service_config_parser.h"
28
26
  #include "src/core/lib/channel/context.h"
29
27
  #include "src/core/lib/gprpp/ref_counted_ptr.h"
28
+ #include "src/core/lib/service_config/service_config.h"
29
+ #include "src/core/lib/service_config/service_config_parser.h"
30
30
 
31
31
  namespace grpc_core {
32
32
 
@@ -69,4 +69,4 @@ class ServiceConfigCallData {
69
69
 
70
70
  } // namespace grpc_core
71
71
 
72
- #endif /* GRPC_CORE_EXT_SERVICE_CONFIG_SERVICE_CONFIG_CALL_DATA_H */
72
+ #endif /* GRPC_CORE_LIB_SERVICE_CONFIG_SERVICE_CONFIG_CALL_DATA_H */
@@ -16,7 +16,7 @@
16
16
 
17
17
  #include <grpc/support/port_platform.h>
18
18
 
19
- #include "src/core/ext/service_config/service_config_parser.h"
19
+ #include "src/core/lib/service_config/service_config_parser.h"
20
20
 
21
21
  #include <grpc/support/log.h>
22
22
 
@@ -14,8 +14,8 @@
14
14
  // limitations under the License.
15
15
  //
16
16
 
17
- #ifndef GRPC_CORE_EXT_SERVICE_CONFIG_SERVICE_CONFIG_PARSER_H
18
- #define GRPC_CORE_EXT_SERVICE_CONFIG_SERVICE_CONFIG_PARSER_H
17
+ #ifndef GRPC_CORE_LIB_SERVICE_CONFIG_SERVICE_CONFIG_PARSER_H
18
+ #define GRPC_CORE_LIB_SERVICE_CONFIG_SERVICE_CONFIG_PARSER_H
19
19
 
20
20
  #include <grpc/support/port_platform.h>
21
21
 
@@ -94,4 +94,4 @@ class ServiceConfigParser {
94
94
 
95
95
  } // namespace grpc_core
96
96
 
97
- #endif /* GRPC_CORE_EXT_SERVICE_CONFIG_SERVICE_CONFIG_PARSER_H */
97
+ #endif /* GRPC_CORE_LIB_SERVICE_CONFIG_SERVICE_CONFIG_PARSER_H */
@@ -215,7 +215,9 @@ grpc_slice grpc_slice_from_copied_buffer(const char* source, size_t length) {
215
215
  slice = grpc_core::UnmanagedMemorySlice(
216
216
  length, grpc_core::UnmanagedMemorySlice::ForceHeapAllocation());
217
217
  }
218
- memcpy(GRPC_SLICE_START_PTR(slice), source, length);
218
+ if (length > 0) {
219
+ memcpy(GRPC_SLICE_START_PTR(slice), source, length);
220
+ }
219
221
  return slice;
220
222
  }
221
223