afs: Use a dynamic port if 7001 is in use
authorMarc Dionne <marc.dionne@auristor.com>
Thu, 2 Nov 2017 15:27:52 +0000 (15:27 +0000)
committerDavid Howells <dhowells@redhat.com>
Mon, 13 Nov 2017 15:38:20 +0000 (15:38 +0000)
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 <marc.dionne@auristor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
fs/afs/rxrpc.c

index 06a51d7..bd44ae8 100644 (file)
@@ -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;