From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dNl4v-0004Hh-Bh for barebox@lists.infradead.org; Wed, 21 Jun 2017 19:14:16 +0000 Received: by mail-wr0-x242.google.com with SMTP id x23so29083854wrb.0 for ; Wed, 21 Jun 2017 12:13:49 -0700 (PDT) From: Aleksander Morgado Date: Wed, 21 Jun 2017 21:13:08 +0200 Message-Id: <20170621191323.18191-2-aleksander@aleksander.es> In-Reply-To: <20170621191323.18191-1-aleksander@aleksander.es> References: <20170621191323.18191-1-aleksander@aleksander.es> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH v2 01/16] ratp: add missing transition to SYN-RECEIVED in behavior B To: s.hauer@pengutronix.de Cc: barebox@lists.infradead.org, Aleksander Morgado The reference says: If the SYN flag was set but the ACK was not set then the other end of the connection has executed an active open also. Acknowledge the SYN, choose your MDL, and send: Go to the SYN-RECEIVED state without any further processing. Add this missing step. This fix isn't related to any barebox<->bbremote interaction issue, because the case where both ends start an active connection doesn't apply in this case. Signed-off-by: Aleksander Morgado --- lib/ratp.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/ratp.c b/lib/ratp.c index 22e83636f..0d384aa4e 100644 --- a/lib/ratp.c +++ b/lib/ratp.c @@ -619,21 +619,25 @@ static void ratp_behaviour_b(struct ratp_internal *ri, void *pkt) if (hdr->control & RATP_CONTROL_SYN) { uint8_t control; + ri->sn_received = ratp_sn(hdr); + if (hdr->control & RATP_CONTROL_ACK) { control = ratp_set_sn(ratp_an(hdr)) | ratp_set_an(!ratp_sn(hdr)) | RATP_CONTROL_ACK; + ratp_send_hdr(ri, control); + ratp_state_change(ri, RATP_STATE_ESTABLISHED); } else { + struct ratp_header synack = {}; + control = ratp_set_an(!ratp_sn(hdr)) | RATP_CONTROL_SYN | RATP_CONTROL_ACK; + ratp_create_packet(ri, &synack, control, 255); + ratp_send_pkt(ri, &synack, sizeof(synack)); + ratp_state_change(ri, RATP_STATE_SYN_RECEIVED); } - - ri->sn_received = ratp_sn(hdr); - - ratp_send_hdr(ri, control); - ratp_state_change(ri, RATP_STATE_ESTABLISHED); } } -- 2.13.1 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox