Merge pull request #2273 from lucas-clemente/improve-dropped-packet-logging

log the packet size of dropped packets
This commit is contained in:
Marten Seemann
2020-01-06 17:42:53 +07:00
committed by GitHub

View File

@@ -684,7 +684,7 @@ func (s *session) handleSinglePacket(p *receivedPacket, hdr *wire.Header) bool /
// The server can change the source connection ID with the first Handshake packet. // The server can change the source connection ID with the first Handshake packet.
// After this, all packets with a different source connection have to be ignored. // After this, all packets with a different source connection have to be ignored.
if s.receivedFirstPacket && hdr.IsLongHeader && !hdr.SrcConnectionID.Equal(s.handshakeDestConnID) { if s.receivedFirstPacket && hdr.IsLongHeader && !hdr.SrcConnectionID.Equal(s.handshakeDestConnID) {
s.logger.Debugf("Dropping %s packet with unexpected source connection ID: %s (expected %s)", hdr.PacketType(), hdr.SrcConnectionID, s.handshakeDestConnID) s.logger.Debugf("Dropping %s packet (%d bytes) with unexpected source connection ID: %s (expected %s)", hdr.PacketType(), len(p.data), hdr.SrcConnectionID, s.handshakeDestConnID)
return false return false
} }
// drop 0-RTT packets, if we are a client // drop 0-RTT packets, if we are a client
@@ -696,7 +696,7 @@ func (s *session) handleSinglePacket(p *receivedPacket, hdr *wire.Header) bool /
if err != nil { if err != nil {
switch err { switch err {
case handshake.ErrKeysDropped: case handshake.ErrKeysDropped:
s.logger.Debugf("Dropping %s packet because we already dropped the keys.", hdr.PacketType()) s.logger.Debugf("Dropping %s packet (%d bytes) because we already dropped the keys.", hdr.PacketType(), len(p.data))
case handshake.ErrKeysNotYetAvailable: case handshake.ErrKeysNotYetAvailable:
// Sealer for this encryption level not yet available. // Sealer for this encryption level not yet available.
// Try again later. // Try again later.
@@ -707,7 +707,7 @@ func (s *session) handleSinglePacket(p *receivedPacket, hdr *wire.Header) bool /
default: default:
// This might be a packet injected by an attacker. // This might be a packet injected by an attacker.
// Drop it. // Drop it.
s.logger.Debugf("Dropping %s packet that could not be unpacked. Error: %s", hdr.PacketType(), err) s.logger.Debugf("Dropping %s packet (%d bytes) that could not be unpacked. Error: %s", hdr.PacketType(), len(p.data), err)
} }
return false return false
} }