public inbox for v9fs@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] net/9p/fd: change port to char *
@ 2025-01-24 21:14 Joshua Murphy
  2025-01-24 23:12 ` Daniel Verkamp
  2025-01-25  3:00 ` asmadeus
  0 siblings, 2 replies; 4+ messages in thread
From: Joshua Murphy @ 2025-01-24 21:14 UTC (permalink / raw)
  To: ericvh, lucho, asmadeus, linux_oss; +Cc: v9fs, Joshua Murphy

The port variable in the option structs is changed to char * to
remove the conversions from u16 to char *.

Signed-off-by: Joshua Murphy <joshuamurphy@posteo.net>
---
 include/net/9p/client.h |  2 +-
 net/9p/trans_fd.c       | 14 ++++++--------
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/include/net/9p/client.h b/include/net/9p/client.h
index 4f785098c..62be2073e 100644
--- a/include/net/9p/client.h
+++ b/include/net/9p/client.h
@@ -114,7 +114,7 @@ struct p9_client {
 			int wfd;
 		} fd;
 		struct {
-			u16 port;
+			char *port;
 			bool privport;
 
 		} tcp;
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index 2fea50bf0..2874c7348 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -31,7 +31,7 @@
 
 #include <linux/syscalls.h> /* killme */
 
-#define P9_PORT 564
+#define P9_PORT "564"
 #define MAX_SOCK_BUF (1024*1024)
 #define MAXPOLLWADDR	2
 
@@ -49,7 +49,7 @@ static struct p9_trans_module p9_fd_trans;
 struct p9_fd_opts {
 	int rfd;
 	int wfd;
-	u16 port;
+	char *port;
 	bool privport;
 };
 
@@ -746,8 +746,8 @@ static int p9_fd_cancelled(struct p9_client *client, struct p9_req_t *req)
 static int p9_fd_show_options(struct seq_file *m, struct p9_client *clnt)
 {
 	if (clnt->trans_mod == &p9_tcp_trans) {
-		if (clnt->trans_opts.tcp.port != P9_PORT)
-			seq_printf(m, ",port=%u", clnt->trans_opts.tcp.port);
+		if (!strcmp(clnt->trans_opts.tcp.port, P9_PORT))
+			seq_printf(m, ",port=%s", clnt->trans_opts.tcp.port);
 	} else if (clnt->trans_mod == &p9_fd_trans) {
 		if (clnt->trans_opts.fd.rfd != ~0)
 			seq_printf(m, ",rfd=%u", clnt->trans_opts.fd.rfd);
@@ -804,7 +804,7 @@ static int parse_opts(char *params, struct p9_fd_opts *opts)
 		}
 		switch (token) {
 		case Opt_port:
-			opts->port = option;
+			opts->port = args[0].from;
 			break;
 		case Opt_rfdno:
 			opts->rfd = option;
@@ -981,7 +981,6 @@ static int
 p9_fd_create_tcp(struct p9_client *client, const char *addr, char *args)
 {
 	int err;
-	char port_str[6];
 	struct socket *csocket;
 	struct sockaddr_storage stor = { 0 };
 	struct p9_fd_opts opts;
@@ -993,9 +992,8 @@ p9_fd_create_tcp(struct p9_client *client, const char *addr, char *args)
 	if (!addr)
 		return -EINVAL;
 
-	sprintf(port_str, "%u", opts.port);
 	err = inet_pton_with_scope(current->nsproxy->net_ns, AF_UNSPEC, addr,
-				   port_str, &stor);
+				   opts.port, &stor);
 	if (err < 0)
 		return err;
 
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-01-25 17:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-24 21:14 [PATCH] net/9p/fd: change port to char * Joshua Murphy
2025-01-24 23:12 ` Daniel Verkamp
2025-01-25  3:00 ` asmadeus
2025-01-25 17:48   ` Joshua Murphy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox