maskit commented on code in PR #14065:
URL: https://github.com/apache/trafficserver/pull/14065#discussion_r4557978258
##########
src/proxy/ProtocolProbeSessionAccept.cc:
##########
@@ -157,7 +157,11 @@ struct ProtocolProbeTrampoline : public Continuation,
public ProtocolProbeSessio
acceptor = probeParent->endpoint[static_cast<int>(key)];
if (acceptor == nullptr) {
- Warning("Unregistered protocol type %d", static_cast<int>(key));
+ char client_ip[INET6_ADDRSTRLEN];
+ ats_ip_ntop(netvc->get_remote_addr(), client_ip, sizeof(client_ip));
+ Warning("Closing connection from client_ip=%s on local port %d: the
client spoke %s, but this port is not configured for it. "
+ "Check the protocols for this port in
proxy.config.http.server_ports (proto=...).",
+ client_ip, netvc->get_local_port(), key == ProtoGroupKey::HTTP2
? "HTTP/2 with prior knowledge (h2c)" : "HTTP/1.x");
Review Comment:
The `HTTP/1.x` label is often wrong: `key == HTTP` only means "not the h2
preface", or "this is TLS".
- `proto_is_http2()` is the only check. A TLS ClientHello, scanner junk, or
fewer than 4 bytes all get `key = HTTP`.
- TLS ports send connections without ALPN to this probe. If such a client
sends the h2 preface, the RFC 9113 ยง3.3 branch above forces `key = HTTP`.
Resulting misleading warnings:
1. On a plaintext `proto=http2` port, a TLS client or a scanner is logged as
"the client spoke HTTP/1.x".
2. On a TLS `proto=http2` port, a client that sends the h2 preface without
ALPN is also logged as "HTTP/1.x". The `proto=...` hint then points toward
enabling HTTP/1.x, which doesn't fix what actually happened.
**Ask:** describe what was detected rather than what the client spoke. For
example, "did not send an HTTP/2 connection preface (handled as HTTP/1.x)",
plus a separate message for the h2-preface-over-TLS case. A test for the `HTTP`
branch would help too.
##########
src/proxy/ProtocolProbeSessionAccept.cc:
##########
@@ -157,7 +157,11 @@ struct ProtocolProbeTrampoline : public Continuation,
public ProtocolProbeSessio
acceptor = probeParent->endpoint[static_cast<int>(key)];
if (acceptor == nullptr) {
- Warning("Unregistered protocol type %d", static_cast<int>(key));
+ char client_ip[INET6_ADDRSTRLEN];
+ ats_ip_ntop(netvc->get_remote_addr(), client_ip, sizeof(client_ip));
Review Comment:
Not blocking: behind PROXY protocol, this logs the load balancer's IP rather
than the client's.
- The PROXY header has already been parsed above, so
`get_proxy_protocol_src_addr()` is available here.
- `get_remote_addr()` is the TCP peer, so behind a load balancer every
warning would show the same address.
**Suggestion:** also log the PROXY source when present, e.g.
`client_ip=<pp-src> (peer <lb>)`. `Http2SessionAccept::accept` already picks
the address from the same choices.
##########
src/proxy/ProtocolProbeSessionAccept.cc:
##########
@@ -157,7 +157,11 @@ struct ProtocolProbeTrampoline : public Continuation,
public ProtocolProbeSessio
acceptor = probeParent->endpoint[static_cast<int>(key)];
if (acceptor == nullptr) {
- Warning("Unregistered protocol type %d", static_cast<int>(key));
+ char client_ip[INET6_ADDRSTRLEN];
+ ats_ip_ntop(netvc->get_remote_addr(), client_ip, sizeof(client_ip));
Review Comment:
On Unix domain socket ports, this can read past `client_ip` on the stack.
- `server_ports` accepts Unix socket paths, and the probe handles those
connections too.
- `remote_addr` holds the client's full `sockaddr_un`, because `ats_ip_copy`
copies `sizeof(sockaddr_un)`.
- For `AF_UNIX`, `ats_ip_ntop` does `strncpy(dst, sun_path, size)`. A path
of 46 bytes or more leaves the 46-byte buffer without a NUL terminator, and
`Warning("%s")` then reads past it.
Steps:
1. A local client binds its socket to a path of 46+ bytes.
2. It connects to a default (HTTP-only) Unix socket port and sends the h2
preface.
3. This warning fires and reads beyond `client_ip`. The line also says
"local port 0".
**Ask:** do what `HttpSessionAccept::accept` does. Format the address only
when `ats_is_ip()` is true, and otherwise name the listener (or log the socket
path with a correctly sized buffer).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]