Correctly print non-matching layers

PiperOrigin-RevId: 346818310
This commit is contained in:
Tamir Duberstein
2020-12-10 10:52:13 -08:00
committed by gVisor bot
parent 65a2242db4
commit a177bfdbc4
+8 -3
View File
@@ -306,11 +306,11 @@ func (s *tcpState) incoming(received Layer) Layer {
if s.remoteSeqNum != nil {
newIn.SeqNum = Uint32(uint32(*s.remoteSeqNum))
}
if s.localSeqNum != nil && (*tcpReceived.Flags&header.TCPFlagAck) != 0 {
if seq, flags := s.localSeqNum, tcpReceived.Flags; seq != nil && flags != nil && *flags&header.TCPFlagAck != 0 {
// The caller didn't specify an AckNum so we'll expect the calculated one,
// but only if the ACK flag is set because the AckNum is not valid in a
// header if ACK is not set.
newIn.AckNum = Uint32(uint32(*s.localSeqNum))
newIn.AckNum = Uint32(uint32(*seq))
}
return &newIn
}
@@ -615,7 +615,12 @@ func (conn *Connection) ExpectFrame(t *testing.T, layers Layers, timeout time.Du
}
return gotLayers, nil
}
errs = multierr.Combine(errs, &layersError{got: gotLayers, want: conn.incoming(gotLayers)})
want := conn.incoming(layers)
if err := want.merge(layers); err != nil {
errs = multierr.Combine(errs, err)
} else {
errs = multierr.Combine(errs, &layersError{got: gotLayers, want: want})
}
}
}