Log protocol error causes at debug (#371)

Currently, there are many cases where `h2` will fail a connection or
stream with a PROTOCOL_ERROR, without recording why the protocol error
occurred. Since protocol errors may result from a bug in `h2` or from a
misbehaving peer, it is important to be able to debug the cause of
protocol errors.

This branch adds a log line to almost all cases where a protocol error
occurs. I've tried to make the new log lines consistent with the
existing logging, and in some cases, changed existing log lines to make
them internally consistent with other log lines in that module. All
receive-side errors that would send a reset are now logged at the debug
level, using a formatting based on the format used in `framed_read`.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
This commit is contained in:
Eliza Weisman
2019-06-17 14:14:40 -07:00
committed by GitHub
parent 383593a01e
commit 0e9fbe4a90
7 changed files with 117 additions and 42 deletions

View File

@@ -1070,6 +1070,7 @@ where
}
if PREFACE[self.pos..self.pos + n] != buf[..n] {
proto_err!(conn: "read_preface: invalid preface");
// TODO: Should this just write the GO_AWAY frame directly?
return Err(Reason::PROTOCOL_ERROR.into());
}
@@ -1230,6 +1231,7 @@ impl proto::Peer for Peer {
// Specifying :status for a request is a protocol error
if pseudo.status.is_some() {
trace!("malformed headers: :status field on request; PROTOCOL_ERROR");
return Err(RecvError::Connection(Reason::PROTOCOL_ERROR));
}
@@ -1280,9 +1282,10 @@ impl proto::Peer for Peer {
let mut request = match b.body(()) {
Ok(request) => request,
Err(_) => {
Err(e) => {
// TODO: Should there be more specialized handling for different
// kinds of errors
proto_err!(stream: "error building request: {}; stream={:?}", e, stream_id);
return Err(RecvError::Stream {
id: stream_id,
reason: Reason::PROTOCOL_ERROR,