Skip to content

Commit 6ea44ad

Browse files
NeilBrowntrondmypd
authored andcommitted
SUNRPC: ensure correct error is reported by xs_tcp_setup_socket()
If you attempt a TCP mount from an host that is unreachable in a way that triggers an immediate error from kernel_connect(), that error does not propagate up, instead EAGAIN is reported. This results in call_connect_status receiving the wrong error. A case that it easy to demonstrate is to attempt to mount from an address that results in ENETUNREACH, but first deleting any default route. Without this patch, the mount.nfs process is persistently runnable and is hard to kill. With this patch it exits as it should. The problem is caused by the fact that xs_tcp_force_close() eventually calls xprt_wake_pending_tasks(xprt, -EAGAIN); which causes an error return of -EAGAIN. so when xs_tcp_setup_sock() calls xprt_wake_pending_tasks(xprt, status); the status is ignored. Fixes: 4efdd92 ("SUNRPC: Remove TCP client connection reset hack") Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
1 parent b49c15f commit 6ea44ad

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

net/sunrpc/xprtsock.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2432,7 +2432,12 @@ static void xs_tcp_setup_socket(struct work_struct *work)
24322432
case -ENETUNREACH:
24332433
case -EADDRINUSE:
24342434
case -ENOBUFS:
2435-
/* retry with existing socket, after a delay */
2435+
/*
2436+
* xs_tcp_force_close() wakes tasks with -EIO.
2437+
* We need to wake them first to ensure the
2438+
* correct error code.
2439+
*/
2440+
xprt_wake_pending_tasks(xprt, status);
24362441
xs_tcp_force_close(xprt);
24372442
goto out;
24382443
}

0 commit comments

Comments
 (0)