From: Marc Dionne Date: Thu, 2 Nov 2017 15:27:52 +0000 (+0000) Subject: afs: Use a dynamic port if 7001 is in use X-Git-Tag: v4.15-rc1~84^2~5 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=83732ec5146916bd49b3036b0ea7dedb7831b90e;p=linux-block.git afs: Use a dynamic port if 7001 is in use It is not required that the afs client operate on port 7001. The port could be in use because another kernel or userspace client has already bound to it. If the port is in use, just fallback to using a dynamic port. Signed-off-by: Marc Dionne Signed-off-by: David Howells --- diff --git a/fs/afs/rxrpc.c b/fs/afs/rxrpc.c index 06a51d70b82b..bd44ae8b63d8 100644 --- a/fs/afs/rxrpc.c +++ b/fs/afs/rxrpc.c @@ -61,6 +61,10 @@ int afs_open_socket(struct afs_net *net) srx.transport.sin6.sin6_port = htons(AFS_CM_PORT); ret = kernel_bind(socket, (struct sockaddr *) &srx, sizeof(srx)); + if (ret == -EADDRINUSE) { + srx.transport.sin6.sin6_port = 0; + ret = kernel_bind(socket, (struct sockaddr *) &srx, sizeof(srx)); + } if (ret < 0) goto error_2;