summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2017-06-21 21:13:10 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2017-06-23 13:34:07 +0200
commitbdafe8150dddcde945170dfdb268542a128ea038 (patch)
tree28a77a99cb42023d3813b1905f003133be6db5ce
parent95ec61ecb0bd1aad69b7f387768369c09ff532b4 (diff)
downloadbarebox-bdafe8150dddcde945170dfdb268542a128ea038.tar.gz
barebox-bdafe8150dddcde945170dfdb268542a128ea038.tar.xz
ratp: send missing RST in behavior C2
The reference says: If SYN was set we assume that the other end crashed and has attempted to open a new connection. We respond by sending a legal reset: <SN=received AN><AN=received SN+1 modulo 2><CTL=RST, ACK> Add this missing step. This issue affects the barebox<->bbremote interaction if bbremote crashes without closing the channel and restarts opening a complete new connection. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--lib/ratp.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/ratp.c b/lib/ratp.c
index e9536499e..a8ac52c75 100644
--- a/lib/ratp.c
+++ b/lib/ratp.c
@@ -731,8 +731,15 @@ static int ratp_behaviour_c2(struct ratp_internal *ri, void *pkt)
return 1;
if (hdr->control & RATP_CONTROL_SYN) {
+ uint8_t control;
+
ri->status = -ECONNRESET;
pr_debug("Error: Connection reset\n");
+
+ control = RATP_CONTROL_RST | RATP_CONTROL_ACK |
+ ratp_set_sn(ratp_an(hdr)) | ratp_set_an(!ratp_sn(hdr));
+ ratp_send_hdr(ri, control);
+
ratp_state_change(ri, RATP_STATE_CLOSED);
return 1;
}