mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Aleksander Morgado <aleksander@aleksander.es>
To: s.hauer@pengutronix.de, barebox@lists.infradead.org
Cc: Aleksander Morgado <aleksander@aleksander.es>
Subject: [PATCH 08/16] ratp: remove bogus data checks in behavior C2
Date: Thu, 15 Jun 2017 13:14:12 +0200	[thread overview]
Message-ID: <20170615111420.5318-9-aleksander@aleksander.es> (raw)
In-Reply-To: <20170615111420.5318-1-aleksander@aleksander.es>

The SN validation was being completely ignored if the packet had no
data (e.g. for RST, FIN or SYN or plain ACKs). This condition is now
removed so that the SN check is done.

The second check removed was actually never being used, as it was
already being tested for not having data in the first one.

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

diff --git a/lib/ratp.c b/lib/ratp.c
index 846f8130c..321721ab7 100644
--- a/lib/ratp.c
+++ b/lib/ratp.c
@@ -721,9 +721,6 @@ static int ratp_behaviour_c2(struct ratp_internal *ri, void *pkt)
 
 	pr_debug("%s\n", __func__);
 
-	if (!ratp_has_data(hdr))
-		return 0;
-
 	if (ratp_sn_expected(ri, hdr))
 		return 0;
 
@@ -745,9 +742,6 @@ static int ratp_behaviour_c2(struct ratp_internal *ri, void *pkt)
 		return 1;
 	}
 
-	if (!ratp_has_data(hdr))
-		return 1;
-
 	pr_debug("Sending ack for duplicate message\n");
 	ret = ratp_send_ack(ri, hdr);
 	if (ret)
@@ -1846,4 +1840,4 @@ eor:
 	}
 
 	return 0;
-}
\ No newline at end of file
+}
diff --git a/scripts/remote/ratp.py b/scripts/remote/ratp.py
index a41d2e8a3..0dfc8420c 100644
--- a/scripts/remote/ratp.py
+++ b/scripts/remote/ratp.py
@@ -339,9 +339,6 @@ class RatpConnection(object):
     def _c2(self, r):
         logging.info("C2")
 
-        if r.length == 0 and r.c_so == 0:
-            return True
-
         if r.c_sn != self._r_sn:
             return True
 
@@ -358,14 +355,11 @@ class RatpConnection(object):
             self._state = RatpState.closed
             return False
 
-        # FIXME: only ack duplicate data packages?
-        # This is not documented in RFC 916
-        if r.length or r.c_so:
-            logging.info("C2: duplicate data packet, dropping")
-            s = RatpPacket(flags='A')
-            s.c_sn = r.c_an
-            s.c_an = (r.c_sn + 1) % 2
-            self._write(s)
+        logging.info("C2: duplicate packet")
+        s = RatpPacket(flags='A')
+        s.c_sn = r.c_an
+        s.c_an = (r.c_sn + 1) % 2
+        self._write(s)
 
         return False
 
-- 
2.13.1


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

  parent reply	other threads:[~2017-06-15 11:15 UTC|newest]

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