From 83732ec5146916bd49b3036b0ea7dedb7831b90e Mon Sep 17 00:00:00 2001 From: Marc Dionne Date: Thu, 2 Nov 2017 15:27:52 +0000 Subject: 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 --- fs/afs/rxrpc.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'fs/afs/rxrpc.c') 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; -- cgit v1.2.3