From: asmadeus@codewreck.org
To: Joshua Murphy <joshuamurphy@posteo.net>,
Daniel Verkamp <dverkamp@chromium.org>
Cc: ericvh@kernel.org, lucho@ionkov.net, linux_oss@crudebyte.com,
v9fs@lists.linux.dev
Subject: Re: [PATCH] net/9p/fd: change port to char *
Date: Sat, 25 Jan 2025 12:00:03 +0900 [thread overview]
Message-ID: <Z5RTs5XANcDxvZT0@codewreck.org> (raw)
In-Reply-To: <CABVzXAnHmyXtsNPHrYDCubifhrGdDyy_W7=mX_FQ58Pwt1swFA@mail.gmail.com> <20250124211432.5698-3-joshuamurphy@posteo.net>
Joshua Murphy wrote on Fri, Jan 24, 2025 at 09:14:34PM +0000:
> 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))
Daniel pointed out at the inverted check (thank you for these reviews!),
but it also needs a null check, because fd/fd_unix variants will not be
setting this field so the strcmp will crash with trans=fd or trans=unix
> + 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;
This is a substring from tmp_options that will be freed when parsinig is
finished, so we'll need to kstrdup() it here, which means we'll need to
free it when we're done with options... So, err, at the end of
p9_fd_create which doesn't copy it to the client, and in p9_fd_close for
tcp success (stored in client), and in p9_fd_create_tcp on error
(fd_close not called), and I _think_ that's about it...
I didn't quite estimate the clean up path would be this messy, this
"simple cleanup" is ending up being more complicated than the originial
version so I'm thinking we're better off keeping the int -- what do you
think?
--
Dominique Martinet | Asmadeus
next prev parent reply other threads:[~2025-01-25 3:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2025-01-25 17:48 ` Joshua Murphy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z5RTs5XANcDxvZT0@codewreck.org \
--to=asmadeus@codewreck.org \
--cc=dverkamp@chromium.org \
--cc=ericvh@kernel.org \
--cc=joshuamurphy@posteo.net \
--cc=linux_oss@crudebyte.com \
--cc=lucho@ionkov.net \
--cc=v9fs@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox