mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Aleksander Morgado <aleksander@aleksander.es>
To: s.hauer@pengutronix.de
Cc: barebox@lists.infradead.org,
	Aleksander Morgado <aleksander@aleksander.es>
Subject: [PATCH v2 14/16] ratp: don't ignore data that may arrive in behaviour H1
Date: Wed, 21 Jun 2017 21:13:21 +0200	[thread overview]
Message-ID: <20170621191323.18191-15-aleksander@aleksander.es> (raw)
In-Reply-To: <20170621191323.18191-1-aleksander@aleksander.es>

If an input packet arrives H1 that has data in it, we need to:
  * track sn_received
  * if we have data pending, send it
  * if we don't have data pending, send a plain ACK

This process, as noted in RFC916, is the same as the I1 procedure, so
go and run it:

     Go to the ESTABLISHED state and execute procedure I1 to process
     any data which might be in this packet.

This fix allows the peer to queue data in the last packet doing the
connection establishment. It doesn't apply to the barebox<->bbremote
interaction because bbremote won't queue data until the connection is
completely established, but it allows third party ratp implementations
to do that.

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

diff --git a/lib/ratp.c b/lib/ratp.c
index e810a9e54..2dee41009 100644
--- a/lib/ratp.c
+++ b/lib/ratp.c
@@ -1042,6 +1042,8 @@ static int ratp_behaviour_g(struct ratp_internal *ri, void *pkt)
 	return 0;
 }
 
+static int ratp_behaviour_i1(struct ratp_internal *ri, void *pkt);
+
 /*
  * Our SYN has been acknowledged.  At this point we are
  * technically in the ESTABLISHED state.  Send any initial data
@@ -1062,7 +1064,11 @@ static int ratp_behaviour_h1(struct ratp_internal *ri, void *pkt)
 
 	ratp_state_change(ri, RATP_STATE_ESTABLISHED);
 
-	return 0;
+	/* If the input message has data (i.e. it is not just an ACK
+	 * without data) then we need to send back an ACK ourselves,
+	 * or even data if we have it pending. This is the same
+	 * procedure done in i1, so just run it. */
+	return ratp_behaviour_i1 (ri, pkt);
 }
 
 /*
diff --git a/scripts/remote/ratp.py b/scripts/remote/ratp.py
index e6b3e19b6..7972d31f2 100644
--- a/scripts/remote/ratp.py
+++ b/scripts/remote/ratp.py
@@ -489,12 +489,8 @@ class RatpConnection(object):
 
     def _h1(self, r):
         logging.info("H1")
-
-        # FIXME: initial data?
         self._state = RatpState.established
-        self._r_sn = r.c_sn
-
-        return False
+        return self._common_i1(r)
 
     def _h2(self, r):
         logging.info("H2")
@@ -584,9 +580,7 @@ class RatpConnection(object):
         self._time_wait_deadline = monotonic() + self._get_rto()
         return False
 
-    def _i1(self, r):
-        logging.info("I1")
-
+    def _common_i1(self, r):
         if r.c_so:
             self._r_sn = r.c_sn
             self._rx_buf.append(chr(r.length))
@@ -608,6 +602,10 @@ class RatpConnection(object):
         self._write(s)
         return False
 
+    def _i1(self, r):
+        logging.info("I1")
+        return self._common_i1(r)
+
     def _machine(self, pkt):
         logging.info("State: %r", self._state)
         if self._state == RatpState.listen:
-- 
2.13.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2017-06-21 19:14 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-21 19:13 [PATCH v2 00/16] RATP logic fixes and improvements Aleksander Morgado
2017-06-21 19:13 ` [PATCH v2 01/16] ratp: add missing transition to SYN-RECEIVED in behavior B Aleksander Morgado
2017-06-21 19:13 ` [PATCH v2 02/16] ratp: avoid unnecessary variable initializations Aleksander Morgado
2017-06-21 19:13 ` [PATCH v2 03/16] ratp: send missing RST in behavior C2 Aleksander Morgado
2017-06-21 19:13 ` [PATCH v2 04/16] ratp: add missing RST flag in behavior G Aleksander Morgado
2017-06-21 19:13 ` [PATCH v2 05/16] ratp: completely ignore RST flagged packets " Aleksander Morgado
2017-06-21 19:13 ` [PATCH v2 06/16] ratp: fix data presence check Aleksander Morgado
2017-06-21 19:13 ` [PATCH v2 07/16] ratp: fix single byte sending flagged with SO Aleksander Morgado
2017-06-21 19:13 ` [PATCH v2 08/16] ratp: remove bogus data checks in behavior C2 Aleksander Morgado
2017-06-21 19:13 ` [PATCH v2 09/16] ratp: remove FIXME comment: FIN always requires ACK Aleksander Morgado
2017-06-21 19:13 ` [PATCH v2 10/16] ratp: fix sending ACKs without data Aleksander Morgado
2017-06-21 19:13 ` [PATCH v2 11/16] ratp: consolidate ratp_sn_expected() and ratp_an_expected() Aleksander Morgado
2017-06-21 19:13 ` [PATCH v2 12/16] ratp: prefer using ratp_send_ack() in behaviour I1 Aleksander Morgado
2017-06-21 19:13 ` [PATCH v2 13/16] ratp: send initial data in behaviour B if any pending Aleksander Morgado
2017-06-21 19:13 ` Aleksander Morgado [this message]
2017-06-21 19:13 ` [PATCH v2 15/16] ratp: consolidate setting the next AN or SN flags Aleksander Morgado
2017-06-21 19:13 ` [PATCH v2 16/16] ratp: user close may happen in SYN-RECEIVED state Aleksander Morgado
2017-06-23 11:37 ` [PATCH v2 00/16] RATP logic fixes and improvements Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170621191323.18191-15-aleksander@aleksander.es \
    --to=aleksander@aleksander.es \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox