linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] can-isotp: enable RX timeout handling in listen-only mode
@ 2020-10-19 12:02 Oliver Hartkopp
  2020-10-19 18:13 ` Marc Kleine-Budde
  0 siblings, 1 reply; 2+ messages in thread
From: Oliver Hartkopp @ 2020-10-19 12:02 UTC (permalink / raw)
  To: linux-can; +Cc: Oliver Hartkopp, Thomas Wagner

As reported by Thomas Wagner here
https://github.com/hartkopp/can-isotp/issues/34
the timeout handling for data frames is not enabled when the isotp socket
is used in listen-only mode (sockopt CAN_ISOTP_LISTEN_MODE).
This mode is enabled by the isotpsniffer application which therefore
became inconsistend with the strict rx timeout rules when running the
isotp protocol in the operational mode.

This patch fixes this inconsistency by moving the return condition for the
listen-only mode behind the timeout handling code.

Reported-by: Thomas Wagner <thwa1@web.de>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
---
 net/can/isotp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/can/isotp.c b/net/can/isotp.c
index 4c2062875893..a79287ef86da 100644
--- a/net/can/isotp.c
+++ b/net/can/isotp.c
@@ -567,22 +567,22 @@ static int isotp_rcv_cf(struct sock *sk, struct canfd_frame *cf, int ae,
 		nskb->dev = skb->dev;
 		isotp_rcv_skb(nskb, sk);
 		return 0;
 	}
 
-	/* no creation of flow control frames */
-	if (so->opt.flags & CAN_ISOTP_LISTEN_MODE)
-		return 0;
-
 	/* perform blocksize handling, if enabled */
 	if (!so->rxfc.bs || ++so->rx.bs < so->rxfc.bs) {
 		/* start rx timeout watchdog */
 		hrtimer_start(&so->rxtimer, ktime_set(1, 0),
 			      HRTIMER_MODE_REL_SOFT);
 		return 0;
 	}
 
+	/* no creation of flow control frames */
+	if (so->opt.flags & CAN_ISOTP_LISTEN_MODE)
+		return 0;
+
 	/* we reached the specified blocksize so->rxfc.bs */
 	isotp_send_fc(sk, ae, ISOTP_FC_CTS);
 	return 0;
 }
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] can-isotp: enable RX timeout handling in listen-only mode
  2020-10-19 12:02 [PATCH] can-isotp: enable RX timeout handling in listen-only mode Oliver Hartkopp
@ 2020-10-19 18:13 ` Marc Kleine-Budde
  0 siblings, 0 replies; 2+ messages in thread
From: Marc Kleine-Budde @ 2020-10-19 18:13 UTC (permalink / raw)
  To: Oliver Hartkopp, linux-can; +Cc: Thomas Wagner


[-- Attachment #1.1: Type: text/plain, Size: 1018 bytes --]

On 10/19/20 2:02 PM, Oliver Hartkopp wrote:
> As reported by Thomas Wagner here
> https://github.com/hartkopp/can-isotp/issues/34
> the timeout handling for data frames is not enabled when the isotp socket
> is used in listen-only mode (sockopt CAN_ISOTP_LISTEN_MODE).
> This mode is enabled by the isotpsniffer application which therefore
> became inconsistend with the strict rx timeout rules when running the
> isotp protocol in the operational mode.
> 
> This patch fixes this inconsistency by moving the return condition for the
> listen-only mode behind the timeout handling code.
> 
> Reported-by: Thomas Wagner <thwa1@web.de>
> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>

Applied to linux-can.

tnx,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-20  6:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-19 12:02 [PATCH] can-isotp: enable RX timeout handling in listen-only mode Oliver Hartkopp
2020-10-19 18:13 ` Marc Kleine-Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).