On 09/25/2018 07:34 AM, Jon Maloy wrote:
> We refactor this function as a preparation for the coming commits in
> the same series.
>
> Signed-off-by: Jon Maloy <[email protected]>
> ---
> net/tipc/socket.c | 61
> +++++++++++++++++++++++++++++++++----------------------
> 1 file changed, 37 insertions(+), 24 deletions(-)
>
> diff --git a/net/tipc/socket.c b/net/tipc/socket.c
> index 3f03ddd..4c50cff 100644
> --- a/net/tipc/socket.c
> +++ b/net/tipc/socket.c
> @@ -2545,43 +2545,56 @@ static int tipc_shutdown(struct socket *sock, int how)
> return res;
> }
>
> +static void tipc_sk_check_probing_state(struct sock *sk,
> + struct sk_buff_head *list)
> +{
> + struct tipc_sock *tsk = tipc_sk(sk);
> + u32 pnode = tsk_peer_node(tsk);
> + u32 pport = tsk_peer_port(tsk);
> + u32 self = tsk_own_node(tsk);
> + u32 oport = tsk->portid;
> + struct sk_buff *skb;
> +
> + if (tsk->probe_unacked) {
> + tipc_set_sk_state(sk, TIPC_DISCONNECTING);
sk->sk_err = ETIMEDOUT;
Or we can select other error code, but it's better to set an error code
to sk->sk_err.
> + tipc_node_remove_conn(sock_net(sk), pnode, pport);
> + sk->sk_state_change(sk);
> + return;
> + }
> + /* Prepare new probe */
> + skb = tipc_msg_create(CONN_MANAGER, CONN_PROBE, INT_H_SIZE, 0,
> + pnode, self, pport, oport, TIPC_OK);
> + if (skb)
> + __skb_queue_tail(list, skb);
> + tsk->probe_unacked = true;
> + sk_reset_timer(sk, &sk->sk_timer, jiffies + CONN_PROBING_INTV);
> +}
> +
> static void tipc_sk_timeout(struct timer_list *t)
> {
> struct sock *sk = from_timer(sk, t, sk_timer);
> struct tipc_sock *tsk = tipc_sk(sk);
> - u32 peer_port = tsk_peer_port(tsk);
> - u32 peer_node = tsk_peer_node(tsk);
> - u32 own_node = tsk_own_node(tsk);
> - u32 own_port = tsk->portid;
> - struct net *net = sock_net(sk);
> - struct sk_buff *skb = NULL;
> + u32 pnode = tsk_peer_node(tsk);
> + struct sk_buff_head list;
>
> + skb_queue_head_init(&list);
> bh_lock_sock(sk);
> - if (!tipc_sk_connected(sk))
> - goto exit;
>
> /* Try again later if socket is busy */
> if (sock_owned_by_user(sk)) {
> sk_reset_timer(sk, &sk->sk_timer, jiffies + HZ / 20);
> - goto exit;
> + bh_unlock_sock(sk);
> + return;
> }
>
> - if (tsk->probe_unacked) {
> - tipc_set_sk_state(sk, TIPC_DISCONNECTING);
> - tipc_node_remove_conn(net, peer_node, peer_port);
> - sk->sk_state_change(sk);
> - goto exit;
> - }
> - /* Send new probe */
> - skb = tipc_msg_create(CONN_MANAGER, CONN_PROBE, INT_H_SIZE, 0,
> - peer_node, own_node, peer_port, own_port,
> - TIPC_OK);
> - tsk->probe_unacked = true;
> - sk_reset_timer(sk, &sk->sk_timer, jiffies + CONN_PROBING_INTV);
> -exit:
> + if (sk->sk_state == TIPC_ESTABLISHED)
s/sk->sk_state == TIPC_ESTABLISHED/tipc_sk_connected(sk)
> + tipc_sk_check_probing_state(sk, &list);
> +
> bh_unlock_sock(sk);
> - if (skb)
> - tipc_node_xmit_skb(net, skb, peer_node, own_port);
> +
> + if (!skb_queue_empty(&list))
> + tipc_node_xmit(sock_net(sk), &list, pnode, tsk->portid);
> +
> sock_put(sk);
> }
>
>
_______________________________________________
tipc-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tipc-discussion