[PATCH v1 12/17] j1939: add session state

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

 



we will needed it for socket session queue

Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>
---
 net/can/j1939/j1939-priv.h | 7 +++++++
 net/can/j1939/transport.c  | 3 +++
 2 files changed, 10 insertions(+)

diff --git a/net/can/j1939/j1939-priv.h b/net/can/j1939/j1939-priv.h
index 58bf1eaca6ec..08de30e87779 100644
--- a/net/can/j1939/j1939-priv.h
+++ b/net/can/j1939/j1939-priv.h
@@ -198,6 +198,12 @@ void j1939_tp_init(struct j1939_priv *priv);
 /* decrement pending skb for a j1939 socket */
 void j1939_sock_pending_del(struct sock *sk);
 
+enum j1939_session_state {
+	J1939_SESSION_NEW,
+	J1939_SESSION_ACTIVE,
+	J1939_SESSION_DONE,
+};
+
 struct j1939_session {
 	struct j1939_priv *priv;
 	struct list_head list;
@@ -225,6 +231,7 @@ struct j1939_session {
 	unsigned int total_message_size; /* Total message size, number of bytes */
 	int err;
 	u32 tskey;
+	enum j1939_session_state state;
 
 	/* Packets counters for a (extended) transfer session. The packet is
 	 * maximal of 7 bytes. */
diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c
index e4668979a2a5..5152b5518613 100644
--- a/net/can/j1939/transport.c
+++ b/net/can/j1939/transport.c
@@ -1083,6 +1083,7 @@ static struct j1939_session *j1939_session_new(struct j1939_priv *priv,
 	j1939_priv_get(priv);
 	session->priv = priv;
 	session->total_message_size = size;
+	session->state = J1939_SESSION_NEW;
 
 	skb_queue_head_init(&session->skb_queue);
 	skb_queue_tail(&session->skb_queue, skb);
@@ -1146,7 +1147,9 @@ static int j1939_session_insert(struct j1939_session *session)
 		ret = -EAGAIN;
 	} else {
 		j1939_session_list_lock(priv);
+		WARN_ON_ONCE(session->state != J1939_SESSION_NEW);
 		j1939_session_list_add(session);
+		session->state = J1939_SESSION_ACTIVE;
 		j1939_session_list_unlock(priv);
 	}
 
-- 
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