Skip to content

Commit 3933feb

Browse files
authored
Skip h2 upgrade when target is local (#2407)
In the most recent stable versions, pods cannot communicate with themselves when using a ClusterIP. While direct (pod-to-pod) connections are never sent through the proxy and are skipped at the iptables level, connections to a logical service still pass through the proxy. When the chosen endpoint is the same as the source of the traffic, TLS and H2 upgrades should be skipped. Every endpoint receives an h2 upgrade hint in its metadata. When looking into the problem, I noticed that client settings do not take into account that the target may be local. When deciding what client settings to use, we do not upgrade the connection when the hint is "unknown" (gatewayed connections) or "opaque". This change does a similar thing by using H1 settings when the protocol is H1 and the target IP is also part of the inbound IPs passed to the proxy. Fixes linkerd/linkerd2#10816 Signed-off-by: Matei David <[email protected]>
1 parent 5366652 commit 3933feb

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

linkerd/app/outbound/src/http/concrete.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -407,13 +407,20 @@ where
407407
fn param(&self) -> client::Settings {
408408
match self.param() {
409409
http::Version::H2 => client::Settings::H2,
410-
http::Version::Http1 => match self.metadata.protocol_hint() {
411-
// If the protocol hint is unknown or indicates that the
412-
// endpoint's proxy will treat connections as opaque, do not
413-
// perform a protocol upgrade to HTTP/2.
414-
ProtocolHint::Unknown | ProtocolHint::Opaque => client::Settings::Http1,
415-
ProtocolHint::Http2 => client::Settings::OrigProtoUpgrade,
416-
},
410+
http::Version::Http1 => {
411+
// When the target is local (i.e. same as source of traffic)
412+
// then do not perform a protocol upgrade to HTTP/2
413+
if self.is_local {
414+
return client::Settings::Http1;
415+
}
416+
match self.metadata.protocol_hint() {
417+
// If the protocol hint is unknown or indicates that the
418+
// endpoint's proxy will treat connections as opaque, do not
419+
// perform a protocol upgrade to HTTP/2.
420+
ProtocolHint::Unknown | ProtocolHint::Opaque => client::Settings::Http1,
421+
ProtocolHint::Http2 => client::Settings::OrigProtoUpgrade,
422+
}
423+
}
417424
}
418425
}
419426
}

0 commit comments

Comments
 (0)