瀏覽代碼

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 <marc.dionne@auristor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Marc Dionne 7 年之前
父節點
當前提交
83732ec514
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      fs/afs/rxrpc.c

+ 4 - 0
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);
 	srx.transport.sin6.sin6_port	= htons(AFS_CM_PORT);
 
 
 	ret = kernel_bind(socket, (struct sockaddr *) &srx, sizeof(srx));
 	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)
 	if (ret < 0)
 		goto error_2;
 		goto error_2;