Commit 8b1aa267 authored by Parthasarathy Bhuvaragan's avatar Parthasarathy Bhuvaragan Committed by Greg Kroah-Hartman

tipc: ignore requests when the connection state is not CONNECTED


[ Upstream commit 4c887aa6 ]

In tipc_conn_sendmsg(), we first queue the request to the outqueue
followed by the connection state check. If the connection is not
connected, we should not queue this message.

In this commit, we reject the messages if the connection state is
not CF_CONNECTED.
Acked-by: default avatarYing Xue <ying.xue@windriver.com>
Acked-by: default avatarJon Maloy <jon.maloy@ericsson.com>
Tested-by: default avatarJohn Thompson <thompa.atl@gmail.com>
Signed-off-by: default avatarParthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 77d2b8dc
...@@ -452,6 +452,11 @@ int tipc_conn_sendmsg(struct tipc_server *s, int conid, ...@@ -452,6 +452,11 @@ int tipc_conn_sendmsg(struct tipc_server *s, int conid,
if (!con) if (!con)
return -EINVAL; return -EINVAL;
if (!test_bit(CF_CONNECTED, &con->flags)) {
conn_put(con);
return 0;
}
e = tipc_alloc_entry(data, len); e = tipc_alloc_entry(data, len);
if (!e) { if (!e) {
conn_put(con); conn_put(con);
...@@ -465,12 +470,8 @@ int tipc_conn_sendmsg(struct tipc_server *s, int conid, ...@@ -465,12 +470,8 @@ int tipc_conn_sendmsg(struct tipc_server *s, int conid,
list_add_tail(&e->list, &con->outqueue); list_add_tail(&e->list, &con->outqueue);
spin_unlock_bh(&con->outqueue_lock); spin_unlock_bh(&con->outqueue_lock);
if (test_bit(CF_CONNECTED, &con->flags)) {
if (!queue_work(s->send_wq, &con->swork)) if (!queue_work(s->send_wq, &con->swork))
conn_put(con); conn_put(con);
} else {
conn_put(con);
}
return 0; return 0;
} }
...@@ -494,7 +495,7 @@ static void tipc_send_to_sock(struct tipc_conn *con) ...@@ -494,7 +495,7 @@ static void tipc_send_to_sock(struct tipc_conn *con)
int ret; int ret;
spin_lock_bh(&con->outqueue_lock); spin_lock_bh(&con->outqueue_lock);
while (1) { while (test_bit(CF_CONNECTED, &con->flags)) {
e = list_entry(con->outqueue.next, struct outqueue_entry, e = list_entry(con->outqueue.next, struct outqueue_entry,
list); list);
if ((struct list_head *) e == &con->outqueue) if ((struct list_head *) e == &con->outqueue)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment