Skip to content

Commit afe8792

Browse files
Jon Maloydavem330
authored andcommitted
tipc: refactor function tipc_sk_timeout()
We refactor this function as a preparation for the coming commits in the same series. Acked-by: Ying Xue <[email protected]> Signed-off-by: Jon Maloy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5cbdbd1 commit afe8792

File tree

1 file changed

+38
-24
lines changed

1 file changed

+38
-24
lines changed

net/tipc/socket.c

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2545,43 +2545,57 @@ static int tipc_shutdown(struct socket *sock, int how)
25452545
return res;
25462546
}
25472547

2548+
static void tipc_sk_check_probing_state(struct sock *sk,
2549+
struct sk_buff_head *list)
2550+
{
2551+
struct tipc_sock *tsk = tipc_sk(sk);
2552+
u32 pnode = tsk_peer_node(tsk);
2553+
u32 pport = tsk_peer_port(tsk);
2554+
u32 self = tsk_own_node(tsk);
2555+
u32 oport = tsk->portid;
2556+
struct sk_buff *skb;
2557+
2558+
if (tsk->probe_unacked) {
2559+
tipc_set_sk_state(sk, TIPC_DISCONNECTING);
2560+
sk->sk_err = ECONNABORTED;
2561+
tipc_node_remove_conn(sock_net(sk), pnode, pport);
2562+
sk->sk_state_change(sk);
2563+
return;
2564+
}
2565+
/* Prepare new probe */
2566+
skb = tipc_msg_create(CONN_MANAGER, CONN_PROBE, INT_H_SIZE, 0,
2567+
pnode, self, pport, oport, TIPC_OK);
2568+
if (skb)
2569+
__skb_queue_tail(list, skb);
2570+
tsk->probe_unacked = true;
2571+
sk_reset_timer(sk, &sk->sk_timer, jiffies + CONN_PROBING_INTV);
2572+
}
2573+
25482574
static void tipc_sk_timeout(struct timer_list *t)
25492575
{
25502576
struct sock *sk = from_timer(sk, t, sk_timer);
25512577
struct tipc_sock *tsk = tipc_sk(sk);
2552-
u32 peer_port = tsk_peer_port(tsk);
2553-
u32 peer_node = tsk_peer_node(tsk);
2554-
u32 own_node = tsk_own_node(tsk);
2555-
u32 own_port = tsk->portid;
2556-
struct net *net = sock_net(sk);
2557-
struct sk_buff *skb = NULL;
2578+
u32 pnode = tsk_peer_node(tsk);
2579+
struct sk_buff_head list;
25582580

2581+
skb_queue_head_init(&list);
25592582
bh_lock_sock(sk);
2560-
if (!tipc_sk_connected(sk))
2561-
goto exit;
25622583

25632584
/* Try again later if socket is busy */
25642585
if (sock_owned_by_user(sk)) {
25652586
sk_reset_timer(sk, &sk->sk_timer, jiffies + HZ / 20);
2566-
goto exit;
2587+
bh_unlock_sock(sk);
2588+
return;
25672589
}
25682590

2569-
if (tsk->probe_unacked) {
2570-
tipc_set_sk_state(sk, TIPC_DISCONNECTING);
2571-
tipc_node_remove_conn(net, peer_node, peer_port);
2572-
sk->sk_state_change(sk);
2573-
goto exit;
2574-
}
2575-
/* Send new probe */
2576-
skb = tipc_msg_create(CONN_MANAGER, CONN_PROBE, INT_H_SIZE, 0,
2577-
peer_node, own_node, peer_port, own_port,
2578-
TIPC_OK);
2579-
tsk->probe_unacked = true;
2580-
sk_reset_timer(sk, &sk->sk_timer, jiffies + CONN_PROBING_INTV);
2581-
exit:
2591+
if (sk->sk_state == TIPC_ESTABLISHED)
2592+
tipc_sk_check_probing_state(sk, &list);
2593+
25822594
bh_unlock_sock(sk);
2583-
if (skb)
2584-
tipc_node_xmit_skb(net, skb, peer_node, own_port);
2595+
2596+
if (!skb_queue_empty(&list))
2597+
tipc_node_xmit(sock_net(sk), &list, pnode, tsk->portid);
2598+
25852599
sock_put(sk);
25862600
}
25872601

0 commit comments

Comments
 (0)