Skip to content

Commit efce2d0

Browse files
author
Trond Myklebust
committed
SUNRPC: Ensure timely close of disconnected AF_LOCAL sockets
When the rpcbind server closes the socket, we need to ensure that the socket is closed by the kernel as soon as feasible, so add a sk_state_change callback to trigger this close. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent aad41a7 commit efce2d0

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

net/sunrpc/xprtsock.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,26 @@ static size_t xs_tcp_bc_maxpayload(struct rpc_xprt *xprt)
14181418
}
14191419
#endif /* CONFIG_SUNRPC_BACKCHANNEL */
14201420

1421+
/**
1422+
* xs_local_state_change - callback to handle AF_LOCAL socket state changes
1423+
* @sk: socket whose state has changed
1424+
*
1425+
*/
1426+
static void xs_local_state_change(struct sock *sk)
1427+
{
1428+
struct rpc_xprt *xprt;
1429+
struct sock_xprt *transport;
1430+
1431+
if (!(xprt = xprt_from_sock(sk)))
1432+
return;
1433+
transport = container_of(xprt, struct sock_xprt, xprt);
1434+
if (sk->sk_shutdown & SHUTDOWN_MASK) {
1435+
clear_bit(XPRT_CONNECTED, &xprt->state);
1436+
/* Trigger the socket release */
1437+
xs_run_error_worker(transport, XPRT_SOCK_WAKE_DISCONNECT);
1438+
}
1439+
}
1440+
14211441
/**
14221442
* xs_tcp_state_change - callback to handle TCP socket state changes
14231443
* @sk: socket whose state has changed
@@ -1866,6 +1886,7 @@ static int xs_local_finish_connecting(struct rpc_xprt *xprt,
18661886
sk->sk_user_data = xprt;
18671887
sk->sk_data_ready = xs_data_ready;
18681888
sk->sk_write_space = xs_udp_write_space;
1889+
sk->sk_state_change = xs_local_state_change;
18691890
sk->sk_error_report = xs_error_report;
18701891

18711892
xprt_clear_connected(xprt);

0 commit comments

Comments
 (0)