]> git.meshlink.io Git - utcp/commitdiff
Fix the logic for determining whether a packets has an acceptable ack seqno.
authorGuus Sliepen <guus@meshlink.io>
Sun, 18 Oct 2015 18:30:48 +0000 (20:30 +0200)
committerGuus Sliepen <guus@sliepen.org>
Sun, 2 Jul 2017 10:04:03 +0000 (12:04 +0200)
snd.last accurately tracks the last possible seqno that can be acked, so
use it. This fixes a case where retransmitted ACKs of a FIN were not handled
correctly.

utcp.c

diff --git a/utcp.c b/utcp.c
index fceffbd0856b2a383b008bafb7f488f1ae3489fa..1b498a2897d0c4063b568040c24804c6235f636d 100644 (file)
--- a/utcp.c
+++ b/utcp.c
@@ -879,10 +879,7 @@ ssize_t utcp_recv(struct utcp *utcp, const void *data, size_t len) {
        // ackno should not roll back, and it should also not be bigger than what we ever could have sent
        // (= snd.una + c->sndbuf.used).
 
-       if(hdr.ctl & ACK &&
-                       ((seqdiff(hdr.ack, c->snd.una + c->sndbuf.used) > 0 &&
-                         seqdiff(hdr.ack, c->snd.nxt) > 0) // TODO: simplify this if
-                        || seqdiff(hdr.ack, c->snd.una) < 0)) {
+       if(hdr.ctl & ACK && (seqdiff(hdr.ack, c->snd.last) > 0 || seqdiff(hdr.ack, c->snd.una) < 0)) {
                debug("Packet ack seqno out of range, %u <= %u < %u\n", c->snd.una, hdr.ack, c->snd.una + c->sndbuf.used);
                // Ignore unacceptable RST packets.
                if(hdr.ctl & RST)