From 1a023116b9d5e9a8fa93e81fcef725fd7b343593 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Tue, 29 Sep 2020 22:38:55 +0200 Subject: [PATCH] Send RST packets when receiving data after we closed a UDP channel. 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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/utcp.c b/src/utcp.c index 65e6be7a..c1add218 100644 --- a/src/utcp.c +++ b/src/utcp.c @@ -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) { -- 2.39.5