aboutsummaryrefslogtreecommitdiffstats
path: root/net/9p
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-04-18 17:45:30 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-18 17:45:30 -0400
commitdba94f2155f581395ef9608418778e3491b3d470 (patch)
tree71b034aa2f6bafd5bb7ffcefe68c89cef6bbfc6d /net/9p
parent34a984f7b0cc6355a1e0c184251d0d4cc86f44d2 (diff)
parentf569d3ef8254d4b3b8daa4f131f9397d48bf296c (diff)
Merge tag 'for-linus-4.1-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/ericvh/v9fs
Pull 9pfs updates from Eric Van Hensbergen: "Some accumulated cleanup patches for kerneldoc and unused variables as well as some lock bug fixes and adding privateport option for RDMA" * tag 'for-linus-4.1-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/ericvh/v9fs: net/9p: add a privport option for RDMA transport. fs/9p: Initialize status in v9fs_file_do_lock. net/9p: Initialize opts->privport as it should be. net/9p: use memcpy() instead of snprintf() in p9_mount_tag_show() 9p: use unsigned integers for nwqid/count 9p: do not crash on unknown lock status code 9p: fix error handling in v9fs_file_do_lock 9p: remove unused variable in p9_fd_create() 9p: kerneldoc warning fixes
Diffstat (limited to 'net/9p')
-rw-r--r--net/9p/protocol.c6
-rw-r--r--net/9p/trans_fd.c3
-rw-r--r--net/9p/trans_rdma.c52
-rw-r--r--net/9p/trans_virtio.c5
4 files changed, 52 insertions, 14 deletions
diff --git a/net/9p/protocol.c b/net/9p/protocol.c
index e9d0f0c1a048..16d287565987 100644
--- a/net/9p/protocol.c
+++ b/net/9p/protocol.c
@@ -275,7 +275,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt,
275 } 275 }
276 break; 276 break;
277 case 'R':{ 277 case 'R':{
278 int16_t *nwqid = va_arg(ap, int16_t *); 278 uint16_t *nwqid = va_arg(ap, uint16_t *);
279 struct p9_qid **wqids = 279 struct p9_qid **wqids =
280 va_arg(ap, struct p9_qid **); 280 va_arg(ap, struct p9_qid **);
281 281
@@ -440,7 +440,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
440 stbuf->n_gid, stbuf->n_muid); 440 stbuf->n_gid, stbuf->n_muid);
441 } break; 441 } break;
442 case 'V':{ 442 case 'V':{
443 int32_t count = va_arg(ap, int32_t); 443 uint32_t count = va_arg(ap, uint32_t);
444 struct iov_iter *from = 444 struct iov_iter *from =
445 va_arg(ap, struct iov_iter *); 445 va_arg(ap, struct iov_iter *);
446 errcode = p9pdu_writef(pdu, proto_version, "d", 446 errcode = p9pdu_writef(pdu, proto_version, "d",
@@ -471,7 +471,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
471 } 471 }
472 break; 472 break;
473 case 'R':{ 473 case 'R':{
474 int16_t nwqid = va_arg(ap, int); 474 uint16_t nwqid = va_arg(ap, int);
475 struct p9_qid *wqids = 475 struct p9_qid *wqids =
476 va_arg(ap, struct p9_qid *); 476 va_arg(ap, struct p9_qid *);
477 477
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index 3e3d82d8ff70..bced8c074c12 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -734,6 +734,7 @@ static int parse_opts(char *params, struct p9_fd_opts *opts)
734 opts->port = P9_PORT; 734 opts->port = P9_PORT;
735 opts->rfd = ~0; 735 opts->rfd = ~0;
736 opts->wfd = ~0; 736 opts->wfd = ~0;
737 opts->privport = 0;
737 738
738 if (!params) 739 if (!params)
739 return 0; 740 return 0;
@@ -1013,7 +1014,6 @@ p9_fd_create(struct p9_client *client, const char *addr, char *args)
1013{ 1014{
1014 int err; 1015 int err;
1015 struct p9_fd_opts opts; 1016 struct p9_fd_opts opts;
1016 struct p9_trans_fd *p;
1017 1017
1018 parse_opts(args, &opts); 1018 parse_opts(args, &opts);
1019 1019
@@ -1026,7 +1026,6 @@ p9_fd_create(struct p9_client *client, const char *addr, char *args)
1026 if (err < 0) 1026 if (err < 0)
1027 return err; 1027 return err;
1028 1028
1029 p = (struct p9_trans_fd *) client->trans;
1030 p9_conn_create(client); 1029 p9_conn_create(client);
1031 1030
1032 return 0; 1031 return 0;
diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c
index 14ad43b5cf89..3533d2a53ab6 100644
--- a/net/9p/trans_rdma.c
+++ b/net/9p/trans_rdma.c
@@ -139,6 +139,7 @@ struct p9_rdma_opts {
139 int sq_depth; 139 int sq_depth;
140 int rq_depth; 140 int rq_depth;
141 long timeout; 141 long timeout;
142 int privport;
142}; 143};
143 144
144/* 145/*
@@ -146,7 +147,10 @@ struct p9_rdma_opts {
146 */ 147 */
147enum { 148enum {
148 /* Options that take integer arguments */ 149 /* Options that take integer arguments */
149 Opt_port, Opt_rq_depth, Opt_sq_depth, Opt_timeout, Opt_err, 150 Opt_port, Opt_rq_depth, Opt_sq_depth, Opt_timeout,
151 /* Options that take no argument */
152 Opt_privport,
153 Opt_err,
150}; 154};
151 155
152static match_table_t tokens = { 156static match_table_t tokens = {
@@ -154,6 +158,7 @@ static match_table_t tokens = {
154 {Opt_sq_depth, "sq=%u"}, 158 {Opt_sq_depth, "sq=%u"},
155 {Opt_rq_depth, "rq=%u"}, 159 {Opt_rq_depth, "rq=%u"},
156 {Opt_timeout, "timeout=%u"}, 160 {Opt_timeout, "timeout=%u"},
161 {Opt_privport, "privport"},
157 {Opt_err, NULL}, 162 {Opt_err, NULL},
158}; 163};
159 164
@@ -175,6 +180,7 @@ static int parse_opts(char *params, struct p9_rdma_opts *opts)
175 opts->sq_depth = P9_RDMA_SQ_DEPTH; 180 opts->sq_depth = P9_RDMA_SQ_DEPTH;
176 opts->rq_depth = P9_RDMA_RQ_DEPTH; 181 opts->rq_depth = P9_RDMA_RQ_DEPTH;
177 opts->timeout = P9_RDMA_TIMEOUT; 182 opts->timeout = P9_RDMA_TIMEOUT;
183 opts->privport = 0;
178 184
179 if (!params) 185 if (!params)
180 return 0; 186 return 0;
@@ -193,13 +199,13 @@ static int parse_opts(char *params, struct p9_rdma_opts *opts)
193 if (!*p) 199 if (!*p)
194 continue; 200 continue;
195 token = match_token(p, tokens, args); 201 token = match_token(p, tokens, args);
196 if (token == Opt_err) 202 if ((token != Opt_err) && (token != Opt_privport)) {
197 continue; 203 r = match_int(&args[0], &option);
198 r = match_int(&args[0], &option); 204 if (r < 0) {
199 if (r < 0) { 205 p9_debug(P9_DEBUG_ERROR,
200 p9_debug(P9_DEBUG_ERROR, 206 "integer field, but no integer?\n");
201 "integer field, but no integer?\n"); 207 continue;
202 continue; 208 }
203 } 209 }
204 switch (token) { 210 switch (token) {
205 case Opt_port: 211 case Opt_port:
@@ -214,6 +220,9 @@ static int parse_opts(char *params, struct p9_rdma_opts *opts)
214 case Opt_timeout: 220 case Opt_timeout:
215 opts->timeout = option; 221 opts->timeout = option;
216 break; 222 break;
223 case Opt_privport:
224 opts->privport = 1;
225 break;
217 default: 226 default:
218 continue; 227 continue;
219 } 228 }
@@ -607,6 +616,23 @@ static int rdma_cancelled(struct p9_client *client, struct p9_req_t *req)
607 return 0; 616 return 0;
608} 617}
609 618
619static int p9_rdma_bind_privport(struct p9_trans_rdma *rdma)
620{
621 struct sockaddr_in cl = {
622 .sin_family = AF_INET,
623 .sin_addr.s_addr = htonl(INADDR_ANY),
624 };
625 int port, err = -EINVAL;
626
627 for (port = P9_DEF_MAX_RESVPORT; port >= P9_DEF_MIN_RESVPORT; port--) {
628 cl.sin_port = htons((ushort)port);
629 err = rdma_bind_addr(rdma->cm_id, (struct sockaddr *)&cl);
630 if (err != -EADDRINUSE)
631 break;
632 }
633 return err;
634}
635
610/** 636/**
611 * trans_create_rdma - Transport method for creating atransport instance 637 * trans_create_rdma - Transport method for creating atransport instance
612 * @client: client instance 638 * @client: client instance
@@ -642,6 +668,16 @@ rdma_create_trans(struct p9_client *client, const char *addr, char *args)
642 /* Associate the client with the transport */ 668 /* Associate the client with the transport */
643 client->trans = rdma; 669 client->trans = rdma;
644 670
671 /* Bind to a privileged port if we need to */
672 if (opts.privport) {
673 err = p9_rdma_bind_privport(rdma);
674 if (err < 0) {
675 pr_err("%s (%d): problem binding to privport: %d\n",
676 __func__, task_pid_nr(current), -err);
677 goto error;
678 }
679 }
680
645 /* Resolve the server's address */ 681 /* Resolve the server's address */
646 rdma->addr.sin_family = AF_INET; 682 rdma->addr.sin_family = AF_INET;
647 rdma->addr.sin_addr.s_addr = in_aton(addr); 683 rdma->addr.sin_addr.s_addr = in_aton(addr);
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index e62bcbbabb5e..9dd49ca67dbc 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -525,7 +525,10 @@ static ssize_t p9_mount_tag_show(struct device *dev,
525 vdev = dev_to_virtio(dev); 525 vdev = dev_to_virtio(dev);
526 chan = vdev->priv; 526 chan = vdev->priv;
527 527
528 return snprintf(buf, chan->tag_len + 1, "%s", chan->tag); 528 memcpy(buf, chan->tag, chan->tag_len);
529 buf[chan->tag_len] = 0;
530
531 return chan->tag_len + 1;
529} 532}
530 533
531static DEVICE_ATTR(mount_tag, 0444, p9_mount_tag_show, NULL); 534static DEVICE_ATTR(mount_tag, 0444, p9_mount_tag_show, NULL);