[RFC PATCH v2 7/7] sunrpc: Connect to a new IP address provided by the user

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Anna Schumaker <Anna.Schumaker@xxxxxxxxxx>

We preserve the same port number, rather than providing a way to change
it. This keeps the implementation simpler for now.

Signed-off-by: Anna Schumaker <Anna.Schumaker@xxxxxxxxxx>
---
v2: Whoops, I forgot to commit the actual connection code to this patch!
---
 net/sunrpc/sysfs.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c
index 537d83635670..5bf8d293ab7c 100644
--- a/net/sunrpc/sysfs.c
+++ b/net/sunrpc/sysfs.c
@@ -4,6 +4,7 @@
  */
 #include <linux/sunrpc/clnt.h>
 #include <linux/sunrpc/addr.h>
+#include <linux/sunrpc/xprtsock.h>
 #include <net/sock.h>
 #include "sysfs.h"
 
@@ -70,6 +71,20 @@ static ssize_t rpc_netns_address_show(struct kobject *kobj,
 static ssize_t rpc_netns_address_store(struct kobject *kobj,
 		struct kobj_attribute *attr, const char *buf, size_t count)
 {
+	struct rpc_netns_client *c = container_of(kobj,
+				struct rpc_netns_client, kobject);
+	struct rpc_clnt *clnt = c->clnt;
+	struct rpc_xprt *xprt = rcu_dereference(clnt->cl_xprt);
+	struct sockaddr *saddr = (struct sockaddr *)&xprt->addr;
+	int port = rpc_get_port(saddr);
+
+	xprt->addrlen = rpc_pton(xprt->xprt_net, buf, count - 1, saddr, sizeof(*saddr));
+	rpc_set_port(saddr, port);
+
+	kfree(xprt->address_strings[RPC_DISPLAY_ADDR]);
+	xprt->address_strings[RPC_DISPLAY_ADDR] = kstrndup(buf, count - 1, GFP_KERNEL);
+
+	xprt->ops->connect(xprt, NULL);
 	return count;
 }
 
-- 
2.29.2




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux