grpc 1.85.0 → 1.85.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Makefile +1 -1
- data/src/core/call/evaluate_args.cc +15 -14
- data/src/core/call/metadata_batch.h +21 -0
- data/src/core/channelz/ztrace_collector.h +11 -2
- data/src/core/credentials/call/oauth2/oauth2_credentials.cc +6 -4
- data/src/core/credentials/call/regional_access_boundary_fetcher.cc +16 -0
- data/src/core/credentials/call/regional_access_boundary_fetcher.h +6 -2
- data/src/core/ext/filters/http/server/http_server_filter.cc +6 -1
- data/src/core/ext/transport/chttp2/transport/hpack_parse_result.cc +3 -0
- data/src/core/ext/transport/chttp2/transport/hpack_parse_result.h +8 -0
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +33 -0
- data/src/core/lib/experiments/experiments.cc +3 -15
- data/src/core/lib/experiments/experiments.h +6 -11
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/load_balancing/autosharding/autosharding.cc +8 -0
- data/src/core/xds/grpc/xds_matcher_context.cc +8 -0
- data/src/core/xds/grpc/xds_matcher_context.h +3 -2
- data/src/core/xds/grpc/xds_routing.cc +22 -1
- data/src/core/xds/grpc/xds_routing.h +2 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- metadata +4081 -4049
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 45b30d253f4cf486a38f9b69bcc0a7041c238b6719d16b7e406208b433d01b54
|
|
4
|
+
data.tar.gz: 1868745a5677e021675a720ee686895446d3d13fecd601829208392593e9be26
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6cd92490fbb9fec0478b7c76c9e13250da8a320ed9c11f00b2f06a5e59f52d71df4b49c1f95315602ef639a819ea2a368794f2e430041384abe7bd41cdf83e2f
|
|
7
|
+
data.tar.gz: 48a53b20a0fafa0cbe36a5dd5976a4d299986ff0d9b4417b2320a913190de180c8450fc64aad6eddb7018cca8b0548e7f590e041d7413e5eb80afb37ccd64b49
|
data/Makefile
CHANGED
|
@@ -15,13 +15,18 @@
|
|
|
15
15
|
#include "src/core/call/evaluate_args.h"
|
|
16
16
|
|
|
17
17
|
#include <grpc/grpc_security_constants.h>
|
|
18
|
-
#include <grpc/support/port_platform.h>
|
|
19
18
|
#include <string.h>
|
|
20
19
|
|
|
20
|
+
#include <optional>
|
|
21
|
+
#include <vector>
|
|
22
|
+
|
|
23
|
+
#include "src/core/call/metadata_batch.h"
|
|
21
24
|
#include "src/core/credentials/transport/tls/tls_utils.h"
|
|
22
25
|
#include "src/core/handshaker/endpoint_info/endpoint_info_handshaker.h"
|
|
23
26
|
#include "src/core/lib/address_utils/parse_address.h"
|
|
27
|
+
#include "src/core/lib/channel/channel_args.h"
|
|
24
28
|
#include "src/core/lib/slice/slice.h"
|
|
29
|
+
#include "src/core/transport/auth_context.h"
|
|
25
30
|
#include "src/core/util/host_port.h"
|
|
26
31
|
#include "src/core/util/uri.h"
|
|
27
32
|
#include "absl/log/log.h"
|
|
@@ -29,6 +34,7 @@
|
|
|
29
34
|
#include "absl/status/statusor.h"
|
|
30
35
|
#include "absl/strings/match.h"
|
|
31
36
|
#include "absl/strings/numbers.h"
|
|
37
|
+
#include "absl/strings/string_view.h"
|
|
32
38
|
|
|
33
39
|
namespace grpc_core {
|
|
34
40
|
|
|
@@ -100,16 +106,10 @@ absl::string_view EvaluateArgs::GetPath() const {
|
|
|
100
106
|
}
|
|
101
107
|
|
|
102
108
|
absl::string_view EvaluateArgs::GetAuthority() const {
|
|
103
|
-
absl::string_view
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
} else if (auto* host_md = metadata_->get_pointer(HostMetadata())) {
|
|
108
|
-
// Fall back to the legacy host header.
|
|
109
|
-
authority = host_md->as_string_view();
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return authority;
|
|
109
|
+
if (metadata_ == nullptr) return absl::string_view();
|
|
110
|
+
const Slice* authority = GetAuthorityOrHost(*metadata_);
|
|
111
|
+
if (authority == nullptr) return absl::string_view();
|
|
112
|
+
return authority->as_string_view();
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
absl::string_view EvaluateArgs::GetMethod() const {
|
|
@@ -130,9 +130,10 @@ std::optional<absl::string_view> EvaluateArgs::GetHeaderValue(
|
|
|
130
130
|
if (absl::EqualsIgnoreCase(key, "te")) {
|
|
131
131
|
return std::nullopt;
|
|
132
132
|
}
|
|
133
|
-
if (
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
if (IsAuthorityHeaderName(key)) {
|
|
134
|
+
const Slice* authority = GetAuthorityOrHost(*metadata_);
|
|
135
|
+
if (authority == nullptr) return std::nullopt;
|
|
136
|
+
return authority->as_string_view();
|
|
136
137
|
}
|
|
137
138
|
return metadata_->GetStringValue(key, concatenated_value);
|
|
138
139
|
}
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
#include "absl/container/inlined_vector.h"
|
|
48
48
|
#include "absl/functional/function_ref.h"
|
|
49
49
|
#include "absl/meta/type_traits.h"
|
|
50
|
+
#include "absl/strings/match.h"
|
|
50
51
|
#include "absl/strings/numbers.h"
|
|
51
52
|
#include "absl/strings/string_view.h"
|
|
52
53
|
|
|
@@ -379,6 +380,13 @@ struct HttpAuthorityMetadata : public SimpleSliceBasedMetadata {
|
|
|
379
380
|
static absl::string_view key() { return ":authority"; }
|
|
380
381
|
};
|
|
381
382
|
|
|
383
|
+
// Returns true if `name` refers to the request authority, i.e. ":authority"
|
|
384
|
+
// or the legacy "host" header. Header names are compared case-insensitively.
|
|
385
|
+
inline bool IsAuthorityHeaderName(absl::string_view name) {
|
|
386
|
+
return absl::EqualsIgnoreCase(name, HttpAuthorityMetadata::key()) ||
|
|
387
|
+
absl::EqualsIgnoreCase(name, HostMetadata::key());
|
|
388
|
+
}
|
|
389
|
+
|
|
382
390
|
// :path metadata trait.
|
|
383
391
|
struct HttpPathMetadata : public SimpleSliceBasedMetadata {
|
|
384
392
|
static constexpr bool kPublishToApp = false;
|
|
@@ -1746,6 +1754,19 @@ Derived MetadataMap<Derived, Traits...>::Copy() const {
|
|
|
1746
1754
|
return out;
|
|
1747
1755
|
}
|
|
1748
1756
|
|
|
1757
|
+
// Returns the request authority: ":authority" if present, otherwise the
|
|
1758
|
+
// legacy "host" header, otherwise nullptr. Header matchers that look up the
|
|
1759
|
+
// authority (xDS route header matchers, RBAC, and xDS matcher contexts) use
|
|
1760
|
+
// this so that they all agree on the authority even if a request carries both
|
|
1761
|
+
// headers with different values.
|
|
1762
|
+
template <typename Derived, typename... Traits>
|
|
1763
|
+
const Slice* GetAuthorityOrHost(const MetadataMap<Derived, Traits...>& md) {
|
|
1764
|
+
if (const Slice* authority = md.get_pointer(HttpAuthorityMetadata())) {
|
|
1765
|
+
return authority;
|
|
1766
|
+
}
|
|
1767
|
+
return md.get_pointer(HostMetadata());
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1749
1770
|
} // namespace grpc_core
|
|
1750
1771
|
|
|
1751
1772
|
struct grpc_metadata_batch;
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
|
|
18
18
|
#include <grpc/support/time.h>
|
|
19
19
|
|
|
20
|
+
#include <algorithm>
|
|
21
|
+
#include <cstddef>
|
|
20
22
|
#include <memory>
|
|
21
23
|
#include <tuple>
|
|
22
24
|
#include <type_traits>
|
|
@@ -122,6 +124,9 @@ constexpr bool kIsElement<Needle, H, Haystack...> =
|
|
|
122
124
|
|
|
123
125
|
} // namespace ztrace_collector_detail
|
|
124
126
|
|
|
127
|
+
constexpr int64_t kDefaultZTraceMemoryCap = 1024 * 1024;
|
|
128
|
+
constexpr int64_t kMaxZTraceMemoryCap = 16 * 1024 * 1024;
|
|
129
|
+
|
|
125
130
|
inline std::optional<int64_t> IntFromArgs(const ZTrace::Args& args,
|
|
126
131
|
const std::string& name) {
|
|
127
132
|
auto it = args.find(name);
|
|
@@ -220,7 +225,9 @@ class ZTraceCollector {
|
|
|
220
225
|
Instance(ZTrace::Args args,
|
|
221
226
|
std::shared_ptr<grpc_event_engine::experimental::EventEngine>
|
|
222
227
|
event_engine)
|
|
223
|
-
: memory_cap_(
|
|
228
|
+
: memory_cap_(std::clamp<int64_t>(
|
|
229
|
+
IntFromArgs(args, "memory_cap").value_or(kDefaultZTraceMemoryCap),
|
|
230
|
+
0, kMaxZTraceMemoryCap)),
|
|
224
231
|
config_(std::move(args)),
|
|
225
232
|
event_engine_(std::move(event_engine)) {}
|
|
226
233
|
using Collections = std::tuple<Collection<Data>...>;
|
|
@@ -236,8 +243,10 @@ class ZTraceCollector {
|
|
|
236
243
|
return;
|
|
237
244
|
}
|
|
238
245
|
if (state_ == State::kDone) return;
|
|
246
|
+
size_t incoming_usage = MemoryUsageOf(value.second);
|
|
247
|
+
if (incoming_usage > memory_cap_) return;
|
|
239
248
|
++items_matched_;
|
|
240
|
-
memory_used_ +=
|
|
249
|
+
memory_used_ += incoming_usage;
|
|
241
250
|
while (memory_used_ > memory_cap_) {
|
|
242
251
|
auto memory_used_before = memory_used_;
|
|
243
252
|
RemoveMostRecent();
|
|
@@ -255,7 +255,9 @@ class TokenWithEmail final : public grpc_core::TokenFetcherCredentials::Token {
|
|
|
255
255
|
void AddTokenToClientInitialMetadata(
|
|
256
256
|
grpc_core::ClientMetadata& metadata) override {
|
|
257
257
|
Token::AddTokenToClientInitialMetadata(metadata);
|
|
258
|
-
email_fetcher_
|
|
258
|
+
if (email_fetcher_ != nullptr) {
|
|
259
|
+
email_fetcher_->Fetch(token().as_string_view(), metadata);
|
|
260
|
+
}
|
|
259
261
|
}
|
|
260
262
|
|
|
261
263
|
private:
|
|
@@ -266,10 +268,10 @@ class grpc_compute_engine_token_fetcher_credentials
|
|
|
266
268
|
: public grpc_core::HttpTokenFetcherCredentials {
|
|
267
269
|
public:
|
|
268
270
|
grpc_compute_engine_token_fetcher_credentials()
|
|
269
|
-
: email_fetcher_(grpc_core::
|
|
271
|
+
: email_fetcher_(grpc_core::EmailFetcher::Create()) {}
|
|
270
272
|
explicit grpc_compute_engine_token_fetcher_credentials(
|
|
271
273
|
std::vector<grpc_core::URI::QueryParam> query_params)
|
|
272
|
-
: email_fetcher_(grpc_core::
|
|
274
|
+
: email_fetcher_(grpc_core::EmailFetcher::Create()),
|
|
273
275
|
query_params_(std::move(query_params)) {}
|
|
274
276
|
|
|
275
277
|
std::string debug_string() override {
|
|
@@ -285,7 +287,7 @@ class grpc_compute_engine_token_fetcher_credentials
|
|
|
285
287
|
grpc_core::OrphanablePtr<grpc_core::HttpRequest> StartHttpRequest(
|
|
286
288
|
grpc_polling_entity* pollent, grpc_core::Timestamp deadline,
|
|
287
289
|
grpc_http_response* response, grpc_closure* on_complete) override {
|
|
288
|
-
email_fetcher_->StartEmailFetch();
|
|
290
|
+
if (email_fetcher_ != nullptr) email_fetcher_->StartEmailFetch();
|
|
289
291
|
memset(response, 0, sizeof(*response));
|
|
290
292
|
grpc_http_header header = {const_cast<char*>("Metadata-Flavor"),
|
|
291
293
|
const_cast<char*>("Google")};
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
#include <grpc/support/alloc.h>
|
|
20
20
|
#include <grpc/support/string_util.h>
|
|
21
21
|
|
|
22
|
+
#include "src/core/config/experiment_env_var.h"
|
|
22
23
|
#include "src/core/credentials/call/call_credentials.h"
|
|
23
24
|
#include "src/core/credentials/transport/transport_credentials.h"
|
|
24
25
|
#include "src/core/lib/iomgr/polling_entity.h"
|
|
@@ -40,6 +41,7 @@
|
|
|
40
41
|
namespace grpc_core {
|
|
41
42
|
|
|
42
43
|
namespace {
|
|
44
|
+
|
|
43
45
|
constexpr absl::string_view kAllowedLocationsKey = "x-allowed-locations";
|
|
44
46
|
constexpr Duration kRegionalAccessBoundarySoftCacheGraceDuration =
|
|
45
47
|
Duration::Hours(1);
|
|
@@ -47,6 +49,12 @@ constexpr Duration kRegionalAccessBoundaryCacheDuration = Duration::Hours(6);
|
|
|
47
49
|
constexpr absl::string_view kRegionalEndpoint = "rep.googleapis.com";
|
|
48
50
|
constexpr char kComputeEngineDefaultSaEmailPath[] =
|
|
49
51
|
"/computeMetadata/v1/instance/service-accounts/default/email";
|
|
52
|
+
|
|
53
|
+
bool IsRegionalAccessBoundaryFetcherEnabled() {
|
|
54
|
+
return IsExperimentEnvVarEnabled(
|
|
55
|
+
"GRPC_EXPERIMENTAL_REGIONAL_ACCESS_BOUNDARY_LOOKUP");
|
|
56
|
+
}
|
|
57
|
+
|
|
50
58
|
} // namespace
|
|
51
59
|
|
|
52
60
|
RefCountedPtr<RegionalAccessBoundaryFetcher>
|
|
@@ -54,6 +62,7 @@ RegionalAccessBoundaryFetcher::Create(
|
|
|
54
62
|
absl::string_view lookup_url,
|
|
55
63
|
std::shared_ptr<grpc_event_engine::experimental::EventEngine> event_engine,
|
|
56
64
|
std::optional<BackOff::Options> backoff_options) {
|
|
65
|
+
if (!IsRegionalAccessBoundaryFetcherEnabled()) return nullptr;
|
|
57
66
|
auto uri = URI::Parse(lookup_url);
|
|
58
67
|
if (!uri.ok()) {
|
|
59
68
|
LOG(INFO) << "Invalid RegionalAccessBoundary lookup URI \"" << lookup_url
|
|
@@ -313,6 +322,13 @@ class EmailFetcher::EmailRequest final
|
|
|
313
322
|
grpc_closure closure_;
|
|
314
323
|
};
|
|
315
324
|
|
|
325
|
+
RefCountedPtr<EmailFetcher> EmailFetcher::Create(
|
|
326
|
+
std::shared_ptr<grpc_event_engine::experimental::EventEngine>
|
|
327
|
+
event_engine) {
|
|
328
|
+
if (!IsRegionalAccessBoundaryFetcherEnabled()) return nullptr;
|
|
329
|
+
return MakeRefCounted<EmailFetcher>(std::move(event_engine));
|
|
330
|
+
}
|
|
331
|
+
|
|
316
332
|
EmailFetcher::EmailFetcher(
|
|
317
333
|
std::shared_ptr<grpc_event_engine::experimental::EventEngine> event_engine)
|
|
318
334
|
: event_engine_(
|
|
@@ -64,7 +64,7 @@ class RegionalAccessBoundaryFetcher final
|
|
|
64
64
|
void Orphaned() override;
|
|
65
65
|
|
|
66
66
|
private:
|
|
67
|
-
friend class
|
|
67
|
+
friend class RegionalAccessBoundaryFetcherTestBase;
|
|
68
68
|
|
|
69
69
|
struct RegionalAccessBoundary {
|
|
70
70
|
Slice encoded_locations;
|
|
@@ -115,6 +115,10 @@ class RegionalAccessBoundaryFetcher::Request final
|
|
|
115
115
|
|
|
116
116
|
class EmailFetcher final : public DualRefCounted<EmailFetcher> {
|
|
117
117
|
public:
|
|
118
|
+
static RefCountedPtr<EmailFetcher> Create(
|
|
119
|
+
std::shared_ptr<grpc_event_engine::experimental::EventEngine>
|
|
120
|
+
event_engine = nullptr);
|
|
121
|
+
|
|
118
122
|
explicit EmailFetcher(
|
|
119
123
|
std::shared_ptr<grpc_event_engine::experimental::EventEngine>
|
|
120
124
|
event_engine = nullptr);
|
|
@@ -155,4 +159,4 @@ class EmailFetcher final : public DualRefCounted<EmailFetcher> {
|
|
|
155
159
|
|
|
156
160
|
} // namespace grpc_core
|
|
157
161
|
|
|
158
|
-
#endif // GRPC_SRC_CORE_CREDENTIALS_CALL_REGIONAL_ACCESS_BOUNDARY_FETCHER_H
|
|
162
|
+
#endif // GRPC_SRC_CORE_CREDENTIALS_CALL_REGIONAL_ACCESS_BOUNDARY_FETCHER_H
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
#include "src/core/lib/channel/channel_args.h"
|
|
32
32
|
#include "src/core/lib/channel/channel_stack.h"
|
|
33
33
|
#include "src/core/lib/debug/trace.h"
|
|
34
|
+
#include "src/core/lib/experiments/experiments.h"
|
|
34
35
|
#include "src/core/lib/promise/activity.h"
|
|
35
36
|
#include "src/core/lib/promise/context.h"
|
|
36
37
|
#include "src/core/lib/promise/map.h"
|
|
@@ -115,7 +116,11 @@ ServerMetadataHandle HttpServerFilter::Call::OnClientInitialMetadata(
|
|
|
115
116
|
return MalformedRequest("Missing :path header");
|
|
116
117
|
}
|
|
117
118
|
|
|
118
|
-
|
|
119
|
+
// TODO(rishesh): Remove this once the map_host_header_to_authority
|
|
120
|
+
// experiment rolls out, since the HPACK parser then copies "host" into
|
|
121
|
+
// ":authority" itself.
|
|
122
|
+
if (!IsMapHostHeaderToAuthorityEnabled() &&
|
|
123
|
+
md.get_pointer(HttpAuthorityMetadata()) == nullptr) {
|
|
119
124
|
std::optional<Slice> host = md.Take(HostMetadata());
|
|
120
125
|
if (host.has_value()) {
|
|
121
126
|
md.Set(HttpAuthorityMetadata(), std::move(*host));
|
|
@@ -127,6 +127,9 @@ absl::Status HpackParseResult::BuildMaterialized() const {
|
|
|
127
127
|
} else {
|
|
128
128
|
return MakeStreamError(absl::InternalError("Error parsing metadata"));
|
|
129
129
|
}
|
|
130
|
+
case HpackParseStatus::kDuplicateHeader:
|
|
131
|
+
return MakeStreamError(absl::InternalError(
|
|
132
|
+
absl::StrCat("Duplicate '", state_->key, "' header received")));
|
|
130
133
|
case HpackParseStatus::kUnbase64Failed:
|
|
131
134
|
if (!state_->key.empty()) {
|
|
132
135
|
return MakeStreamError(absl::InternalError(
|
|
@@ -68,6 +68,8 @@ enum class HpackParseStatus : uint8_t {
|
|
|
68
68
|
// Hard metadata limit exceeded by a single value string
|
|
69
69
|
kHardMetadataLimitExceededByValue,
|
|
70
70
|
kMetadataParseError,
|
|
71
|
+
// Duplicate header received for a non-repeatable metadata key
|
|
72
|
+
kDuplicateHeader,
|
|
71
73
|
// Parse failed due to a base64 decode error
|
|
72
74
|
kUnbase64Failed,
|
|
73
75
|
// Error triggered by the mitigation engine (stream error)
|
|
@@ -178,6 +180,12 @@ class HpackParseResult {
|
|
|
178
180
|
return r;
|
|
179
181
|
}
|
|
180
182
|
|
|
183
|
+
static HpackParseResult DuplicateHeaderError(absl::string_view key) {
|
|
184
|
+
HpackParseResult r{HpackParseStatus::kDuplicateHeader};
|
|
185
|
+
r.state_->key = std::string(key);
|
|
186
|
+
return r;
|
|
187
|
+
}
|
|
188
|
+
|
|
181
189
|
static HpackParseResult AddBeforeTableSizeUpdated(uint32_t current_size,
|
|
182
190
|
uint32_t max_size) {
|
|
183
191
|
HpackParseResult p{HpackParseStatus::kAddBeforeTableSizeUpdated};
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
#include "src/core/ext/transport/chttp2/transport/hpack_parse_result.h"
|
|
38
38
|
#include "src/core/ext/transport/chttp2/transport/hpack_parser_table.h"
|
|
39
39
|
#include "src/core/lib/debug/trace.h"
|
|
40
|
+
#include "src/core/lib/experiments/experiments.h"
|
|
40
41
|
#include "src/core/lib/slice/slice.h"
|
|
41
42
|
#include "src/core/lib/slice/slice_refcount.h"
|
|
42
43
|
#include "src/core/lib/surface/validate_metadata.h"
|
|
@@ -728,6 +729,20 @@ class HPackParser::Parser {
|
|
|
728
729
|
input_->SetErrorAndContinueParsing(*md.parse_status);
|
|
729
730
|
}
|
|
730
731
|
if (GPR_LIKELY(metadata_buffer_ != nullptr)) {
|
|
732
|
+
if (IsMapHostHeaderToAuthorityEnabled()) {
|
|
733
|
+
if (GPR_UNLIKELY(metadata_buffer_->get_pointer(
|
|
734
|
+
HttpAuthorityMetadata()) != nullptr &&
|
|
735
|
+
md.md.key() == HttpAuthorityMetadata::key())) {
|
|
736
|
+
input_->SetErrorAndContinueParsing(
|
|
737
|
+
HpackParseResult::DuplicateHeaderError(
|
|
738
|
+
HttpAuthorityMetadata::key()));
|
|
739
|
+
} else if (GPR_UNLIKELY(metadata_buffer_->get_pointer(HostMetadata()) !=
|
|
740
|
+
nullptr &&
|
|
741
|
+
md.md.key() == HostMetadata::key())) {
|
|
742
|
+
input_->SetErrorAndContinueParsing(
|
|
743
|
+
HpackParseResult::DuplicateHeaderError(HostMetadata::key()));
|
|
744
|
+
}
|
|
745
|
+
}
|
|
731
746
|
metadata_buffer_->Set(md.md);
|
|
732
747
|
}
|
|
733
748
|
if (state_.metadata_early_detection.MustReject(state_.frame_length)) {
|
|
@@ -1163,6 +1178,24 @@ grpc_error_handle HPackParser::ParseInput(Input input, bool is_last,
|
|
|
1163
1178
|
CallSpan* call_tracer) {
|
|
1164
1179
|
ParseInputInner(&input);
|
|
1165
1180
|
if (is_last && is_boundary()) {
|
|
1181
|
+
if (IsMapHostHeaderToAuthorityEnabled() && metadata_buffer_ != nullptr &&
|
|
1182
|
+
!log_info_.is_client && log_info_.type == LogInfo::kHeaders) {
|
|
1183
|
+
// Note: HostMetadata cannot be removed completely from
|
|
1184
|
+
// grpc_metadata_batch or parsed directly as HttpAuthorityMetadata because
|
|
1185
|
+
// "host" is stored at index 38 in the HPACK static table (and may be
|
|
1186
|
+
// added to the dynamic table). HPackTable::Memento preserves HostMetadata
|
|
1187
|
+
// so that indexed key lookups return "host" (4 bytes) rather than
|
|
1188
|
+
// ":authority" (10 bytes), preventing HPACK dynamic table size
|
|
1189
|
+
// desynchronization (RFC 7541). Once a server has fully parsed the
|
|
1190
|
+
// request headers, if "host" is present and ":authority" is missing, we
|
|
1191
|
+
// copy "host" into HttpAuthorityMetadata so that downstream layers are
|
|
1192
|
+
// guaranteed to see HttpAuthorityMetadata. HostMetadata is left as-is.
|
|
1193
|
+
const Slice* host = metadata_buffer_->get_pointer(HostMetadata());
|
|
1194
|
+
if (host != nullptr &&
|
|
1195
|
+
metadata_buffer_->get_pointer(HttpAuthorityMetadata()) == nullptr) {
|
|
1196
|
+
metadata_buffer_->Set(HttpAuthorityMetadata(), host->Ref());
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1166
1199
|
if (state_.mitigation_engine != nullptr && metadata_buffer_ != nullptr) {
|
|
1167
1200
|
auto action = state_.mitigation_engine->EvaluateAllIncomingMetadata(
|
|
1168
1201
|
*metadata_buffer_,
|
|
@@ -102,8 +102,6 @@ const char* const additional_constraints_header_data_frame = "{}";
|
|
|
102
102
|
const char* const description_inproc_cancel_stream =
|
|
103
103
|
"If set, cancel inproc stream inside the transport mutex.";
|
|
104
104
|
const char* const additional_constraints_inproc_cancel_stream = "{}";
|
|
105
|
-
const char* const description_internal_fix = "Gate for the internal fix.";
|
|
106
|
-
const char* const additional_constraints_internal_fix = "{}";
|
|
107
105
|
const char* const description_keep_alive_ping_timer_batch =
|
|
108
106
|
"Avoid explicitly cancelling the keepalive timer. Instead adjust the "
|
|
109
107
|
"callback to re-schedule itself to the next ping interval.";
|
|
@@ -341,15 +339,13 @@ const ExperimentMetadata g_experiment_metadata[] = {
|
|
|
341
339
|
additional_constraints_header_data_frame, nullptr, 0, true, true},
|
|
342
340
|
{"inproc_cancel_stream", description_inproc_cancel_stream,
|
|
343
341
|
additional_constraints_inproc_cancel_stream, nullptr, 0, true, true},
|
|
344
|
-
{"internal_fix", description_internal_fix,
|
|
345
|
-
additional_constraints_internal_fix, nullptr, 0, false, true},
|
|
346
342
|
{"keep_alive_ping_timer_batch", description_keep_alive_ping_timer_batch,
|
|
347
343
|
additional_constraints_keep_alive_ping_timer_batch, nullptr, 0, false,
|
|
348
344
|
true},
|
|
349
345
|
{"local_connector_secure", description_local_connector_secure,
|
|
350
346
|
additional_constraints_local_connector_secure, nullptr, 0, false, true},
|
|
351
347
|
{"map_host_header_to_authority", description_map_host_header_to_authority,
|
|
352
|
-
additional_constraints_map_host_header_to_authority, nullptr, 0,
|
|
348
|
+
additional_constraints_map_host_header_to_authority, nullptr, 0, true,
|
|
353
349
|
true},
|
|
354
350
|
{"memory_optimization_01", description_memory_optimization_01,
|
|
355
351
|
additional_constraints_memory_optimization_01, nullptr, 0, false, false},
|
|
@@ -562,8 +558,6 @@ const char* const additional_constraints_header_data_frame = "{}";
|
|
|
562
558
|
const char* const description_inproc_cancel_stream =
|
|
563
559
|
"If set, cancel inproc stream inside the transport mutex.";
|
|
564
560
|
const char* const additional_constraints_inproc_cancel_stream = "{}";
|
|
565
|
-
const char* const description_internal_fix = "Gate for the internal fix.";
|
|
566
|
-
const char* const additional_constraints_internal_fix = "{}";
|
|
567
561
|
const char* const description_keep_alive_ping_timer_batch =
|
|
568
562
|
"Avoid explicitly cancelling the keepalive timer. Instead adjust the "
|
|
569
563
|
"callback to re-schedule itself to the next ping interval.";
|
|
@@ -801,15 +795,13 @@ const ExperimentMetadata g_experiment_metadata[] = {
|
|
|
801
795
|
additional_constraints_header_data_frame, nullptr, 0, true, true},
|
|
802
796
|
{"inproc_cancel_stream", description_inproc_cancel_stream,
|
|
803
797
|
additional_constraints_inproc_cancel_stream, nullptr, 0, true, true},
|
|
804
|
-
{"internal_fix", description_internal_fix,
|
|
805
|
-
additional_constraints_internal_fix, nullptr, 0, false, true},
|
|
806
798
|
{"keep_alive_ping_timer_batch", description_keep_alive_ping_timer_batch,
|
|
807
799
|
additional_constraints_keep_alive_ping_timer_batch, nullptr, 0, false,
|
|
808
800
|
true},
|
|
809
801
|
{"local_connector_secure", description_local_connector_secure,
|
|
810
802
|
additional_constraints_local_connector_secure, nullptr, 0, false, true},
|
|
811
803
|
{"map_host_header_to_authority", description_map_host_header_to_authority,
|
|
812
|
-
additional_constraints_map_host_header_to_authority, nullptr, 0,
|
|
804
|
+
additional_constraints_map_host_header_to_authority, nullptr, 0, true,
|
|
813
805
|
true},
|
|
814
806
|
{"memory_optimization_01", description_memory_optimization_01,
|
|
815
807
|
additional_constraints_memory_optimization_01, nullptr, 0, false, false},
|
|
@@ -1022,8 +1014,6 @@ const char* const additional_constraints_header_data_frame = "{}";
|
|
|
1022
1014
|
const char* const description_inproc_cancel_stream =
|
|
1023
1015
|
"If set, cancel inproc stream inside the transport mutex.";
|
|
1024
1016
|
const char* const additional_constraints_inproc_cancel_stream = "{}";
|
|
1025
|
-
const char* const description_internal_fix = "Gate for the internal fix.";
|
|
1026
|
-
const char* const additional_constraints_internal_fix = "{}";
|
|
1027
1017
|
const char* const description_keep_alive_ping_timer_batch =
|
|
1028
1018
|
"Avoid explicitly cancelling the keepalive timer. Instead adjust the "
|
|
1029
1019
|
"callback to re-schedule itself to the next ping interval.";
|
|
@@ -1261,15 +1251,13 @@ const ExperimentMetadata g_experiment_metadata[] = {
|
|
|
1261
1251
|
additional_constraints_header_data_frame, nullptr, 0, true, true},
|
|
1262
1252
|
{"inproc_cancel_stream", description_inproc_cancel_stream,
|
|
1263
1253
|
additional_constraints_inproc_cancel_stream, nullptr, 0, true, true},
|
|
1264
|
-
{"internal_fix", description_internal_fix,
|
|
1265
|
-
additional_constraints_internal_fix, nullptr, 0, false, true},
|
|
1266
1254
|
{"keep_alive_ping_timer_batch", description_keep_alive_ping_timer_batch,
|
|
1267
1255
|
additional_constraints_keep_alive_ping_timer_batch, nullptr, 0, false,
|
|
1268
1256
|
true},
|
|
1269
1257
|
{"local_connector_secure", description_local_connector_secure,
|
|
1270
1258
|
additional_constraints_local_connector_secure, nullptr, 0, false, true},
|
|
1271
1259
|
{"map_host_header_to_authority", description_map_host_header_to_authority,
|
|
1272
|
-
additional_constraints_map_host_header_to_authority, nullptr, 0,
|
|
1260
|
+
additional_constraints_map_host_header_to_authority, nullptr, 0, true,
|
|
1273
1261
|
true},
|
|
1274
1262
|
{"memory_optimization_01", description_memory_optimization_01,
|
|
1275
1263
|
additional_constraints_memory_optimization_01, nullptr, 0, false, false},
|
|
@@ -94,10 +94,10 @@ inline bool IsH2MaxDeallocatingStreamsHeadroomEnabled() { return false; }
|
|
|
94
94
|
inline bool IsHeaderDataFrameEnabled() { return true; }
|
|
95
95
|
#define GRPC_EXPERIMENT_IS_INCLUDED_INPROC_CANCEL_STREAM
|
|
96
96
|
inline bool IsInprocCancelStreamEnabled() { return true; }
|
|
97
|
-
inline bool IsInternalFixEnabled() { return false; }
|
|
98
97
|
inline bool IsKeepAlivePingTimerBatchEnabled() { return false; }
|
|
99
98
|
inline bool IsLocalConnectorSecureEnabled() { return false; }
|
|
100
|
-
|
|
99
|
+
#define GRPC_EXPERIMENT_IS_INCLUDED_MAP_HOST_HEADER_TO_AUTHORITY
|
|
100
|
+
inline bool IsMapHostHeaderToAuthorityEnabled() { return true; }
|
|
101
101
|
inline bool IsMemoryOptimization01Enabled() { return false; }
|
|
102
102
|
inline bool IsMemoryOptimization02Enabled() { return false; }
|
|
103
103
|
#define GRPC_EXPERIMENT_IS_INCLUDED_MESSAGE_SIZE_REFACTORING
|
|
@@ -191,10 +191,10 @@ inline bool IsH2MaxDeallocatingStreamsHeadroomEnabled() { return false; }
|
|
|
191
191
|
inline bool IsHeaderDataFrameEnabled() { return true; }
|
|
192
192
|
#define GRPC_EXPERIMENT_IS_INCLUDED_INPROC_CANCEL_STREAM
|
|
193
193
|
inline bool IsInprocCancelStreamEnabled() { return true; }
|
|
194
|
-
inline bool IsInternalFixEnabled() { return false; }
|
|
195
194
|
inline bool IsKeepAlivePingTimerBatchEnabled() { return false; }
|
|
196
195
|
inline bool IsLocalConnectorSecureEnabled() { return false; }
|
|
197
|
-
|
|
196
|
+
#define GRPC_EXPERIMENT_IS_INCLUDED_MAP_HOST_HEADER_TO_AUTHORITY
|
|
197
|
+
inline bool IsMapHostHeaderToAuthorityEnabled() { return true; }
|
|
198
198
|
inline bool IsMemoryOptimization01Enabled() { return false; }
|
|
199
199
|
inline bool IsMemoryOptimization02Enabled() { return false; }
|
|
200
200
|
#define GRPC_EXPERIMENT_IS_INCLUDED_MESSAGE_SIZE_REFACTORING
|
|
@@ -288,10 +288,10 @@ inline bool IsH2MaxDeallocatingStreamsHeadroomEnabled() { return false; }
|
|
|
288
288
|
inline bool IsHeaderDataFrameEnabled() { return true; }
|
|
289
289
|
#define GRPC_EXPERIMENT_IS_INCLUDED_INPROC_CANCEL_STREAM
|
|
290
290
|
inline bool IsInprocCancelStreamEnabled() { return true; }
|
|
291
|
-
inline bool IsInternalFixEnabled() { return false; }
|
|
292
291
|
inline bool IsKeepAlivePingTimerBatchEnabled() { return false; }
|
|
293
292
|
inline bool IsLocalConnectorSecureEnabled() { return false; }
|
|
294
|
-
|
|
293
|
+
#define GRPC_EXPERIMENT_IS_INCLUDED_MAP_HOST_HEADER_TO_AUTHORITY
|
|
294
|
+
inline bool IsMapHostHeaderToAuthorityEnabled() { return true; }
|
|
295
295
|
inline bool IsMemoryOptimization01Enabled() { return false; }
|
|
296
296
|
inline bool IsMemoryOptimization02Enabled() { return false; }
|
|
297
297
|
#define GRPC_EXPERIMENT_IS_INCLUDED_MESSAGE_SIZE_REFACTORING
|
|
@@ -370,7 +370,6 @@ enum ExperimentIds {
|
|
|
370
370
|
kExperimentIdH2MaxDeallocatingStreamsHeadroom,
|
|
371
371
|
kExperimentIdHeaderDataFrame,
|
|
372
372
|
kExperimentIdInprocCancelStream,
|
|
373
|
-
kExperimentIdInternalFix,
|
|
374
373
|
kExperimentIdKeepAlivePingTimerBatch,
|
|
375
374
|
kExperimentIdLocalConnectorSecure,
|
|
376
375
|
kExperimentIdMapHostHeaderToAuthority,
|
|
@@ -500,10 +499,6 @@ inline bool IsHeaderDataFrameEnabled() {
|
|
|
500
499
|
inline bool IsInprocCancelStreamEnabled() {
|
|
501
500
|
return IsExperimentEnabled<kExperimentIdInprocCancelStream>();
|
|
502
501
|
}
|
|
503
|
-
#define GRPC_EXPERIMENT_IS_INCLUDED_INTERNAL_FIX
|
|
504
|
-
inline bool IsInternalFixEnabled() {
|
|
505
|
-
return IsExperimentEnabled<kExperimentIdInternalFix>();
|
|
506
|
-
}
|
|
507
502
|
#define GRPC_EXPERIMENT_IS_INCLUDED_KEEP_ALIVE_PING_TIMER_BATCH
|
|
508
503
|
inline bool IsKeepAlivePingTimerBatchEnabled() {
|
|
509
504
|
return IsExperimentEnabled<kExperimentIdKeepAlivePingTimerBatch>();
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
#include <vector>
|
|
30
30
|
|
|
31
31
|
#include "src/core/config/core_configuration.h"
|
|
32
|
+
#include "src/core/config/experiment_env_var.h"
|
|
32
33
|
#include "src/core/lib/address_utils/sockaddr_utils.h"
|
|
33
34
|
#include "src/core/lib/channel/channel_args.h"
|
|
34
35
|
#include "src/core/lib/debug/trace.h"
|
|
@@ -924,6 +925,13 @@ void AutoShardingLbConfig::JsonPostLoad(const Json&, const JsonArgs&,
|
|
|
924
925
|
}
|
|
925
926
|
|
|
926
927
|
void RegisterAutoShardingLbPolicy(CoreConfiguration::Builder* builder) {
|
|
928
|
+
// TODO(bpawan): Remove this once the feature has proven stable (gRFC A119).
|
|
929
|
+
// If the policy is not registered, a service config that lists it falls
|
|
930
|
+
// through to the next policy in its loadBalancingConfig list.
|
|
931
|
+
if (!IsExperimentEnvVarEnabled(
|
|
932
|
+
"GRPC_XDS_EXPERIMENTAL_ENABLE_AUTOSHARDING_LB")) {
|
|
933
|
+
return;
|
|
934
|
+
}
|
|
927
935
|
builder->lb_policy_registry()->RegisterLoadBalancingPolicyFactory(
|
|
928
936
|
std::make_unique<AutoShardingFactory>());
|
|
929
937
|
}
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
|
|
15
15
|
#include "src/core/xds/grpc/xds_matcher_context.h"
|
|
16
16
|
|
|
17
|
+
#include "src/core/call/metadata_batch.h"
|
|
18
|
+
#include "src/core/lib/slice/slice.h"
|
|
19
|
+
#include "absl/strings/string_view.h"
|
|
20
|
+
|
|
17
21
|
namespace grpc_core {
|
|
18
22
|
|
|
19
23
|
std::optional<absl::string_view> RpcMatchContext::GetHeaderValue(
|
|
@@ -22,6 +26,10 @@ std::optional<absl::string_view> RpcMatchContext::GetHeaderValue(
|
|
|
22
26
|
return std::nullopt;
|
|
23
27
|
} else if (header_name == "content-type") {
|
|
24
28
|
return "application/grpc";
|
|
29
|
+
} else if (IsAuthorityHeaderName(header_name)) {
|
|
30
|
+
const Slice* authority = GetAuthorityOrHost(*initial_metadata_);
|
|
31
|
+
if (authority == nullptr) return std::nullopt;
|
|
32
|
+
return authority->as_string_view();
|
|
25
33
|
}
|
|
26
34
|
return initial_metadata_->GetStringValue(header_name, &buffer_);
|
|
27
35
|
}
|
|
@@ -31,8 +31,9 @@ class RpcMatchContext : public XdsMatcher::MatchContext {
|
|
|
31
31
|
UniqueTypeName type() const override { return Type(); }
|
|
32
32
|
|
|
33
33
|
// Returns the metadata value(s) for the specified key.
|
|
34
|
-
// As special cases, binary headers return a value of std::nullopt,
|
|
35
|
-
// "content-type" header returns "application/grpc"
|
|
34
|
+
// As special cases, binary headers return a value of std::nullopt,
|
|
35
|
+
// "content-type" header returns "application/grpc", and "host" and
|
|
36
|
+
// ":authority" both return GetAuthorityOrHost().
|
|
36
37
|
std::optional<absl::string_view> GetHeaderValue(
|
|
37
38
|
absl::string_view header_name) const;
|
|
38
39
|
|
|
@@ -23,18 +23,33 @@
|
|
|
23
23
|
|
|
24
24
|
#include <algorithm>
|
|
25
25
|
#include <cctype>
|
|
26
|
+
#include <optional>
|
|
27
|
+
#include <string>
|
|
26
28
|
#include <utility>
|
|
29
|
+
#include <vector>
|
|
27
30
|
|
|
31
|
+
#include "src/core/call/metadata_batch.h"
|
|
32
|
+
#include "src/core/filter/filter_args.h"
|
|
33
|
+
#include "src/core/filter/filter_chain.h"
|
|
28
34
|
#include "src/core/lib/channel/channel_args.h"
|
|
35
|
+
#include "src/core/lib/debug/trace.h"
|
|
36
|
+
#include "src/core/lib/slice/slice.h"
|
|
29
37
|
#include "src/core/util/grpc_check.h"
|
|
38
|
+
#include "src/core/util/json/json.h"
|
|
30
39
|
#include "src/core/util/matchers.h"
|
|
40
|
+
#include "src/core/util/ref_counted_ptr.h"
|
|
41
|
+
#include "src/core/xds/grpc/blackboard.h"
|
|
31
42
|
#include "src/core/xds/grpc/xds_http_filter.h"
|
|
32
|
-
#include "
|
|
43
|
+
#include "src/core/xds/grpc/xds_http_filter_registry.h"
|
|
44
|
+
#include "src/core/xds/grpc/xds_listener.h"
|
|
45
|
+
#include "src/core/xds/grpc/xds_route_config.h"
|
|
46
|
+
#include "src/core/xds/xds_client/xds_transport.h"
|
|
33
47
|
#include "absl/functional/function_ref.h"
|
|
34
48
|
#include "absl/status/status.h"
|
|
35
49
|
#include "absl/status/statusor.h"
|
|
36
50
|
#include "absl/strings/match.h"
|
|
37
51
|
#include "absl/strings/str_cat.h"
|
|
52
|
+
#include "absl/strings/string_view.h"
|
|
38
53
|
|
|
39
54
|
namespace grpc_core {
|
|
40
55
|
|
|
@@ -187,6 +202,12 @@ std::optional<absl::string_view> XdsRouting::GetHeaderValue(
|
|
|
187
202
|
return std::nullopt;
|
|
188
203
|
} else if (header_name == "content-type") {
|
|
189
204
|
return "application/grpc";
|
|
205
|
+
} else if (IsAuthorityHeaderName(header_name)) {
|
|
206
|
+
// ":authority" and "host" are treated as the same header so that routing
|
|
207
|
+
// and RBAC always agree on the authority.
|
|
208
|
+
const Slice* authority = GetAuthorityOrHost(*initial_metadata);
|
|
209
|
+
if (authority == nullptr) return std::nullopt;
|
|
210
|
+
return authority->as_string_view();
|
|
190
211
|
}
|
|
191
212
|
return initial_metadata->GetStringValue(header_name, concatenated_value);
|
|
192
213
|
}
|
|
@@ -75,7 +75,8 @@ class XdsRouting final {
|
|
|
75
75
|
|
|
76
76
|
// Returns the metadata value(s) for the specified key.
|
|
77
77
|
// As special cases, binary headers return a value of std::nullopt, and
|
|
78
|
-
// "content-type" header returns "application/grpc".
|
|
78
|
+
// "content-type" header returns "application/grpc". "host" and
|
|
79
|
+
// ":authority" both return GetAuthorityOrHost().
|
|
79
80
|
static std::optional<absl::string_view> GetHeaderValue(
|
|
80
81
|
grpc_metadata_batch* initial_metadata, absl::string_view header_name,
|
|
81
82
|
std::string* concatenated_value);
|