[PATCH v1 10/17] j1939: transport: cancel session on j1939_tp_txnext error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>
---
 net/can/j1939/transport.c | 42 ++++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c
index 93df0c0c8ce2..13ffc7d315b2 100644
--- a/net/can/j1939/transport.c
+++ b/net/can/j1939/transport.c
@@ -840,7 +840,24 @@ static int j1939_tp_txnext(struct j1939_session *session)
 	return ret;
 }
 
-/* timer & scheduler functions */
+static void j1939_session_cancel(struct j1939_session *session,
+				 enum j1939_xtp_abort err)
+{
+	struct j1939_priv *priv = session->priv;
+
+	WARN_ON_ONCE(!err);
+
+	session->err = j1939_xtp_abort_to_errno(priv, err);
+	/* do not send aborts on incoming broadcasts */
+	if (!j1939_cb_is_broadcast(&session->skcb))
+		j1939_xtp_tx_abort(priv, &session->skcb,
+				   !(session->skcb.src_flags & J1939_ECU_LOCAL),
+				   err, session->skcb.addr.pgn);
+
+	if (session->sk)
+		j1939_sk_send_multi_abort(priv, session->sk, session->err);
+}
+
 static enum hrtimer_restart j1939_tp_txtimer(struct hrtimer *hrtimer)
 {
 	struct j1939_session *session =
@@ -858,8 +875,11 @@ static enum hrtimer_restart j1939_tp_txtimer(struct hrtimer *hrtimer)
 		ret = j1939_tp_txnext(session);
 	}
 
-	if (ret < 0)
+	if (ret == -ENOBUFS) {
 		j1939_tp_schedule_txtimer(session, 10 + prandom_u32_max(16));
+	} else if (ret) {
+		j1939_session_cancel(session, J1939_XTP_ABORT_OTHER);
+	}
 
 	j1939_session_put(session);
 
@@ -874,24 +894,6 @@ static void j1939_session_completed(struct j1939_session *session)
 	j1939_sk_recv(session->priv, se_skb);
 }
 
-static void j1939_session_cancel(struct j1939_session *session,
-				 enum j1939_xtp_abort err)
-{
-	struct j1939_priv *priv = session->priv;
-
-	WARN_ON_ONCE(!err);
-
-	session->err = j1939_xtp_abort_to_errno(priv, err);
-	/* do not send aborts on incoming broadcasts */
-	if (!j1939_cb_is_broadcast(&session->skcb))
-		j1939_xtp_tx_abort(priv, &session->skcb,
-				   !(session->skcb.src_flags & J1939_ECU_LOCAL),
-				   err, session->skcb.addr.pgn);
-
-	if (session->sk)
-		j1939_sk_send_multi_abort(priv, session->sk, session->err);
-}
-
 static enum hrtimer_restart j1939_tp_rxtimer(struct hrtimer *hrtimer)
 {
 	struct j1939_session *session = container_of(hrtimer,
-- 
2.20.1




[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux