[PATCH 16/16] ratp: user close may happen in SYN-RECEIVED state

Aleksander Morgado aleksander at aleksander.es
Thu Jun 15 04:14:20 PDT 2017


The reference says:

     5.2.3. SYN-RECEIVED
     ...
     Departures
       - A CLOSE request is made by the user.  Create a packet with
         FIN set.  Send it and go to the FIN-WAIT state.

Add this missing step.

Signed-off-by: Aleksander Morgado <aleksander at aleksander.es>
---
 lib/ratp.c             | 2 +-
 scripts/remote/ratp.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/ratp.c b/lib/ratp.c
index 46a82c69a..e7fbf640a 100644
--- a/lib/ratp.c
+++ b/lib/ratp.c
@@ -1689,7 +1689,7 @@ void ratp_close(struct ratp *ratp)
 	if (!ri)
 		return;
 
-	if (ri->state == RATP_STATE_ESTABLISHED) {
+	if (ri->state == RATP_STATE_ESTABLISHED || ri->state == RATP_STATE_SYN_RECEIVED) {
 		uint64_t start;
 		u8 control;
 
diff --git a/scripts/remote/ratp.py b/scripts/remote/ratp.py
index 7972d31f2..44f3e2f40 100644
--- a/scripts/remote/ratp.py
+++ b/scripts/remote/ratp.py
@@ -721,7 +721,7 @@ class RatpConnection(object):
     def close(self, timeout=1.0):
         deadline = monotonic() + timeout
         logging.info("CLOSE")
-        if self._state == RatpState.established:
+        if self._state == RatpState.established or self._state == RatpState.syn_received:
             fin = RatpPacket(flags='FA')
             fin.c_sn = (self._s_sn + 1) % 2
             fin.c_an = (self._r_sn + 1) % 2
-- 
2.13.1




More information about the barebox mailing list