]> git.meshlink.io Git - meshlink/commitdiff
Send RST packets when receiving data after we closed a UDP channel.
authorGuus Sliepen <guus@meshlink.io>
Tue, 29 Sep 2020 20:38:55 +0000 (22:38 +0200)
committerGuus Sliepen <guus@meshlink.io>
Tue, 29 Sep 2020 20:38:55 +0000 (22:38 +0200)
If the application closed a channel, we keep the UTCP connection alive for
a bit longer to handle resends of FIN packets. However, if this is missed
for some reason, either because the FIN got lost or the peer ignored the
receive callback, and the peer is sending new data, we need to inform it
that we are no longer listening. To do this, send a RST back.

src/utcp.c

index 65e6be7a2de4e19ac42401ef2696a1590561435d..c1add21808cd51031c07b5919b5aa90c4b1f84c7 100644 (file)
@@ -1559,6 +1559,11 @@ synack:
        advanced = seqdiff(hdr.ack, c->snd.una);
 
        if(advanced) {
+               if(c->reapable && !is_reliable(c)) {
+                       // TODO: we should also send RST for reliable connections
+                       goto reset;
+               }
+
                // RTT measurement
                if(c->rtt_start.tv_sec) {
                        if(c->rtt_seq == hdr.ack) {