tcp: bugfix for seq not in snd/rcv.wnd error (#49)

* tcp: bugfix for seq not in snd/rcv.wnd error

* accept dupe ACKs for window updates and prevent decrement of UNA

* add fixes for incorrect tcp functioning

* remove Conn.Available* methods in favor of Conn.Free* methods due to ambiguous name
This commit is contained in:
Pat Whittingslow
2026-03-04 16:59:30 +01:00
committed by GitHub
parent 02b4e71c2a
commit d5c4fa53c6
10 changed files with 600 additions and 85 deletions
+5 -3
View File
@@ -48,8 +48,9 @@ func (tcb *ControlBlock) rcvSynSent(seg Segment) (pending Flags, err error) {
func (tcb *ControlBlock) rcvSynRcvd(seg Segment) (pending Flags, err error) {
switch {
// case !seg.Flags.HasAll(FlagACK):
// err = errors.New("rcvSynRcvd: expected ACK")
case !seg.Flags.HasAll(FlagACK):
// RFC 9293 §3.10.7.4 step 5: "If the ACK bit is off, drop the segment and return."
err = errBadSegack
case seg.ACK != tcb.snd.UNA+1:
err = errBadSegack
}
@@ -69,7 +70,8 @@ func (tcb *ControlBlock) rcvEstablished(seg Segment) (pending Flags, err error)
if hasFin {
// See Figure 5: TCP Connection State Diagram of RFC 9293.
tcb._state = StateCloseWait
tcb.pending[1] = FlagFIN // Queue FIN for after the CloseWait ACK.
// RFC 9293 §3.5: CLOSE-WAIT allows local side to continue sending.
// Do NOT auto-queue FIN here; user must call Close() explicitly.
}
}