* [RFC PATCH] ratp: Fix retransmission for header-only packets
@ 2023-01-23 10:27 Jules Maselbas
2023-01-25 15:39 ` [PATCH v2] " Jules Maselbas
0 siblings, 1 reply; 5+ messages in thread
From: Jules Maselbas @ 2023-01-23 10:27 UTC (permalink / raw)
To: barebox; +Cc: Jules Maselbas
Using sendmsg_current to detect if a packet needs to be retransmitted is
brittle as only packets containing data will ever be considered, packets
only containing a header (without data) were never being retransmitted.
The sendbuf_len is used to determine if a packets is being send or not,
a non-zero length means that a packets is still being in the "try-send"
state, the length is not set to zero when a valid SN is received.
Retransmission issue can be easily reproduced with a physical UART (not
cdc_acm over USB), by running the following command:
while ratp-barebox-cli -b 115200 -t /dev/ttyACMx -p; do :; done
Alternatively, it is possible to modify lib/ratp.c to force packets to
be sent by the retransmission logic with the following change:
@ int ratp_send_pkt(struct ratp_internal *ri, void *pkt, int length)
ri->sendbuf_len = length;
- ri->retransmission_timer_start = get_time_ns();
+ ri->retransmission_timer_start = get_time_ns() - ri->rto * MSECOND/2;
ri->retransmission_count = 0;
}
- return ri->ratp->send(ri->ratp, pkt, length);
+ return 0;
Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
lib/ratp.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/ratp.c b/lib/ratp.c
index ce30223bac..afa76ac894 100644
--- a/lib/ratp.c
+++ b/lib/ratp.c
@@ -1391,6 +1391,9 @@ static int ratp_state_machine(struct ratp_internal *ri, void *pkt)
ratp_print_header(ri, hdr, " recv");
pr_debug(" state %s\n", ratp_state_str[ri->state]);
+ if ((hdr->control & RATP_CONTROL_ACK) && (ratp_an_expected(ri, hdr)))
+ ri->sendbuf_len = 0;
+
switch (ri->state) {
case RATP_STATE_LISTEN:
ratp_behaviour_a(ri, pkt);
@@ -1580,9 +1583,8 @@ int ratp_poll(struct ratp *ratp)
}
}
- if (ri->sendmsg_current && is_timeout(ri->retransmission_timer_start,
+ if (ri->sendbuf_len && is_timeout(ri->retransmission_timer_start,
ri->rto * MSECOND)) {
-
ri->retransmission_count++;
if (ri->retransmission_count == ri->max_retransmission) {
ri->status = ret = -ETIMEDOUT;
@@ -1601,7 +1603,7 @@ int ratp_poll(struct ratp *ratp)
goto out;
}
- if (!ri->sendmsg_current && !list_empty(&ri->sendmsg))
+ if (ri->sendbuf_len == 0 && !list_empty(&ri->sendmsg))
ratp_send_next_data(ri);
ret = 0;
--
2.17.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] ratp: Fix retransmission for header-only packets
2023-01-23 10:27 [RFC PATCH] ratp: Fix retransmission for header-only packets Jules Maselbas
@ 2023-01-25 15:39 ` Jules Maselbas
2023-01-25 15:44 ` Jules Maselbas
2023-02-03 8:16 ` Sascha Hauer
0 siblings, 2 replies; 5+ messages in thread
From: Jules Maselbas @ 2023-01-25 15:39 UTC (permalink / raw)
To: barebox; +Cc: Jules Maselbas
Using sendmsg_current to detect if a packet needs to be retransmitted is
brittle as only packets containing data will ever be considered, packets
only containing a header (without data) were never being retransmitted.
The sendbuf_len is used to determine if a packets is being send or not,
a non-zero length means that a packets is still being in the "try-send"
state, the length is not set to zero when a valid SN is received.
Retransmission issue can be easily reproduced with a physical UART (not
cdc_acm over USB), by running the following command:
while ratp-barebox-cli -b 115200 -t /dev/ttyACMx -p; do :; done
Alternatively, it is possible to modify lib/ratp.c to force packets to
be sent by the retransmission logic with the following change:
@ int ratp_send_pkt(struct ratp_internal *ri, void *pkt, int length)
ri->sendbuf_len = length;
- ri->retransmission_timer_start = get_time_ns();
+ ri->retransmission_timer_start = get_time_ns() - ri->rto * MSECOND/2;
ri->retransmission_count = 0;
}
- return ri->ratp->send(ri->ratp, pkt, length);
+ return 0;
Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
changes in v2: reset sendbuf_len to zero where appropriated (in each behavior)
lib/ratp.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/lib/ratp.c b/lib/ratp.c
index ce30223bac..b582e4e779 100644
--- a/lib/ratp.c
+++ b/lib/ratp.c
@@ -738,7 +738,7 @@ static int ratp_behaviour_c2(struct ratp_internal *ri, void *pkt)
control = RATP_CONTROL_RST | RATP_CONTROL_ACK |
ratp_set_sn(ratp_an(hdr)) | ratp_set_next_an(ratp_sn(hdr));
ratp_send_hdr(ri, control);
-
+ ri->sendbuf_len = 0;
ratp_state_change(ri, RATP_STATE_CLOSED);
return 1;
}
@@ -784,7 +784,7 @@ static int ratp_behaviour_d1(struct ratp_internal *ri, void *pkt)
ri->status = -ECONNREFUSED;
pr_debug("Error: connection refused\n");
-
+ ri->sendbuf_len = 0;
ratp_state_change(ri, RATP_STATE_CLOSED);
return 1;
@@ -812,6 +812,8 @@ static int ratp_behaviour_d2(struct ratp_internal *ri, void *pkt)
ri->status = -ECONNRESET;
pr_debug("connection reset\n");
+ ri->sendbuf_len = 0;
+ ratp_state_change(ri, RATP_STATE_CLOSED);
return 0;
}
@@ -879,7 +881,7 @@ static int ratp_behaviour_e(struct ratp_internal *ri, void *pkt)
ratp_send_hdr(ri, control);
pr_debug("connection reset\n");
-
+ ri->sendbuf_len = 0;
ratp_state_change(ri, RATP_STATE_CLOSED);
return 1;
@@ -924,8 +926,10 @@ static int ratp_behaviour_f1(struct ratp_internal *ri, void *pkt)
if (!(hdr->control & RATP_CONTROL_ACK))
return 1;
- if (ratp_an_expected(ri, hdr))
+ if (ratp_an_expected(ri, hdr)) {
+ ri->sendbuf_len = 0; /* packet succesfully received */
return 0;
+ }
control = RATP_CONTROL_RST | ratp_set_sn(ratp_an(hdr));
ratp_send_hdr(ri, control);
@@ -971,6 +975,8 @@ static int ratp_behaviour_f2(struct ratp_internal *ri, void *pkt)
if (ri->sendmsg_current)
ratp_msg_done(ri, ri->sendmsg_current, 0);
ri->sendmsg_current = NULL;
+ ri->sendbuf_len = 0; /* packet succesfully received */
+ pr_debug("Data succesfully sent 0\n");
return 0;
} else {
pr_vdebug("%s: an not expected\n", __func__);
@@ -1175,6 +1181,7 @@ static int ratp_behaviour_h3(struct ratp_internal *ri, void *pkt)
ratp_send_hdr(ri, control);
ri->status = -ECONNRESET;
pr_debug("Error: Connection reset\n");
+ ri->sendbuf_len = 0;
ratp_state_change(ri, RATP_STATE_CLOSED);
return 1;
}
@@ -1217,8 +1224,10 @@ static int ratp_behaviour_h4(struct ratp_internal *ri, void *pkt)
pr_debug("%s\n", __func__);
- if (ratp_an_expected(ri, hdr))
+ if (ratp_an_expected(ri, hdr)) {
+ ri->sendbuf_len = 0; /* packet succesfully received */
ratp_state_change(ri, RATP_STATE_CLOSED);
+ }
return 1;
}
@@ -1244,6 +1253,7 @@ static int ratp_behaviour_h5(struct ratp_internal *ri, void *pkt)
pr_debug("%s\n", __func__);
if (ratp_an_expected(ri, hdr)) {
+ ri->sendbuf_len = 0; /* packet succesfully received */
ratp_state_change(ri, RATP_STATE_TIME_WAIT);
ratp_start_time_wait_timer(ri);
}
@@ -1580,9 +1590,8 @@ int ratp_poll(struct ratp *ratp)
}
}
- if (ri->sendmsg_current && is_timeout(ri->retransmission_timer_start,
+ if (ri->sendbuf_len && is_timeout(ri->retransmission_timer_start,
ri->rto * MSECOND)) {
-
ri->retransmission_count++;
if (ri->retransmission_count == ri->max_retransmission) {
ri->status = ret = -ETIMEDOUT;
@@ -1601,7 +1610,7 @@ int ratp_poll(struct ratp *ratp)
goto out;
}
- if (!ri->sendmsg_current && !list_empty(&ri->sendmsg))
+ if (ri->sendbuf_len == 0 && !list_empty(&ri->sendmsg))
ratp_send_next_data(ri);
ret = 0;
--
2.17.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] ratp: Fix retransmission for header-only packets
2023-01-25 15:39 ` [PATCH v2] " Jules Maselbas
@ 2023-01-25 15:44 ` Jules Maselbas
2023-02-03 8:16 ` Sascha Hauer
1 sibling, 0 replies; 5+ messages in thread
From: Jules Maselbas @ 2023-01-25 15:44 UTC (permalink / raw)
To: barebox
On Wed, Jan 25, 2023 at 04:39:59PM +0100, Jules Maselbas wrote:
> Using sendmsg_current to detect if a packet needs to be retransmitted is
> brittle as only packets containing data will ever be considered, packets
> only containing a header (without data) were never being retransmitted.
>
> The sendbuf_len is used to determine if a packets is being send or not,
> a non-zero length means that a packets is still being in the "try-send"
> state, the length is not set to zero when a valid SN is received.
>
> Retransmission issue can be easily reproduced with a physical UART (not
> cdc_acm over USB), by running the following command:
>
> while ratp-barebox-cli -b 115200 -t /dev/ttyACMx -p; do :; done
>
> Alternatively, it is possible to modify lib/ratp.c to force packets to
> be sent by the retransmission logic with the following change:
>
> @ int ratp_send_pkt(struct ratp_internal *ri, void *pkt, int length)
> ri->sendbuf_len = length;
> - ri->retransmission_timer_start = get_time_ns();
> + ri->retransmission_timer_start = get_time_ns() - ri->rto * MSECOND/2;
> ri->retransmission_count = 0;
> }
> - return ri->ratp->send(ri->ratp, pkt, length);
> + return 0;
>
> Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
> ---
> changes in v2: reset sendbuf_len to zero where appropriated (in each behavior)
>
> lib/ratp.c | 25 +++++++++++++++++--------
> 1 file changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/lib/ratp.c b/lib/ratp.c
> index ce30223bac..b582e4e779 100644
> --- a/lib/ratp.c
> +++ b/lib/ratp.c
> @@ -738,7 +738,7 @@ static int ratp_behaviour_c2(struct ratp_internal *ri, void *pkt)
> control = RATP_CONTROL_RST | RATP_CONTROL_ACK |
> ratp_set_sn(ratp_an(hdr)) | ratp_set_next_an(ratp_sn(hdr));
> ratp_send_hdr(ri, control);
> -
> + ri->sendbuf_len = 0;
> ratp_state_change(ri, RATP_STATE_CLOSED);
> return 1;
> }
> @@ -784,7 +784,7 @@ static int ratp_behaviour_d1(struct ratp_internal *ri, void *pkt)
> ri->status = -ECONNREFUSED;
>
> pr_debug("Error: connection refused\n");
> -
> + ri->sendbuf_len = 0;
> ratp_state_change(ri, RATP_STATE_CLOSED);
>
> return 1;
> @@ -812,6 +812,8 @@ static int ratp_behaviour_d2(struct ratp_internal *ri, void *pkt)
> ri->status = -ECONNRESET;
>
> pr_debug("connection reset\n");
> + ri->sendbuf_len = 0;
> + ratp_state_change(ri, RATP_STATE_CLOSED);
>
> return 0;
> }
> @@ -879,7 +881,7 @@ static int ratp_behaviour_e(struct ratp_internal *ri, void *pkt)
> ratp_send_hdr(ri, control);
>
> pr_debug("connection reset\n");
> -
> + ri->sendbuf_len = 0;
> ratp_state_change(ri, RATP_STATE_CLOSED);
>
> return 1;
> @@ -924,8 +926,10 @@ static int ratp_behaviour_f1(struct ratp_internal *ri, void *pkt)
> if (!(hdr->control & RATP_CONTROL_ACK))
> return 1;
>
> - if (ratp_an_expected(ri, hdr))
> + if (ratp_an_expected(ri, hdr)) {
> + ri->sendbuf_len = 0; /* packet succesfully received */
> return 0;
> + }
>
> control = RATP_CONTROL_RST | ratp_set_sn(ratp_an(hdr));
> ratp_send_hdr(ri, control);
> @@ -971,6 +975,8 @@ static int ratp_behaviour_f2(struct ratp_internal *ri, void *pkt)
> if (ri->sendmsg_current)
> ratp_msg_done(ri, ri->sendmsg_current, 0);
> ri->sendmsg_current = NULL;
> + ri->sendbuf_len = 0; /* packet succesfully received */
> + pr_debug("Data succesfully sent 0\n");
This pr_debug line was not intended to be included.
> return 0;
> } else {
> pr_vdebug("%s: an not expected\n", __func__);
> @@ -1175,6 +1181,7 @@ static int ratp_behaviour_h3(struct ratp_internal *ri, void *pkt)
> ratp_send_hdr(ri, control);
> ri->status = -ECONNRESET;
> pr_debug("Error: Connection reset\n");
> + ri->sendbuf_len = 0;
> ratp_state_change(ri, RATP_STATE_CLOSED);
> return 1;
> }
> @@ -1217,8 +1224,10 @@ static int ratp_behaviour_h4(struct ratp_internal *ri, void *pkt)
>
> pr_debug("%s\n", __func__);
>
> - if (ratp_an_expected(ri, hdr))
> + if (ratp_an_expected(ri, hdr)) {
> + ri->sendbuf_len = 0; /* packet succesfully received */
> ratp_state_change(ri, RATP_STATE_CLOSED);
> + }
>
> return 1;
> }
> @@ -1244,6 +1253,7 @@ static int ratp_behaviour_h5(struct ratp_internal *ri, void *pkt)
> pr_debug("%s\n", __func__);
>
> if (ratp_an_expected(ri, hdr)) {
> + ri->sendbuf_len = 0; /* packet succesfully received */
> ratp_state_change(ri, RATP_STATE_TIME_WAIT);
> ratp_start_time_wait_timer(ri);
> }
> @@ -1580,9 +1590,8 @@ int ratp_poll(struct ratp *ratp)
> }
> }
>
> - if (ri->sendmsg_current && is_timeout(ri->retransmission_timer_start,
> + if (ri->sendbuf_len && is_timeout(ri->retransmission_timer_start,
> ri->rto * MSECOND)) {
> -
> ri->retransmission_count++;
> if (ri->retransmission_count == ri->max_retransmission) {
> ri->status = ret = -ETIMEDOUT;
> @@ -1601,7 +1610,7 @@ int ratp_poll(struct ratp *ratp)
> goto out;
> }
>
> - if (!ri->sendmsg_current && !list_empty(&ri->sendmsg))
> + if (ri->sendbuf_len == 0 && !list_empty(&ri->sendmsg))
> ratp_send_next_data(ri);
>
> ret = 0;
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] ratp: Fix retransmission for header-only packets
2023-01-25 15:39 ` [PATCH v2] " Jules Maselbas
2023-01-25 15:44 ` Jules Maselbas
@ 2023-02-03 8:16 ` Sascha Hauer
2023-02-05 17:07 ` Jules Maselbas
1 sibling, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2023-02-03 8:16 UTC (permalink / raw)
To: Jules Maselbas; +Cc: barebox
Hi Jules,
On Wed, Jan 25, 2023 at 04:39:59PM +0100, Jules Maselbas wrote:
> Using sendmsg_current to detect if a packet needs to be retransmitted is
> brittle as only packets containing data will ever be considered, packets
> only containing a header (without data) were never being retransmitted.
>
> The sendbuf_len is used to determine if a packets is being send or not,
> a non-zero length means that a packets is still being in the "try-send"
> state, the length is not set to zero when a valid SN is received.
>
> Retransmission issue can be easily reproduced with a physical UART (not
> cdc_acm over USB), by running the following command:
>
> while ratp-barebox-cli -b 115200 -t /dev/ttyACMx -p; do :; done
>
> Alternatively, it is possible to modify lib/ratp.c to force packets to
> be sent by the retransmission logic with the following change:
>
> @ int ratp_send_pkt(struct ratp_internal *ri, void *pkt, int length)
> ri->sendbuf_len = length;
> - ri->retransmission_timer_start = get_time_ns();
> + ri->retransmission_timer_start = get_time_ns() - ri->rto * MSECOND/2;
> ri->retransmission_count = 0;
> }
> - return ri->ratp->send(ri->ratp, pkt, length);
> + return 0;
>
> Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
> ---
> changes in v2: reset sendbuf_len to zero where appropriated (in each behavior)
>
> lib/ratp.c | 25 +++++++++++++++++--------
> 1 file changed, 17 insertions(+), 8 deletions(-)
Is this one still ok to be applied from your side?
This doesn't fix the issue you are mentioning in the other thread,
right?
Sascha
>
> diff --git a/lib/ratp.c b/lib/ratp.c
> index ce30223bac..b582e4e779 100644
> --- a/lib/ratp.c
> +++ b/lib/ratp.c
> @@ -738,7 +738,7 @@ static int ratp_behaviour_c2(struct ratp_internal *ri, void *pkt)
> control = RATP_CONTROL_RST | RATP_CONTROL_ACK |
> ratp_set_sn(ratp_an(hdr)) | ratp_set_next_an(ratp_sn(hdr));
> ratp_send_hdr(ri, control);
> -
> + ri->sendbuf_len = 0;
> ratp_state_change(ri, RATP_STATE_CLOSED);
> return 1;
> }
> @@ -784,7 +784,7 @@ static int ratp_behaviour_d1(struct ratp_internal *ri, void *pkt)
> ri->status = -ECONNREFUSED;
>
> pr_debug("Error: connection refused\n");
> -
> + ri->sendbuf_len = 0;
> ratp_state_change(ri, RATP_STATE_CLOSED);
>
> return 1;
> @@ -812,6 +812,8 @@ static int ratp_behaviour_d2(struct ratp_internal *ri, void *pkt)
> ri->status = -ECONNRESET;
>
> pr_debug("connection reset\n");
> + ri->sendbuf_len = 0;
> + ratp_state_change(ri, RATP_STATE_CLOSED);
>
> return 0;
> }
> @@ -879,7 +881,7 @@ static int ratp_behaviour_e(struct ratp_internal *ri, void *pkt)
> ratp_send_hdr(ri, control);
>
> pr_debug("connection reset\n");
> -
> + ri->sendbuf_len = 0;
> ratp_state_change(ri, RATP_STATE_CLOSED);
>
> return 1;
> @@ -924,8 +926,10 @@ static int ratp_behaviour_f1(struct ratp_internal *ri, void *pkt)
> if (!(hdr->control & RATP_CONTROL_ACK))
> return 1;
>
> - if (ratp_an_expected(ri, hdr))
> + if (ratp_an_expected(ri, hdr)) {
> + ri->sendbuf_len = 0; /* packet succesfully received */
> return 0;
> + }
>
> control = RATP_CONTROL_RST | ratp_set_sn(ratp_an(hdr));
> ratp_send_hdr(ri, control);
> @@ -971,6 +975,8 @@ static int ratp_behaviour_f2(struct ratp_internal *ri, void *pkt)
> if (ri->sendmsg_current)
> ratp_msg_done(ri, ri->sendmsg_current, 0);
> ri->sendmsg_current = NULL;
> + ri->sendbuf_len = 0; /* packet succesfully received */
> + pr_debug("Data succesfully sent 0\n");
> return 0;
> } else {
> pr_vdebug("%s: an not expected\n", __func__);
> @@ -1175,6 +1181,7 @@ static int ratp_behaviour_h3(struct ratp_internal *ri, void *pkt)
> ratp_send_hdr(ri, control);
> ri->status = -ECONNRESET;
> pr_debug("Error: Connection reset\n");
> + ri->sendbuf_len = 0;
> ratp_state_change(ri, RATP_STATE_CLOSED);
> return 1;
> }
> @@ -1217,8 +1224,10 @@ static int ratp_behaviour_h4(struct ratp_internal *ri, void *pkt)
>
> pr_debug("%s\n", __func__);
>
> - if (ratp_an_expected(ri, hdr))
> + if (ratp_an_expected(ri, hdr)) {
> + ri->sendbuf_len = 0; /* packet succesfully received */
> ratp_state_change(ri, RATP_STATE_CLOSED);
> + }
>
> return 1;
> }
> @@ -1244,6 +1253,7 @@ static int ratp_behaviour_h5(struct ratp_internal *ri, void *pkt)
> pr_debug("%s\n", __func__);
>
> if (ratp_an_expected(ri, hdr)) {
> + ri->sendbuf_len = 0; /* packet succesfully received */
> ratp_state_change(ri, RATP_STATE_TIME_WAIT);
> ratp_start_time_wait_timer(ri);
> }
> @@ -1580,9 +1590,8 @@ int ratp_poll(struct ratp *ratp)
> }
> }
>
> - if (ri->sendmsg_current && is_timeout(ri->retransmission_timer_start,
> + if (ri->sendbuf_len && is_timeout(ri->retransmission_timer_start,
> ri->rto * MSECOND)) {
> -
> ri->retransmission_count++;
> if (ri->retransmission_count == ri->max_retransmission) {
> ri->status = ret = -ETIMEDOUT;
> @@ -1601,7 +1610,7 @@ int ratp_poll(struct ratp *ratp)
> goto out;
> }
>
> - if (!ri->sendmsg_current && !list_empty(&ri->sendmsg))
> + if (ri->sendbuf_len == 0 && !list_empty(&ri->sendmsg))
> ratp_send_next_data(ri);
>
> ret = 0;
> --
> 2.17.1
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] ratp: Fix retransmission for header-only packets
2023-02-03 8:16 ` Sascha Hauer
@ 2023-02-05 17:07 ` Jules Maselbas
0 siblings, 0 replies; 5+ messages in thread
From: Jules Maselbas @ 2023-02-05 17:07 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
Hi Sascha,
On Fri, Feb 03, 2023 at 09:16:08AM +0100, Sascha Hauer wrote:
> Hi Jules,
>
> On Wed, Jan 25, 2023 at 04:39:59PM +0100, Jules Maselbas wrote:
> > Using sendmsg_current to detect if a packet needs to be retransmitted is
> > brittle as only packets containing data will ever be considered, packets
> > only containing a header (without data) were never being retransmitted.
> >
> > The sendbuf_len is used to determine if a packets is being send or not,
> > a non-zero length means that a packets is still being in the "try-send"
> > state, the length is not set to zero when a valid SN is received.
> >
> > Retransmission issue can be easily reproduced with a physical UART (not
> > cdc_acm over USB), by running the following command:
> >
> > while ratp-barebox-cli -b 115200 -t /dev/ttyACMx -p; do :; done
> >
> > Alternatively, it is possible to modify lib/ratp.c to force packets to
> > be sent by the retransmission logic with the following change:
> >
> > @ int ratp_send_pkt(struct ratp_internal *ri, void *pkt, int length)
> > ri->sendbuf_len = length;
> > - ri->retransmission_timer_start = get_time_ns();
> > + ri->retransmission_timer_start = get_time_ns() - ri->rto * MSECOND/2;
> > ri->retransmission_count = 0;
> > }
> > - return ri->ratp->send(ri->ratp, pkt, length);
> > + return 0;
> >
> > Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
> > ---
> > changes in v2: reset sendbuf_len to zero where appropriated (in each behavior)
> >
> > lib/ratp.c | 25 +++++++++++++++++--------
> > 1 file changed, 17 insertions(+), 8 deletions(-)
>
> Is this one still ok to be applied from your side?
No, I will send a new series with some additional patches.
> This doesn't fix the issue you are mentioning in the other thread,
> right?
It does fix an issue but it is not sufficient, but the RATP protcol needs
to fix as well
> Sascha
>
> >
> > diff --git a/lib/ratp.c b/lib/ratp.c
> > index ce30223bac..b582e4e779 100644
> > --- a/lib/ratp.c
> > +++ b/lib/ratp.c
> > @@ -738,7 +738,7 @@ static int ratp_behaviour_c2(struct ratp_internal *ri, void *pkt)
> > control = RATP_CONTROL_RST | RATP_CONTROL_ACK |
> > ratp_set_sn(ratp_an(hdr)) | ratp_set_next_an(ratp_sn(hdr));
> > ratp_send_hdr(ri, control);
> > -
> > + ri->sendbuf_len = 0;
> > ratp_state_change(ri, RATP_STATE_CLOSED);
> > return 1;
> > }
> > @@ -784,7 +784,7 @@ static int ratp_behaviour_d1(struct ratp_internal *ri, void *pkt)
> > ri->status = -ECONNREFUSED;
> >
> > pr_debug("Error: connection refused\n");
> > -
> > + ri->sendbuf_len = 0;
> > ratp_state_change(ri, RATP_STATE_CLOSED);
> >
> > return 1;
> > @@ -812,6 +812,8 @@ static int ratp_behaviour_d2(struct ratp_internal *ri, void *pkt)
> > ri->status = -ECONNRESET;
> >
> > pr_debug("connection reset\n");
> > + ri->sendbuf_len = 0;
> > + ratp_state_change(ri, RATP_STATE_CLOSED);
> >
> > return 0;
> > }
> > @@ -879,7 +881,7 @@ static int ratp_behaviour_e(struct ratp_internal *ri, void *pkt)
> > ratp_send_hdr(ri, control);
> >
> > pr_debug("connection reset\n");
> > -
> > + ri->sendbuf_len = 0;
> > ratp_state_change(ri, RATP_STATE_CLOSED);
> >
> > return 1;
> > @@ -924,8 +926,10 @@ static int ratp_behaviour_f1(struct ratp_internal *ri, void *pkt)
> > if (!(hdr->control & RATP_CONTROL_ACK))
> > return 1;
> >
> > - if (ratp_an_expected(ri, hdr))
> > + if (ratp_an_expected(ri, hdr)) {
> > + ri->sendbuf_len = 0; /* packet succesfully received */
> > return 0;
> > + }
> >
> > control = RATP_CONTROL_RST | ratp_set_sn(ratp_an(hdr));
> > ratp_send_hdr(ri, control);
> > @@ -971,6 +975,8 @@ static int ratp_behaviour_f2(struct ratp_internal *ri, void *pkt)
> > if (ri->sendmsg_current)
> > ratp_msg_done(ri, ri->sendmsg_current, 0);
> > ri->sendmsg_current = NULL;
> > + ri->sendbuf_len = 0; /* packet succesfully received */
> > + pr_debug("Data succesfully sent 0\n");
> > return 0;
> > } else {
> > pr_vdebug("%s: an not expected\n", __func__);
> > @@ -1175,6 +1181,7 @@ static int ratp_behaviour_h3(struct ratp_internal *ri, void *pkt)
> > ratp_send_hdr(ri, control);
> > ri->status = -ECONNRESET;
> > pr_debug("Error: Connection reset\n");
> > + ri->sendbuf_len = 0;
> > ratp_state_change(ri, RATP_STATE_CLOSED);
> > return 1;
> > }
> > @@ -1217,8 +1224,10 @@ static int ratp_behaviour_h4(struct ratp_internal *ri, void *pkt)
> >
> > pr_debug("%s\n", __func__);
> >
> > - if (ratp_an_expected(ri, hdr))
> > + if (ratp_an_expected(ri, hdr)) {
> > + ri->sendbuf_len = 0; /* packet succesfully received */
> > ratp_state_change(ri, RATP_STATE_CLOSED);
> > + }
> >
> > return 1;
> > }
> > @@ -1244,6 +1253,7 @@ static int ratp_behaviour_h5(struct ratp_internal *ri, void *pkt)
> > pr_debug("%s\n", __func__);
> >
> > if (ratp_an_expected(ri, hdr)) {
> > + ri->sendbuf_len = 0; /* packet succesfully received */
> > ratp_state_change(ri, RATP_STATE_TIME_WAIT);
> > ratp_start_time_wait_timer(ri);
> > }
> > @@ -1580,9 +1590,8 @@ int ratp_poll(struct ratp *ratp)
> > }
> > }
> >
> > - if (ri->sendmsg_current && is_timeout(ri->retransmission_timer_start,
> > + if (ri->sendbuf_len && is_timeout(ri->retransmission_timer_start,
> > ri->rto * MSECOND)) {
> > -
> > ri->retransmission_count++;
> > if (ri->retransmission_count == ri->max_retransmission) {
> > ri->status = ret = -ETIMEDOUT;
> > @@ -1601,7 +1610,7 @@ int ratp_poll(struct ratp *ratp)
> > goto out;
> > }
> >
> > - if (!ri->sendmsg_current && !list_empty(&ri->sendmsg))
> > + if (ri->sendbuf_len == 0 && !list_empty(&ri->sendmsg))
> > ratp_send_next_data(ri);
> >
> > ret = 0;
> > --
> > 2.17.1
> >
> >
> >
>
> --
> Pengutronix e.K. | |
> Steuerwalder Str. 21 | http://www.pengutronix.de/ |
> 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
>
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-02-05 17:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-23 10:27 [RFC PATCH] ratp: Fix retransmission for header-only packets Jules Maselbas
2023-01-25 15:39 ` [PATCH v2] " Jules Maselbas
2023-01-25 15:44 ` Jules Maselbas
2023-02-03 8:16 ` Sascha Hauer
2023-02-05 17:07 ` Jules Maselbas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox