Skip to contentSkip to conversation

tipc: check group dests after tipc_wait_for_cond()

PATCH In review Cong Wang 3 participants 3 messages Dec 17, 2018 – Dec 18, 2018

Subsystems (3)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH 1/1 tipc: check group dests after tipc_wait_for_cond()

Similar to commit 143ece654f9f ("tipc: check tsk->group in tipc_wait_for_cond()") we have to reload grp->dests too after we re-take the sock lock. This means we need to move the dsts check after tipc_wait_for_cond() too.

Fixes 75da2163dbb6 ("tipc: introduce communication groups")
Reported-and-tested-by [email protected]
Cc Ying Xue <[email protected]>
Cc Jon Maloy <[email protected]>
---
 net/tipc/socket.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
net/tipc/socket.c +5 -4
index 656940692a44..8f34db2a9785 100644
@@ -1009,7 +1009,7 @@ static int tipc_send_group_bcast(struct socket *sock, struct msghdr *m,
 	struct sock *sk = sock->sk;
 	struct net *net = sock_net(sk);
 	struct tipc_sock *tsk = tipc_sk(sk);
-	struct tipc_nlist *dsts = tipc_group_dests(tsk->group);
+	struct tipc_nlist *dsts;
 	struct tipc_mc_method *method = &tsk->mc_method;
 	bool ack = method->mandatory && method->rcast;
 	int blks = tsk_blocks(MCAST_H_SIZE + dlen);
@@ -1018,9 +1018,6 @@ static int tipc_send_group_bcast(struct socket *sock, struct msghdr *m,
 	struct sk_buff_head pkts;
 	int rc = -EHOSTUNREACH;
 
-	if (!dsts->local && !dsts->remote)
-		return -EHOSTUNREACH;
-
 	/* Block or return if any destination link or member is congested */
 	rc = tipc_wait_for_cond(sock, &timeout,
 				!tsk->cong_link_cnt && tsk->group &&
@@ -1028,6 +1025,10 @@ static int tipc_send_group_bcast(struct socket *sock, struct msghdr *m,
 	if (unlikely(rc))
 		return rc;
 
+	dsts = tipc_group_dests(tsk->group);
+	if (!dsts->local && !dsts->remote)
+		return -EHOSTUNREACH;
+
 	/* Complete message header */
 	if (dest) {
 		msg_set_type(hdr, TIPC_GRP_MCAST_MSG);
Signature · 1 line
2.19.2
Acked-by on v1 1/1
#1 lore raw

Thank you, Cong.

///jon

Quoted 61 lines

-----Original Message-----
From: Cong Wang <[email protected]>
Sent: 17-Dec-18 02:25
To: [email protected]
Cc: Cong Wang <[email protected]>; Ying Xue <[email protected]>; Jon Maloy <[email protected]>
Subject: [Patch net] tipc: check group dests after tipc_wait_for_cond()

Similar to commit 143ece654f9f ("tipc: check tsk->group in tipc_wait_for_cond()") we have to reload grp->dests too after we re-take the sock lock.
This means we need to move the dsts check after tipc_wait_for_cond() too.

Fixes 75da2163dbb6 ("tipc: introduce communication groups")

Reported-and-tested-by:
[email protected]

---
 net/tipc/socket.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
net/tipc/socket.c index renamed from net/tipc/socket.c +0 -0

656940692a44..8f34db2a9785 100644

net/tipc/socket.c +1 -1
@@ -1009,7 +1009,7 @@ static int tipc_send_group_bcast(struct socket
 *sock, struct msghdr *m,
 	struct sock *sk = sock->sk;
 	struct net *net = sock_net(sk);
 	struct tipc_sock *tsk = tipc_sk(sk);
-	struct tipc_nlist *dsts = tipc_group_dests(tsk->group);
+	struct tipc_nlist *dsts;
 	struct tipc_mc_method *method = &tsk->mc_method;
 	bool ack = method->mandatory && method->rcast;

int blks = tsk_blocks(MCAST_H_SIZE + dlen); @@ -1018,9 +1018,6
@@ static int tipc_send_group_bcast(struct socket *sock, struct msghdr *m,

net/tipc/socket.c +0 -3
 	struct sk_buff_head pkts;
 	int rc = -EHOSTUNREACH;
 
-	if (!dsts->local && !dsts->remote)
-		return -EHOSTUNREACH;
-
 	/* Block or return if any destination link or member is congested */
 	rc = tipc_wait_for_cond(sock, &timeout,
 				!tsk->cong_link_cnt && tsk->group && @@ -

1028,6 +1025,10 @@ static int tipc_send_group_bcast(struct socket *sock, struct msghdr *m,

net/tipc/socket.c +4 -1
 	if (unlikely(rc))
 		return rc;
 
+	dsts = tipc_group_dests(tsk->group);
+	if (!dsts->local && !dsts->remote)
+		return -EHOSTUNREACH;
+
 	/* Complete message header */
 	if (dest) {
 		msg_set_type(hdr, TIPC_GRP_MCAST_MSG);
--

2.19.2

maintainer
#2 lore raw
In reply to Cong Wang

From: Cong Wang <[email protected]>
Date: Sun, 16 Dec 2018 23:25:12 -0800

Quoted 10 lines

Similar to commit 143ece654f9f ("tipc: check tsk->group in tipc_wait_for_cond()") we have to reload grp->dests too after we re-take the sock lock. This means we need to move the dsts check after tipc_wait_for_cond() too.

Fixes 75da2163dbb6 ("tipc: introduce communication groups")
Reported-and-tested-by [email protected]
Cc Ying Xue <[email protected]>
Cc Jon Maloy <[email protected]>

Applied and queued up for -stable.