Skip to content

Commit aaa3425

Browse files
committed
Merge branch 'tipc-Fix-some-bugs-at-socket-layer'
Tung Nguyen says: ==================== tipc: Fix some bugs at socket layer This series fixes some bugs at socket layer. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 61183b0 + d34910e commit aaa3425

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

net/tipc/socket.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -532,20 +532,18 @@ static void __tipc_shutdown(struct socket *sock, int error)
532532
struct sock *sk = sock->sk;
533533
struct tipc_sock *tsk = tipc_sk(sk);
534534
struct net *net = sock_net(sk);
535-
long timeout = CONN_TIMEOUT_DEFAULT;
535+
long timeout = msecs_to_jiffies(CONN_TIMEOUT_DEFAULT);
536536
u32 dnode = tsk_peer_node(tsk);
537537
struct sk_buff *skb;
538538

539539
/* Avoid that hi-prio shutdown msgs bypass msgs in link wakeup queue */
540540
tipc_wait_for_cond(sock, &timeout, (!tsk->cong_link_cnt &&
541541
!tsk_conn_cong(tsk)));
542542

543-
/* Push out unsent messages or remove if pending SYN */
544-
skb = skb_peek(&sk->sk_write_queue);
545-
if (skb && !msg_is_syn(buf_msg(skb)))
546-
tipc_sk_push_backlog(tsk);
547-
else
548-
__skb_queue_purge(&sk->sk_write_queue);
543+
/* Push out delayed messages if in Nagle mode */
544+
tipc_sk_push_backlog(tsk);
545+
/* Remove pending SYN */
546+
__skb_queue_purge(&sk->sk_write_queue);
549547

550548
/* Reject all unreceived messages, except on an active connection
551549
* (which disconnects locally & sends a 'FIN+' to peer).
@@ -1248,9 +1246,14 @@ static void tipc_sk_push_backlog(struct tipc_sock *tsk)
12481246
struct sk_buff_head *txq = &tsk->sk.sk_write_queue;
12491247
struct net *net = sock_net(&tsk->sk);
12501248
u32 dnode = tsk_peer_node(tsk);
1249+
struct sk_buff *skb = skb_peek(txq);
12511250
int rc;
12521251

1253-
if (skb_queue_empty(txq) || tsk->cong_link_cnt)
1252+
if (!skb || tsk->cong_link_cnt)
1253+
return;
1254+
1255+
/* Do not send SYN again after congestion */
1256+
if (msg_is_syn(buf_msg(skb)))
12541257
return;
12551258

12561259
tsk->snt_unacked += tsk->snd_backlog;
@@ -1447,8 +1450,10 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen)
14471450
rc = tipc_msg_build(hdr, m, 0, dlen, mtu, &pkts);
14481451
if (unlikely(rc != dlen))
14491452
return rc;
1450-
if (unlikely(syn && !tipc_msg_skb_clone(&pkts, &sk->sk_write_queue)))
1453+
if (unlikely(syn && !tipc_msg_skb_clone(&pkts, &sk->sk_write_queue))) {
1454+
__skb_queue_purge(&pkts);
14511455
return -ENOMEM;
1456+
}
14521457

14531458
trace_tipc_sk_sendmsg(sk, skb_peek(&pkts), TIPC_DUMP_SK_SNDQ, " ");
14541459
rc = tipc_node_xmit(net, &pkts, dnode, tsk->portid);
@@ -2757,6 +2762,7 @@ static void tipc_sk_timeout(struct timer_list *t)
27572762
if (sock_owned_by_user(sk)) {
27582763
sk_reset_timer(sk, &sk->sk_timer, jiffies + HZ / 20);
27592764
bh_unlock_sock(sk);
2765+
sock_put(sk);
27602766
return;
27612767
}
27622768

0 commit comments

Comments
 (0)