diff options
author | Kevin Krakauer <krakauer@google.com> | 2021-10-27 15:37:20 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-10-27 15:39:59 -0700 |
commit | 9541a5842bf843414d872a539d32ce6e3202bf04 (patch) | |
tree | 22581f118ac6bc64eaa97ad11abc3f04876b7da9 /pkg | |
parent | 3015c0ac67ef7703899e753121efe326dc0cbecd (diff) |
rename tcp_conntrack inbound/outbound to reply/original
Connection tracking is agnostic to whether the packet is inbound or outbound. It
cares who initiated the connection. The naming can get confusing as conntrack
can track connections originating from any host.
Part of resolving #6736.
PiperOrigin-RevId: 405997540
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/tcpip/stack/conntrack.go | 4 | ||||
-rw-r--r-- | pkg/tcpip/transport/tcpconntrack/tcp_conntrack.go | 175 | ||||
-rw-r--r-- | pkg/tcpip/transport/tcpconntrack/tcp_conntrack_test.go | 66 |
3 files changed, 123 insertions, 122 deletions
diff --git a/pkg/tcpip/stack/conntrack.go b/pkg/tcpip/stack/conntrack.go index 4a28be585..f5e990f03 100644 --- a/pkg/tcpip/stack/conntrack.go +++ b/pkg/tcpip/stack/conntrack.go @@ -164,9 +164,9 @@ func (cn *conn) updateLocked(pkt *PacketBuffer, reply bool) { } if reply { - cn.tcb.UpdateStateInbound(tcpHeader) + cn.tcb.UpdateStateReply(tcpHeader) } else { - cn.tcb.UpdateStateOutbound(tcpHeader) + cn.tcb.UpdateStateOriginal(tcpHeader) } } diff --git a/pkg/tcpip/transport/tcpconntrack/tcp_conntrack.go b/pkg/tcpip/transport/tcpconntrack/tcp_conntrack.go index 558b06df0..a3ea9e197 100644 --- a/pkg/tcpip/transport/tcpconntrack/tcp_conntrack.go +++ b/pkg/tcpip/transport/tcpconntrack/tcp_conntrack.go @@ -22,8 +22,8 @@ import ( "gvisor.dev/gvisor/pkg/tcpip/seqnum" ) -// Result is returned when the state of a TCB is updated in response to an -// inbound or outbound segment. +// Result is returned when the state of a TCB is updated in response to a +// segment. type Result int const ( @@ -40,24 +40,24 @@ const ( // ResultReset indicates that the connection was reset. ResultReset - // ResultClosedByPeer indicates that the connection was gracefully - // closed, and the inbound stream was closed first. - ResultClosedByPeer + // ResultClosedByResponder indicates that the connection was gracefully + // closed, and the reply stream was closed first. + ResultClosedByResponder - // ResultClosedBySelf indicates that the connection was gracefully - // closed, and the outbound stream was closed first. - ResultClosedBySelf + // ResultClosedByOriginator indicates that the connection was gracefully + // closed, and the original stream was closed first. + ResultClosedByOriginator ) // TCB is a TCP Control Block. It holds state necessary to keep track of a TCP // connection and inform the caller when the connection has been closed. type TCB struct { - inbound stream - outbound stream + reply stream + original stream // State handlers. - handlerInbound func(*TCB, header.TCP) Result - handlerOutbound func(*TCB, header.TCP) Result + handlerReply func(*TCB, header.TCP) Result + handlerOriginal func(*TCB, header.TCP) Result // firstFin holds a pointer to the first stream to send a FIN. firstFin *stream @@ -68,38 +68,38 @@ type TCB struct { // Init initializes the state of the TCB according to the initial SYN. func (t *TCB) Init(initialSyn header.TCP) Result { - t.handlerInbound = synSentStateInbound - t.handlerOutbound = synSentStateOutbound + t.handlerReply = synSentStateReply + t.handlerOriginal = synSentStateOriginal iss := seqnum.Value(initialSyn.SequenceNumber()) - t.outbound.una = iss - t.outbound.nxt = iss.Add(logicalLen(initialSyn)) - t.outbound.end = t.outbound.nxt + t.original.una = iss + t.original.nxt = iss.Add(logicalLen(initialSyn)) + t.original.end = t.original.nxt // Even though "end" is a sequence number, we don't know the initial // receive sequence number yet, so we store the window size until we get - // a SYN from the peer. - t.inbound.una = 0 - t.inbound.nxt = 0 - t.inbound.end = seqnum.Value(initialSyn.WindowSize()) + // a SYN from the server. + t.reply.una = 0 + t.reply.nxt = 0 + t.reply.end = seqnum.Value(initialSyn.WindowSize()) t.state = ResultConnecting return t.state } -// UpdateStateInbound updates the state of the TCB based on the supplied inbound +// UpdateStateReply updates the state of the TCB based on the supplied reply // segment. -func (t *TCB) UpdateStateInbound(tcp header.TCP) Result { - st := t.handlerInbound(t, tcp) +func (t *TCB) UpdateStateReply(tcp header.TCP) Result { + st := t.handlerReply(t, tcp) if st != ResultDrop { t.state = st } return st } -// UpdateStateOutbound updates the state of the TCB based on the supplied -// outbound segment. -func (t *TCB) UpdateStateOutbound(tcp header.TCP) Result { - st := t.handlerOutbound(t, tcp) +// UpdateStateOriginal updates the state of the TCB based on the supplied +// original segment. +func (t *TCB) UpdateStateOriginal(tcp header.TCP) Result { + st := t.handlerOriginal(t, tcp) if st != ResultDrop { t.state = st } @@ -114,46 +114,47 @@ func (t *TCB) State() Result { // IsAlive returns true as long as the connection is established(Alive) // or connecting state. func (t *TCB) IsAlive() bool { - return !t.inbound.rstSeen && !t.outbound.rstSeen && (!t.inbound.closed() || !t.outbound.closed()) + return !t.reply.rstSeen && !t.original.rstSeen && (!t.reply.closed() || !t.original.closed()) } -// OutboundSendSequenceNumber returns the snd.NXT for the outbound stream. -func (t *TCB) OutboundSendSequenceNumber() seqnum.Value { - return t.outbound.nxt +// OriginalSendSequenceNumber returns the snd.NXT for the original stream. +func (t *TCB) OriginalSendSequenceNumber() seqnum.Value { + return t.original.nxt } -// InboundSendSequenceNumber returns the snd.NXT for the inbound stream. -func (t *TCB) InboundSendSequenceNumber() seqnum.Value { - return t.inbound.nxt +// ReplySendSequenceNumber returns the snd.NXT for the reply stream. +func (t *TCB) ReplySendSequenceNumber() seqnum.Value { + return t.reply.nxt } // adapResult modifies the supplied "Result" according to the state of the TCB; // if r is anything other than "Alive", or if one of the streams isn't closed // yet, it is returned unmodified. Otherwise it's converted to either -// ClosedBySelf or ClosedByPeer depending on which stream was closed first. +// ClosedByOriginator or ClosedByResponder depending on which stream was closed +// first. func (t *TCB) adaptResult(r Result) Result { // Check the unmodified case. - if r != ResultAlive || !t.inbound.closed() || !t.outbound.closed() { + if r != ResultAlive || !t.reply.closed() || !t.original.closed() { return r } // Find out which was closed first. - if t.firstFin == &t.outbound { - return ResultClosedBySelf + if t.firstFin == &t.original { + return ResultClosedByOriginator } - return ResultClosedByPeer + return ResultClosedByResponder } -// synSentStateInbound is the state handler for inbound segments when the +// synSentStateReply is the state handler for reply segments when the // connection is in SYN-SENT state. -func synSentStateInbound(t *TCB, tcp header.TCP) Result { +func synSentStateReply(t *TCB, tcp header.TCP) Result { flags := tcp.Flags() ackPresent := flags&header.TCPFlagAck != 0 ack := seqnum.Value(tcp.AckNumber()) // Ignore segment if ack is present but not acceptable. - if ackPresent && !(ack-1).InRange(t.outbound.una, t.outbound.nxt) { + if ackPresent && !(ack-1).InRange(t.original.una, t.original.nxt) { return ResultConnecting } @@ -162,7 +163,7 @@ func synSentStateInbound(t *TCB, tcp header.TCP) Result { // implicitly acceptable). if flags&header.TCPFlagRst != 0 { if ackPresent { - t.inbound.rstSeen = true + t.reply.rstSeen = true return ResultReset } return ResultConnecting @@ -175,62 +176,62 @@ func synSentStateInbound(t *TCB, tcp header.TCP) Result { // Update state informed by this SYN. irs := seqnum.Value(tcp.SequenceNumber()) - t.inbound.una = irs - t.inbound.nxt = irs.Add(logicalLen(tcp)) - t.inbound.end += irs + t.reply.una = irs + t.reply.nxt = irs.Add(logicalLen(tcp)) + t.reply.end += irs - t.outbound.end = t.outbound.una.Add(seqnum.Size(tcp.WindowSize())) + t.original.end = t.original.una.Add(seqnum.Size(tcp.WindowSize())) // If the ACK was set (it is acceptable), update our unacknowledgement // tracking. if ackPresent { - // Advance the "una" and "end" indices of the outbound stream. - if t.outbound.una.LessThan(ack) { - t.outbound.una = ack + // Advance the "una" and "end" indices of the original stream. + if t.original.una.LessThan(ack) { + t.original.una = ack } - if end := ack.Add(seqnum.Size(tcp.WindowSize())); t.outbound.end.LessThan(end) { - t.outbound.end = end + if end := ack.Add(seqnum.Size(tcp.WindowSize())); t.original.end.LessThan(end) { + t.original.end = end } } // Update handlers so that new calls will be handled by new state. - t.handlerInbound = allOtherInbound - t.handlerOutbound = allOtherOutbound + t.handlerReply = allOtherReply + t.handlerOriginal = allOtherOriginal return ResultAlive } -// synSentStateOutbound is the state handler for outbound segments when the +// synSentStateOriginal is the state handler for original segments when the // connection is in SYN-SENT state. -func synSentStateOutbound(t *TCB, tcp header.TCP) Result { - // Drop outbound segments that aren't retransmits of the original one. +func synSentStateOriginal(t *TCB, tcp header.TCP) Result { + // Drop original segments that aren't retransmits of the original one. if tcp.Flags() != header.TCPFlagSyn || - tcp.SequenceNumber() != uint32(t.outbound.una) { + tcp.SequenceNumber() != uint32(t.original.una) { return ResultDrop } // Update the receive window. We only remember the largest value seen. - if wnd := seqnum.Value(tcp.WindowSize()); wnd > t.inbound.end { - t.inbound.end = wnd + if wnd := seqnum.Value(tcp.WindowSize()); wnd > t.reply.end { + t.reply.end = wnd } return ResultConnecting } -// update updates the state of inbound and outbound streams, given the supplied -// inbound segment. For outbound segments, this same function can be called with -// swapped inbound/outbound streams. -func update(tcp header.TCP, inbound, outbound *stream, firstFin **stream) Result { +// update updates the state of reply and original streams, given the supplied +// reply segment. For original segments, this same function can be called with +// swapped reply/original streams. +func update(tcp header.TCP, reply, original *stream, firstFin **stream) Result { // Ignore segments out of the window. s := seqnum.Value(tcp.SequenceNumber()) - if !inbound.acceptable(s, dataLen(tcp)) { + if !reply.acceptable(s, dataLen(tcp)) { return ResultAlive } flags := tcp.Flags() if flags&header.TCPFlagRst != 0 { - inbound.rstSeen = true + reply.rstSeen = true return ResultReset } @@ -242,49 +243,49 @@ func update(tcp header.TCP, inbound, outbound *stream, firstFin **stream) Result // Ignore segments that acknowledge not yet sent data. ack := seqnum.Value(tcp.AckNumber()) - if outbound.nxt.LessThan(ack) { + if original.nxt.LessThan(ack) { return ResultAlive } - // Advance the "una" and "end" indices of the outbound stream. - if outbound.una.LessThan(ack) { - outbound.una = ack + // Advance the "una" and "end" indices of the original stream. + if original.una.LessThan(ack) { + original.una = ack } - if end := ack.Add(seqnum.Size(tcp.WindowSize())); outbound.end.LessThan(end) { - outbound.end = end + if end := ack.Add(seqnum.Size(tcp.WindowSize())); original.end.LessThan(end) { + original.end = end } - // Advance the "nxt" index of the inbound stream. + // Advance the "nxt" index of the reply stream. end := s.Add(logicalLen(tcp)) - if inbound.nxt.LessThan(end) { - inbound.nxt = end + if reply.nxt.LessThan(end) { + reply.nxt = end } // Note the index of the FIN segment. And stash away a pointer to the // first stream to see a FIN. - if flags&header.TCPFlagFin != 0 && !inbound.finSeen { - inbound.finSeen = true - inbound.fin = end - 1 + if flags&header.TCPFlagFin != 0 && !reply.finSeen { + reply.finSeen = true + reply.fin = end - 1 if *firstFin == nil { - *firstFin = inbound + *firstFin = reply } } return ResultAlive } -// allOtherInbound is the state handler for inbound segments in all states +// allOtherReply is the state handler for reply segments in all states // except SYN-SENT. -func allOtherInbound(t *TCB, tcp header.TCP) Result { - return t.adaptResult(update(tcp, &t.inbound, &t.outbound, &t.firstFin)) +func allOtherReply(t *TCB, tcp header.TCP) Result { + return t.adaptResult(update(tcp, &t.reply, &t.original, &t.firstFin)) } -// allOtherOutbound is the state handler for outbound segments in all states +// allOtherOriginal is the state handler for original segments in all states // except SYN-SENT. -func allOtherOutbound(t *TCB, tcp header.TCP) Result { - return t.adaptResult(update(tcp, &t.outbound, &t.inbound, &t.firstFin)) +func allOtherOriginal(t *TCB, tcp header.TCP) Result { + return t.adaptResult(update(tcp, &t.original, &t.reply, &t.firstFin)) } // streams holds the state of a TCP unidirectional stream. @@ -345,7 +346,7 @@ func logicalLen(tcp header.TCP) seqnum.Size { // IsEmpty returns true if tcb is not initialized. func (t *TCB) IsEmpty() bool { - if t.inbound != (stream{}) || t.outbound != (stream{}) { + if t.reply != (stream{}) || t.original != (stream{}) { return false } diff --git a/pkg/tcpip/transport/tcpconntrack/tcp_conntrack_test.go b/pkg/tcpip/transport/tcpconntrack/tcp_conntrack_test.go index 6c5ddc3c7..30732b73d 100644 --- a/pkg/tcpip/transport/tcpconntrack/tcp_conntrack_test.go +++ b/pkg/tcpip/transport/tcpconntrack/tcp_conntrack_test.go @@ -46,7 +46,7 @@ func connected(t *testing.T, iss, irs uint32, isw, irw uint16) *tcpconntrack.TCB WindowSize: isw, }) - if r := tcb.UpdateStateInbound(tcp); r != tcpconntrack.ResultAlive { + if r := tcb.UpdateStateReply(tcp); r != tcpconntrack.ResultAlive { t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive) } @@ -59,7 +59,7 @@ func connected(t *testing.T, iss, irs uint32, isw, irw uint16) *tcpconntrack.TCB WindowSize: irw, }) - if r := tcb.UpdateStateOutbound(tcp); r != tcpconntrack.ResultAlive { + if r := tcb.UpdateStateOriginal(tcp); r != tcpconntrack.ResultAlive { t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive) } @@ -89,7 +89,7 @@ func TestConnectionRefused(t *testing.T) { WindowSize: 50000, }) - if r := tcb.UpdateStateInbound(tcp); r != tcpconntrack.ResultReset { + if r := tcb.UpdateStateReply(tcp); r != tcpconntrack.ResultReset { t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultReset) } } @@ -117,7 +117,7 @@ func TestConnectionRefusedInSynRcvd(t *testing.T) { WindowSize: 50000, }) - if r := tcb.UpdateStateInbound(tcp); r != tcpconntrack.ResultAlive { + if r := tcb.UpdateStateReply(tcp); r != tcpconntrack.ResultAlive { t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive) } @@ -130,7 +130,7 @@ func TestConnectionRefusedInSynRcvd(t *testing.T) { WindowSize: 50000, }) - if r := tcb.UpdateStateInbound(tcp); r != tcpconntrack.ResultReset { + if r := tcb.UpdateStateReply(tcp); r != tcpconntrack.ResultReset { t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultReset) } } @@ -158,7 +158,7 @@ func TestConnectionResetInSynRcvd(t *testing.T) { WindowSize: 50000, }) - if r := tcb.UpdateStateInbound(tcp); r != tcpconntrack.ResultAlive { + if r := tcb.UpdateStateReply(tcp); r != tcpconntrack.ResultAlive { t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive) } @@ -170,7 +170,7 @@ func TestConnectionResetInSynRcvd(t *testing.T) { Flags: header.TCPFlagRst, }) - if r := tcb.UpdateStateOutbound(tcp); r != tcpconntrack.ResultReset { + if r := tcb.UpdateStateOriginal(tcp); r != tcpconntrack.ResultReset { t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultReset) } } @@ -190,7 +190,7 @@ func TestRetransmitOnSynSent(t *testing.T) { tcb.Init(tcp) // Retransmit the same SYN. - if r := tcb.UpdateStateOutbound(tcp); r != tcpconntrack.ResultConnecting { + if r := tcb.UpdateStateOriginal(tcp); r != tcpconntrack.ResultConnecting { t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultConnecting) } } @@ -218,7 +218,7 @@ func TestRetransmitOnSynRcvd(t *testing.T) { WindowSize: 50000, }) - if r := tcb.UpdateStateInbound(tcp); r != tcpconntrack.ResultAlive { + if r := tcb.UpdateStateReply(tcp); r != tcpconntrack.ResultAlive { t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive) } @@ -231,7 +231,7 @@ func TestRetransmitOnSynRcvd(t *testing.T) { WindowSize: 30000, }) - if r := tcb.UpdateStateOutbound(tcp); r != tcpconntrack.ResultAlive { + if r := tcb.UpdateStateOriginal(tcp); r != tcpconntrack.ResultAlive { t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive) } @@ -244,12 +244,12 @@ func TestRetransmitOnSynRcvd(t *testing.T) { WindowSize: 30000, }) - if r := tcb.UpdateStateOutbound(tcp); r != tcpconntrack.ResultAlive { + if r := tcb.UpdateStateOriginal(tcp); r != tcpconntrack.ResultAlive { t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive) } } -func TestClosedBySelf(t *testing.T) { +func TestClosedByOriginator(t *testing.T) { tcb := connected(t, 1234, 789, 30000, 50000) // Send FIN. @@ -262,7 +262,7 @@ func TestClosedBySelf(t *testing.T) { WindowSize: 30000, }) - if r := tcb.UpdateStateOutbound(tcp); r != tcpconntrack.ResultAlive { + if r := tcb.UpdateStateOriginal(tcp); r != tcpconntrack.ResultAlive { t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive) } @@ -275,7 +275,7 @@ func TestClosedBySelf(t *testing.T) { WindowSize: 50000, }) - if r := tcb.UpdateStateInbound(tcp); r != tcpconntrack.ResultAlive { + if r := tcb.UpdateStateReply(tcp); r != tcpconntrack.ResultAlive { t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive) } @@ -288,12 +288,12 @@ func TestClosedBySelf(t *testing.T) { WindowSize: 30000, }) - if r := tcb.UpdateStateOutbound(tcp); r != tcpconntrack.ResultClosedBySelf { - t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultClosedBySelf) + if r := tcb.UpdateStateOriginal(tcp); r != tcpconntrack.ResultClosedByOriginator { + t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultClosedByOriginator) } } -func TestClosedByPeer(t *testing.T) { +func TestClosedByResponder(t *testing.T) { tcb := connected(t, 1234, 789, 30000, 50000) // Receive FIN. @@ -306,7 +306,7 @@ func TestClosedByPeer(t *testing.T) { WindowSize: 50000, }) - if r := tcb.UpdateStateInbound(tcp); r != tcpconntrack.ResultAlive { + if r := tcb.UpdateStateReply(tcp); r != tcpconntrack.ResultAlive { t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive) } @@ -319,7 +319,7 @@ func TestClosedByPeer(t *testing.T) { WindowSize: 30000, }) - if r := tcb.UpdateStateOutbound(tcp); r != tcpconntrack.ResultAlive { + if r := tcb.UpdateStateOriginal(tcp); r != tcpconntrack.ResultAlive { t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive) } @@ -332,12 +332,12 @@ func TestClosedByPeer(t *testing.T) { WindowSize: 50000, }) - if r := tcb.UpdateStateInbound(tcp); r != tcpconntrack.ResultClosedByPeer { - t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultClosedByPeer) + if r := tcb.UpdateStateReply(tcp); r != tcpconntrack.ResultClosedByResponder { + t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultClosedByResponder) } } -func TestSendAndReceiveDataClosedBySelf(t *testing.T) { +func TestSendAndReceiveDataClosedByOriginator(t *testing.T) { sseq := uint32(1234) rseq := uint32(789) tcb := connected(t, sseq, rseq, 30000, 50000) @@ -358,7 +358,7 @@ func TestSendAndReceiveDataClosedBySelf(t *testing.T) { }) sseq += uint32(len(tcp)) - header.TCPMinimumSize - if r := tcb.UpdateStateOutbound(tcp); r != tcpconntrack.ResultAlive { + if r := tcb.UpdateStateOriginal(tcp); r != tcpconntrack.ResultAlive { t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive) } @@ -371,7 +371,7 @@ func TestSendAndReceiveDataClosedBySelf(t *testing.T) { WindowSize: 50000, }) - if r := tcb.UpdateStateInbound(tcp[:header.TCPMinimumSize]); r != tcpconntrack.ResultAlive { + if r := tcb.UpdateStateReply(tcp[:header.TCPMinimumSize]); r != tcpconntrack.ResultAlive { t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive) } } @@ -387,7 +387,7 @@ func TestSendAndReceiveDataClosedBySelf(t *testing.T) { }) rseq += uint32(len(tcp)) - header.TCPMinimumSize - if r := tcb.UpdateStateInbound(tcp); r != tcpconntrack.ResultAlive { + if r := tcb.UpdateStateReply(tcp); r != tcpconntrack.ResultAlive { t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive) } @@ -400,7 +400,7 @@ func TestSendAndReceiveDataClosedBySelf(t *testing.T) { WindowSize: 30000, }) - if r := tcb.UpdateStateOutbound(tcp[:header.TCPMinimumSize]); r != tcpconntrack.ResultAlive { + if r := tcb.UpdateStateOriginal(tcp[:header.TCPMinimumSize]); r != tcpconntrack.ResultAlive { t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive) } } @@ -416,7 +416,7 @@ func TestSendAndReceiveDataClosedBySelf(t *testing.T) { }) sseq++ - if r := tcb.UpdateStateOutbound(tcp); r != tcpconntrack.ResultAlive { + if r := tcb.UpdateStateOriginal(tcp); r != tcpconntrack.ResultAlive { t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive) } @@ -430,7 +430,7 @@ func TestSendAndReceiveDataClosedBySelf(t *testing.T) { }) rseq++ - if r := tcb.UpdateStateInbound(tcp); r != tcpconntrack.ResultAlive { + if r := tcb.UpdateStateReply(tcp); r != tcpconntrack.ResultAlive { t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive) } @@ -443,8 +443,8 @@ func TestSendAndReceiveDataClosedBySelf(t *testing.T) { WindowSize: 30000, }) - if r := tcb.UpdateStateOutbound(tcp); r != tcpconntrack.ResultClosedBySelf { - t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultClosedBySelf) + if r := tcb.UpdateStateOriginal(tcp); r != tcpconntrack.ResultClosedByOriginator { + t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultClosedByOriginator) } } @@ -476,7 +476,7 @@ func TestIgnoreBadResetOnSynSent(t *testing.T) { WindowSize: 50000, }) - if r := tcb.UpdateStateInbound(tcp); r != tcpconntrack.ResultConnecting { + if r := tcb.UpdateStateReply(tcp); r != tcpconntrack.ResultConnecting { t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive) } } @@ -492,7 +492,7 @@ func TestIgnoreBadResetOnSynSent(t *testing.T) { WindowSize: 50000, }) - if r := tcb.UpdateStateInbound(tcp); r != tcpconntrack.ResultAlive { + if r := tcb.UpdateStateReply(tcp); r != tcpconntrack.ResultAlive { t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive) } @@ -505,7 +505,7 @@ func TestIgnoreBadResetOnSynSent(t *testing.T) { WindowSize: 30000, }) - if r := tcb.UpdateStateOutbound(tcp); r != tcpconntrack.ResultAlive { + if r := tcb.UpdateStateOriginal(tcp); r != tcpconntrack.ResultAlive { t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive) } } |