diff options
Diffstat (limited to 'net')
62 files changed, 1874 insertions, 1637 deletions
diff --git a/net/9p/Makefile b/net/9p/Makefile index d3abb246ccab..8a1051101898 100644 --- a/net/9p/Makefile +++ b/net/9p/Makefile | |||
@@ -4,7 +4,6 @@ obj-$(CONFIG_NET_9P_VIRTIO) += 9pnet_virtio.o | |||
4 | 4 | ||
5 | 9pnet-objs := \ | 5 | 9pnet-objs := \ |
6 | mod.o \ | 6 | mod.o \ |
7 | mux.o \ | ||
8 | client.o \ | 7 | client.o \ |
9 | conv.o \ | 8 | conv.o \ |
10 | error.o \ | 9 | error.o \ |
diff --git a/net/9p/client.c b/net/9p/client.c index af9199364049..84e087e24146 100644 --- a/net/9p/client.c +++ b/net/9p/client.c | |||
@@ -3,6 +3,7 @@ | |||
3 | * | 3 | * |
4 | * 9P Client | 4 | * 9P Client |
5 | * | 5 | * |
6 | * Copyright (C) 2008 by Eric Van Hensbergen <ericvh@gmail.com> | ||
6 | * Copyright (C) 2007 by Latchesar Ionkov <lucho@ionkov.net> | 7 | * Copyright (C) 2007 by Latchesar Ionkov <lucho@ionkov.net> |
7 | * | 8 | * |
8 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
@@ -25,6 +26,7 @@ | |||
25 | #include <linux/module.h> | 26 | #include <linux/module.h> |
26 | #include <linux/errno.h> | 27 | #include <linux/errno.h> |
27 | #include <linux/fs.h> | 28 | #include <linux/fs.h> |
29 | #include <linux/poll.h> | ||
28 | #include <linux/idr.h> | 30 | #include <linux/idr.h> |
29 | #include <linux/mutex.h> | 31 | #include <linux/mutex.h> |
30 | #include <linux/sched.h> | 32 | #include <linux/sched.h> |
@@ -32,15 +34,97 @@ | |||
32 | #include <net/9p/9p.h> | 34 | #include <net/9p/9p.h> |
33 | #include <linux/parser.h> | 35 | #include <linux/parser.h> |
34 | #include <net/9p/transport.h> | 36 | #include <net/9p/transport.h> |
35 | #include <net/9p/conn.h> | ||
36 | #include <net/9p/client.h> | 37 | #include <net/9p/client.h> |
37 | 38 | ||
38 | static struct p9_fid *p9_fid_create(struct p9_client *clnt); | 39 | static struct p9_fid *p9_fid_create(struct p9_client *clnt); |
39 | static void p9_fid_destroy(struct p9_fid *fid); | 40 | static void p9_fid_destroy(struct p9_fid *fid); |
40 | static struct p9_stat *p9_clone_stat(struct p9_stat *st, int dotu); | 41 | static struct p9_stat *p9_clone_stat(struct p9_stat *st, int dotu); |
41 | 42 | ||
42 | struct p9_client *p9_client_create(struct p9_trans *trans, int msize, | 43 | /* |
43 | int dotu) | 44 | * Client Option Parsing (code inspired by NFS code) |
45 | * - a little lazy - parse all client options | ||
46 | */ | ||
47 | |||
48 | enum { | ||
49 | Opt_msize, | ||
50 | Opt_trans, | ||
51 | Opt_legacy, | ||
52 | Opt_err, | ||
53 | }; | ||
54 | |||
55 | static match_table_t tokens = { | ||
56 | {Opt_msize, "msize=%u"}, | ||
57 | {Opt_legacy, "noextend"}, | ||
58 | {Opt_trans, "trans=%s"}, | ||
59 | {Opt_err, NULL}, | ||
60 | }; | ||
61 | |||
62 | /** | ||
63 | * v9fs_parse_options - parse mount options into session structure | ||
64 | * @options: options string passed from mount | ||
65 | * @v9ses: existing v9fs session information | ||
66 | * | ||
67 | */ | ||
68 | |||
69 | static void parse_opts(char *options, struct p9_client *clnt) | ||
70 | { | ||
71 | char *p; | ||
72 | substring_t args[MAX_OPT_ARGS]; | ||
73 | int option; | ||
74 | int ret; | ||
75 | |||
76 | clnt->trans_mod = v9fs_default_trans(); | ||
77 | clnt->dotu = 1; | ||
78 | clnt->msize = 8192; | ||
79 | |||
80 | if (!options) | ||
81 | return; | ||
82 | |||
83 | while ((p = strsep(&options, ",")) != NULL) { | ||
84 | int token; | ||
85 | if (!*p) | ||
86 | continue; | ||
87 | token = match_token(p, tokens, args); | ||
88 | if (token < Opt_trans) { | ||
89 | ret = match_int(&args[0], &option); | ||
90 | if (ret < 0) { | ||
91 | P9_DPRINTK(P9_DEBUG_ERROR, | ||
92 | "integer field, but no integer?\n"); | ||
93 | continue; | ||
94 | } | ||
95 | } | ||
96 | switch (token) { | ||
97 | case Opt_msize: | ||
98 | clnt->msize = option; | ||
99 | break; | ||
100 | case Opt_trans: | ||
101 | clnt->trans_mod = v9fs_match_trans(&args[0]); | ||
102 | break; | ||
103 | case Opt_legacy: | ||
104 | clnt->dotu = 0; | ||
105 | break; | ||
106 | default: | ||
107 | continue; | ||
108 | } | ||
109 | } | ||
110 | } | ||
111 | |||
112 | |||
113 | /** | ||
114 | * p9_client_rpc - sends 9P request and waits until a response is available. | ||
115 | * The function can be interrupted. | ||
116 | * @c: client data | ||
117 | * @tc: request to be sent | ||
118 | * @rc: pointer where a pointer to the response is stored | ||
119 | */ | ||
120 | int | ||
121 | p9_client_rpc(struct p9_client *c, struct p9_fcall *tc, | ||
122 | struct p9_fcall **rc) | ||
123 | { | ||
124 | return c->trans->rpc(c->trans, tc, rc); | ||
125 | } | ||
126 | |||
127 | struct p9_client *p9_client_create(const char *dev_name, char *options) | ||
44 | { | 128 | { |
45 | int err, n; | 129 | int err, n; |
46 | struct p9_client *clnt; | 130 | struct p9_client *clnt; |
@@ -54,12 +138,7 @@ struct p9_client *p9_client_create(struct p9_trans *trans, int msize, | |||
54 | if (!clnt) | 138 | if (!clnt) |
55 | return ERR_PTR(-ENOMEM); | 139 | return ERR_PTR(-ENOMEM); |
56 | 140 | ||
57 | P9_DPRINTK(P9_DEBUG_9P, "clnt %p trans %p msize %d dotu %d\n", | ||
58 | clnt, trans, msize, dotu); | ||
59 | spin_lock_init(&clnt->lock); | 141 | spin_lock_init(&clnt->lock); |
60 | clnt->trans = trans; | ||
61 | clnt->msize = msize; | ||
62 | clnt->dotu = dotu; | ||
63 | INIT_LIST_HEAD(&clnt->fidlist); | 142 | INIT_LIST_HEAD(&clnt->fidlist); |
64 | clnt->fidpool = p9_idpool_create(); | 143 | clnt->fidpool = p9_idpool_create(); |
65 | if (!clnt->fidpool) { | 144 | if (!clnt->fidpool) { |
@@ -68,13 +147,29 @@ struct p9_client *p9_client_create(struct p9_trans *trans, int msize, | |||
68 | goto error; | 147 | goto error; |
69 | } | 148 | } |
70 | 149 | ||
71 | clnt->conn = p9_conn_create(clnt->trans, clnt->msize, &clnt->dotu); | 150 | parse_opts(options, clnt); |
72 | if (IS_ERR(clnt->conn)) { | 151 | if (clnt->trans_mod == NULL) { |
73 | err = PTR_ERR(clnt->conn); | 152 | err = -EPROTONOSUPPORT; |
74 | clnt->conn = NULL; | 153 | P9_DPRINTK(P9_DEBUG_ERROR, |
154 | "No transport defined or default transport\n"); | ||
75 | goto error; | 155 | goto error; |
76 | } | 156 | } |
77 | 157 | ||
158 | P9_DPRINTK(P9_DEBUG_9P, "clnt %p trans %p msize %d dotu %d\n", | ||
159 | clnt, clnt->trans_mod, clnt->msize, clnt->dotu); | ||
160 | |||
161 | |||
162 | clnt->trans = clnt->trans_mod->create(dev_name, options, clnt->msize, | ||
163 | clnt->dotu); | ||
164 | if (IS_ERR(clnt->trans)) { | ||
165 | err = PTR_ERR(clnt->trans); | ||
166 | clnt->trans = NULL; | ||
167 | goto error; | ||
168 | } | ||
169 | |||
170 | if ((clnt->msize+P9_IOHDRSZ) > clnt->trans_mod->maxsize) | ||
171 | clnt->msize = clnt->trans_mod->maxsize-P9_IOHDRSZ; | ||
172 | |||
78 | tc = p9_create_tversion(clnt->msize, clnt->dotu?"9P2000.u":"9P2000"); | 173 | tc = p9_create_tversion(clnt->msize, clnt->dotu?"9P2000.u":"9P2000"); |
79 | if (IS_ERR(tc)) { | 174 | if (IS_ERR(tc)) { |
80 | err = PTR_ERR(tc); | 175 | err = PTR_ERR(tc); |
@@ -82,7 +177,7 @@ struct p9_client *p9_client_create(struct p9_trans *trans, int msize, | |||
82 | goto error; | 177 | goto error; |
83 | } | 178 | } |
84 | 179 | ||
85 | err = p9_conn_rpc(clnt->conn, tc, &rc); | 180 | err = p9_client_rpc(clnt, tc, &rc); |
86 | if (err) | 181 | if (err) |
87 | goto error; | 182 | goto error; |
88 | 183 | ||
@@ -117,10 +212,6 @@ void p9_client_destroy(struct p9_client *clnt) | |||
117 | struct p9_fid *fid, *fidptr; | 212 | struct p9_fid *fid, *fidptr; |
118 | 213 | ||
119 | P9_DPRINTK(P9_DEBUG_9P, "clnt %p\n", clnt); | 214 | P9_DPRINTK(P9_DEBUG_9P, "clnt %p\n", clnt); |
120 | if (clnt->conn) { | ||
121 | p9_conn_destroy(clnt->conn); | ||
122 | clnt->conn = NULL; | ||
123 | } | ||
124 | 215 | ||
125 | if (clnt->trans) { | 216 | if (clnt->trans) { |
126 | clnt->trans->close(clnt->trans); | 217 | clnt->trans->close(clnt->trans); |
@@ -142,7 +233,6 @@ void p9_client_disconnect(struct p9_client *clnt) | |||
142 | { | 233 | { |
143 | P9_DPRINTK(P9_DEBUG_9P, "clnt %p\n", clnt); | 234 | P9_DPRINTK(P9_DEBUG_9P, "clnt %p\n", clnt); |
144 | clnt->trans->status = Disconnected; | 235 | clnt->trans->status = Disconnected; |
145 | p9_conn_cancel(clnt->conn, -EIO); | ||
146 | } | 236 | } |
147 | EXPORT_SYMBOL(p9_client_disconnect); | 237 | EXPORT_SYMBOL(p9_client_disconnect); |
148 | 238 | ||
@@ -174,7 +264,7 @@ struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid, | |||
174 | goto error; | 264 | goto error; |
175 | } | 265 | } |
176 | 266 | ||
177 | err = p9_conn_rpc(clnt->conn, tc, &rc); | 267 | err = p9_client_rpc(clnt, tc, &rc); |
178 | if (err) | 268 | if (err) |
179 | goto error; | 269 | goto error; |
180 | 270 | ||
@@ -219,7 +309,7 @@ struct p9_fid *p9_client_auth(struct p9_client *clnt, char *uname, | |||
219 | goto error; | 309 | goto error; |
220 | } | 310 | } |
221 | 311 | ||
222 | err = p9_conn_rpc(clnt->conn, tc, &rc); | 312 | err = p9_client_rpc(clnt, tc, &rc); |
223 | if (err) | 313 | if (err) |
224 | goto error; | 314 | goto error; |
225 | 315 | ||
@@ -270,7 +360,7 @@ struct p9_fid *p9_client_walk(struct p9_fid *oldfid, int nwname, char **wnames, | |||
270 | goto error; | 360 | goto error; |
271 | } | 361 | } |
272 | 362 | ||
273 | err = p9_conn_rpc(clnt->conn, tc, &rc); | 363 | err = p9_client_rpc(clnt, tc, &rc); |
274 | if (err) { | 364 | if (err) { |
275 | if (rc && rc->id == P9_RWALK) | 365 | if (rc && rc->id == P9_RWALK) |
276 | goto clunk_fid; | 366 | goto clunk_fid; |
@@ -305,7 +395,7 @@ clunk_fid: | |||
305 | goto error; | 395 | goto error; |
306 | } | 396 | } |
307 | 397 | ||
308 | p9_conn_rpc(clnt->conn, tc, &rc); | 398 | p9_client_rpc(clnt, tc, &rc); |
309 | 399 | ||
310 | error: | 400 | error: |
311 | kfree(tc); | 401 | kfree(tc); |
@@ -339,7 +429,7 @@ int p9_client_open(struct p9_fid *fid, int mode) | |||
339 | goto done; | 429 | goto done; |
340 | } | 430 | } |
341 | 431 | ||
342 | err = p9_conn_rpc(clnt->conn, tc, &rc); | 432 | err = p9_client_rpc(clnt, tc, &rc); |
343 | if (err) | 433 | if (err) |
344 | goto done; | 434 | goto done; |
345 | 435 | ||
@@ -378,7 +468,7 @@ int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode, | |||
378 | goto done; | 468 | goto done; |
379 | } | 469 | } |
380 | 470 | ||
381 | err = p9_conn_rpc(clnt->conn, tc, &rc); | 471 | err = p9_client_rpc(clnt, tc, &rc); |
382 | if (err) | 472 | if (err) |
383 | goto done; | 473 | goto done; |
384 | 474 | ||
@@ -411,7 +501,7 @@ int p9_client_clunk(struct p9_fid *fid) | |||
411 | goto done; | 501 | goto done; |
412 | } | 502 | } |
413 | 503 | ||
414 | err = p9_conn_rpc(clnt->conn, tc, &rc); | 504 | err = p9_client_rpc(clnt, tc, &rc); |
415 | if (err) | 505 | if (err) |
416 | goto done; | 506 | goto done; |
417 | 507 | ||
@@ -443,7 +533,7 @@ int p9_client_remove(struct p9_fid *fid) | |||
443 | goto done; | 533 | goto done; |
444 | } | 534 | } |
445 | 535 | ||
446 | err = p9_conn_rpc(clnt->conn, tc, &rc); | 536 | err = p9_client_rpc(clnt, tc, &rc); |
447 | if (err) | 537 | if (err) |
448 | goto done; | 538 | goto done; |
449 | 539 | ||
@@ -485,7 +575,7 @@ int p9_client_read(struct p9_fid *fid, char *data, u64 offset, u32 count) | |||
485 | goto error; | 575 | goto error; |
486 | } | 576 | } |
487 | 577 | ||
488 | err = p9_conn_rpc(clnt->conn, tc, &rc); | 578 | err = p9_client_rpc(clnt, tc, &rc); |
489 | if (err) | 579 | if (err) |
490 | goto error; | 580 | goto error; |
491 | 581 | ||
@@ -542,7 +632,7 @@ int p9_client_write(struct p9_fid *fid, char *data, u64 offset, u32 count) | |||
542 | goto error; | 632 | goto error; |
543 | } | 633 | } |
544 | 634 | ||
545 | err = p9_conn_rpc(clnt->conn, tc, &rc); | 635 | err = p9_client_rpc(clnt, tc, &rc); |
546 | if (err) | 636 | if (err) |
547 | goto error; | 637 | goto error; |
548 | 638 | ||
@@ -596,7 +686,7 @@ p9_client_uread(struct p9_fid *fid, char __user *data, u64 offset, u32 count) | |||
596 | goto error; | 686 | goto error; |
597 | } | 687 | } |
598 | 688 | ||
599 | err = p9_conn_rpc(clnt->conn, tc, &rc); | 689 | err = p9_client_rpc(clnt, tc, &rc); |
600 | if (err) | 690 | if (err) |
601 | goto error; | 691 | goto error; |
602 | 692 | ||
@@ -660,7 +750,7 @@ p9_client_uwrite(struct p9_fid *fid, const char __user *data, u64 offset, | |||
660 | goto error; | 750 | goto error; |
661 | } | 751 | } |
662 | 752 | ||
663 | err = p9_conn_rpc(clnt->conn, tc, &rc); | 753 | err = p9_client_rpc(clnt, tc, &rc); |
664 | if (err) | 754 | if (err) |
665 | goto error; | 755 | goto error; |
666 | 756 | ||
@@ -731,7 +821,7 @@ struct p9_stat *p9_client_stat(struct p9_fid *fid) | |||
731 | goto error; | 821 | goto error; |
732 | } | 822 | } |
733 | 823 | ||
734 | err = p9_conn_rpc(clnt->conn, tc, &rc); | 824 | err = p9_client_rpc(clnt, tc, &rc); |
735 | if (err) | 825 | if (err) |
736 | goto error; | 826 | goto error; |
737 | 827 | ||
@@ -773,7 +863,7 @@ int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst) | |||
773 | goto done; | 863 | goto done; |
774 | } | 864 | } |
775 | 865 | ||
776 | err = p9_conn_rpc(clnt->conn, tc, &rc); | 866 | err = p9_client_rpc(clnt, tc, &rc); |
777 | 867 | ||
778 | done: | 868 | done: |
779 | kfree(tc); | 869 | kfree(tc); |
@@ -830,7 +920,7 @@ struct p9_stat *p9_client_dirread(struct p9_fid *fid, u64 offset) | |||
830 | goto error; | 920 | goto error; |
831 | } | 921 | } |
832 | 922 | ||
833 | err = p9_conn_rpc(clnt->conn, tc, &rc); | 923 | err = p9_client_rpc(clnt, tc, &rc); |
834 | if (err) | 924 | if (err) |
835 | goto error; | 925 | goto error; |
836 | 926 | ||
@@ -901,16 +991,21 @@ static struct p9_stat *p9_clone_stat(struct p9_stat *st, int dotu) | |||
901 | memmove(ret, st, sizeof(struct p9_stat)); | 991 | memmove(ret, st, sizeof(struct p9_stat)); |
902 | p = ((char *) ret) + sizeof(struct p9_stat); | 992 | p = ((char *) ret) + sizeof(struct p9_stat); |
903 | memmove(p, st->name.str, st->name.len); | 993 | memmove(p, st->name.str, st->name.len); |
994 | ret->name.str = p; | ||
904 | p += st->name.len; | 995 | p += st->name.len; |
905 | memmove(p, st->uid.str, st->uid.len); | 996 | memmove(p, st->uid.str, st->uid.len); |
997 | ret->uid.str = p; | ||
906 | p += st->uid.len; | 998 | p += st->uid.len; |
907 | memmove(p, st->gid.str, st->gid.len); | 999 | memmove(p, st->gid.str, st->gid.len); |
1000 | ret->gid.str = p; | ||
908 | p += st->gid.len; | 1001 | p += st->gid.len; |
909 | memmove(p, st->muid.str, st->muid.len); | 1002 | memmove(p, st->muid.str, st->muid.len); |
1003 | ret->muid.str = p; | ||
910 | p += st->muid.len; | 1004 | p += st->muid.len; |
911 | 1005 | ||
912 | if (dotu) { | 1006 | if (dotu) { |
913 | memmove(p, st->extension.str, st->extension.len); | 1007 | memmove(p, st->extension.str, st->extension.len); |
1008 | ret->extension.str = p; | ||
914 | p += st->extension.len; | 1009 | p += st->extension.len; |
915 | } | 1010 | } |
916 | 1011 | ||
diff --git a/net/9p/fcprint.c b/net/9p/fcprint.c index b1ae8ec57d54..40244fbd9b0d 100644 --- a/net/9p/fcprint.c +++ b/net/9p/fcprint.c | |||
@@ -347,12 +347,12 @@ p9_printfcall(char *buf, int buflen, struct p9_fcall *fc, int extended) | |||
347 | 347 | ||
348 | return ret; | 348 | return ret; |
349 | } | 349 | } |
350 | |||
351 | #else | 350 | #else |
352 | int | 351 | int |
353 | p9_printfcall(char *buf, int buflen, struct p9_fcall *fc, int extended) | 352 | p9_printfcall(char *buf, int buflen, struct p9_fcall *fc, int extended) |
354 | { | 353 | { |
355 | return 0; | 354 | return 0; |
356 | } | 355 | } |
357 | EXPORT_SYMBOL(p9_printfcall); | ||
358 | #endif /* CONFIG_NET_9P_DEBUG */ | 356 | #endif /* CONFIG_NET_9P_DEBUG */ |
357 | EXPORT_SYMBOL(p9_printfcall); | ||
358 | |||
diff --git a/net/9p/mod.c b/net/9p/mod.c index 8f9763a9dc12..c285aab2af04 100644 --- a/net/9p/mod.c +++ b/net/9p/mod.c | |||
@@ -106,15 +106,10 @@ EXPORT_SYMBOL(v9fs_default_trans); | |||
106 | */ | 106 | */ |
107 | static int __init init_p9(void) | 107 | static int __init init_p9(void) |
108 | { | 108 | { |
109 | int ret; | 109 | int ret = 0; |
110 | 110 | ||
111 | p9_error_init(); | 111 | p9_error_init(); |
112 | printk(KERN_INFO "Installing 9P2000 support\n"); | 112 | printk(KERN_INFO "Installing 9P2000 support\n"); |
113 | ret = p9_mux_global_init(); | ||
114 | if (ret) { | ||
115 | printk(KERN_WARNING "9p: starting mux failed\n"); | ||
116 | return ret; | ||
117 | } | ||
118 | 113 | ||
119 | return ret; | 114 | return ret; |
120 | } | 115 | } |
@@ -126,7 +121,7 @@ static int __init init_p9(void) | |||
126 | 121 | ||
127 | static void __exit exit_p9(void) | 122 | static void __exit exit_p9(void) |
128 | { | 123 | { |
129 | p9_mux_global_exit(); | 124 | printk(KERN_INFO "Unloading 9P2000 support\n"); |
130 | } | 125 | } |
131 | 126 | ||
132 | module_init(init_p9) | 127 | module_init(init_p9) |
diff --git a/net/9p/mux.c b/net/9p/mux.c deleted file mode 100644 index c9f0805048e4..000000000000 --- a/net/9p/mux.c +++ /dev/null | |||
@@ -1,1060 +0,0 @@ | |||
1 | /* | ||
2 | * net/9p/mux.c | ||
3 | * | ||
4 | * Protocol Multiplexer | ||
5 | * | ||
6 | * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com> | ||
7 | * Copyright (C) 2004-2005 by Latchesar Ionkov <lucho@ionkov.net> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 | ||
11 | * as published by the Free Software Foundation. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to: | ||
20 | * Free Software Foundation | ||
21 | * 51 Franklin Street, Fifth Floor | ||
22 | * Boston, MA 02111-1301 USA | ||
23 | * | ||
24 | */ | ||
25 | |||
26 | #include <linux/module.h> | ||
27 | #include <linux/errno.h> | ||
28 | #include <linux/fs.h> | ||
29 | #include <linux/poll.h> | ||
30 | #include <linux/kthread.h> | ||
31 | #include <linux/idr.h> | ||
32 | #include <linux/mutex.h> | ||
33 | #include <net/9p/9p.h> | ||
34 | #include <linux/parser.h> | ||
35 | #include <net/9p/transport.h> | ||
36 | #include <net/9p/conn.h> | ||
37 | |||
38 | #define ERREQFLUSH 1 | ||
39 | #define SCHED_TIMEOUT 10 | ||
40 | #define MAXPOLLWADDR 2 | ||
41 | |||
42 | enum { | ||
43 | Rworksched = 1, /* read work scheduled or running */ | ||
44 | Rpending = 2, /* can read */ | ||
45 | Wworksched = 4, /* write work scheduled or running */ | ||
46 | Wpending = 8, /* can write */ | ||
47 | }; | ||
48 | |||
49 | enum { | ||
50 | None, | ||
51 | Flushing, | ||
52 | Flushed, | ||
53 | }; | ||
54 | |||
55 | struct p9_mux_poll_task; | ||
56 | |||
57 | struct p9_req { | ||
58 | spinlock_t lock; /* protect request structure */ | ||
59 | int tag; | ||
60 | struct p9_fcall *tcall; | ||
61 | struct p9_fcall *rcall; | ||
62 | int err; | ||
63 | p9_conn_req_callback cb; | ||
64 | void *cba; | ||
65 | int flush; | ||
66 | struct list_head req_list; | ||
67 | }; | ||
68 | |||
69 | struct p9_conn { | ||
70 | spinlock_t lock; /* protect lock structure */ | ||
71 | struct list_head mux_list; | ||
72 | struct p9_mux_poll_task *poll_task; | ||
73 | int msize; | ||
74 | unsigned char *extended; | ||
75 | struct p9_trans *trans; | ||
76 | struct p9_idpool *tagpool; | ||
77 | int err; | ||
78 | wait_queue_head_t equeue; | ||
79 | struct list_head req_list; | ||
80 | struct list_head unsent_req_list; | ||
81 | struct p9_fcall *rcall; | ||
82 | int rpos; | ||
83 | char *rbuf; | ||
84 | int wpos; | ||
85 | int wsize; | ||
86 | char *wbuf; | ||
87 | wait_queue_t poll_wait[MAXPOLLWADDR]; | ||
88 | wait_queue_head_t *poll_waddr[MAXPOLLWADDR]; | ||
89 | poll_table pt; | ||
90 | struct work_struct rq; | ||
91 | struct work_struct wq; | ||
92 | unsigned long wsched; | ||
93 | }; | ||
94 | |||
95 | struct p9_mux_poll_task { | ||
96 | struct task_struct *task; | ||
97 | struct list_head mux_list; | ||
98 | int muxnum; | ||
99 | }; | ||
100 | |||
101 | struct p9_mux_rpc { | ||
102 | struct p9_conn *m; | ||
103 | int err; | ||
104 | struct p9_fcall *tcall; | ||
105 | struct p9_fcall *rcall; | ||
106 | wait_queue_head_t wqueue; | ||
107 | }; | ||
108 | |||
109 | static int p9_poll_proc(void *); | ||
110 | static void p9_read_work(struct work_struct *work); | ||
111 | static void p9_write_work(struct work_struct *work); | ||
112 | static void p9_pollwait(struct file *filp, wait_queue_head_t *wait_address, | ||
113 | poll_table * p); | ||
114 | static u16 p9_mux_get_tag(struct p9_conn *); | ||
115 | static void p9_mux_put_tag(struct p9_conn *, u16); | ||
116 | |||
117 | static DEFINE_MUTEX(p9_mux_task_lock); | ||
118 | static struct workqueue_struct *p9_mux_wq; | ||
119 | |||
120 | static int p9_mux_num; | ||
121 | static int p9_mux_poll_task_num; | ||
122 | static struct p9_mux_poll_task p9_mux_poll_tasks[100]; | ||
123 | |||
124 | int p9_mux_global_init(void) | ||
125 | { | ||
126 | int i; | ||
127 | |||
128 | for (i = 0; i < ARRAY_SIZE(p9_mux_poll_tasks); i++) | ||
129 | p9_mux_poll_tasks[i].task = NULL; | ||
130 | |||
131 | p9_mux_wq = create_workqueue("v9fs"); | ||
132 | if (!p9_mux_wq) { | ||
133 | printk(KERN_WARNING "v9fs: mux: creating workqueue failed\n"); | ||
134 | return -ENOMEM; | ||
135 | } | ||
136 | |||
137 | return 0; | ||
138 | } | ||
139 | |||
140 | void p9_mux_global_exit(void) | ||
141 | { | ||
142 | destroy_workqueue(p9_mux_wq); | ||
143 | } | ||
144 | |||
145 | /** | ||
146 | * p9_mux_calc_poll_procs - calculates the number of polling procs | ||
147 | * based on the number of mounted v9fs filesystems. | ||
148 | * | ||
149 | * The current implementation returns sqrt of the number of mounts. | ||
150 | */ | ||
151 | static int p9_mux_calc_poll_procs(int muxnum) | ||
152 | { | ||
153 | int n; | ||
154 | |||
155 | if (p9_mux_poll_task_num) | ||
156 | n = muxnum / p9_mux_poll_task_num + | ||
157 | (muxnum % p9_mux_poll_task_num ? 1 : 0); | ||
158 | else | ||
159 | n = 1; | ||
160 | |||
161 | if (n > ARRAY_SIZE(p9_mux_poll_tasks)) | ||
162 | n = ARRAY_SIZE(p9_mux_poll_tasks); | ||
163 | |||
164 | return n; | ||
165 | } | ||
166 | |||
167 | static int p9_mux_poll_start(struct p9_conn *m) | ||
168 | { | ||
169 | int i, n; | ||
170 | struct p9_mux_poll_task *vpt, *vptlast; | ||
171 | struct task_struct *pproc; | ||
172 | |||
173 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p muxnum %d procnum %d\n", m, p9_mux_num, | ||
174 | p9_mux_poll_task_num); | ||
175 | mutex_lock(&p9_mux_task_lock); | ||
176 | |||
177 | n = p9_mux_calc_poll_procs(p9_mux_num + 1); | ||
178 | if (n > p9_mux_poll_task_num) { | ||
179 | for (i = 0; i < ARRAY_SIZE(p9_mux_poll_tasks); i++) { | ||
180 | if (p9_mux_poll_tasks[i].task == NULL) { | ||
181 | vpt = &p9_mux_poll_tasks[i]; | ||
182 | P9_DPRINTK(P9_DEBUG_MUX, "create proc %p\n", | ||
183 | vpt); | ||
184 | pproc = kthread_create(p9_poll_proc, vpt, | ||
185 | "v9fs-poll"); | ||
186 | |||
187 | if (!IS_ERR(pproc)) { | ||
188 | vpt->task = pproc; | ||
189 | INIT_LIST_HEAD(&vpt->mux_list); | ||
190 | vpt->muxnum = 0; | ||
191 | p9_mux_poll_task_num++; | ||
192 | wake_up_process(vpt->task); | ||
193 | } | ||
194 | break; | ||
195 | } | ||
196 | } | ||
197 | |||
198 | if (i >= ARRAY_SIZE(p9_mux_poll_tasks)) | ||
199 | P9_DPRINTK(P9_DEBUG_ERROR, | ||
200 | "warning: no free poll slots\n"); | ||
201 | } | ||
202 | |||
203 | n = (p9_mux_num + 1) / p9_mux_poll_task_num + | ||
204 | ((p9_mux_num + 1) % p9_mux_poll_task_num ? 1 : 0); | ||
205 | |||
206 | vptlast = NULL; | ||
207 | for (i = 0; i < ARRAY_SIZE(p9_mux_poll_tasks); i++) { | ||
208 | vpt = &p9_mux_poll_tasks[i]; | ||
209 | if (vpt->task != NULL) { | ||
210 | vptlast = vpt; | ||
211 | if (vpt->muxnum < n) { | ||
212 | P9_DPRINTK(P9_DEBUG_MUX, "put in proc %d\n", i); | ||
213 | list_add(&m->mux_list, &vpt->mux_list); | ||
214 | vpt->muxnum++; | ||
215 | m->poll_task = vpt; | ||
216 | memset(&m->poll_waddr, 0, | ||
217 | sizeof(m->poll_waddr)); | ||
218 | init_poll_funcptr(&m->pt, p9_pollwait); | ||
219 | break; | ||
220 | } | ||
221 | } | ||
222 | } | ||
223 | |||
224 | if (i >= ARRAY_SIZE(p9_mux_poll_tasks)) { | ||
225 | if (vptlast == NULL) { | ||
226 | mutex_unlock(&p9_mux_task_lock); | ||
227 | return -ENOMEM; | ||
228 | } | ||
229 | |||
230 | P9_DPRINTK(P9_DEBUG_MUX, "put in proc %d\n", i); | ||
231 | list_add(&m->mux_list, &vptlast->mux_list); | ||
232 | vptlast->muxnum++; | ||
233 | m->poll_task = vptlast; | ||
234 | memset(&m->poll_waddr, 0, sizeof(m->poll_waddr)); | ||
235 | init_poll_funcptr(&m->pt, p9_pollwait); | ||
236 | } | ||
237 | |||
238 | p9_mux_num++; | ||
239 | mutex_unlock(&p9_mux_task_lock); | ||
240 | |||
241 | return 0; | ||
242 | } | ||
243 | |||
244 | static void p9_mux_poll_stop(struct p9_conn *m) | ||
245 | { | ||
246 | int i; | ||
247 | struct p9_mux_poll_task *vpt; | ||
248 | |||
249 | mutex_lock(&p9_mux_task_lock); | ||
250 | vpt = m->poll_task; | ||
251 | list_del(&m->mux_list); | ||
252 | for (i = 0; i < ARRAY_SIZE(m->poll_waddr); i++) { | ||
253 | if (m->poll_waddr[i] != NULL) { | ||
254 | remove_wait_queue(m->poll_waddr[i], &m->poll_wait[i]); | ||
255 | m->poll_waddr[i] = NULL; | ||
256 | } | ||
257 | } | ||
258 | vpt->muxnum--; | ||
259 | if (!vpt->muxnum) { | ||
260 | P9_DPRINTK(P9_DEBUG_MUX, "destroy proc %p\n", vpt); | ||
261 | kthread_stop(vpt->task); | ||
262 | vpt->task = NULL; | ||
263 | p9_mux_poll_task_num--; | ||
264 | } | ||
265 | p9_mux_num--; | ||
266 | mutex_unlock(&p9_mux_task_lock); | ||
267 | } | ||
268 | |||
269 | /** | ||
270 | * p9_conn_create - allocate and initialize the per-session mux data | ||
271 | * Creates the polling task if this is the first session. | ||
272 | * | ||
273 | * @trans - transport structure | ||
274 | * @msize - maximum message size | ||
275 | * @extended - pointer to the extended flag | ||
276 | */ | ||
277 | struct p9_conn *p9_conn_create(struct p9_trans *trans, int msize, | ||
278 | unsigned char *extended) | ||
279 | { | ||
280 | int i, n; | ||
281 | struct p9_conn *m, *mtmp; | ||
282 | |||
283 | P9_DPRINTK(P9_DEBUG_MUX, "transport %p msize %d\n", trans, msize); | ||
284 | m = kmalloc(sizeof(struct p9_conn), GFP_KERNEL); | ||
285 | if (!m) | ||
286 | return ERR_PTR(-ENOMEM); | ||
287 | |||
288 | spin_lock_init(&m->lock); | ||
289 | INIT_LIST_HEAD(&m->mux_list); | ||
290 | m->msize = msize; | ||
291 | m->extended = extended; | ||
292 | m->trans = trans; | ||
293 | m->tagpool = p9_idpool_create(); | ||
294 | if (IS_ERR(m->tagpool)) { | ||
295 | mtmp = ERR_PTR(-ENOMEM); | ||
296 | kfree(m); | ||
297 | return mtmp; | ||
298 | } | ||
299 | |||
300 | m->err = 0; | ||
301 | init_waitqueue_head(&m->equeue); | ||
302 | INIT_LIST_HEAD(&m->req_list); | ||
303 | INIT_LIST_HEAD(&m->unsent_req_list); | ||
304 | m->rcall = NULL; | ||
305 | m->rpos = 0; | ||
306 | m->rbuf = NULL; | ||
307 | m->wpos = m->wsize = 0; | ||
308 | m->wbuf = NULL; | ||
309 | INIT_WORK(&m->rq, p9_read_work); | ||
310 | INIT_WORK(&m->wq, p9_write_work); | ||
311 | m->wsched = 0; | ||
312 | memset(&m->poll_waddr, 0, sizeof(m->poll_waddr)); | ||
313 | m->poll_task = NULL; | ||
314 | n = p9_mux_poll_start(m); | ||
315 | if (n) { | ||
316 | kfree(m); | ||
317 | return ERR_PTR(n); | ||
318 | } | ||
319 | |||
320 | n = trans->poll(trans, &m->pt); | ||
321 | if (n & POLLIN) { | ||
322 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p can read\n", m); | ||
323 | set_bit(Rpending, &m->wsched); | ||
324 | } | ||
325 | |||
326 | if (n & POLLOUT) { | ||
327 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p can write\n", m); | ||
328 | set_bit(Wpending, &m->wsched); | ||
329 | } | ||
330 | |||
331 | for (i = 0; i < ARRAY_SIZE(m->poll_waddr); i++) { | ||
332 | if (IS_ERR(m->poll_waddr[i])) { | ||
333 | p9_mux_poll_stop(m); | ||
334 | mtmp = (void *)m->poll_waddr; /* the error code */ | ||
335 | kfree(m); | ||
336 | m = mtmp; | ||
337 | break; | ||
338 | } | ||
339 | } | ||
340 | |||
341 | return m; | ||
342 | } | ||
343 | EXPORT_SYMBOL(p9_conn_create); | ||
344 | |||
345 | /** | ||
346 | * p9_mux_destroy - cancels all pending requests and frees mux resources | ||
347 | */ | ||
348 | void p9_conn_destroy(struct p9_conn *m) | ||
349 | { | ||
350 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p prev %p next %p\n", m, | ||
351 | m->mux_list.prev, m->mux_list.next); | ||
352 | p9_conn_cancel(m, -ECONNRESET); | ||
353 | |||
354 | if (!list_empty(&m->req_list)) { | ||
355 | /* wait until all processes waiting on this session exit */ | ||
356 | P9_DPRINTK(P9_DEBUG_MUX, | ||
357 | "mux %p waiting for empty request queue\n", m); | ||
358 | wait_event_timeout(m->equeue, (list_empty(&m->req_list)), 5000); | ||
359 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p request queue empty: %d\n", m, | ||
360 | list_empty(&m->req_list)); | ||
361 | } | ||
362 | |||
363 | p9_mux_poll_stop(m); | ||
364 | m->trans = NULL; | ||
365 | p9_idpool_destroy(m->tagpool); | ||
366 | kfree(m); | ||
367 | } | ||
368 | EXPORT_SYMBOL(p9_conn_destroy); | ||
369 | |||
370 | /** | ||
371 | * p9_pollwait - called by files poll operation to add v9fs-poll task | ||
372 | * to files wait queue | ||
373 | */ | ||
374 | static void | ||
375 | p9_pollwait(struct file *filp, wait_queue_head_t *wait_address, | ||
376 | poll_table * p) | ||
377 | { | ||
378 | int i; | ||
379 | struct p9_conn *m; | ||
380 | |||
381 | m = container_of(p, struct p9_conn, pt); | ||
382 | for (i = 0; i < ARRAY_SIZE(m->poll_waddr); i++) | ||
383 | if (m->poll_waddr[i] == NULL) | ||
384 | break; | ||
385 | |||
386 | if (i >= ARRAY_SIZE(m->poll_waddr)) { | ||
387 | P9_DPRINTK(P9_DEBUG_ERROR, "not enough wait_address slots\n"); | ||
388 | return; | ||
389 | } | ||
390 | |||
391 | m->poll_waddr[i] = wait_address; | ||
392 | |||
393 | if (!wait_address) { | ||
394 | P9_DPRINTK(P9_DEBUG_ERROR, "no wait_address\n"); | ||
395 | m->poll_waddr[i] = ERR_PTR(-EIO); | ||
396 | return; | ||
397 | } | ||
398 | |||
399 | init_waitqueue_entry(&m->poll_wait[i], m->poll_task->task); | ||
400 | add_wait_queue(wait_address, &m->poll_wait[i]); | ||
401 | } | ||
402 | |||
403 | /** | ||
404 | * p9_poll_mux - polls a mux and schedules read or write works if necessary | ||
405 | */ | ||
406 | static void p9_poll_mux(struct p9_conn *m) | ||
407 | { | ||
408 | int n; | ||
409 | |||
410 | if (m->err < 0) | ||
411 | return; | ||
412 | |||
413 | n = m->trans->poll(m->trans, NULL); | ||
414 | if (n < 0 || n & (POLLERR | POLLHUP | POLLNVAL)) { | ||
415 | P9_DPRINTK(P9_DEBUG_MUX, "error mux %p err %d\n", m, n); | ||
416 | if (n >= 0) | ||
417 | n = -ECONNRESET; | ||
418 | p9_conn_cancel(m, n); | ||
419 | } | ||
420 | |||
421 | if (n & POLLIN) { | ||
422 | set_bit(Rpending, &m->wsched); | ||
423 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p can read\n", m); | ||
424 | if (!test_and_set_bit(Rworksched, &m->wsched)) { | ||
425 | P9_DPRINTK(P9_DEBUG_MUX, "schedule read work %p\n", m); | ||
426 | queue_work(p9_mux_wq, &m->rq); | ||
427 | } | ||
428 | } | ||
429 | |||
430 | if (n & POLLOUT) { | ||
431 | set_bit(Wpending, &m->wsched); | ||
432 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p can write\n", m); | ||
433 | if ((m->wsize || !list_empty(&m->unsent_req_list)) | ||
434 | && !test_and_set_bit(Wworksched, &m->wsched)) { | ||
435 | P9_DPRINTK(P9_DEBUG_MUX, "schedule write work %p\n", m); | ||
436 | queue_work(p9_mux_wq, &m->wq); | ||
437 | } | ||
438 | } | ||
439 | } | ||
440 | |||
441 | /** | ||
442 | * p9_poll_proc - polls all v9fs transports for new events and queues | ||
443 | * the appropriate work to the work queue | ||
444 | */ | ||
445 | static int p9_poll_proc(void *a) | ||
446 | { | ||
447 | struct p9_conn *m, *mtmp; | ||
448 | struct p9_mux_poll_task *vpt; | ||
449 | |||
450 | vpt = a; | ||
451 | P9_DPRINTK(P9_DEBUG_MUX, "start %p %p\n", current, vpt); | ||
452 | while (!kthread_should_stop()) { | ||
453 | set_current_state(TASK_INTERRUPTIBLE); | ||
454 | |||
455 | list_for_each_entry_safe(m, mtmp, &vpt->mux_list, mux_list) { | ||
456 | p9_poll_mux(m); | ||
457 | } | ||
458 | |||
459 | P9_DPRINTK(P9_DEBUG_MUX, "sleeping...\n"); | ||
460 | schedule_timeout(SCHED_TIMEOUT * HZ); | ||
461 | } | ||
462 | |||
463 | __set_current_state(TASK_RUNNING); | ||
464 | P9_DPRINTK(P9_DEBUG_MUX, "finish\n"); | ||
465 | return 0; | ||
466 | } | ||
467 | |||
468 | /** | ||
469 | * p9_write_work - called when a transport can send some data | ||
470 | */ | ||
471 | static void p9_write_work(struct work_struct *work) | ||
472 | { | ||
473 | int n, err; | ||
474 | struct p9_conn *m; | ||
475 | struct p9_req *req; | ||
476 | |||
477 | m = container_of(work, struct p9_conn, wq); | ||
478 | |||
479 | if (m->err < 0) { | ||
480 | clear_bit(Wworksched, &m->wsched); | ||
481 | return; | ||
482 | } | ||
483 | |||
484 | if (!m->wsize) { | ||
485 | if (list_empty(&m->unsent_req_list)) { | ||
486 | clear_bit(Wworksched, &m->wsched); | ||
487 | return; | ||
488 | } | ||
489 | |||
490 | spin_lock(&m->lock); | ||
491 | again: | ||
492 | req = list_entry(m->unsent_req_list.next, struct p9_req, | ||
493 | req_list); | ||
494 | list_move_tail(&req->req_list, &m->req_list); | ||
495 | if (req->err == ERREQFLUSH) | ||
496 | goto again; | ||
497 | |||
498 | m->wbuf = req->tcall->sdata; | ||
499 | m->wsize = req->tcall->size; | ||
500 | m->wpos = 0; | ||
501 | spin_unlock(&m->lock); | ||
502 | } | ||
503 | |||
504 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p pos %d size %d\n", m, m->wpos, | ||
505 | m->wsize); | ||
506 | clear_bit(Wpending, &m->wsched); | ||
507 | err = m->trans->write(m->trans, m->wbuf + m->wpos, m->wsize - m->wpos); | ||
508 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p sent %d bytes\n", m, err); | ||
509 | if (err == -EAGAIN) { | ||
510 | clear_bit(Wworksched, &m->wsched); | ||
511 | return; | ||
512 | } | ||
513 | |||
514 | if (err < 0) | ||
515 | goto error; | ||
516 | else if (err == 0) { | ||
517 | err = -EREMOTEIO; | ||
518 | goto error; | ||
519 | } | ||
520 | |||
521 | m->wpos += err; | ||
522 | if (m->wpos == m->wsize) | ||
523 | m->wpos = m->wsize = 0; | ||
524 | |||
525 | if (m->wsize == 0 && !list_empty(&m->unsent_req_list)) { | ||
526 | if (test_and_clear_bit(Wpending, &m->wsched)) | ||
527 | n = POLLOUT; | ||
528 | else | ||
529 | n = m->trans->poll(m->trans, NULL); | ||
530 | |||
531 | if (n & POLLOUT) { | ||
532 | P9_DPRINTK(P9_DEBUG_MUX, "schedule write work %p\n", m); | ||
533 | queue_work(p9_mux_wq, &m->wq); | ||
534 | } else | ||
535 | clear_bit(Wworksched, &m->wsched); | ||
536 | } else | ||
537 | clear_bit(Wworksched, &m->wsched); | ||
538 | |||
539 | return; | ||
540 | |||
541 | error: | ||
542 | p9_conn_cancel(m, err); | ||
543 | clear_bit(Wworksched, &m->wsched); | ||
544 | } | ||
545 | |||
546 | static void process_request(struct p9_conn *m, struct p9_req *req) | ||
547 | { | ||
548 | int ecode; | ||
549 | struct p9_str *ename; | ||
550 | |||
551 | if (!req->err && req->rcall->id == P9_RERROR) { | ||
552 | ecode = req->rcall->params.rerror.errno; | ||
553 | ename = &req->rcall->params.rerror.error; | ||
554 | |||
555 | P9_DPRINTK(P9_DEBUG_MUX, "Rerror %.*s\n", ename->len, | ||
556 | ename->str); | ||
557 | |||
558 | if (*m->extended) | ||
559 | req->err = -ecode; | ||
560 | |||
561 | if (!req->err) { | ||
562 | req->err = p9_errstr2errno(ename->str, ename->len); | ||
563 | |||
564 | if (!req->err) { /* string match failed */ | ||
565 | PRINT_FCALL_ERROR("unknown error", req->rcall); | ||
566 | } | ||
567 | |||
568 | if (!req->err) | ||
569 | req->err = -ESERVERFAULT; | ||
570 | } | ||
571 | } else if (req->tcall && req->rcall->id != req->tcall->id + 1) { | ||
572 | P9_DPRINTK(P9_DEBUG_ERROR, | ||
573 | "fcall mismatch: expected %d, got %d\n", | ||
574 | req->tcall->id + 1, req->rcall->id); | ||
575 | if (!req->err) | ||
576 | req->err = -EIO; | ||
577 | } | ||
578 | } | ||
579 | |||
580 | /** | ||
581 | * p9_read_work - called when there is some data to be read from a transport | ||
582 | */ | ||
583 | static void p9_read_work(struct work_struct *work) | ||
584 | { | ||
585 | int n, err; | ||
586 | struct p9_conn *m; | ||
587 | struct p9_req *req, *rptr, *rreq; | ||
588 | struct p9_fcall *rcall; | ||
589 | char *rbuf; | ||
590 | |||
591 | m = container_of(work, struct p9_conn, rq); | ||
592 | |||
593 | if (m->err < 0) | ||
594 | return; | ||
595 | |||
596 | rcall = NULL; | ||
597 | P9_DPRINTK(P9_DEBUG_MUX, "start mux %p pos %d\n", m, m->rpos); | ||
598 | |||
599 | if (!m->rcall) { | ||
600 | m->rcall = | ||
601 | kmalloc(sizeof(struct p9_fcall) + m->msize, GFP_KERNEL); | ||
602 | if (!m->rcall) { | ||
603 | err = -ENOMEM; | ||
604 | goto error; | ||
605 | } | ||
606 | |||
607 | m->rbuf = (char *)m->rcall + sizeof(struct p9_fcall); | ||
608 | m->rpos = 0; | ||
609 | } | ||
610 | |||
611 | clear_bit(Rpending, &m->wsched); | ||
612 | err = m->trans->read(m->trans, m->rbuf + m->rpos, m->msize - m->rpos); | ||
613 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p got %d bytes\n", m, err); | ||
614 | if (err == -EAGAIN) { | ||
615 | clear_bit(Rworksched, &m->wsched); | ||
616 | return; | ||
617 | } | ||
618 | |||
619 | if (err <= 0) | ||
620 | goto error; | ||
621 | |||
622 | m->rpos += err; | ||
623 | while (m->rpos > 4) { | ||
624 | n = le32_to_cpu(*(__le32 *) m->rbuf); | ||
625 | if (n >= m->msize) { | ||
626 | P9_DPRINTK(P9_DEBUG_ERROR, | ||
627 | "requested packet size too big: %d\n", n); | ||
628 | err = -EIO; | ||
629 | goto error; | ||
630 | } | ||
631 | |||
632 | if (m->rpos < n) | ||
633 | break; | ||
634 | |||
635 | err = | ||
636 | p9_deserialize_fcall(m->rbuf, n, m->rcall, *m->extended); | ||
637 | if (err < 0) { | ||
638 | goto error; | ||
639 | } | ||
640 | |||
641 | #ifdef CONFIG_NET_9P_DEBUG | ||
642 | if ((p9_debug_level&P9_DEBUG_FCALL) == P9_DEBUG_FCALL) { | ||
643 | char buf[150]; | ||
644 | |||
645 | p9_printfcall(buf, sizeof(buf), m->rcall, | ||
646 | *m->extended); | ||
647 | printk(KERN_NOTICE ">>> %p %s\n", m, buf); | ||
648 | } | ||
649 | #endif | ||
650 | |||
651 | rcall = m->rcall; | ||
652 | rbuf = m->rbuf; | ||
653 | if (m->rpos > n) { | ||
654 | m->rcall = kmalloc(sizeof(struct p9_fcall) + m->msize, | ||
655 | GFP_KERNEL); | ||
656 | if (!m->rcall) { | ||
657 | err = -ENOMEM; | ||
658 | goto error; | ||
659 | } | ||
660 | |||
661 | m->rbuf = (char *)m->rcall + sizeof(struct p9_fcall); | ||
662 | memmove(m->rbuf, rbuf + n, m->rpos - n); | ||
663 | m->rpos -= n; | ||
664 | } else { | ||
665 | m->rcall = NULL; | ||
666 | m->rbuf = NULL; | ||
667 | m->rpos = 0; | ||
668 | } | ||
669 | |||
670 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p fcall id %d tag %d\n", m, | ||
671 | rcall->id, rcall->tag); | ||
672 | |||
673 | req = NULL; | ||
674 | spin_lock(&m->lock); | ||
675 | list_for_each_entry_safe(rreq, rptr, &m->req_list, req_list) { | ||
676 | if (rreq->tag == rcall->tag) { | ||
677 | req = rreq; | ||
678 | if (req->flush != Flushing) | ||
679 | list_del(&req->req_list); | ||
680 | break; | ||
681 | } | ||
682 | } | ||
683 | spin_unlock(&m->lock); | ||
684 | |||
685 | if (req) { | ||
686 | req->rcall = rcall; | ||
687 | process_request(m, req); | ||
688 | |||
689 | if (req->flush != Flushing) { | ||
690 | if (req->cb) | ||
691 | (*req->cb) (req, req->cba); | ||
692 | else | ||
693 | kfree(req->rcall); | ||
694 | |||
695 | wake_up(&m->equeue); | ||
696 | } | ||
697 | } else { | ||
698 | if (err >= 0 && rcall->id != P9_RFLUSH) | ||
699 | P9_DPRINTK(P9_DEBUG_ERROR, | ||
700 | "unexpected response mux %p id %d tag %d\n", | ||
701 | m, rcall->id, rcall->tag); | ||
702 | kfree(rcall); | ||
703 | } | ||
704 | } | ||
705 | |||
706 | if (!list_empty(&m->req_list)) { | ||
707 | if (test_and_clear_bit(Rpending, &m->wsched)) | ||
708 | n = POLLIN; | ||
709 | else | ||
710 | n = m->trans->poll(m->trans, NULL); | ||
711 | |||
712 | if (n & POLLIN) { | ||
713 | P9_DPRINTK(P9_DEBUG_MUX, "schedule read work %p\n", m); | ||
714 | queue_work(p9_mux_wq, &m->rq); | ||
715 | } else | ||
716 | clear_bit(Rworksched, &m->wsched); | ||
717 | } else | ||
718 | clear_bit(Rworksched, &m->wsched); | ||
719 | |||
720 | return; | ||
721 | |||
722 | error: | ||
723 | p9_conn_cancel(m, err); | ||
724 | clear_bit(Rworksched, &m->wsched); | ||
725 | } | ||
726 | |||
727 | /** | ||
728 | * p9_send_request - send 9P request | ||
729 | * The function can sleep until the request is scheduled for sending. | ||
730 | * The function can be interrupted. Return from the function is not | ||
731 | * a guarantee that the request is sent successfully. Can return errors | ||
732 | * that can be retrieved by PTR_ERR macros. | ||
733 | * | ||
734 | * @m: mux data | ||
735 | * @tc: request to be sent | ||
736 | * @cb: callback function to call when response is received | ||
737 | * @cba: parameter to pass to the callback function | ||
738 | */ | ||
739 | static struct p9_req *p9_send_request(struct p9_conn *m, | ||
740 | struct p9_fcall *tc, | ||
741 | p9_conn_req_callback cb, void *cba) | ||
742 | { | ||
743 | int n; | ||
744 | struct p9_req *req; | ||
745 | |||
746 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p task %p tcall %p id %d\n", m, current, | ||
747 | tc, tc->id); | ||
748 | if (m->err < 0) | ||
749 | return ERR_PTR(m->err); | ||
750 | |||
751 | req = kmalloc(sizeof(struct p9_req), GFP_KERNEL); | ||
752 | if (!req) | ||
753 | return ERR_PTR(-ENOMEM); | ||
754 | |||
755 | if (tc->id == P9_TVERSION) | ||
756 | n = P9_NOTAG; | ||
757 | else | ||
758 | n = p9_mux_get_tag(m); | ||
759 | |||
760 | if (n < 0) | ||
761 | return ERR_PTR(-ENOMEM); | ||
762 | |||
763 | p9_set_tag(tc, n); | ||
764 | |||
765 | #ifdef CONFIG_NET_9P_DEBUG | ||
766 | if ((p9_debug_level&P9_DEBUG_FCALL) == P9_DEBUG_FCALL) { | ||
767 | char buf[150]; | ||
768 | |||
769 | p9_printfcall(buf, sizeof(buf), tc, *m->extended); | ||
770 | printk(KERN_NOTICE "<<< %p %s\n", m, buf); | ||
771 | } | ||
772 | #endif | ||
773 | |||
774 | spin_lock_init(&req->lock); | ||
775 | req->tag = n; | ||
776 | req->tcall = tc; | ||
777 | req->rcall = NULL; | ||
778 | req->err = 0; | ||
779 | req->cb = cb; | ||
780 | req->cba = cba; | ||
781 | req->flush = None; | ||
782 | |||
783 | spin_lock(&m->lock); | ||
784 | list_add_tail(&req->req_list, &m->unsent_req_list); | ||
785 | spin_unlock(&m->lock); | ||
786 | |||
787 | if (test_and_clear_bit(Wpending, &m->wsched)) | ||
788 | n = POLLOUT; | ||
789 | else | ||
790 | n = m->trans->poll(m->trans, NULL); | ||
791 | |||
792 | if (n & POLLOUT && !test_and_set_bit(Wworksched, &m->wsched)) | ||
793 | queue_work(p9_mux_wq, &m->wq); | ||
794 | |||
795 | return req; | ||
796 | } | ||
797 | |||
798 | static void p9_mux_free_request(struct p9_conn *m, struct p9_req *req) | ||
799 | { | ||
800 | p9_mux_put_tag(m, req->tag); | ||
801 | kfree(req); | ||
802 | } | ||
803 | |||
804 | static void p9_mux_flush_cb(struct p9_req *freq, void *a) | ||
805 | { | ||
806 | p9_conn_req_callback cb; | ||
807 | int tag; | ||
808 | struct p9_conn *m; | ||
809 | struct p9_req *req, *rreq, *rptr; | ||
810 | |||
811 | m = a; | ||
812 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p tc %p rc %p err %d oldtag %d\n", m, | ||
813 | freq->tcall, freq->rcall, freq->err, | ||
814 | freq->tcall->params.tflush.oldtag); | ||
815 | |||
816 | spin_lock(&m->lock); | ||
817 | cb = NULL; | ||
818 | tag = freq->tcall->params.tflush.oldtag; | ||
819 | req = NULL; | ||
820 | list_for_each_entry_safe(rreq, rptr, &m->req_list, req_list) { | ||
821 | if (rreq->tag == tag) { | ||
822 | req = rreq; | ||
823 | list_del(&req->req_list); | ||
824 | break; | ||
825 | } | ||
826 | } | ||
827 | spin_unlock(&m->lock); | ||
828 | |||
829 | if (req) { | ||
830 | spin_lock(&req->lock); | ||
831 | req->flush = Flushed; | ||
832 | spin_unlock(&req->lock); | ||
833 | |||
834 | if (req->cb) | ||
835 | (*req->cb) (req, req->cba); | ||
836 | else | ||
837 | kfree(req->rcall); | ||
838 | |||
839 | wake_up(&m->equeue); | ||
840 | } | ||
841 | |||
842 | kfree(freq->tcall); | ||
843 | kfree(freq->rcall); | ||
844 | p9_mux_free_request(m, freq); | ||
845 | } | ||
846 | |||
847 | static int | ||
848 | p9_mux_flush_request(struct p9_conn *m, struct p9_req *req) | ||
849 | { | ||
850 | struct p9_fcall *fc; | ||
851 | struct p9_req *rreq, *rptr; | ||
852 | |||
853 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p req %p tag %d\n", m, req, req->tag); | ||
854 | |||
855 | /* if a response was received for a request, do nothing */ | ||
856 | spin_lock(&req->lock); | ||
857 | if (req->rcall || req->err) { | ||
858 | spin_unlock(&req->lock); | ||
859 | P9_DPRINTK(P9_DEBUG_MUX, | ||
860 | "mux %p req %p response already received\n", m, req); | ||
861 | return 0; | ||
862 | } | ||
863 | |||
864 | req->flush = Flushing; | ||
865 | spin_unlock(&req->lock); | ||
866 | |||
867 | spin_lock(&m->lock); | ||
868 | /* if the request is not sent yet, just remove it from the list */ | ||
869 | list_for_each_entry_safe(rreq, rptr, &m->unsent_req_list, req_list) { | ||
870 | if (rreq->tag == req->tag) { | ||
871 | P9_DPRINTK(P9_DEBUG_MUX, | ||
872 | "mux %p req %p request is not sent yet\n", m, req); | ||
873 | list_del(&rreq->req_list); | ||
874 | req->flush = Flushed; | ||
875 | spin_unlock(&m->lock); | ||
876 | if (req->cb) | ||
877 | (*req->cb) (req, req->cba); | ||
878 | return 0; | ||
879 | } | ||
880 | } | ||
881 | spin_unlock(&m->lock); | ||
882 | |||
883 | clear_thread_flag(TIF_SIGPENDING); | ||
884 | fc = p9_create_tflush(req->tag); | ||
885 | p9_send_request(m, fc, p9_mux_flush_cb, m); | ||
886 | return 1; | ||
887 | } | ||
888 | |||
889 | static void | ||
890 | p9_conn_rpc_cb(struct p9_req *req, void *a) | ||
891 | { | ||
892 | struct p9_mux_rpc *r; | ||
893 | |||
894 | P9_DPRINTK(P9_DEBUG_MUX, "req %p r %p\n", req, a); | ||
895 | r = a; | ||
896 | r->rcall = req->rcall; | ||
897 | r->err = req->err; | ||
898 | |||
899 | if (req->flush != None && !req->err) | ||
900 | r->err = -ERESTARTSYS; | ||
901 | |||
902 | wake_up(&r->wqueue); | ||
903 | } | ||
904 | |||
905 | /** | ||
906 | * p9_mux_rpc - sends 9P request and waits until a response is available. | ||
907 | * The function can be interrupted. | ||
908 | * @m: mux data | ||
909 | * @tc: request to be sent | ||
910 | * @rc: pointer where a pointer to the response is stored | ||
911 | */ | ||
912 | int | ||
913 | p9_conn_rpc(struct p9_conn *m, struct p9_fcall *tc, | ||
914 | struct p9_fcall **rc) | ||
915 | { | ||
916 | int err, sigpending; | ||
917 | unsigned long flags; | ||
918 | struct p9_req *req; | ||
919 | struct p9_mux_rpc r; | ||
920 | |||
921 | r.err = 0; | ||
922 | r.tcall = tc; | ||
923 | r.rcall = NULL; | ||
924 | r.m = m; | ||
925 | init_waitqueue_head(&r.wqueue); | ||
926 | |||
927 | if (rc) | ||
928 | *rc = NULL; | ||
929 | |||
930 | sigpending = 0; | ||
931 | if (signal_pending(current)) { | ||
932 | sigpending = 1; | ||
933 | clear_thread_flag(TIF_SIGPENDING); | ||
934 | } | ||
935 | |||
936 | req = p9_send_request(m, tc, p9_conn_rpc_cb, &r); | ||
937 | if (IS_ERR(req)) { | ||
938 | err = PTR_ERR(req); | ||
939 | P9_DPRINTK(P9_DEBUG_MUX, "error %d\n", err); | ||
940 | return err; | ||
941 | } | ||
942 | |||
943 | err = wait_event_interruptible(r.wqueue, r.rcall != NULL || r.err < 0); | ||
944 | if (r.err < 0) | ||
945 | err = r.err; | ||
946 | |||
947 | if (err == -ERESTARTSYS && m->trans->status == Connected | ||
948 | && m->err == 0) { | ||
949 | if (p9_mux_flush_request(m, req)) { | ||
950 | /* wait until we get response of the flush message */ | ||
951 | do { | ||
952 | clear_thread_flag(TIF_SIGPENDING); | ||
953 | err = wait_event_interruptible(r.wqueue, | ||
954 | r.rcall || r.err); | ||
955 | } while (!r.rcall && !r.err && err == -ERESTARTSYS && | ||
956 | m->trans->status == Connected && !m->err); | ||
957 | |||
958 | err = -ERESTARTSYS; | ||
959 | } | ||
960 | sigpending = 1; | ||
961 | } | ||
962 | |||
963 | if (sigpending) { | ||
964 | spin_lock_irqsave(¤t->sighand->siglock, flags); | ||
965 | recalc_sigpending(); | ||
966 | spin_unlock_irqrestore(¤t->sighand->siglock, flags); | ||
967 | } | ||
968 | |||
969 | if (rc) | ||
970 | *rc = r.rcall; | ||
971 | else | ||
972 | kfree(r.rcall); | ||
973 | |||
974 | p9_mux_free_request(m, req); | ||
975 | if (err > 0) | ||
976 | err = -EIO; | ||
977 | |||
978 | return err; | ||
979 | } | ||
980 | EXPORT_SYMBOL(p9_conn_rpc); | ||
981 | |||
982 | #ifdef P9_NONBLOCK | ||
983 | /** | ||
984 | * p9_conn_rpcnb - sends 9P request without waiting for response. | ||
985 | * @m: mux data | ||
986 | * @tc: request to be sent | ||
987 | * @cb: callback function to be called when response arrives | ||
988 | * @cba: value to pass to the callback function | ||
989 | */ | ||
990 | int p9_conn_rpcnb(struct p9_conn *m, struct p9_fcall *tc, | ||
991 | p9_conn_req_callback cb, void *a) | ||
992 | { | ||
993 | int err; | ||
994 | struct p9_req *req; | ||
995 | |||
996 | req = p9_send_request(m, tc, cb, a); | ||
997 | if (IS_ERR(req)) { | ||
998 | err = PTR_ERR(req); | ||
999 | P9_DPRINTK(P9_DEBUG_MUX, "error %d\n", err); | ||
1000 | return PTR_ERR(req); | ||
1001 | } | ||
1002 | |||
1003 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p tc %p tag %d\n", m, tc, req->tag); | ||
1004 | return 0; | ||
1005 | } | ||
1006 | EXPORT_SYMBOL(p9_conn_rpcnb); | ||
1007 | #endif /* P9_NONBLOCK */ | ||
1008 | |||
1009 | /** | ||
1010 | * p9_conn_cancel - cancel all pending requests with error | ||
1011 | * @m: mux data | ||
1012 | * @err: error code | ||
1013 | */ | ||
1014 | void p9_conn_cancel(struct p9_conn *m, int err) | ||
1015 | { | ||
1016 | struct p9_req *req, *rtmp; | ||
1017 | LIST_HEAD(cancel_list); | ||
1018 | |||
1019 | P9_DPRINTK(P9_DEBUG_ERROR, "mux %p err %d\n", m, err); | ||
1020 | m->err = err; | ||
1021 | spin_lock(&m->lock); | ||
1022 | list_for_each_entry_safe(req, rtmp, &m->req_list, req_list) { | ||
1023 | list_move(&req->req_list, &cancel_list); | ||
1024 | } | ||
1025 | list_for_each_entry_safe(req, rtmp, &m->unsent_req_list, req_list) { | ||
1026 | list_move(&req->req_list, &cancel_list); | ||
1027 | } | ||
1028 | spin_unlock(&m->lock); | ||
1029 | |||
1030 | list_for_each_entry_safe(req, rtmp, &cancel_list, req_list) { | ||
1031 | list_del(&req->req_list); | ||
1032 | if (!req->err) | ||
1033 | req->err = err; | ||
1034 | |||
1035 | if (req->cb) | ||
1036 | (*req->cb) (req, req->cba); | ||
1037 | else | ||
1038 | kfree(req->rcall); | ||
1039 | } | ||
1040 | |||
1041 | wake_up(&m->equeue); | ||
1042 | } | ||
1043 | EXPORT_SYMBOL(p9_conn_cancel); | ||
1044 | |||
1045 | static u16 p9_mux_get_tag(struct p9_conn *m) | ||
1046 | { | ||
1047 | int tag; | ||
1048 | |||
1049 | tag = p9_idpool_get(m->tagpool); | ||
1050 | if (tag < 0) | ||
1051 | return P9_NOTAG; | ||
1052 | else | ||
1053 | return (u16) tag; | ||
1054 | } | ||
1055 | |||
1056 | static void p9_mux_put_tag(struct p9_conn *m, u16 tag) | ||
1057 | { | ||
1058 | if (tag != P9_NOTAG && p9_idpool_check(tag, m->tagpool)) | ||
1059 | p9_idpool_put(tag, m->tagpool); | ||
1060 | } | ||
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c index 62332ed9da4a..1aa9d5175398 100644 --- a/net/9p/trans_fd.c +++ b/net/9p/trans_fd.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * | 5 | * |
6 | * Copyright (C) 2006 by Russ Cox <rsc@swtch.com> | 6 | * Copyright (C) 2006 by Russ Cox <rsc@swtch.com> |
7 | * Copyright (C) 2004-2005 by Latchesar Ionkov <lucho@ionkov.net> | 7 | * Copyright (C) 2004-2005 by Latchesar Ionkov <lucho@ionkov.net> |
8 | * Copyright (C) 2004-2007 by Eric Van Hensbergen <ericvh@gmail.com> | 8 | * Copyright (C) 2004-2008 by Eric Van Hensbergen <ericvh@gmail.com> |
9 | * Copyright (C) 1997-2002 by Ron Minnich <rminnich@sarnoff.com> | 9 | * Copyright (C) 1997-2002 by Ron Minnich <rminnich@sarnoff.com> |
10 | * | 10 | * |
11 | * This program is free software; you can redistribute it and/or modify | 11 | * This program is free software; you can redistribute it and/or modify |
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/module.h> | 29 | #include <linux/module.h> |
30 | #include <linux/net.h> | 30 | #include <linux/net.h> |
31 | #include <linux/ipv6.h> | 31 | #include <linux/ipv6.h> |
32 | #include <linux/kthread.h> | ||
32 | #include <linux/errno.h> | 33 | #include <linux/errno.h> |
33 | #include <linux/kernel.h> | 34 | #include <linux/kernel.h> |
34 | #include <linux/un.h> | 35 | #include <linux/un.h> |
@@ -42,7 +43,9 @@ | |||
42 | 43 | ||
43 | #define P9_PORT 564 | 44 | #define P9_PORT 564 |
44 | #define MAX_SOCK_BUF (64*1024) | 45 | #define MAX_SOCK_BUF (64*1024) |
45 | 46 | #define ERREQFLUSH 1 | |
47 | #define SCHED_TIMEOUT 10 | ||
48 | #define MAXPOLLWADDR 2 | ||
46 | 49 | ||
47 | struct p9_fd_opts { | 50 | struct p9_fd_opts { |
48 | int rfd; | 51 | int rfd; |
@@ -53,6 +56,7 @@ struct p9_fd_opts { | |||
53 | struct p9_trans_fd { | 56 | struct p9_trans_fd { |
54 | struct file *rd; | 57 | struct file *rd; |
55 | struct file *wr; | 58 | struct file *wr; |
59 | struct p9_conn *conn; | ||
56 | }; | 60 | }; |
57 | 61 | ||
58 | /* | 62 | /* |
@@ -72,6 +76,1028 @@ static match_table_t tokens = { | |||
72 | {Opt_err, NULL}, | 76 | {Opt_err, NULL}, |
73 | }; | 77 | }; |
74 | 78 | ||
79 | enum { | ||
80 | Rworksched = 1, /* read work scheduled or running */ | ||
81 | Rpending = 2, /* can read */ | ||
82 | Wworksched = 4, /* write work scheduled or running */ | ||
83 | Wpending = 8, /* can write */ | ||
84 | }; | ||
85 | |||
86 | enum { | ||
87 | None, | ||
88 | Flushing, | ||
89 | Flushed, | ||
90 | }; | ||
91 | |||
92 | struct p9_req; | ||
93 | |||
94 | typedef void (*p9_conn_req_callback)(struct p9_req *req, void *a); | ||
95 | struct p9_req { | ||
96 | spinlock_t lock; /* protect request structure */ | ||
97 | int tag; | ||
98 | struct p9_fcall *tcall; | ||
99 | struct p9_fcall *rcall; | ||
100 | int err; | ||
101 | p9_conn_req_callback cb; | ||
102 | void *cba; | ||
103 | int flush; | ||
104 | struct list_head req_list; | ||
105 | }; | ||
106 | |||
107 | struct p9_mux_poll_task; | ||
108 | |||
109 | struct p9_conn { | ||
110 | spinlock_t lock; /* protect lock structure */ | ||
111 | struct list_head mux_list; | ||
112 | struct p9_mux_poll_task *poll_task; | ||
113 | int msize; | ||
114 | unsigned char extended; | ||
115 | struct p9_trans *trans; | ||
116 | struct p9_idpool *tagpool; | ||
117 | int err; | ||
118 | wait_queue_head_t equeue; | ||
119 | struct list_head req_list; | ||
120 | struct list_head unsent_req_list; | ||
121 | struct p9_fcall *rcall; | ||
122 | int rpos; | ||
123 | char *rbuf; | ||
124 | int wpos; | ||
125 | int wsize; | ||
126 | char *wbuf; | ||
127 | wait_queue_t poll_wait[MAXPOLLWADDR]; | ||
128 | wait_queue_head_t *poll_waddr[MAXPOLLWADDR]; | ||
129 | poll_table pt; | ||
130 | struct work_struct rq; | ||
131 | struct work_struct wq; | ||
132 | unsigned long wsched; | ||
133 | }; | ||
134 | |||
135 | struct p9_mux_poll_task { | ||
136 | struct task_struct *task; | ||
137 | struct list_head mux_list; | ||
138 | int muxnum; | ||
139 | }; | ||
140 | |||
141 | struct p9_mux_rpc { | ||
142 | struct p9_conn *m; | ||
143 | int err; | ||
144 | struct p9_fcall *tcall; | ||
145 | struct p9_fcall *rcall; | ||
146 | wait_queue_head_t wqueue; | ||
147 | }; | ||
148 | |||
149 | static int p9_poll_proc(void *); | ||
150 | static void p9_read_work(struct work_struct *work); | ||
151 | static void p9_write_work(struct work_struct *work); | ||
152 | static void p9_pollwait(struct file *filp, wait_queue_head_t *wait_address, | ||
153 | poll_table *p); | ||
154 | static int p9_fd_write(struct p9_trans *trans, void *v, int len); | ||
155 | static int p9_fd_read(struct p9_trans *trans, void *v, int len); | ||
156 | |||
157 | static DEFINE_MUTEX(p9_mux_task_lock); | ||
158 | static struct workqueue_struct *p9_mux_wq; | ||
159 | |||
160 | static int p9_mux_num; | ||
161 | static int p9_mux_poll_task_num; | ||
162 | static struct p9_mux_poll_task p9_mux_poll_tasks[100]; | ||
163 | |||
164 | static void p9_conn_destroy(struct p9_conn *); | ||
165 | static unsigned int p9_fd_poll(struct p9_trans *trans, | ||
166 | struct poll_table_struct *pt); | ||
167 | |||
168 | #ifdef P9_NONBLOCK | ||
169 | static int p9_conn_rpcnb(struct p9_conn *m, struct p9_fcall *tc, | ||
170 | p9_conn_req_callback cb, void *a); | ||
171 | #endif /* P9_NONBLOCK */ | ||
172 | |||
173 | static void p9_conn_cancel(struct p9_conn *m, int err); | ||
174 | |||
175 | static int p9_mux_global_init(void) | ||
176 | { | ||
177 | int i; | ||
178 | |||
179 | for (i = 0; i < ARRAY_SIZE(p9_mux_poll_tasks); i++) | ||
180 | p9_mux_poll_tasks[i].task = NULL; | ||
181 | |||
182 | p9_mux_wq = create_workqueue("v9fs"); | ||
183 | if (!p9_mux_wq) { | ||
184 | printk(KERN_WARNING "v9fs: mux: creating workqueue failed\n"); | ||
185 | return -ENOMEM; | ||
186 | } | ||
187 | |||
188 | return 0; | ||
189 | } | ||
190 | |||
191 | static u16 p9_mux_get_tag(struct p9_conn *m) | ||
192 | { | ||
193 | int tag; | ||
194 | |||
195 | tag = p9_idpool_get(m->tagpool); | ||
196 | if (tag < 0) | ||
197 | return P9_NOTAG; | ||
198 | else | ||
199 | return (u16) tag; | ||
200 | } | ||
201 | |||
202 | static void p9_mux_put_tag(struct p9_conn *m, u16 tag) | ||
203 | { | ||
204 | if (tag != P9_NOTAG && p9_idpool_check(tag, m->tagpool)) | ||
205 | p9_idpool_put(tag, m->tagpool); | ||
206 | } | ||
207 | |||
208 | /** | ||
209 | * p9_mux_calc_poll_procs - calculates the number of polling procs | ||
210 | * based on the number of mounted v9fs filesystems. | ||
211 | * | ||
212 | * The current implementation returns sqrt of the number of mounts. | ||
213 | */ | ||
214 | static int p9_mux_calc_poll_procs(int muxnum) | ||
215 | { | ||
216 | int n; | ||
217 | |||
218 | if (p9_mux_poll_task_num) | ||
219 | n = muxnum / p9_mux_poll_task_num + | ||
220 | (muxnum % p9_mux_poll_task_num ? 1 : 0); | ||
221 | else | ||
222 | n = 1; | ||
223 | |||
224 | if (n > ARRAY_SIZE(p9_mux_poll_tasks)) | ||
225 | n = ARRAY_SIZE(p9_mux_poll_tasks); | ||
226 | |||
227 | return n; | ||
228 | } | ||
229 | |||
230 | static int p9_mux_poll_start(struct p9_conn *m) | ||
231 | { | ||
232 | int i, n; | ||
233 | struct p9_mux_poll_task *vpt, *vptlast; | ||
234 | struct task_struct *pproc; | ||
235 | |||
236 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p muxnum %d procnum %d\n", m, p9_mux_num, | ||
237 | p9_mux_poll_task_num); | ||
238 | mutex_lock(&p9_mux_task_lock); | ||
239 | |||
240 | n = p9_mux_calc_poll_procs(p9_mux_num + 1); | ||
241 | if (n > p9_mux_poll_task_num) { | ||
242 | for (i = 0; i < ARRAY_SIZE(p9_mux_poll_tasks); i++) { | ||
243 | if (p9_mux_poll_tasks[i].task == NULL) { | ||
244 | vpt = &p9_mux_poll_tasks[i]; | ||
245 | P9_DPRINTK(P9_DEBUG_MUX, "create proc %p\n", | ||
246 | vpt); | ||
247 | pproc = kthread_create(p9_poll_proc, vpt, | ||
248 | "v9fs-poll"); | ||
249 | |||
250 | if (!IS_ERR(pproc)) { | ||
251 | vpt->task = pproc; | ||
252 | INIT_LIST_HEAD(&vpt->mux_list); | ||
253 | vpt->muxnum = 0; | ||
254 | p9_mux_poll_task_num++; | ||
255 | wake_up_process(vpt->task); | ||
256 | } | ||
257 | break; | ||
258 | } | ||
259 | } | ||
260 | |||
261 | if (i >= ARRAY_SIZE(p9_mux_poll_tasks)) | ||
262 | P9_DPRINTK(P9_DEBUG_ERROR, | ||
263 | "warning: no free poll slots\n"); | ||
264 | } | ||
265 | |||
266 | n = (p9_mux_num + 1) / p9_mux_poll_task_num + | ||
267 | ((p9_mux_num + 1) % p9_mux_poll_task_num ? 1 : 0); | ||
268 | |||
269 | vptlast = NULL; | ||
270 | for (i = 0; i < ARRAY_SIZE(p9_mux_poll_tasks); i++) { | ||
271 | vpt = &p9_mux_poll_tasks[i]; | ||
272 | if (vpt->task != NULL) { | ||
273 | vptlast = vpt; | ||
274 | if (vpt->muxnum < n) { | ||
275 | P9_DPRINTK(P9_DEBUG_MUX, "put in proc %d\n", i); | ||
276 | list_add(&m->mux_list, &vpt->mux_list); | ||
277 | vpt->muxnum++; | ||
278 | m->poll_task = vpt; | ||
279 | memset(&m->poll_waddr, 0, | ||
280 | sizeof(m->poll_waddr)); | ||
281 | init_poll_funcptr(&m->pt, p9_pollwait); | ||
282 | break; | ||
283 | } | ||
284 | } | ||
285 | } | ||
286 | |||
287 | if (i >= ARRAY_SIZE(p9_mux_poll_tasks)) { | ||
288 | if (vptlast == NULL) { | ||
289 | mutex_unlock(&p9_mux_task_lock); | ||
290 | return -ENOMEM; | ||
291 | } | ||
292 | |||
293 | P9_DPRINTK(P9_DEBUG_MUX, "put in proc %d\n", i); | ||
294 | list_add(&m->mux_list, &vptlast->mux_list); | ||
295 | vptlast->muxnum++; | ||
296 | m->poll_task = vptlast; | ||
297 | memset(&m->poll_waddr, 0, sizeof(m->poll_waddr)); | ||
298 | init_poll_funcptr(&m->pt, p9_pollwait); | ||
299 | } | ||
300 | |||
301 | p9_mux_num++; | ||
302 | mutex_unlock(&p9_mux_task_lock); | ||
303 | |||
304 | return 0; | ||
305 | } | ||
306 | |||
307 | static void p9_mux_poll_stop(struct p9_conn *m) | ||
308 | { | ||
309 | int i; | ||
310 | struct p9_mux_poll_task *vpt; | ||
311 | |||
312 | mutex_lock(&p9_mux_task_lock); | ||
313 | vpt = m->poll_task; | ||
314 | list_del(&m->mux_list); | ||
315 | for (i = 0; i < ARRAY_SIZE(m->poll_waddr); i++) { | ||
316 | if (m->poll_waddr[i] != NULL) { | ||
317 | remove_wait_queue(m->poll_waddr[i], &m->poll_wait[i]); | ||
318 | m->poll_waddr[i] = NULL; | ||
319 | } | ||
320 | } | ||
321 | vpt->muxnum--; | ||
322 | if (!vpt->muxnum) { | ||
323 | P9_DPRINTK(P9_DEBUG_MUX, "destroy proc %p\n", vpt); | ||
324 | kthread_stop(vpt->task); | ||
325 | vpt->task = NULL; | ||
326 | p9_mux_poll_task_num--; | ||
327 | } | ||
328 | p9_mux_num--; | ||
329 | mutex_unlock(&p9_mux_task_lock); | ||
330 | } | ||
331 | |||
332 | /** | ||
333 | * p9_conn_create - allocate and initialize the per-session mux data | ||
334 | * Creates the polling task if this is the first session. | ||
335 | * | ||
336 | * @trans - transport structure | ||
337 | * @msize - maximum message size | ||
338 | * @extended - extended flag | ||
339 | */ | ||
340 | static struct p9_conn *p9_conn_create(struct p9_trans *trans) | ||
341 | { | ||
342 | int i, n; | ||
343 | struct p9_conn *m, *mtmp; | ||
344 | |||
345 | P9_DPRINTK(P9_DEBUG_MUX, "transport %p msize %d\n", trans, | ||
346 | trans->msize); | ||
347 | m = kmalloc(sizeof(struct p9_conn), GFP_KERNEL); | ||
348 | if (!m) | ||
349 | return ERR_PTR(-ENOMEM); | ||
350 | |||
351 | spin_lock_init(&m->lock); | ||
352 | INIT_LIST_HEAD(&m->mux_list); | ||
353 | m->msize = trans->msize; | ||
354 | m->extended = trans->extended; | ||
355 | m->trans = trans; | ||
356 | m->tagpool = p9_idpool_create(); | ||
357 | if (IS_ERR(m->tagpool)) { | ||
358 | mtmp = ERR_PTR(-ENOMEM); | ||
359 | kfree(m); | ||
360 | return mtmp; | ||
361 | } | ||
362 | |||
363 | m->err = 0; | ||
364 | init_waitqueue_head(&m->equeue); | ||
365 | INIT_LIST_HEAD(&m->req_list); | ||
366 | INIT_LIST_HEAD(&m->unsent_req_list); | ||
367 | m->rcall = NULL; | ||
368 | m->rpos = 0; | ||
369 | m->rbuf = NULL; | ||
370 | m->wpos = m->wsize = 0; | ||
371 | m->wbuf = NULL; | ||
372 | INIT_WORK(&m->rq, p9_read_work); | ||
373 | INIT_WORK(&m->wq, p9_write_work); | ||
374 | m->wsched = 0; | ||
375 | memset(&m->poll_waddr, 0, sizeof(m->poll_waddr)); | ||
376 | m->poll_task = NULL; | ||
377 | n = p9_mux_poll_start(m); | ||
378 | if (n) { | ||
379 | kfree(m); | ||
380 | return ERR_PTR(n); | ||
381 | } | ||
382 | |||
383 | n = p9_fd_poll(trans, &m->pt); | ||
384 | if (n & POLLIN) { | ||
385 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p can read\n", m); | ||
386 | set_bit(Rpending, &m->wsched); | ||
387 | } | ||
388 | |||
389 | if (n & POLLOUT) { | ||
390 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p can write\n", m); | ||
391 | set_bit(Wpending, &m->wsched); | ||
392 | } | ||
393 | |||
394 | for (i = 0; i < ARRAY_SIZE(m->poll_waddr); i++) { | ||
395 | if (IS_ERR(m->poll_waddr[i])) { | ||
396 | p9_mux_poll_stop(m); | ||
397 | mtmp = (void *)m->poll_waddr; /* the error code */ | ||
398 | kfree(m); | ||
399 | m = mtmp; | ||
400 | break; | ||
401 | } | ||
402 | } | ||
403 | |||
404 | return m; | ||
405 | } | ||
406 | |||
407 | /** | ||
408 | * p9_mux_destroy - cancels all pending requests and frees mux resources | ||
409 | */ | ||
410 | static void p9_conn_destroy(struct p9_conn *m) | ||
411 | { | ||
412 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p prev %p next %p\n", m, | ||
413 | m->mux_list.prev, m->mux_list.next); | ||
414 | p9_conn_cancel(m, -ECONNRESET); | ||
415 | |||
416 | if (!list_empty(&m->req_list)) { | ||
417 | /* wait until all processes waiting on this session exit */ | ||
418 | P9_DPRINTK(P9_DEBUG_MUX, | ||
419 | "mux %p waiting for empty request queue\n", m); | ||
420 | wait_event_timeout(m->equeue, (list_empty(&m->req_list)), 5000); | ||
421 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p request queue empty: %d\n", m, | ||
422 | list_empty(&m->req_list)); | ||
423 | } | ||
424 | |||
425 | p9_mux_poll_stop(m); | ||
426 | m->trans = NULL; | ||
427 | p9_idpool_destroy(m->tagpool); | ||
428 | kfree(m); | ||
429 | } | ||
430 | |||
431 | /** | ||
432 | * p9_pollwait - called by files poll operation to add v9fs-poll task | ||
433 | * to files wait queue | ||
434 | */ | ||
435 | static void | ||
436 | p9_pollwait(struct file *filp, wait_queue_head_t *wait_address, poll_table *p) | ||
437 | { | ||
438 | int i; | ||
439 | struct p9_conn *m; | ||
440 | |||
441 | m = container_of(p, struct p9_conn, pt); | ||
442 | for (i = 0; i < ARRAY_SIZE(m->poll_waddr); i++) | ||
443 | if (m->poll_waddr[i] == NULL) | ||
444 | break; | ||
445 | |||
446 | if (i >= ARRAY_SIZE(m->poll_waddr)) { | ||
447 | P9_DPRINTK(P9_DEBUG_ERROR, "not enough wait_address slots\n"); | ||
448 | return; | ||
449 | } | ||
450 | |||
451 | m->poll_waddr[i] = wait_address; | ||
452 | |||
453 | if (!wait_address) { | ||
454 | P9_DPRINTK(P9_DEBUG_ERROR, "no wait_address\n"); | ||
455 | m->poll_waddr[i] = ERR_PTR(-EIO); | ||
456 | return; | ||
457 | } | ||
458 | |||
459 | init_waitqueue_entry(&m->poll_wait[i], m->poll_task->task); | ||
460 | add_wait_queue(wait_address, &m->poll_wait[i]); | ||
461 | } | ||
462 | |||
463 | /** | ||
464 | * p9_poll_mux - polls a mux and schedules read or write works if necessary | ||
465 | */ | ||
466 | static void p9_poll_mux(struct p9_conn *m) | ||
467 | { | ||
468 | int n; | ||
469 | |||
470 | if (m->err < 0) | ||
471 | return; | ||
472 | |||
473 | n = p9_fd_poll(m->trans, NULL); | ||
474 | if (n < 0 || n & (POLLERR | POLLHUP | POLLNVAL)) { | ||
475 | P9_DPRINTK(P9_DEBUG_MUX, "error mux %p err %d\n", m, n); | ||
476 | if (n >= 0) | ||
477 | n = -ECONNRESET; | ||
478 | p9_conn_cancel(m, n); | ||
479 | } | ||
480 | |||
481 | if (n & POLLIN) { | ||
482 | set_bit(Rpending, &m->wsched); | ||
483 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p can read\n", m); | ||
484 | if (!test_and_set_bit(Rworksched, &m->wsched)) { | ||
485 | P9_DPRINTK(P9_DEBUG_MUX, "schedule read work %p\n", m); | ||
486 | queue_work(p9_mux_wq, &m->rq); | ||
487 | } | ||
488 | } | ||
489 | |||
490 | if (n & POLLOUT) { | ||
491 | set_bit(Wpending, &m->wsched); | ||
492 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p can write\n", m); | ||
493 | if ((m->wsize || !list_empty(&m->unsent_req_list)) | ||
494 | && !test_and_set_bit(Wworksched, &m->wsched)) { | ||
495 | P9_DPRINTK(P9_DEBUG_MUX, "schedule write work %p\n", m); | ||
496 | queue_work(p9_mux_wq, &m->wq); | ||
497 | } | ||
498 | } | ||
499 | } | ||
500 | |||
501 | /** | ||
502 | * p9_poll_proc - polls all v9fs transports for new events and queues | ||
503 | * the appropriate work to the work queue | ||
504 | */ | ||
505 | static int p9_poll_proc(void *a) | ||
506 | { | ||
507 | struct p9_conn *m, *mtmp; | ||
508 | struct p9_mux_poll_task *vpt; | ||
509 | |||
510 | vpt = a; | ||
511 | P9_DPRINTK(P9_DEBUG_MUX, "start %p %p\n", current, vpt); | ||
512 | while (!kthread_should_stop()) { | ||
513 | set_current_state(TASK_INTERRUPTIBLE); | ||
514 | |||
515 | list_for_each_entry_safe(m, mtmp, &vpt->mux_list, mux_list) { | ||
516 | p9_poll_mux(m); | ||
517 | } | ||
518 | |||
519 | P9_DPRINTK(P9_DEBUG_MUX, "sleeping...\n"); | ||
520 | schedule_timeout(SCHED_TIMEOUT * HZ); | ||
521 | } | ||
522 | |||
523 | __set_current_state(TASK_RUNNING); | ||
524 | P9_DPRINTK(P9_DEBUG_MUX, "finish\n"); | ||
525 | return 0; | ||
526 | } | ||
527 | |||
528 | /** | ||
529 | * p9_write_work - called when a transport can send some data | ||
530 | */ | ||
531 | static void p9_write_work(struct work_struct *work) | ||
532 | { | ||
533 | int n, err; | ||
534 | struct p9_conn *m; | ||
535 | struct p9_req *req; | ||
536 | |||
537 | m = container_of(work, struct p9_conn, wq); | ||
538 | |||
539 | if (m->err < 0) { | ||
540 | clear_bit(Wworksched, &m->wsched); | ||
541 | return; | ||
542 | } | ||
543 | |||
544 | if (!m->wsize) { | ||
545 | if (list_empty(&m->unsent_req_list)) { | ||
546 | clear_bit(Wworksched, &m->wsched); | ||
547 | return; | ||
548 | } | ||
549 | |||
550 | spin_lock(&m->lock); | ||
551 | again: | ||
552 | req = list_entry(m->unsent_req_list.next, struct p9_req, | ||
553 | req_list); | ||
554 | list_move_tail(&req->req_list, &m->req_list); | ||
555 | if (req->err == ERREQFLUSH) | ||
556 | goto again; | ||
557 | |||
558 | m->wbuf = req->tcall->sdata; | ||
559 | m->wsize = req->tcall->size; | ||
560 | m->wpos = 0; | ||
561 | spin_unlock(&m->lock); | ||
562 | } | ||
563 | |||
564 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p pos %d size %d\n", m, m->wpos, | ||
565 | m->wsize); | ||
566 | clear_bit(Wpending, &m->wsched); | ||
567 | err = p9_fd_write(m->trans, m->wbuf + m->wpos, m->wsize - m->wpos); | ||
568 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p sent %d bytes\n", m, err); | ||
569 | if (err == -EAGAIN) { | ||
570 | clear_bit(Wworksched, &m->wsched); | ||
571 | return; | ||
572 | } | ||
573 | |||
574 | if (err < 0) | ||
575 | goto error; | ||
576 | else if (err == 0) { | ||
577 | err = -EREMOTEIO; | ||
578 | goto error; | ||
579 | } | ||
580 | |||
581 | m->wpos += err; | ||
582 | if (m->wpos == m->wsize) | ||
583 | m->wpos = m->wsize = 0; | ||
584 | |||
585 | if (m->wsize == 0 && !list_empty(&m->unsent_req_list)) { | ||
586 | if (test_and_clear_bit(Wpending, &m->wsched)) | ||
587 | n = POLLOUT; | ||
588 | else | ||
589 | n = p9_fd_poll(m->trans, NULL); | ||
590 | |||
591 | if (n & POLLOUT) { | ||
592 | P9_DPRINTK(P9_DEBUG_MUX, "schedule write work %p\n", m); | ||
593 | queue_work(p9_mux_wq, &m->wq); | ||
594 | } else | ||
595 | clear_bit(Wworksched, &m->wsched); | ||
596 | } else | ||
597 | clear_bit(Wworksched, &m->wsched); | ||
598 | |||
599 | return; | ||
600 | |||
601 | error: | ||
602 | p9_conn_cancel(m, err); | ||
603 | clear_bit(Wworksched, &m->wsched); | ||
604 | } | ||
605 | |||
606 | static void process_request(struct p9_conn *m, struct p9_req *req) | ||
607 | { | ||
608 | int ecode; | ||
609 | struct p9_str *ename; | ||
610 | |||
611 | if (!req->err && req->rcall->id == P9_RERROR) { | ||
612 | ecode = req->rcall->params.rerror.errno; | ||
613 | ename = &req->rcall->params.rerror.error; | ||
614 | |||
615 | P9_DPRINTK(P9_DEBUG_MUX, "Rerror %.*s\n", ename->len, | ||
616 | ename->str); | ||
617 | |||
618 | if (m->extended) | ||
619 | req->err = -ecode; | ||
620 | |||
621 | if (!req->err) { | ||
622 | req->err = p9_errstr2errno(ename->str, ename->len); | ||
623 | |||
624 | /* string match failed */ | ||
625 | if (!req->err) { | ||
626 | PRINT_FCALL_ERROR("unknown error", req->rcall); | ||
627 | req->err = -ESERVERFAULT; | ||
628 | } | ||
629 | } | ||
630 | } else if (req->tcall && req->rcall->id != req->tcall->id + 1) { | ||
631 | P9_DPRINTK(P9_DEBUG_ERROR, | ||
632 | "fcall mismatch: expected %d, got %d\n", | ||
633 | req->tcall->id + 1, req->rcall->id); | ||
634 | if (!req->err) | ||
635 | req->err = -EIO; | ||
636 | } | ||
637 | } | ||
638 | |||
639 | /** | ||
640 | * p9_read_work - called when there is some data to be read from a transport | ||
641 | */ | ||
642 | static void p9_read_work(struct work_struct *work) | ||
643 | { | ||
644 | int n, err; | ||
645 | struct p9_conn *m; | ||
646 | struct p9_req *req, *rptr, *rreq; | ||
647 | struct p9_fcall *rcall; | ||
648 | char *rbuf; | ||
649 | |||
650 | m = container_of(work, struct p9_conn, rq); | ||
651 | |||
652 | if (m->err < 0) | ||
653 | return; | ||
654 | |||
655 | rcall = NULL; | ||
656 | P9_DPRINTK(P9_DEBUG_MUX, "start mux %p pos %d\n", m, m->rpos); | ||
657 | |||
658 | if (!m->rcall) { | ||
659 | m->rcall = | ||
660 | kmalloc(sizeof(struct p9_fcall) + m->msize, GFP_KERNEL); | ||
661 | if (!m->rcall) { | ||
662 | err = -ENOMEM; | ||
663 | goto error; | ||
664 | } | ||
665 | |||
666 | m->rbuf = (char *)m->rcall + sizeof(struct p9_fcall); | ||
667 | m->rpos = 0; | ||
668 | } | ||
669 | |||
670 | clear_bit(Rpending, &m->wsched); | ||
671 | err = p9_fd_read(m->trans, m->rbuf + m->rpos, m->msize - m->rpos); | ||
672 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p got %d bytes\n", m, err); | ||
673 | if (err == -EAGAIN) { | ||
674 | clear_bit(Rworksched, &m->wsched); | ||
675 | return; | ||
676 | } | ||
677 | |||
678 | if (err <= 0) | ||
679 | goto error; | ||
680 | |||
681 | m->rpos += err; | ||
682 | while (m->rpos > 4) { | ||
683 | n = le32_to_cpu(*(__le32 *) m->rbuf); | ||
684 | if (n >= m->msize) { | ||
685 | P9_DPRINTK(P9_DEBUG_ERROR, | ||
686 | "requested packet size too big: %d\n", n); | ||
687 | err = -EIO; | ||
688 | goto error; | ||
689 | } | ||
690 | |||
691 | if (m->rpos < n) | ||
692 | break; | ||
693 | |||
694 | err = | ||
695 | p9_deserialize_fcall(m->rbuf, n, m->rcall, m->extended); | ||
696 | if (err < 0) | ||
697 | goto error; | ||
698 | |||
699 | #ifdef CONFIG_NET_9P_DEBUG | ||
700 | if ((p9_debug_level&P9_DEBUG_FCALL) == P9_DEBUG_FCALL) { | ||
701 | char buf[150]; | ||
702 | |||
703 | p9_printfcall(buf, sizeof(buf), m->rcall, | ||
704 | m->extended); | ||
705 | printk(KERN_NOTICE ">>> %p %s\n", m, buf); | ||
706 | } | ||
707 | #endif | ||
708 | |||
709 | rcall = m->rcall; | ||
710 | rbuf = m->rbuf; | ||
711 | if (m->rpos > n) { | ||
712 | m->rcall = kmalloc(sizeof(struct p9_fcall) + m->msize, | ||
713 | GFP_KERNEL); | ||
714 | if (!m->rcall) { | ||
715 | err = -ENOMEM; | ||
716 | goto error; | ||
717 | } | ||
718 | |||
719 | m->rbuf = (char *)m->rcall + sizeof(struct p9_fcall); | ||
720 | memmove(m->rbuf, rbuf + n, m->rpos - n); | ||
721 | m->rpos -= n; | ||
722 | } else { | ||
723 | m->rcall = NULL; | ||
724 | m->rbuf = NULL; | ||
725 | m->rpos = 0; | ||
726 | } | ||
727 | |||
728 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p fcall id %d tag %d\n", m, | ||
729 | rcall->id, rcall->tag); | ||
730 | |||
731 | req = NULL; | ||
732 | spin_lock(&m->lock); | ||
733 | list_for_each_entry_safe(rreq, rptr, &m->req_list, req_list) { | ||
734 | if (rreq->tag == rcall->tag) { | ||
735 | req = rreq; | ||
736 | if (req->flush != Flushing) | ||
737 | list_del(&req->req_list); | ||
738 | break; | ||
739 | } | ||
740 | } | ||
741 | spin_unlock(&m->lock); | ||
742 | |||
743 | if (req) { | ||
744 | req->rcall = rcall; | ||
745 | process_request(m, req); | ||
746 | |||
747 | if (req->flush != Flushing) { | ||
748 | if (req->cb) | ||
749 | (*req->cb) (req, req->cba); | ||
750 | else | ||
751 | kfree(req->rcall); | ||
752 | |||
753 | wake_up(&m->equeue); | ||
754 | } | ||
755 | } else { | ||
756 | if (err >= 0 && rcall->id != P9_RFLUSH) | ||
757 | P9_DPRINTK(P9_DEBUG_ERROR, | ||
758 | "unexpected response mux %p id %d tag %d\n", | ||
759 | m, rcall->id, rcall->tag); | ||
760 | kfree(rcall); | ||
761 | } | ||
762 | } | ||
763 | |||
764 | if (!list_empty(&m->req_list)) { | ||
765 | if (test_and_clear_bit(Rpending, &m->wsched)) | ||
766 | n = POLLIN; | ||
767 | else | ||
768 | n = p9_fd_poll(m->trans, NULL); | ||
769 | |||
770 | if (n & POLLIN) { | ||
771 | P9_DPRINTK(P9_DEBUG_MUX, "schedule read work %p\n", m); | ||
772 | queue_work(p9_mux_wq, &m->rq); | ||
773 | } else | ||
774 | clear_bit(Rworksched, &m->wsched); | ||
775 | } else | ||
776 | clear_bit(Rworksched, &m->wsched); | ||
777 | |||
778 | return; | ||
779 | |||
780 | error: | ||
781 | p9_conn_cancel(m, err); | ||
782 | clear_bit(Rworksched, &m->wsched); | ||
783 | } | ||
784 | |||
785 | /** | ||
786 | * p9_send_request - send 9P request | ||
787 | * The function can sleep until the request is scheduled for sending. | ||
788 | * The function can be interrupted. Return from the function is not | ||
789 | * a guarantee that the request is sent successfully. Can return errors | ||
790 | * that can be retrieved by PTR_ERR macros. | ||
791 | * | ||
792 | * @m: mux data | ||
793 | * @tc: request to be sent | ||
794 | * @cb: callback function to call when response is received | ||
795 | * @cba: parameter to pass to the callback function | ||
796 | */ | ||
797 | static struct p9_req *p9_send_request(struct p9_conn *m, | ||
798 | struct p9_fcall *tc, | ||
799 | p9_conn_req_callback cb, void *cba) | ||
800 | { | ||
801 | int n; | ||
802 | struct p9_req *req; | ||
803 | |||
804 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p task %p tcall %p id %d\n", m, current, | ||
805 | tc, tc->id); | ||
806 | if (m->err < 0) | ||
807 | return ERR_PTR(m->err); | ||
808 | |||
809 | req = kmalloc(sizeof(struct p9_req), GFP_KERNEL); | ||
810 | if (!req) | ||
811 | return ERR_PTR(-ENOMEM); | ||
812 | |||
813 | if (tc->id == P9_TVERSION) | ||
814 | n = P9_NOTAG; | ||
815 | else | ||
816 | n = p9_mux_get_tag(m); | ||
817 | |||
818 | if (n < 0) | ||
819 | return ERR_PTR(-ENOMEM); | ||
820 | |||
821 | p9_set_tag(tc, n); | ||
822 | |||
823 | #ifdef CONFIG_NET_9P_DEBUG | ||
824 | if ((p9_debug_level&P9_DEBUG_FCALL) == P9_DEBUG_FCALL) { | ||
825 | char buf[150]; | ||
826 | |||
827 | p9_printfcall(buf, sizeof(buf), tc, m->extended); | ||
828 | printk(KERN_NOTICE "<<< %p %s\n", m, buf); | ||
829 | } | ||
830 | #endif | ||
831 | |||
832 | spin_lock_init(&req->lock); | ||
833 | req->tag = n; | ||
834 | req->tcall = tc; | ||
835 | req->rcall = NULL; | ||
836 | req->err = 0; | ||
837 | req->cb = cb; | ||
838 | req->cba = cba; | ||
839 | req->flush = None; | ||
840 | |||
841 | spin_lock(&m->lock); | ||
842 | list_add_tail(&req->req_list, &m->unsent_req_list); | ||
843 | spin_unlock(&m->lock); | ||
844 | |||
845 | if (test_and_clear_bit(Wpending, &m->wsched)) | ||
846 | n = POLLOUT; | ||
847 | else | ||
848 | n = p9_fd_poll(m->trans, NULL); | ||
849 | |||
850 | if (n & POLLOUT && !test_and_set_bit(Wworksched, &m->wsched)) | ||
851 | queue_work(p9_mux_wq, &m->wq); | ||
852 | |||
853 | return req; | ||
854 | } | ||
855 | |||
856 | static void p9_mux_free_request(struct p9_conn *m, struct p9_req *req) | ||
857 | { | ||
858 | p9_mux_put_tag(m, req->tag); | ||
859 | kfree(req); | ||
860 | } | ||
861 | |||
862 | static void p9_mux_flush_cb(struct p9_req *freq, void *a) | ||
863 | { | ||
864 | p9_conn_req_callback cb; | ||
865 | int tag; | ||
866 | struct p9_conn *m; | ||
867 | struct p9_req *req, *rreq, *rptr; | ||
868 | |||
869 | m = a; | ||
870 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p tc %p rc %p err %d oldtag %d\n", m, | ||
871 | freq->tcall, freq->rcall, freq->err, | ||
872 | freq->tcall->params.tflush.oldtag); | ||
873 | |||
874 | spin_lock(&m->lock); | ||
875 | cb = NULL; | ||
876 | tag = freq->tcall->params.tflush.oldtag; | ||
877 | req = NULL; | ||
878 | list_for_each_entry_safe(rreq, rptr, &m->req_list, req_list) { | ||
879 | if (rreq->tag == tag) { | ||
880 | req = rreq; | ||
881 | list_del(&req->req_list); | ||
882 | break; | ||
883 | } | ||
884 | } | ||
885 | spin_unlock(&m->lock); | ||
886 | |||
887 | if (req) { | ||
888 | spin_lock(&req->lock); | ||
889 | req->flush = Flushed; | ||
890 | spin_unlock(&req->lock); | ||
891 | |||
892 | if (req->cb) | ||
893 | (*req->cb) (req, req->cba); | ||
894 | else | ||
895 | kfree(req->rcall); | ||
896 | |||
897 | wake_up(&m->equeue); | ||
898 | } | ||
899 | |||
900 | kfree(freq->tcall); | ||
901 | kfree(freq->rcall); | ||
902 | p9_mux_free_request(m, freq); | ||
903 | } | ||
904 | |||
905 | static int | ||
906 | p9_mux_flush_request(struct p9_conn *m, struct p9_req *req) | ||
907 | { | ||
908 | struct p9_fcall *fc; | ||
909 | struct p9_req *rreq, *rptr; | ||
910 | |||
911 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p req %p tag %d\n", m, req, req->tag); | ||
912 | |||
913 | /* if a response was received for a request, do nothing */ | ||
914 | spin_lock(&req->lock); | ||
915 | if (req->rcall || req->err) { | ||
916 | spin_unlock(&req->lock); | ||
917 | P9_DPRINTK(P9_DEBUG_MUX, | ||
918 | "mux %p req %p response already received\n", m, req); | ||
919 | return 0; | ||
920 | } | ||
921 | |||
922 | req->flush = Flushing; | ||
923 | spin_unlock(&req->lock); | ||
924 | |||
925 | spin_lock(&m->lock); | ||
926 | /* if the request is not sent yet, just remove it from the list */ | ||
927 | list_for_each_entry_safe(rreq, rptr, &m->unsent_req_list, req_list) { | ||
928 | if (rreq->tag == req->tag) { | ||
929 | P9_DPRINTK(P9_DEBUG_MUX, | ||
930 | "mux %p req %p request is not sent yet\n", m, req); | ||
931 | list_del(&rreq->req_list); | ||
932 | req->flush = Flushed; | ||
933 | spin_unlock(&m->lock); | ||
934 | if (req->cb) | ||
935 | (*req->cb) (req, req->cba); | ||
936 | return 0; | ||
937 | } | ||
938 | } | ||
939 | spin_unlock(&m->lock); | ||
940 | |||
941 | clear_thread_flag(TIF_SIGPENDING); | ||
942 | fc = p9_create_tflush(req->tag); | ||
943 | p9_send_request(m, fc, p9_mux_flush_cb, m); | ||
944 | return 1; | ||
945 | } | ||
946 | |||
947 | static void | ||
948 | p9_conn_rpc_cb(struct p9_req *req, void *a) | ||
949 | { | ||
950 | struct p9_mux_rpc *r; | ||
951 | |||
952 | P9_DPRINTK(P9_DEBUG_MUX, "req %p r %p\n", req, a); | ||
953 | r = a; | ||
954 | r->rcall = req->rcall; | ||
955 | r->err = req->err; | ||
956 | |||
957 | if (req->flush != None && !req->err) | ||
958 | r->err = -ERESTARTSYS; | ||
959 | |||
960 | wake_up(&r->wqueue); | ||
961 | } | ||
962 | |||
963 | /** | ||
964 | * p9_fd_rpc- sends 9P request and waits until a response is available. | ||
965 | * The function can be interrupted. | ||
966 | * @m: mux data | ||
967 | * @tc: request to be sent | ||
968 | * @rc: pointer where a pointer to the response is stored | ||
969 | */ | ||
970 | int | ||
971 | p9_fd_rpc(struct p9_trans *t, struct p9_fcall *tc, struct p9_fcall **rc) | ||
972 | { | ||
973 | struct p9_trans_fd *p = t->priv; | ||
974 | struct p9_conn *m = p->conn; | ||
975 | int err, sigpending; | ||
976 | unsigned long flags; | ||
977 | struct p9_req *req; | ||
978 | struct p9_mux_rpc r; | ||
979 | |||
980 | r.err = 0; | ||
981 | r.tcall = tc; | ||
982 | r.rcall = NULL; | ||
983 | r.m = m; | ||
984 | init_waitqueue_head(&r.wqueue); | ||
985 | |||
986 | if (rc) | ||
987 | *rc = NULL; | ||
988 | |||
989 | sigpending = 0; | ||
990 | if (signal_pending(current)) { | ||
991 | sigpending = 1; | ||
992 | clear_thread_flag(TIF_SIGPENDING); | ||
993 | } | ||
994 | |||
995 | req = p9_send_request(m, tc, p9_conn_rpc_cb, &r); | ||
996 | if (IS_ERR(req)) { | ||
997 | err = PTR_ERR(req); | ||
998 | P9_DPRINTK(P9_DEBUG_MUX, "error %d\n", err); | ||
999 | return err; | ||
1000 | } | ||
1001 | |||
1002 | err = wait_event_interruptible(r.wqueue, r.rcall != NULL || r.err < 0); | ||
1003 | if (r.err < 0) | ||
1004 | err = r.err; | ||
1005 | |||
1006 | if (err == -ERESTARTSYS && m->trans->status == Connected | ||
1007 | && m->err == 0) { | ||
1008 | if (p9_mux_flush_request(m, req)) { | ||
1009 | /* wait until we get response of the flush message */ | ||
1010 | do { | ||
1011 | clear_thread_flag(TIF_SIGPENDING); | ||
1012 | err = wait_event_interruptible(r.wqueue, | ||
1013 | r.rcall || r.err); | ||
1014 | } while (!r.rcall && !r.err && err == -ERESTARTSYS && | ||
1015 | m->trans->status == Connected && !m->err); | ||
1016 | |||
1017 | err = -ERESTARTSYS; | ||
1018 | } | ||
1019 | sigpending = 1; | ||
1020 | } | ||
1021 | |||
1022 | if (sigpending) { | ||
1023 | spin_lock_irqsave(¤t->sighand->siglock, flags); | ||
1024 | recalc_sigpending(); | ||
1025 | spin_unlock_irqrestore(¤t->sighand->siglock, flags); | ||
1026 | } | ||
1027 | |||
1028 | if (rc) | ||
1029 | *rc = r.rcall; | ||
1030 | else | ||
1031 | kfree(r.rcall); | ||
1032 | |||
1033 | p9_mux_free_request(m, req); | ||
1034 | if (err > 0) | ||
1035 | err = -EIO; | ||
1036 | |||
1037 | return err; | ||
1038 | } | ||
1039 | |||
1040 | #ifdef P9_NONBLOCK | ||
1041 | /** | ||
1042 | * p9_conn_rpcnb - sends 9P request without waiting for response. | ||
1043 | * @m: mux data | ||
1044 | * @tc: request to be sent | ||
1045 | * @cb: callback function to be called when response arrives | ||
1046 | * @cba: value to pass to the callback function | ||
1047 | */ | ||
1048 | int p9_conn_rpcnb(struct p9_conn *m, struct p9_fcall *tc, | ||
1049 | p9_conn_req_callback cb, void *a) | ||
1050 | { | ||
1051 | int err; | ||
1052 | struct p9_req *req; | ||
1053 | |||
1054 | req = p9_send_request(m, tc, cb, a); | ||
1055 | if (IS_ERR(req)) { | ||
1056 | err = PTR_ERR(req); | ||
1057 | P9_DPRINTK(P9_DEBUG_MUX, "error %d\n", err); | ||
1058 | return PTR_ERR(req); | ||
1059 | } | ||
1060 | |||
1061 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p tc %p tag %d\n", m, tc, req->tag); | ||
1062 | return 0; | ||
1063 | } | ||
1064 | #endif /* P9_NONBLOCK */ | ||
1065 | |||
1066 | /** | ||
1067 | * p9_conn_cancel - cancel all pending requests with error | ||
1068 | * @m: mux data | ||
1069 | * @err: error code | ||
1070 | */ | ||
1071 | void p9_conn_cancel(struct p9_conn *m, int err) | ||
1072 | { | ||
1073 | struct p9_req *req, *rtmp; | ||
1074 | LIST_HEAD(cancel_list); | ||
1075 | |||
1076 | P9_DPRINTK(P9_DEBUG_ERROR, "mux %p err %d\n", m, err); | ||
1077 | m->err = err; | ||
1078 | spin_lock(&m->lock); | ||
1079 | list_for_each_entry_safe(req, rtmp, &m->req_list, req_list) { | ||
1080 | list_move(&req->req_list, &cancel_list); | ||
1081 | } | ||
1082 | list_for_each_entry_safe(req, rtmp, &m->unsent_req_list, req_list) { | ||
1083 | list_move(&req->req_list, &cancel_list); | ||
1084 | } | ||
1085 | spin_unlock(&m->lock); | ||
1086 | |||
1087 | list_for_each_entry_safe(req, rtmp, &cancel_list, req_list) { | ||
1088 | list_del(&req->req_list); | ||
1089 | if (!req->err) | ||
1090 | req->err = err; | ||
1091 | |||
1092 | if (req->cb) | ||
1093 | (*req->cb) (req, req->cba); | ||
1094 | else | ||
1095 | kfree(req->rcall); | ||
1096 | } | ||
1097 | |||
1098 | wake_up(&m->equeue); | ||
1099 | } | ||
1100 | |||
75 | /** | 1101 | /** |
76 | * v9fs_parse_options - parse mount options into session structure | 1102 | * v9fs_parse_options - parse mount options into session structure |
77 | * @options: options string passed from mount | 1103 | * @options: options string passed from mount |
@@ -268,7 +1294,7 @@ end: | |||
268 | } | 1294 | } |
269 | 1295 | ||
270 | /** | 1296 | /** |
271 | * p9_sock_close - shutdown socket | 1297 | * p9_fd_close - shutdown socket |
272 | * @trans: private socket structure | 1298 | * @trans: private socket structure |
273 | * | 1299 | * |
274 | */ | 1300 | */ |
@@ -284,6 +1310,8 @@ static void p9_fd_close(struct p9_trans *trans) | |||
284 | if (!ts) | 1310 | if (!ts) |
285 | return; | 1311 | return; |
286 | 1312 | ||
1313 | p9_conn_destroy(ts->conn); | ||
1314 | |||
287 | trans->status = Disconnected; | 1315 | trans->status = Disconnected; |
288 | if (ts->rd) | 1316 | if (ts->rd) |
289 | fput(ts->rd); | 1317 | fput(ts->rd); |
@@ -292,13 +1320,15 @@ static void p9_fd_close(struct p9_trans *trans) | |||
292 | kfree(ts); | 1320 | kfree(ts); |
293 | } | 1321 | } |
294 | 1322 | ||
295 | static struct p9_trans *p9_trans_create_tcp(const char *addr, char *args) | 1323 | static struct p9_trans * |
1324 | p9_trans_create_tcp(const char *addr, char *args, int msize, unsigned char dotu) | ||
296 | { | 1325 | { |
297 | int err; | 1326 | int err; |
298 | struct p9_trans *trans; | 1327 | struct p9_trans *trans; |
299 | struct socket *csocket; | 1328 | struct socket *csocket; |
300 | struct sockaddr_in sin_server; | 1329 | struct sockaddr_in sin_server; |
301 | struct p9_fd_opts opts; | 1330 | struct p9_fd_opts opts; |
1331 | struct p9_trans_fd *p; | ||
302 | 1332 | ||
303 | parse_opts(args, &opts); | 1333 | parse_opts(args, &opts); |
304 | 1334 | ||
@@ -306,11 +1336,10 @@ static struct p9_trans *p9_trans_create_tcp(const char *addr, char *args) | |||
306 | trans = kmalloc(sizeof(struct p9_trans), GFP_KERNEL); | 1336 | trans = kmalloc(sizeof(struct p9_trans), GFP_KERNEL); |
307 | if (!trans) | 1337 | if (!trans) |
308 | return ERR_PTR(-ENOMEM); | 1338 | return ERR_PTR(-ENOMEM); |
309 | 1339 | trans->msize = msize; | |
310 | trans->write = p9_fd_write; | 1340 | trans->extended = dotu; |
311 | trans->read = p9_fd_read; | 1341 | trans->rpc = p9_fd_rpc; |
312 | trans->close = p9_fd_close; | 1342 | trans->close = p9_fd_close; |
313 | trans->poll = p9_fd_poll; | ||
314 | 1343 | ||
315 | sin_server.sin_family = AF_INET; | 1344 | sin_server.sin_family = AF_INET; |
316 | sin_server.sin_addr.s_addr = in_aton(addr); | 1345 | sin_server.sin_addr.s_addr = in_aton(addr); |
@@ -337,6 +1366,14 @@ static struct p9_trans *p9_trans_create_tcp(const char *addr, char *args) | |||
337 | if (err < 0) | 1366 | if (err < 0) |
338 | goto error; | 1367 | goto error; |
339 | 1368 | ||
1369 | p = (struct p9_trans_fd *) trans->priv; | ||
1370 | p->conn = p9_conn_create(trans); | ||
1371 | if (IS_ERR(p->conn)) { | ||
1372 | err = PTR_ERR(p->conn); | ||
1373 | p->conn = NULL; | ||
1374 | goto error; | ||
1375 | } | ||
1376 | |||
340 | return trans; | 1377 | return trans; |
341 | 1378 | ||
342 | error: | 1379 | error: |
@@ -347,22 +1384,23 @@ error: | |||
347 | return ERR_PTR(err); | 1384 | return ERR_PTR(err); |
348 | } | 1385 | } |
349 | 1386 | ||
350 | static struct p9_trans *p9_trans_create_unix(const char *addr, char *args) | 1387 | static struct p9_trans * |
1388 | p9_trans_create_unix(const char *addr, char *args, int msize, | ||
1389 | unsigned char dotu) | ||
351 | { | 1390 | { |
352 | int err; | 1391 | int err; |
353 | struct socket *csocket; | 1392 | struct socket *csocket; |
354 | struct sockaddr_un sun_server; | 1393 | struct sockaddr_un sun_server; |
355 | struct p9_trans *trans; | 1394 | struct p9_trans *trans; |
1395 | struct p9_trans_fd *p; | ||
356 | 1396 | ||
357 | csocket = NULL; | 1397 | csocket = NULL; |
358 | trans = kmalloc(sizeof(struct p9_trans), GFP_KERNEL); | 1398 | trans = kmalloc(sizeof(struct p9_trans), GFP_KERNEL); |
359 | if (!trans) | 1399 | if (!trans) |
360 | return ERR_PTR(-ENOMEM); | 1400 | return ERR_PTR(-ENOMEM); |
361 | 1401 | ||
362 | trans->write = p9_fd_write; | 1402 | trans->rpc = p9_fd_rpc; |
363 | trans->read = p9_fd_read; | ||
364 | trans->close = p9_fd_close; | 1403 | trans->close = p9_fd_close; |
365 | trans->poll = p9_fd_poll; | ||
366 | 1404 | ||
367 | if (strlen(addr) > UNIX_PATH_MAX) { | 1405 | if (strlen(addr) > UNIX_PATH_MAX) { |
368 | P9_EPRINTK(KERN_ERR, "p9_trans_unix: address too long: %s\n", | 1406 | P9_EPRINTK(KERN_ERR, "p9_trans_unix: address too long: %s\n", |
@@ -387,6 +1425,16 @@ static struct p9_trans *p9_trans_create_unix(const char *addr, char *args) | |||
387 | if (err < 0) | 1425 | if (err < 0) |
388 | goto error; | 1426 | goto error; |
389 | 1427 | ||
1428 | trans->msize = msize; | ||
1429 | trans->extended = dotu; | ||
1430 | p = (struct p9_trans_fd *) trans->priv; | ||
1431 | p->conn = p9_conn_create(trans); | ||
1432 | if (IS_ERR(p->conn)) { | ||
1433 | err = PTR_ERR(p->conn); | ||
1434 | p->conn = NULL; | ||
1435 | goto error; | ||
1436 | } | ||
1437 | |||
390 | return trans; | 1438 | return trans; |
391 | 1439 | ||
392 | error: | 1440 | error: |
@@ -397,11 +1445,14 @@ error: | |||
397 | return ERR_PTR(err); | 1445 | return ERR_PTR(err); |
398 | } | 1446 | } |
399 | 1447 | ||
400 | static struct p9_trans *p9_trans_create_fd(const char *name, char *args) | 1448 | static struct p9_trans * |
1449 | p9_trans_create_fd(const char *name, char *args, int msize, | ||
1450 | unsigned char extended) | ||
401 | { | 1451 | { |
402 | int err; | 1452 | int err; |
403 | struct p9_trans *trans; | 1453 | struct p9_trans *trans; |
404 | struct p9_fd_opts opts; | 1454 | struct p9_fd_opts opts; |
1455 | struct p9_trans_fd *p; | ||
405 | 1456 | ||
406 | parse_opts(args, &opts); | 1457 | parse_opts(args, &opts); |
407 | 1458 | ||
@@ -414,15 +1465,23 @@ static struct p9_trans *p9_trans_create_fd(const char *name, char *args) | |||
414 | if (!trans) | 1465 | if (!trans) |
415 | return ERR_PTR(-ENOMEM); | 1466 | return ERR_PTR(-ENOMEM); |
416 | 1467 | ||
417 | trans->write = p9_fd_write; | 1468 | trans->rpc = p9_fd_rpc; |
418 | trans->read = p9_fd_read; | ||
419 | trans->close = p9_fd_close; | 1469 | trans->close = p9_fd_close; |
420 | trans->poll = p9_fd_poll; | ||
421 | 1470 | ||
422 | err = p9_fd_open(trans, opts.rfd, opts.wfd); | 1471 | err = p9_fd_open(trans, opts.rfd, opts.wfd); |
423 | if (err < 0) | 1472 | if (err < 0) |
424 | goto error; | 1473 | goto error; |
425 | 1474 | ||
1475 | trans->msize = msize; | ||
1476 | trans->extended = extended; | ||
1477 | p = (struct p9_trans_fd *) trans->priv; | ||
1478 | p->conn = p9_conn_create(trans); | ||
1479 | if (IS_ERR(p->conn)) { | ||
1480 | err = PTR_ERR(p->conn); | ||
1481 | p->conn = NULL; | ||
1482 | goto error; | ||
1483 | } | ||
1484 | |||
426 | return trans; | 1485 | return trans; |
427 | 1486 | ||
428 | error: | 1487 | error: |
@@ -453,6 +1512,12 @@ static struct p9_trans_module p9_fd_trans = { | |||
453 | 1512 | ||
454 | static int __init p9_trans_fd_init(void) | 1513 | static int __init p9_trans_fd_init(void) |
455 | { | 1514 | { |
1515 | int ret = p9_mux_global_init(); | ||
1516 | if (ret) { | ||
1517 | printk(KERN_WARNING "9p: starting mux failed\n"); | ||
1518 | return ret; | ||
1519 | } | ||
1520 | |||
456 | v9fs_register_trans(&p9_tcp_trans); | 1521 | v9fs_register_trans(&p9_tcp_trans); |
457 | v9fs_register_trans(&p9_unix_trans); | 1522 | v9fs_register_trans(&p9_unix_trans); |
458 | v9fs_register_trans(&p9_fd_trans); | 1523 | v9fs_register_trans(&p9_fd_trans); |
@@ -460,13 +1525,7 @@ static int __init p9_trans_fd_init(void) | |||
460 | return 1; | 1525 | return 1; |
461 | } | 1526 | } |
462 | 1527 | ||
463 | static void __exit p9_trans_fd_exit(void) { | ||
464 | printk(KERN_ERR "Removal of 9p transports not implemented\n"); | ||
465 | BUG(); | ||
466 | } | ||
467 | |||
468 | module_init(p9_trans_fd_init); | 1528 | module_init(p9_trans_fd_init); |
469 | module_exit(p9_trans_fd_exit); | ||
470 | 1529 | ||
471 | MODULE_AUTHOR("Latchesar Ionkov <lucho@ionkov.net>"); | 1530 | MODULE_AUTHOR("Latchesar Ionkov <lucho@ionkov.net>"); |
472 | MODULE_AUTHOR("Eric Van Hensbergen <ericvh@gmail.com>"); | 1531 | MODULE_AUTHOR("Eric Van Hensbergen <ericvh@gmail.com>"); |
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c index 42eea5fe2628..0117b9fb8480 100644 --- a/net/9p/trans_virtio.c +++ b/net/9p/trans_virtio.c | |||
@@ -1,17 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * The Guest 9p transport driver | 2 | * The Guest 9p transport driver |
3 | * | 3 | * |
4 | * This is a trivial pipe-based transport driver based on the lguest console | 4 | * This is a block based transport driver based on the lguest block driver |
5 | * code: we use lguest's DMA mechanism to send bytes out, and register a | 5 | * code. |
6 | * DMA buffer to receive bytes in. It is assumed to be present and available | ||
7 | * from the very beginning of boot. | ||
8 | * | ||
9 | * This may be have been done by just instaniating another HVC console, | ||
10 | * but HVC's blocksize of 16 bytes is annoying and painful to performance. | ||
11 | * | ||
12 | * A more efficient transport could be built based on the virtio block driver | ||
13 | * but it requires some changes in the 9p transport model (which are in | ||
14 | * progress) | ||
15 | * | 6 | * |
16 | */ | 7 | */ |
17 | /* | 8 | /* |
@@ -55,11 +46,25 @@ | |||
55 | #include <linux/virtio.h> | 46 | #include <linux/virtio.h> |
56 | #include <linux/virtio_9p.h> | 47 | #include <linux/virtio_9p.h> |
57 | 48 | ||
49 | #define VIRTQUEUE_NUM 128 | ||
50 | |||
58 | /* a single mutex to manage channel initialization and attachment */ | 51 | /* a single mutex to manage channel initialization and attachment */ |
59 | static DECLARE_MUTEX(virtio_9p_lock); | 52 | static DECLARE_MUTEX(virtio_9p_lock); |
60 | /* global which tracks highest initialized channel */ | 53 | /* global which tracks highest initialized channel */ |
61 | static int chan_index; | 54 | static int chan_index; |
62 | 55 | ||
56 | #define P9_INIT_MAXTAG 16 | ||
57 | |||
58 | #define REQ_STATUS_IDLE 0 | ||
59 | #define REQ_STATUS_SENT 1 | ||
60 | #define REQ_STATUS_RCVD 2 | ||
61 | #define REQ_STATUS_FLSH 3 | ||
62 | |||
63 | struct p9_req_t { | ||
64 | int status; | ||
65 | wait_queue_head_t *wq; | ||
66 | }; | ||
67 | |||
63 | /* We keep all per-channel information in a structure. | 68 | /* We keep all per-channel information in a structure. |
64 | * This structure is allocated within the devices dev->mem space. | 69 | * This structure is allocated within the devices dev->mem space. |
65 | * A pointer to the structure will get put in the transport private. | 70 | * A pointer to the structure will get put in the transport private. |
@@ -68,146 +73,198 @@ static struct virtio_chan { | |||
68 | bool initialized; /* channel is initialized */ | 73 | bool initialized; /* channel is initialized */ |
69 | bool inuse; /* channel is in use */ | 74 | bool inuse; /* channel is in use */ |
70 | 75 | ||
71 | struct virtqueue *in_vq, *out_vq; | 76 | spinlock_t lock; |
77 | |||
72 | struct virtio_device *vdev; | 78 | struct virtio_device *vdev; |
79 | struct virtqueue *vq; | ||
73 | 80 | ||
74 | /* This is our input buffer, and how much data is left in it. */ | 81 | struct p9_idpool *tagpool; |
75 | unsigned int in_len; | 82 | struct p9_req_t *reqs; |
76 | char *in, *inbuf; | 83 | int max_tag; |
77 | 84 | ||
78 | wait_queue_head_t wq; /* waitq for buffer */ | 85 | /* Scatterlist: can be too big for stack. */ |
86 | struct scatterlist sg[VIRTQUEUE_NUM]; | ||
79 | } channels[MAX_9P_CHAN]; | 87 | } channels[MAX_9P_CHAN]; |
80 | 88 | ||
89 | /* Lookup requests by tag */ | ||
90 | static struct p9_req_t *p9_lookup_tag(struct virtio_chan *c, u16 tag) | ||
91 | { | ||
92 | /* This looks up the original request by tag so we know which | ||
93 | * buffer to read the data into */ | ||
94 | tag++; | ||
95 | |||
96 | while (tag >= c->max_tag) { | ||
97 | int old_max = c->max_tag; | ||
98 | int count; | ||
99 | |||
100 | if (c->max_tag) | ||
101 | c->max_tag *= 2; | ||
102 | else | ||
103 | c->max_tag = P9_INIT_MAXTAG; | ||
104 | |||
105 | c->reqs = krealloc(c->reqs, sizeof(struct p9_req_t)*c->max_tag, | ||
106 | GFP_ATOMIC); | ||
107 | if (!c->reqs) { | ||
108 | printk(KERN_ERR "Couldn't grow tag array\n"); | ||
109 | BUG(); | ||
110 | } | ||
111 | for (count = old_max; count < c->max_tag; count++) { | ||
112 | c->reqs[count].status = REQ_STATUS_IDLE; | ||
113 | c->reqs[count].wq = kmalloc(sizeof(wait_queue_t), | ||
114 | GFP_ATOMIC); | ||
115 | if (!c->reqs[count].wq) { | ||
116 | printk(KERN_ERR "Couldn't grow tag array\n"); | ||
117 | BUG(); | ||
118 | } | ||
119 | init_waitqueue_head(c->reqs[count].wq); | ||
120 | } | ||
121 | } | ||
122 | |||
123 | return &c->reqs[tag]; | ||
124 | } | ||
125 | |||
126 | |||
81 | /* How many bytes left in this page. */ | 127 | /* How many bytes left in this page. */ |
82 | static unsigned int rest_of_page(void *data) | 128 | static unsigned int rest_of_page(void *data) |
83 | { | 129 | { |
84 | return PAGE_SIZE - ((unsigned long)data % PAGE_SIZE); | 130 | return PAGE_SIZE - ((unsigned long)data % PAGE_SIZE); |
85 | } | 131 | } |
86 | 132 | ||
87 | static int p9_virtio_write(struct p9_trans *trans, void *buf, int count) | 133 | static void p9_virtio_close(struct p9_trans *trans) |
88 | { | 134 | { |
89 | struct virtio_chan *chan = (struct virtio_chan *) trans->priv; | 135 | struct virtio_chan *chan = trans->priv; |
90 | struct virtqueue *out_vq = chan->out_vq; | 136 | int count; |
91 | struct scatterlist sg[1]; | 137 | unsigned int flags; |
92 | unsigned int len; | ||
93 | 138 | ||
94 | P9_DPRINTK(P9_DEBUG_TRANS, "9p debug: virtio write (%d)\n", count); | 139 | spin_lock_irqsave(&chan->lock, flags); |
140 | p9_idpool_destroy(chan->tagpool); | ||
141 | for (count = 0; count < chan->max_tag; count++) | ||
142 | kfree(chan->reqs[count].wq); | ||
143 | kfree(chan->reqs); | ||
144 | chan->max_tag = 0; | ||
145 | spin_unlock_irqrestore(&chan->lock, flags); | ||
95 | 146 | ||
96 | /* keep it simple - make sure we don't overflow a page */ | 147 | down(&virtio_9p_lock); |
97 | if (rest_of_page(buf) < count) | 148 | chan->inuse = false; |
98 | count = rest_of_page(buf); | 149 | up(&virtio_9p_lock); |
99 | 150 | ||
100 | sg_init_one(sg, buf, count); | 151 | kfree(trans); |
152 | } | ||
101 | 153 | ||
102 | /* add_buf wants a token to identify this buffer: we hand it any | 154 | static void req_done(struct virtqueue *vq) |
103 | * non-NULL pointer, since there's only ever one buffer. */ | 155 | { |
104 | if (out_vq->vq_ops->add_buf(out_vq, sg, 1, 0, (void *)1) == 0) { | 156 | struct virtio_chan *chan = vq->vdev->priv; |
105 | /* Tell Host to go! */ | 157 | struct p9_fcall *rc; |
106 | out_vq->vq_ops->kick(out_vq); | 158 | unsigned int len; |
107 | /* Chill out until it's done with the buffer. */ | 159 | unsigned long flags; |
108 | while (!out_vq->vq_ops->get_buf(out_vq, &len)) | 160 | struct p9_req_t *req; |
109 | cpu_relax(); | 161 | |
162 | spin_lock_irqsave(&chan->lock, flags); | ||
163 | while ((rc = chan->vq->vq_ops->get_buf(chan->vq, &len)) != NULL) { | ||
164 | req = p9_lookup_tag(chan, rc->tag); | ||
165 | req->status = REQ_STATUS_RCVD; | ||
166 | wake_up(req->wq); | ||
110 | } | 167 | } |
111 | 168 | /* In case queue is stopped waiting for more buffers. */ | |
112 | P9_DPRINTK(P9_DEBUG_TRANS, "9p debug: virtio wrote (%d)\n", count); | 169 | spin_unlock_irqrestore(&chan->lock, flags); |
113 | |||
114 | /* We're expected to return the amount of data we wrote: all of it. */ | ||
115 | return count; | ||
116 | } | 170 | } |
117 | 171 | ||
118 | /* Create a scatter-gather list representing our input buffer and put it in the | 172 | static int |
119 | * queue. */ | 173 | pack_sg_list(struct scatterlist *sg, int start, int limit, char *data, |
120 | static void add_inbuf(struct virtio_chan *chan) | 174 | int count) |
121 | { | 175 | { |
122 | struct scatterlist sg[1]; | 176 | int s; |
123 | 177 | int index = start; | |
124 | sg_init_one(sg, chan->inbuf, PAGE_SIZE); | 178 | |
179 | while (count) { | ||
180 | s = rest_of_page(data); | ||
181 | if (s > count) | ||
182 | s = count; | ||
183 | sg_set_buf(&sg[index++], data, s); | ||
184 | count -= s; | ||
185 | data += s; | ||
186 | if (index > limit) | ||
187 | BUG(); | ||
188 | } | ||
125 | 189 | ||
126 | /* We should always be able to add one buffer to an empty queue. */ | 190 | return index-start; |
127 | if (chan->in_vq->vq_ops->add_buf(chan->in_vq, sg, 0, 1, chan->inbuf)) | ||
128 | BUG(); | ||
129 | chan->in_vq->vq_ops->kick(chan->in_vq); | ||
130 | } | 191 | } |
131 | 192 | ||
132 | static int p9_virtio_read(struct p9_trans *trans, void *buf, int count) | 193 | static int |
194 | p9_virtio_rpc(struct p9_trans *t, struct p9_fcall *tc, struct p9_fcall **rc) | ||
133 | { | 195 | { |
134 | struct virtio_chan *chan = (struct virtio_chan *) trans->priv; | 196 | int in, out; |
135 | struct virtqueue *in_vq = chan->in_vq; | 197 | int n, err, size; |
136 | 198 | struct virtio_chan *chan = t->priv; | |
137 | P9_DPRINTK(P9_DEBUG_TRANS, "9p debug: virtio read (%d)\n", count); | 199 | char *rdata; |
200 | struct p9_req_t *req; | ||
201 | unsigned long flags; | ||
202 | |||
203 | if (*rc == NULL) { | ||
204 | *rc = kmalloc(sizeof(struct p9_fcall) + t->msize, GFP_KERNEL); | ||
205 | if (!*rc) | ||
206 | return -ENOMEM; | ||
207 | } | ||
138 | 208 | ||
139 | /* If we don't have an input queue yet, we can't get input. */ | 209 | rdata = (char *)*rc+sizeof(struct p9_fcall); |
140 | BUG_ON(!in_vq); | ||
141 | 210 | ||
142 | /* No buffer? Try to get one. */ | 211 | n = P9_NOTAG; |
143 | if (!chan->in_len) { | 212 | if (tc->id != P9_TVERSION) { |
144 | chan->in = in_vq->vq_ops->get_buf(in_vq, &chan->in_len); | 213 | n = p9_idpool_get(chan->tagpool); |
145 | if (!chan->in) | 214 | if (n < 0) |
146 | return 0; | 215 | return -ENOMEM; |
147 | } | 216 | } |
148 | 217 | ||
149 | /* You want more than we have to give? Well, try wanting less! */ | 218 | spin_lock_irqsave(&chan->lock, flags); |
150 | if (chan->in_len < count) | 219 | req = p9_lookup_tag(chan, n); |
151 | count = chan->in_len; | 220 | spin_unlock_irqrestore(&chan->lock, flags); |
152 | 221 | ||
153 | /* Copy across to their buffer and increment offset. */ | 222 | p9_set_tag(tc, n); |
154 | memcpy(buf, chan->in, count); | ||
155 | chan->in += count; | ||
156 | chan->in_len -= count; | ||
157 | 223 | ||
158 | /* Finished? Re-register buffer so Host will use it again. */ | 224 | P9_DPRINTK(P9_DEBUG_TRANS, "9p debug: virtio rpc tag %d\n", n); |
159 | if (chan->in_len == 0) | ||
160 | add_inbuf(chan); | ||
161 | 225 | ||
162 | P9_DPRINTK(P9_DEBUG_TRANS, "9p debug: virtio finished read (%d)\n", | 226 | out = pack_sg_list(chan->sg, 0, VIRTQUEUE_NUM, tc->sdata, tc->size); |
163 | count); | 227 | in = pack_sg_list(chan->sg, out, VIRTQUEUE_NUM-out, rdata, t->msize); |
164 | 228 | ||
165 | return count; | 229 | req->status = REQ_STATUS_SENT; |
166 | } | ||
167 | 230 | ||
168 | /* The poll function is used by 9p transports to determine if there | 231 | if (chan->vq->vq_ops->add_buf(chan->vq, chan->sg, out, in, tc)) { |
169 | * is there is activity available on a particular channel. In our case | 232 | P9_DPRINTK(P9_DEBUG_TRANS, |
170 | * we use it to wait for a callback from the input routines. | 233 | "9p debug: virtio rpc add_buf returned failure"); |
171 | */ | 234 | return -EIO; |
172 | static unsigned int | 235 | } |
173 | p9_virtio_poll(struct p9_trans *trans, struct poll_table_struct *pt) | ||
174 | { | ||
175 | struct virtio_chan *chan = (struct virtio_chan *)trans->priv; | ||
176 | struct virtqueue *in_vq = chan->in_vq; | ||
177 | int ret = POLLOUT; /* we can always handle more output */ | ||
178 | 236 | ||
179 | poll_wait(NULL, &chan->wq, pt); | 237 | chan->vq->vq_ops->kick(chan->vq); |
180 | 238 | ||
181 | /* No buffer? Try to get one. */ | 239 | wait_event(*req->wq, req->status == REQ_STATUS_RCVD); |
182 | if (!chan->in_len) | ||
183 | chan->in = in_vq->vq_ops->get_buf(in_vq, &chan->in_len); | ||
184 | 240 | ||
185 | if (chan->in_len) | 241 | size = le32_to_cpu(*(__le32 *) rdata); |
186 | ret |= POLLIN; | ||
187 | 242 | ||
188 | return ret; | 243 | err = p9_deserialize_fcall(rdata, size, *rc, t->extended); |
189 | } | 244 | if (err < 0) { |
245 | P9_DPRINTK(P9_DEBUG_TRANS, | ||
246 | "9p debug: virtio rpc deserialize returned %d\n", err); | ||
247 | return err; | ||
248 | } | ||
190 | 249 | ||
191 | static void p9_virtio_close(struct p9_trans *trans) | 250 | #ifdef CONFIG_NET_9P_DEBUG |
192 | { | 251 | if ((p9_debug_level&P9_DEBUG_FCALL) == P9_DEBUG_FCALL) { |
193 | struct virtio_chan *chan = trans->priv; | 252 | char buf[150]; |
194 | 253 | ||
195 | down(&virtio_9p_lock); | 254 | p9_printfcall(buf, sizeof(buf), *rc, t->extended); |
196 | chan->inuse = false; | 255 | printk(KERN_NOTICE ">>> %p %s\n", t, buf); |
197 | up(&virtio_9p_lock); | 256 | } |
257 | #endif | ||
198 | 258 | ||
199 | kfree(trans); | 259 | if (n != P9_NOTAG && p9_idpool_check(n, chan->tagpool)) |
200 | } | 260 | p9_idpool_put(n, chan->tagpool); |
201 | 261 | ||
202 | static void p9_virtio_intr(struct virtqueue *q) | 262 | req->status = REQ_STATUS_IDLE; |
203 | { | ||
204 | struct virtio_chan *chan = q->vdev->priv; | ||
205 | 263 | ||
206 | P9_DPRINTK(P9_DEBUG_TRANS, "9p poll_wakeup: %p\n", &chan->wq); | 264 | return 0; |
207 | wake_up_interruptible(&chan->wq); | ||
208 | } | 265 | } |
209 | 266 | ||
210 | static int p9_virtio_probe(struct virtio_device *dev) | 267 | static int p9_virtio_probe(struct virtio_device *vdev) |
211 | { | 268 | { |
212 | int err; | 269 | int err; |
213 | struct virtio_chan *chan; | 270 | struct virtio_chan *chan; |
@@ -221,44 +278,29 @@ static int p9_virtio_probe(struct virtio_device *dev) | |||
221 | if (chan_index > MAX_9P_CHAN) { | 278 | if (chan_index > MAX_9P_CHAN) { |
222 | printk(KERN_ERR "9p: virtio: Maximum channels exceeded\n"); | 279 | printk(KERN_ERR "9p: virtio: Maximum channels exceeded\n"); |
223 | BUG(); | 280 | BUG(); |
224 | } | ||
225 | |||
226 | chan->vdev = dev; | ||
227 | |||
228 | /* This is the scratch page we use to receive console input */ | ||
229 | chan->inbuf = kmalloc(PAGE_SIZE, GFP_KERNEL); | ||
230 | if (!chan->inbuf) { | ||
231 | err = -ENOMEM; | 281 | err = -ENOMEM; |
232 | goto fail; | 282 | goto fail; |
233 | } | 283 | } |
234 | 284 | ||
235 | /* Find the input queue. */ | 285 | chan->vdev = vdev; |
236 | dev->priv = chan; | ||
237 | chan->in_vq = dev->config->find_vq(dev, 0, p9_virtio_intr); | ||
238 | if (IS_ERR(chan->in_vq)) { | ||
239 | err = PTR_ERR(chan->in_vq); | ||
240 | goto free; | ||
241 | } | ||
242 | 286 | ||
243 | chan->out_vq = dev->config->find_vq(dev, 1, NULL); | 287 | /* We expect one virtqueue, for requests. */ |
244 | if (IS_ERR(chan->out_vq)) { | 288 | chan->vq = vdev->config->find_vq(vdev, 0, req_done); |
245 | err = PTR_ERR(chan->out_vq); | 289 | if (IS_ERR(chan->vq)) { |
246 | goto free_in_vq; | 290 | err = PTR_ERR(chan->vq); |
291 | goto out_free_vq; | ||
247 | } | 292 | } |
293 | chan->vq->vdev->priv = chan; | ||
294 | spin_lock_init(&chan->lock); | ||
248 | 295 | ||
249 | init_waitqueue_head(&chan->wq); | 296 | sg_init_table(chan->sg, VIRTQUEUE_NUM); |
250 | 297 | ||
251 | /* Register the input buffer the first time. */ | ||
252 | add_inbuf(chan); | ||
253 | chan->inuse = false; | 298 | chan->inuse = false; |
254 | chan->initialized = true; | 299 | chan->initialized = true; |
255 | |||
256 | return 0; | 300 | return 0; |
257 | 301 | ||
258 | free_in_vq: | 302 | out_free_vq: |
259 | dev->config->del_vq(chan->in_vq); | 303 | vdev->config->del_vq(chan->vq); |
260 | free: | ||
261 | kfree(chan->inbuf); | ||
262 | fail: | 304 | fail: |
263 | down(&virtio_9p_lock); | 305 | down(&virtio_9p_lock); |
264 | chan_index--; | 306 | chan_index--; |
@@ -271,11 +313,13 @@ fail: | |||
271 | * alternate channels by matching devname versus a virtio_config entry. | 313 | * alternate channels by matching devname versus a virtio_config entry. |
272 | * We use a simple reference count mechanism to ensure that only a single | 314 | * We use a simple reference count mechanism to ensure that only a single |
273 | * mount has a channel open at a time. */ | 315 | * mount has a channel open at a time. */ |
274 | static struct p9_trans *p9_virtio_create(const char *devname, char *args) | 316 | static struct p9_trans * |
317 | p9_virtio_create(const char *devname, char *args, int msize, | ||
318 | unsigned char extended) | ||
275 | { | 319 | { |
276 | struct p9_trans *trans; | 320 | struct p9_trans *trans; |
277 | int index = 0; | ||
278 | struct virtio_chan *chan = channels; | 321 | struct virtio_chan *chan = channels; |
322 | int index = 0; | ||
279 | 323 | ||
280 | down(&virtio_9p_lock); | 324 | down(&virtio_9p_lock); |
281 | while (index < MAX_9P_CHAN) { | 325 | while (index < MAX_9P_CHAN) { |
@@ -290,25 +334,45 @@ static struct p9_trans *p9_virtio_create(const char *devname, char *args) | |||
290 | up(&virtio_9p_lock); | 334 | up(&virtio_9p_lock); |
291 | 335 | ||
292 | if (index >= MAX_9P_CHAN) { | 336 | if (index >= MAX_9P_CHAN) { |
293 | printk(KERN_ERR "9p: virtio: couldn't find a free channel\n"); | 337 | printk(KERN_ERR "9p: no channels available\n"); |
294 | return NULL; | 338 | return ERR_PTR(-ENODEV); |
295 | } | 339 | } |
296 | 340 | ||
341 | chan->tagpool = p9_idpool_create(); | ||
342 | if (IS_ERR(chan->tagpool)) { | ||
343 | printk(KERN_ERR "9p: couldn't allocate tagpool\n"); | ||
344 | return ERR_PTR(-ENOMEM); | ||
345 | } | ||
346 | p9_idpool_get(chan->tagpool); /* reserve tag 0 */ | ||
347 | chan->max_tag = 0; | ||
348 | chan->reqs = NULL; | ||
349 | |||
297 | trans = kmalloc(sizeof(struct p9_trans), GFP_KERNEL); | 350 | trans = kmalloc(sizeof(struct p9_trans), GFP_KERNEL); |
298 | if (!trans) { | 351 | if (!trans) { |
299 | printk(KERN_ERR "9p: couldn't allocate transport\n"); | 352 | printk(KERN_ERR "9p: couldn't allocate transport\n"); |
300 | return ERR_PTR(-ENOMEM); | 353 | return ERR_PTR(-ENOMEM); |
301 | } | 354 | } |
302 | 355 | trans->extended = extended; | |
303 | trans->write = p9_virtio_write; | 356 | trans->msize = msize; |
304 | trans->read = p9_virtio_read; | ||
305 | trans->close = p9_virtio_close; | 357 | trans->close = p9_virtio_close; |
306 | trans->poll = p9_virtio_poll; | 358 | trans->rpc = p9_virtio_rpc; |
307 | trans->priv = chan; | 359 | trans->priv = chan; |
308 | 360 | ||
309 | return trans; | 361 | return trans; |
310 | } | 362 | } |
311 | 363 | ||
364 | static void p9_virtio_remove(struct virtio_device *vdev) | ||
365 | { | ||
366 | struct virtio_chan *chan = vdev->priv; | ||
367 | |||
368 | BUG_ON(chan->inuse); | ||
369 | |||
370 | if (chan->initialized) { | ||
371 | vdev->config->del_vq(chan->vq); | ||
372 | chan->initialized = false; | ||
373 | } | ||
374 | } | ||
375 | |||
312 | #define VIRTIO_ID_9P 9 | 376 | #define VIRTIO_ID_9P 9 |
313 | 377 | ||
314 | static struct virtio_device_id id_table[] = { | 378 | static struct virtio_device_id id_table[] = { |
@@ -322,12 +386,13 @@ static struct virtio_driver p9_virtio_drv = { | |||
322 | .driver.owner = THIS_MODULE, | 386 | .driver.owner = THIS_MODULE, |
323 | .id_table = id_table, | 387 | .id_table = id_table, |
324 | .probe = p9_virtio_probe, | 388 | .probe = p9_virtio_probe, |
389 | .remove = p9_virtio_remove, | ||
325 | }; | 390 | }; |
326 | 391 | ||
327 | static struct p9_trans_module p9_virtio_trans = { | 392 | static struct p9_trans_module p9_virtio_trans = { |
328 | .name = "virtio", | 393 | .name = "virtio", |
329 | .create = p9_virtio_create, | 394 | .create = p9_virtio_create, |
330 | .maxsize = PAGE_SIZE, | 395 | .maxsize = PAGE_SIZE*16, |
331 | .def = 0, | 396 | .def = 0, |
332 | }; | 397 | }; |
333 | 398 | ||
@@ -343,7 +408,13 @@ static int __init p9_virtio_init(void) | |||
343 | return register_virtio_driver(&p9_virtio_drv); | 408 | return register_virtio_driver(&p9_virtio_drv); |
344 | } | 409 | } |
345 | 410 | ||
411 | static void __exit p9_virtio_cleanup(void) | ||
412 | { | ||
413 | unregister_virtio_driver(&p9_virtio_drv); | ||
414 | } | ||
415 | |||
346 | module_init(p9_virtio_init); | 416 | module_init(p9_virtio_init); |
417 | module_exit(p9_virtio_cleanup); | ||
347 | 418 | ||
348 | MODULE_DEVICE_TABLE(virtio, id_table); | 419 | MODULE_DEVICE_TABLE(virtio, id_table); |
349 | MODULE_AUTHOR("Eric Van Hensbergen <ericvh@gmail.com>"); | 420 | MODULE_AUTHOR("Eric Van Hensbergen <ericvh@gmail.com>"); |
diff --git a/net/9p/util.c b/net/9p/util.c index 22077b79395d..ef7215565d88 100644 --- a/net/9p/util.c +++ b/net/9p/util.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <net/9p/9p.h> | 33 | #include <net/9p/9p.h> |
34 | 34 | ||
35 | struct p9_idpool { | 35 | struct p9_idpool { |
36 | struct semaphore lock; | 36 | spinlock_t lock; |
37 | struct idr pool; | 37 | struct idr pool; |
38 | }; | 38 | }; |
39 | 39 | ||
@@ -45,7 +45,7 @@ struct p9_idpool *p9_idpool_create(void) | |||
45 | if (!p) | 45 | if (!p) |
46 | return ERR_PTR(-ENOMEM); | 46 | return ERR_PTR(-ENOMEM); |
47 | 47 | ||
48 | init_MUTEX(&p->lock); | 48 | spin_lock_init(&p->lock); |
49 | idr_init(&p->pool); | 49 | idr_init(&p->pool); |
50 | 50 | ||
51 | return p; | 51 | return p; |
@@ -71,19 +71,17 @@ int p9_idpool_get(struct p9_idpool *p) | |||
71 | { | 71 | { |
72 | int i = 0; | 72 | int i = 0; |
73 | int error; | 73 | int error; |
74 | unsigned int flags; | ||
74 | 75 | ||
75 | retry: | 76 | retry: |
76 | if (idr_pre_get(&p->pool, GFP_KERNEL) == 0) | 77 | if (idr_pre_get(&p->pool, GFP_KERNEL) == 0) |
77 | return 0; | 78 | return 0; |
78 | 79 | ||
79 | if (down_interruptible(&p->lock) == -EINTR) { | 80 | spin_lock_irqsave(&p->lock, flags); |
80 | P9_EPRINTK(KERN_WARNING, "Interrupted while locking\n"); | ||
81 | return -1; | ||
82 | } | ||
83 | 81 | ||
84 | /* no need to store exactly p, we just need something non-null */ | 82 | /* no need to store exactly p, we just need something non-null */ |
85 | error = idr_get_new(&p->pool, p, &i); | 83 | error = idr_get_new(&p->pool, p, &i); |
86 | up(&p->lock); | 84 | spin_unlock_irqrestore(&p->lock, flags); |
87 | 85 | ||
88 | if (error == -EAGAIN) | 86 | if (error == -EAGAIN) |
89 | goto retry; | 87 | goto retry; |
@@ -104,12 +102,10 @@ EXPORT_SYMBOL(p9_idpool_get); | |||
104 | 102 | ||
105 | void p9_idpool_put(int id, struct p9_idpool *p) | 103 | void p9_idpool_put(int id, struct p9_idpool *p) |
106 | { | 104 | { |
107 | if (down_interruptible(&p->lock) == -EINTR) { | 105 | unsigned int flags; |
108 | P9_EPRINTK(KERN_WARNING, "Interrupted while locking\n"); | 106 | spin_lock_irqsave(&p->lock, flags); |
109 | return; | ||
110 | } | ||
111 | idr_remove(&p->pool, id); | 107 | idr_remove(&p->pool, id); |
112 | up(&p->lock); | 108 | spin_unlock_irqrestore(&p->lock, flags); |
113 | } | 109 | } |
114 | EXPORT_SYMBOL(p9_idpool_put); | 110 | EXPORT_SYMBOL(p9_idpool_put); |
115 | 111 | ||
diff --git a/net/Kconfig b/net/Kconfig index b6a5d454f2ff..6627c6ae5db6 100644 --- a/net/Kconfig +++ b/net/Kconfig | |||
@@ -30,7 +30,7 @@ menu "Networking options" | |||
30 | config NET_NS | 30 | config NET_NS |
31 | bool "Network namespace support" | 31 | bool "Network namespace support" |
32 | default n | 32 | default n |
33 | depends on EXPERIMENTAL && !SYSFS | 33 | depends on EXPERIMENTAL && !SYSFS && NAMESPACES |
34 | help | 34 | help |
35 | Allow user space to create what appear to be multiple instances | 35 | Allow user space to create what appear to be multiple instances |
36 | of the network stack. | 36 | of the network stack. |
diff --git a/net/can/af_can.c b/net/can/af_can.c index 5158e886630f..36b9f22ed83a 100644 --- a/net/can/af_can.c +++ b/net/can/af_can.c | |||
@@ -118,7 +118,6 @@ static int can_create(struct net *net, struct socket *sock, int protocol) | |||
118 | { | 118 | { |
119 | struct sock *sk; | 119 | struct sock *sk; |
120 | struct can_proto *cp; | 120 | struct can_proto *cp; |
121 | char module_name[sizeof("can-proto-000")]; | ||
122 | int err = 0; | 121 | int err = 0; |
123 | 122 | ||
124 | sock->state = SS_UNCONNECTED; | 123 | sock->state = SS_UNCONNECTED; |
@@ -129,26 +128,21 @@ static int can_create(struct net *net, struct socket *sock, int protocol) | |||
129 | if (net != &init_net) | 128 | if (net != &init_net) |
130 | return -EAFNOSUPPORT; | 129 | return -EAFNOSUPPORT; |
131 | 130 | ||
131 | #ifdef CONFIG_KMOD | ||
132 | /* try to load protocol module, when CONFIG_KMOD is defined */ | 132 | /* try to load protocol module, when CONFIG_KMOD is defined */ |
133 | if (!proto_tab[protocol]) { | 133 | if (!proto_tab[protocol]) { |
134 | sprintf(module_name, "can-proto-%d", protocol); | 134 | err = request_module("can-proto-%d", protocol); |
135 | err = request_module(module_name); | ||
136 | 135 | ||
137 | /* | 136 | /* |
138 | * In case of error we only print a message but don't | 137 | * In case of error we only print a message but don't |
139 | * return the error code immediately. Below we will | 138 | * return the error code immediately. Below we will |
140 | * return -EPROTONOSUPPORT | 139 | * return -EPROTONOSUPPORT |
141 | */ | 140 | */ |
142 | if (err == -ENOSYS) { | 141 | if (err && printk_ratelimit()) |
143 | if (printk_ratelimit()) | 142 | printk(KERN_ERR "can: request_module " |
144 | printk(KERN_INFO "can: request_module(%s)" | 143 | "(can-proto-%d) failed.\n", protocol); |
145 | " not implemented.\n", module_name); | ||
146 | } else if (err) { | ||
147 | if (printk_ratelimit()) | ||
148 | printk(KERN_ERR "can: request_module(%s)" | ||
149 | " failed.\n", module_name); | ||
150 | } | ||
151 | } | 144 | } |
145 | #endif | ||
152 | 146 | ||
153 | spin_lock(&proto_tab_lock); | 147 | spin_lock(&proto_tab_lock); |
154 | cp = proto_tab[protocol]; | 148 | cp = proto_tab[protocol]; |
@@ -662,26 +656,26 @@ int can_proto_register(struct can_proto *cp) | |||
662 | return -EINVAL; | 656 | return -EINVAL; |
663 | } | 657 | } |
664 | 658 | ||
659 | err = proto_register(cp->prot, 0); | ||
660 | if (err < 0) | ||
661 | return err; | ||
662 | |||
665 | spin_lock(&proto_tab_lock); | 663 | spin_lock(&proto_tab_lock); |
666 | if (proto_tab[proto]) { | 664 | if (proto_tab[proto]) { |
667 | printk(KERN_ERR "can: protocol %d already registered\n", | 665 | printk(KERN_ERR "can: protocol %d already registered\n", |
668 | proto); | 666 | proto); |
669 | err = -EBUSY; | 667 | err = -EBUSY; |
670 | goto errout; | 668 | } else { |
669 | proto_tab[proto] = cp; | ||
670 | |||
671 | /* use generic ioctl function if not defined by module */ | ||
672 | if (!cp->ops->ioctl) | ||
673 | cp->ops->ioctl = can_ioctl; | ||
671 | } | 674 | } |
675 | spin_unlock(&proto_tab_lock); | ||
672 | 676 | ||
673 | err = proto_register(cp->prot, 0); | ||
674 | if (err < 0) | 677 | if (err < 0) |
675 | goto errout; | 678 | proto_unregister(cp->prot); |
676 | |||
677 | proto_tab[proto] = cp; | ||
678 | |||
679 | /* use generic ioctl function if the module doesn't bring its own */ | ||
680 | if (!cp->ops->ioctl) | ||
681 | cp->ops->ioctl = can_ioctl; | ||
682 | |||
683 | errout: | ||
684 | spin_unlock(&proto_tab_lock); | ||
685 | 679 | ||
686 | return err; | 680 | return err; |
687 | } | 681 | } |
@@ -700,9 +694,10 @@ void can_proto_unregister(struct can_proto *cp) | |||
700 | printk(KERN_ERR "BUG: can: protocol %d is not registered\n", | 694 | printk(KERN_ERR "BUG: can: protocol %d is not registered\n", |
701 | proto); | 695 | proto); |
702 | } | 696 | } |
703 | proto_unregister(cp->prot); | ||
704 | proto_tab[proto] = NULL; | 697 | proto_tab[proto] = NULL; |
705 | spin_unlock(&proto_tab_lock); | 698 | spin_unlock(&proto_tab_lock); |
699 | |||
700 | proto_unregister(cp->prot); | ||
706 | } | 701 | } |
707 | EXPORT_SYMBOL(can_proto_unregister); | 702 | EXPORT_SYMBOL(can_proto_unregister); |
708 | 703 | ||
diff --git a/net/can/raw.c b/net/can/raw.c index aeefd1419d00..94cd7f27c444 100644 --- a/net/can/raw.c +++ b/net/can/raw.c | |||
@@ -98,7 +98,6 @@ static void raw_rcv(struct sk_buff *skb, void *data) | |||
98 | struct sock *sk = (struct sock *)data; | 98 | struct sock *sk = (struct sock *)data; |
99 | struct raw_sock *ro = raw_sk(sk); | 99 | struct raw_sock *ro = raw_sk(sk); |
100 | struct sockaddr_can *addr; | 100 | struct sockaddr_can *addr; |
101 | int error; | ||
102 | 101 | ||
103 | if (!ro->recv_own_msgs) { | 102 | if (!ro->recv_own_msgs) { |
104 | /* check the received tx sock reference */ | 103 | /* check the received tx sock reference */ |
@@ -121,14 +120,12 @@ static void raw_rcv(struct sk_buff *skb, void *data) | |||
121 | addr->can_family = AF_CAN; | 120 | addr->can_family = AF_CAN; |
122 | addr->can_ifindex = skb->dev->ifindex; | 121 | addr->can_ifindex = skb->dev->ifindex; |
123 | 122 | ||
124 | error = sock_queue_rcv_skb(sk, skb); | 123 | if (sock_queue_rcv_skb(sk, skb) < 0) |
125 | if (error < 0) | ||
126 | kfree_skb(skb); | 124 | kfree_skb(skb); |
127 | } | 125 | } |
128 | 126 | ||
129 | static int raw_enable_filters(struct net_device *dev, struct sock *sk, | 127 | static int raw_enable_filters(struct net_device *dev, struct sock *sk, |
130 | struct can_filter *filter, | 128 | struct can_filter *filter, int count) |
131 | int count) | ||
132 | { | 129 | { |
133 | int err = 0; | 130 | int err = 0; |
134 | int i; | 131 | int i; |
@@ -163,8 +160,7 @@ static int raw_enable_errfilter(struct net_device *dev, struct sock *sk, | |||
163 | } | 160 | } |
164 | 161 | ||
165 | static void raw_disable_filters(struct net_device *dev, struct sock *sk, | 162 | static void raw_disable_filters(struct net_device *dev, struct sock *sk, |
166 | struct can_filter *filter, | 163 | struct can_filter *filter, int count) |
167 | int count) | ||
168 | { | 164 | { |
169 | int i; | 165 | int i; |
170 | 166 | ||
@@ -353,7 +349,6 @@ static int raw_bind(struct socket *sock, struct sockaddr *uaddr, int len) | |||
353 | /* filters set by default/setsockopt */ | 349 | /* filters set by default/setsockopt */ |
354 | err = raw_enable_allfilters(dev, sk); | 350 | err = raw_enable_allfilters(dev, sk); |
355 | dev_put(dev); | 351 | dev_put(dev); |
356 | |||
357 | } else { | 352 | } else { |
358 | ifindex = 0; | 353 | ifindex = 0; |
359 | 354 | ||
@@ -466,7 +461,6 @@ static int raw_setsockopt(struct socket *sock, int level, int optname, | |||
466 | if (err) { | 461 | if (err) { |
467 | if (count > 1) | 462 | if (count > 1) |
468 | kfree(filter); | 463 | kfree(filter); |
469 | |||
470 | goto out_fil; | 464 | goto out_fil; |
471 | } | 465 | } |
472 | 466 | ||
@@ -673,25 +667,25 @@ static int raw_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
673 | { | 667 | { |
674 | struct sock *sk = sock->sk; | 668 | struct sock *sk = sock->sk; |
675 | struct sk_buff *skb; | 669 | struct sk_buff *skb; |
676 | int error = 0; | 670 | int err = 0; |
677 | int noblock; | 671 | int noblock; |
678 | 672 | ||
679 | noblock = flags & MSG_DONTWAIT; | 673 | noblock = flags & MSG_DONTWAIT; |
680 | flags &= ~MSG_DONTWAIT; | 674 | flags &= ~MSG_DONTWAIT; |
681 | 675 | ||
682 | skb = skb_recv_datagram(sk, flags, noblock, &error); | 676 | skb = skb_recv_datagram(sk, flags, noblock, &err); |
683 | if (!skb) | 677 | if (!skb) |
684 | return error; | 678 | return err; |
685 | 679 | ||
686 | if (size < skb->len) | 680 | if (size < skb->len) |
687 | msg->msg_flags |= MSG_TRUNC; | 681 | msg->msg_flags |= MSG_TRUNC; |
688 | else | 682 | else |
689 | size = skb->len; | 683 | size = skb->len; |
690 | 684 | ||
691 | error = memcpy_toiovec(msg->msg_iov, skb->data, size); | 685 | err = memcpy_toiovec(msg->msg_iov, skb->data, size); |
692 | if (error < 0) { | 686 | if (err < 0) { |
693 | skb_free_datagram(sk, skb); | 687 | skb_free_datagram(sk, skb); |
694 | return error; | 688 | return err; |
695 | } | 689 | } |
696 | 690 | ||
697 | sock_recv_timestamp(msg, sk, skb); | 691 | sock_recv_timestamp(msg, sk, skb); |
diff --git a/net/core/flow.c b/net/core/flow.c index 46b38e06e0d7..a77531c139b7 100644 --- a/net/core/flow.c +++ b/net/core/flow.c | |||
@@ -30,8 +30,8 @@ struct flow_cache_entry { | |||
30 | struct flow_cache_entry *next; | 30 | struct flow_cache_entry *next; |
31 | u16 family; | 31 | u16 family; |
32 | u8 dir; | 32 | u8 dir; |
33 | struct flowi key; | ||
34 | u32 genid; | 33 | u32 genid; |
34 | struct flowi key; | ||
35 | void *object; | 35 | void *object; |
36 | atomic_t *object_ref; | 36 | atomic_t *object_ref; |
37 | }; | 37 | }; |
@@ -52,7 +52,7 @@ struct flow_percpu_info { | |||
52 | int hash_rnd_recalc; | 52 | int hash_rnd_recalc; |
53 | u32 hash_rnd; | 53 | u32 hash_rnd; |
54 | int count; | 54 | int count; |
55 | } ____cacheline_aligned; | 55 | }; |
56 | static DEFINE_PER_CPU(struct flow_percpu_info, flow_hash_info) = { 0 }; | 56 | static DEFINE_PER_CPU(struct flow_percpu_info, flow_hash_info) = { 0 }; |
57 | 57 | ||
58 | #define flow_hash_rnd_recalc(cpu) \ | 58 | #define flow_hash_rnd_recalc(cpu) \ |
@@ -346,7 +346,7 @@ static int __init flow_cache_init(void) | |||
346 | 346 | ||
347 | flow_cachep = kmem_cache_create("flow_cache", | 347 | flow_cachep = kmem_cache_create("flow_cache", |
348 | sizeof(struct flow_cache_entry), | 348 | sizeof(struct flow_cache_entry), |
349 | 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, | 349 | 0, SLAB_PANIC, |
350 | NULL); | 350 | NULL); |
351 | flow_hash_shift = 10; | 351 | flow_hash_shift = 10; |
352 | flow_lwm = 2 * flow_hash_size; | 352 | flow_lwm = 2 * flow_hash_size; |
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c index 31be29b8b5a3..9dc0abb50eaf 100644 --- a/net/decnet/dn_route.c +++ b/net/decnet/dn_route.c | |||
@@ -94,7 +94,7 @@ struct dn_rt_hash_bucket | |||
94 | { | 94 | { |
95 | struct dn_route *chain; | 95 | struct dn_route *chain; |
96 | spinlock_t lock; | 96 | spinlock_t lock; |
97 | } __attribute__((__aligned__(8))); | 97 | }; |
98 | 98 | ||
99 | extern struct neigh_table dn_neigh_table; | 99 | extern struct neigh_table dn_neigh_table; |
100 | 100 | ||
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 994648be80ab..732cd07e6071 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c | |||
@@ -922,13 +922,11 @@ int igmp_rcv(struct sk_buff *skb) | |||
922 | struct in_device *in_dev = in_dev_get(skb->dev); | 922 | struct in_device *in_dev = in_dev_get(skb->dev); |
923 | int len = skb->len; | 923 | int len = skb->len; |
924 | 924 | ||
925 | if (in_dev==NULL) { | 925 | if (in_dev == NULL) |
926 | kfree_skb(skb); | 926 | goto drop; |
927 | return 0; | ||
928 | } | ||
929 | 927 | ||
930 | if (!pskb_may_pull(skb, sizeof(struct igmphdr))) | 928 | if (!pskb_may_pull(skb, sizeof(struct igmphdr))) |
931 | goto drop; | 929 | goto drop_ref; |
932 | 930 | ||
933 | switch (skb->ip_summed) { | 931 | switch (skb->ip_summed) { |
934 | case CHECKSUM_COMPLETE: | 932 | case CHECKSUM_COMPLETE: |
@@ -938,7 +936,7 @@ int igmp_rcv(struct sk_buff *skb) | |||
938 | case CHECKSUM_NONE: | 936 | case CHECKSUM_NONE: |
939 | skb->csum = 0; | 937 | skb->csum = 0; |
940 | if (__skb_checksum_complete(skb)) | 938 | if (__skb_checksum_complete(skb)) |
941 | goto drop; | 939 | goto drop_ref; |
942 | } | 940 | } |
943 | 941 | ||
944 | ih = igmp_hdr(skb); | 942 | ih = igmp_hdr(skb); |
@@ -972,8 +970,9 @@ int igmp_rcv(struct sk_buff *skb) | |||
972 | break; | 970 | break; |
973 | } | 971 | } |
974 | 972 | ||
975 | drop: | 973 | drop_ref: |
976 | in_dev_put(in_dev); | 974 | in_dev_put(in_dev); |
975 | drop: | ||
977 | kfree_skb(skb); | 976 | kfree_skb(skb); |
978 | return 0; | 977 | return 0; |
979 | } | 978 | } |
diff --git a/net/ipv4/ipvs/ip_vs_wrr.c b/net/ipv4/ipvs/ip_vs_wrr.c index 749fa044eca5..85c680add6df 100644 --- a/net/ipv4/ipvs/ip_vs_wrr.c +++ b/net/ipv4/ipvs/ip_vs_wrr.c | |||
@@ -22,6 +22,7 @@ | |||
22 | 22 | ||
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
25 | #include <linux/net.h> | ||
25 | 26 | ||
26 | #include <net/ip_vs.h> | 27 | #include <net/ip_vs.h> |
27 | 28 | ||
@@ -169,7 +170,7 @@ ip_vs_wrr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb) | |||
169 | */ | 170 | */ |
170 | if (mark->cw == 0) { | 171 | if (mark->cw == 0) { |
171 | mark->cl = &svc->destinations; | 172 | mark->cl = &svc->destinations; |
172 | IP_VS_INFO("ip_vs_wrr_schedule(): " | 173 | IP_VS_ERR_RL("ip_vs_wrr_schedule(): " |
173 | "no available servers\n"); | 174 | "no available servers\n"); |
174 | dest = NULL; | 175 | dest = NULL; |
175 | goto out; | 176 | goto out; |
diff --git a/net/ipv4/netfilter/nf_nat_core.c b/net/ipv4/netfilter/nf_nat_core.c index dd07362d2b8f..0d5fa3a54d04 100644 --- a/net/ipv4/netfilter/nf_nat_core.c +++ b/net/ipv4/netfilter/nf_nat_core.c | |||
@@ -600,10 +600,10 @@ static void nf_nat_cleanup_conntrack(struct nf_conn *ct) | |||
600 | spin_unlock_bh(&nf_nat_lock); | 600 | spin_unlock_bh(&nf_nat_lock); |
601 | } | 601 | } |
602 | 602 | ||
603 | static void nf_nat_move_storage(struct nf_conn *conntrack, void *old) | 603 | static void nf_nat_move_storage(void *new, void *old) |
604 | { | 604 | { |
605 | struct nf_conn_nat *new_nat = nf_ct_ext_find(conntrack, NF_CT_EXT_NAT); | 605 | struct nf_conn_nat *new_nat = new; |
606 | struct nf_conn_nat *old_nat = (struct nf_conn_nat *)old; | 606 | struct nf_conn_nat *old_nat = old; |
607 | struct nf_conn *ct = old_nat->ct; | 607 | struct nf_conn *ct = old_nat->ct; |
608 | 608 | ||
609 | if (!ct || !(ct->status & IPS_NAT_DONE_MASK)) | 609 | if (!ct || !(ct->status & IPS_NAT_DONE_MASK)) |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 8842ecb9be48..525787b52b72 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -2041,7 +2041,7 @@ int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr, | |||
2041 | int iif = dev->ifindex; | 2041 | int iif = dev->ifindex; |
2042 | struct net *net; | 2042 | struct net *net; |
2043 | 2043 | ||
2044 | net = skb->dev->nd_net; | 2044 | net = dev->nd_net; |
2045 | tos &= IPTOS_RT_MASK; | 2045 | tos &= IPTOS_RT_MASK; |
2046 | hash = rt_hash(daddr, saddr, iif); | 2046 | hash = rt_hash(daddr, saddr, iif); |
2047 | 2047 | ||
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 513f72e3db0d..6e7b56ef4449 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -1620,7 +1620,7 @@ static struct rt6_info *rt6_add_route_info(struct in6_addr *prefix, int prefixle | |||
1620 | { | 1620 | { |
1621 | struct fib6_config cfg = { | 1621 | struct fib6_config cfg = { |
1622 | .fc_table = RT6_TABLE_INFO, | 1622 | .fc_table = RT6_TABLE_INFO, |
1623 | .fc_metric = 1024, | 1623 | .fc_metric = IP6_RT_PRIO_USER, |
1624 | .fc_ifindex = ifindex, | 1624 | .fc_ifindex = ifindex, |
1625 | .fc_dst_len = prefixlen, | 1625 | .fc_dst_len = prefixlen, |
1626 | .fc_flags = RTF_GATEWAY | RTF_ADDRCONF | RTF_ROUTEINFO | | 1626 | .fc_flags = RTF_GATEWAY | RTF_ADDRCONF | RTF_ROUTEINFO | |
@@ -1670,7 +1670,7 @@ struct rt6_info *rt6_add_dflt_router(struct in6_addr *gwaddr, | |||
1670 | { | 1670 | { |
1671 | struct fib6_config cfg = { | 1671 | struct fib6_config cfg = { |
1672 | .fc_table = RT6_TABLE_DFLT, | 1672 | .fc_table = RT6_TABLE_DFLT, |
1673 | .fc_metric = 1024, | 1673 | .fc_metric = IP6_RT_PRIO_USER, |
1674 | .fc_ifindex = dev->ifindex, | 1674 | .fc_ifindex = dev->ifindex, |
1675 | .fc_flags = RTF_GATEWAY | RTF_ADDRCONF | RTF_DEFAULT | | 1675 | .fc_flags = RTF_GATEWAY | RTF_ADDRCONF | RTF_DEFAULT | |
1676 | RTF_UP | RTF_EXPIRES | RTF_PREF(pref), | 1676 | RTF_UP | RTF_EXPIRES | RTF_PREF(pref), |
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c index 2255e3c082ed..fee22caf1bad 100644 --- a/net/iucv/af_iucv.c +++ b/net/iucv/af_iucv.c | |||
@@ -482,6 +482,10 @@ static int iucv_sock_connect(struct socket *sock, struct sockaddr *addr, | |||
482 | /* Create path. */ | 482 | /* Create path. */ |
483 | iucv->path = iucv_path_alloc(IUCV_QUEUELEN_DEFAULT, | 483 | iucv->path = iucv_path_alloc(IUCV_QUEUELEN_DEFAULT, |
484 | IPRMDATA, GFP_KERNEL); | 484 | IPRMDATA, GFP_KERNEL); |
485 | if (!iucv->path) { | ||
486 | err = -ENOMEM; | ||
487 | goto done; | ||
488 | } | ||
485 | err = iucv_path_connect(iucv->path, &af_iucv_handler, | 489 | err = iucv_path_connect(iucv->path, &af_iucv_handler, |
486 | sa->siucv_user_id, NULL, user_data, sk); | 490 | sa->siucv_user_id, NULL, user_data, sk); |
487 | if (err) { | 491 | if (err) { |
@@ -1094,6 +1098,8 @@ static void iucv_callback_rx(struct iucv_path *path, struct iucv_message *msg) | |||
1094 | 1098 | ||
1095 | save_message: | 1099 | save_message: |
1096 | save_msg = kzalloc(sizeof(struct sock_msg_q), GFP_ATOMIC | GFP_DMA); | 1100 | save_msg = kzalloc(sizeof(struct sock_msg_q), GFP_ATOMIC | GFP_DMA); |
1101 | if (!save_msg) | ||
1102 | return; | ||
1097 | save_msg->path = path; | 1103 | save_msg->path = path; |
1098 | save_msg->msg = *msg; | 1104 | save_msg->msg = *msg; |
1099 | 1105 | ||
@@ -1106,24 +1112,31 @@ static void iucv_callback_txdone(struct iucv_path *path, | |||
1106 | struct iucv_message *msg) | 1112 | struct iucv_message *msg) |
1107 | { | 1113 | { |
1108 | struct sock *sk = path->private; | 1114 | struct sock *sk = path->private; |
1109 | struct sk_buff *this; | 1115 | struct sk_buff *this = NULL; |
1110 | struct sk_buff_head *list = &iucv_sk(sk)->send_skb_q; | 1116 | struct sk_buff_head *list = &iucv_sk(sk)->send_skb_q; |
1111 | struct sk_buff *list_skb = list->next; | 1117 | struct sk_buff *list_skb = list->next; |
1112 | unsigned long flags; | 1118 | unsigned long flags; |
1113 | 1119 | ||
1114 | if (list_skb) { | 1120 | if (!skb_queue_empty(list)) { |
1115 | spin_lock_irqsave(&list->lock, flags); | 1121 | spin_lock_irqsave(&list->lock, flags); |
1116 | 1122 | ||
1117 | do { | 1123 | while (list_skb != (struct sk_buff *)list) { |
1118 | this = list_skb; | 1124 | if (!memcmp(&msg->tag, list_skb->cb, 4)) { |
1125 | this = list_skb; | ||
1126 | break; | ||
1127 | } | ||
1119 | list_skb = list_skb->next; | 1128 | list_skb = list_skb->next; |
1120 | } while (memcmp(&msg->tag, this->cb, 4) && list_skb); | 1129 | } |
1130 | if (this) | ||
1131 | __skb_unlink(this, list); | ||
1121 | 1132 | ||
1122 | spin_unlock_irqrestore(&list->lock, flags); | 1133 | spin_unlock_irqrestore(&list->lock, flags); |
1123 | 1134 | ||
1124 | skb_unlink(this, &iucv_sk(sk)->send_skb_q); | 1135 | if (this) |
1125 | kfree_skb(this); | 1136 | kfree_skb(this); |
1126 | } | 1137 | } |
1138 | if (!this) | ||
1139 | printk(KERN_ERR "AF_IUCV msg tag %u not found\n", msg->tag); | ||
1127 | 1140 | ||
1128 | if (sk->sk_state == IUCV_CLOSING) { | 1141 | if (sk->sk_state == IUCV_CLOSING) { |
1129 | if (skb_queue_empty(&iucv_sk(sk)->send_skb_q)) { | 1142 | if (skb_queue_empty(&iucv_sk(sk)->send_skb_q)) { |
diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c index f13fe8821cbd..2753b0c448f3 100644 --- a/net/iucv/iucv.c +++ b/net/iucv/iucv.c | |||
@@ -693,9 +693,9 @@ int iucv_register(struct iucv_handler *handler, int smp) | |||
693 | iucv_setmask_up(); | 693 | iucv_setmask_up(); |
694 | INIT_LIST_HEAD(&handler->paths); | 694 | INIT_LIST_HEAD(&handler->paths); |
695 | 695 | ||
696 | spin_lock_irq(&iucv_table_lock); | 696 | spin_lock_bh(&iucv_table_lock); |
697 | list_add_tail(&handler->list, &iucv_handler_list); | 697 | list_add_tail(&handler->list, &iucv_handler_list); |
698 | spin_unlock_irq(&iucv_table_lock); | 698 | spin_unlock_bh(&iucv_table_lock); |
699 | rc = 0; | 699 | rc = 0; |
700 | out_mutex: | 700 | out_mutex: |
701 | mutex_unlock(&iucv_register_mutex); | 701 | mutex_unlock(&iucv_register_mutex); |
diff --git a/net/key/af_key.c b/net/key/af_key.c index 45c3c27d279a..b3ac85e808ac 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c | |||
@@ -3734,21 +3734,15 @@ static struct net_proto_family pfkey_family_ops = { | |||
3734 | }; | 3734 | }; |
3735 | 3735 | ||
3736 | #ifdef CONFIG_PROC_FS | 3736 | #ifdef CONFIG_PROC_FS |
3737 | static int pfkey_read_proc(char *buffer, char **start, off_t offset, | 3737 | static int pfkey_seq_show(struct seq_file *f, void *v) |
3738 | int length, int *eof, void *data) | ||
3739 | { | 3738 | { |
3740 | off_t pos = 0; | ||
3741 | off_t begin = 0; | ||
3742 | int len = 0; | ||
3743 | struct sock *s; | 3739 | struct sock *s; |
3744 | struct hlist_node *node; | ||
3745 | |||
3746 | len += sprintf(buffer,"sk RefCnt Rmem Wmem User Inode\n"); | ||
3747 | |||
3748 | read_lock(&pfkey_table_lock); | ||
3749 | 3740 | ||
3750 | sk_for_each(s, node, &pfkey_table) { | 3741 | s = (struct sock *)v; |
3751 | len += sprintf(buffer+len,"%p %-6d %-6u %-6u %-6u %-6lu", | 3742 | if (v == SEQ_START_TOKEN) |
3743 | seq_printf(f ,"sk RefCnt Rmem Wmem User Inode\n"); | ||
3744 | else | ||
3745 | seq_printf(f ,"%p %-6d %-6u %-6u %-6u %-6lu\n", | ||
3752 | s, | 3746 | s, |
3753 | atomic_read(&s->sk_refcnt), | 3747 | atomic_read(&s->sk_refcnt), |
3754 | atomic_read(&s->sk_rmem_alloc), | 3748 | atomic_read(&s->sk_rmem_alloc), |
@@ -3756,31 +3750,82 @@ static int pfkey_read_proc(char *buffer, char **start, off_t offset, | |||
3756 | sock_i_uid(s), | 3750 | sock_i_uid(s), |
3757 | sock_i_ino(s) | 3751 | sock_i_ino(s) |
3758 | ); | 3752 | ); |
3753 | return 0; | ||
3754 | } | ||
3759 | 3755 | ||
3760 | buffer[len++] = '\n'; | 3756 | static void *pfkey_seq_start(struct seq_file *f, loff_t *ppos) |
3757 | { | ||
3758 | struct sock *s; | ||
3759 | struct hlist_node *node; | ||
3760 | loff_t pos = *ppos; | ||
3761 | 3761 | ||
3762 | pos = begin + len; | 3762 | read_lock(&pfkey_table_lock); |
3763 | if (pos < offset) { | 3763 | if (pos == 0) |
3764 | len = 0; | 3764 | return SEQ_START_TOKEN; |
3765 | begin = pos; | ||
3766 | } | ||
3767 | if(pos > offset + length) | ||
3768 | goto done; | ||
3769 | } | ||
3770 | *eof = 1; | ||
3771 | 3765 | ||
3772 | done: | 3766 | sk_for_each(s, node, &pfkey_table) |
3767 | if (pos-- == 1) | ||
3768 | return s; | ||
3769 | |||
3770 | return NULL; | ||
3771 | } | ||
3772 | |||
3773 | static void *pfkey_seq_next(struct seq_file *f, void *v, loff_t *ppos) | ||
3774 | { | ||
3775 | ++*ppos; | ||
3776 | return (v == SEQ_START_TOKEN) ? | ||
3777 | sk_head(&pfkey_table) : | ||
3778 | sk_next((struct sock *)v); | ||
3779 | } | ||
3780 | |||
3781 | static void pfkey_seq_stop(struct seq_file *f, void *v) | ||
3782 | { | ||
3773 | read_unlock(&pfkey_table_lock); | 3783 | read_unlock(&pfkey_table_lock); |
3784 | } | ||
3785 | |||
3786 | static struct seq_operations pfkey_seq_ops = { | ||
3787 | .start = pfkey_seq_start, | ||
3788 | .next = pfkey_seq_next, | ||
3789 | .stop = pfkey_seq_stop, | ||
3790 | .show = pfkey_seq_show, | ||
3791 | }; | ||
3792 | |||
3793 | static int pfkey_seq_open(struct inode *inode, struct file *file) | ||
3794 | { | ||
3795 | return seq_open(file, &pfkey_seq_ops); | ||
3796 | } | ||
3774 | 3797 | ||
3775 | *start = buffer + (offset - begin); | 3798 | static struct file_operations pfkey_proc_ops = { |
3776 | len -= (offset - begin); | 3799 | .open = pfkey_seq_open, |
3800 | .read = seq_read, | ||
3801 | .llseek = seq_lseek, | ||
3802 | .release = seq_release, | ||
3803 | }; | ||
3777 | 3804 | ||
3778 | if (len > length) | 3805 | static int pfkey_init_proc(void) |
3779 | len = length; | 3806 | { |
3780 | if (len < 0) | 3807 | struct proc_dir_entry *e; |
3781 | len = 0; | ||
3782 | 3808 | ||
3783 | return len; | 3809 | e = create_proc_entry("pfkey", 0, init_net.proc_net); |
3810 | if (e == NULL) | ||
3811 | return -ENOMEM; | ||
3812 | |||
3813 | e->proc_fops = &pfkey_proc_ops; | ||
3814 | return 0; | ||
3815 | } | ||
3816 | |||
3817 | static void pfkey_exit_proc(void) | ||
3818 | { | ||
3819 | remove_proc_entry("net/pfkey", NULL); | ||
3820 | } | ||
3821 | #else | ||
3822 | static inline int pfkey_init_proc(void) | ||
3823 | { | ||
3824 | return 0; | ||
3825 | } | ||
3826 | |||
3827 | static inline void pfkey_exit_proc(void) | ||
3828 | { | ||
3784 | } | 3829 | } |
3785 | #endif | 3830 | #endif |
3786 | 3831 | ||
@@ -3798,7 +3843,7 @@ static struct xfrm_mgr pfkeyv2_mgr = | |||
3798 | static void __exit ipsec_pfkey_exit(void) | 3843 | static void __exit ipsec_pfkey_exit(void) |
3799 | { | 3844 | { |
3800 | xfrm_unregister_km(&pfkeyv2_mgr); | 3845 | xfrm_unregister_km(&pfkeyv2_mgr); |
3801 | remove_proc_entry("pfkey", init_net.proc_net); | 3846 | pfkey_exit_proc(); |
3802 | sock_unregister(PF_KEY); | 3847 | sock_unregister(PF_KEY); |
3803 | proto_unregister(&key_proto); | 3848 | proto_unregister(&key_proto); |
3804 | } | 3849 | } |
@@ -3813,21 +3858,17 @@ static int __init ipsec_pfkey_init(void) | |||
3813 | err = sock_register(&pfkey_family_ops); | 3858 | err = sock_register(&pfkey_family_ops); |
3814 | if (err != 0) | 3859 | if (err != 0) |
3815 | goto out_unregister_key_proto; | 3860 | goto out_unregister_key_proto; |
3816 | #ifdef CONFIG_PROC_FS | 3861 | err = pfkey_init_proc(); |
3817 | err = -ENOMEM; | 3862 | if (err != 0) |
3818 | if (create_proc_read_entry("pfkey", 0, init_net.proc_net, pfkey_read_proc, NULL) == NULL) | ||
3819 | goto out_sock_unregister; | 3863 | goto out_sock_unregister; |
3820 | #endif | ||
3821 | err = xfrm_register_km(&pfkeyv2_mgr); | 3864 | err = xfrm_register_km(&pfkeyv2_mgr); |
3822 | if (err != 0) | 3865 | if (err != 0) |
3823 | goto out_remove_proc_entry; | 3866 | goto out_remove_proc_entry; |
3824 | out: | 3867 | out: |
3825 | return err; | 3868 | return err; |
3826 | out_remove_proc_entry: | 3869 | out_remove_proc_entry: |
3827 | #ifdef CONFIG_PROC_FS | 3870 | pfkey_exit_proc(); |
3828 | remove_proc_entry("net/pfkey", NULL); | ||
3829 | out_sock_unregister: | 3871 | out_sock_unregister: |
3830 | #endif | ||
3831 | sock_unregister(PF_KEY); | 3872 | sock_unregister(PF_KEY); |
3832 | out_unregister_key_proto: | 3873 | out_unregister_key_proto: |
3833 | proto_unregister(&key_proto); | 3874 | proto_unregister(&key_proto); |
diff --git a/net/mac80211/Kconfig b/net/mac80211/Kconfig index e77592d050ce..45c7c0c3875e 100644 --- a/net/mac80211/Kconfig +++ b/net/mac80211/Kconfig | |||
@@ -1,6 +1,5 @@ | |||
1 | config MAC80211 | 1 | config MAC80211 |
2 | tristate "Generic IEEE 802.11 Networking Stack (mac80211)" | 2 | tristate "Generic IEEE 802.11 Networking Stack (mac80211)" |
3 | depends on EXPERIMENTAL | ||
4 | select CRYPTO | 3 | select CRYPTO |
5 | select CRYPTO_ECB | 4 | select CRYPTO_ECB |
6 | select CRYPTO_ARC4 | 5 | select CRYPTO_ARC4 |
diff --git a/net/netfilter/nf_conntrack_extend.c b/net/netfilter/nf_conntrack_extend.c index cf6ba6659a80..8b9be1e978cd 100644 --- a/net/netfilter/nf_conntrack_extend.c +++ b/net/netfilter/nf_conntrack_extend.c | |||
@@ -109,7 +109,8 @@ void *__nf_ct_ext_add(struct nf_conn *ct, enum nf_ct_ext_id id, gfp_t gfp) | |||
109 | rcu_read_lock(); | 109 | rcu_read_lock(); |
110 | t = rcu_dereference(nf_ct_ext_types[i]); | 110 | t = rcu_dereference(nf_ct_ext_types[i]); |
111 | if (t && t->move) | 111 | if (t && t->move) |
112 | t->move(ct, ct->ext + ct->ext->offset[i]); | 112 | t->move((void *)new + new->offset[i], |
113 | (void *)ct->ext + ct->ext->offset[i]); | ||
113 | rcu_read_unlock(); | 114 | rcu_read_unlock(); |
114 | } | 115 | } |
115 | kfree(ct->ext); | 116 | kfree(ct->ext); |
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c index 3e0cccae5636..202d7fa09483 100644 --- a/net/netfilter/nf_conntrack_proto_tcp.c +++ b/net/netfilter/nf_conntrack_proto_tcp.c | |||
@@ -125,7 +125,7 @@ enum tcp_bit_set { | |||
125 | * CLOSE_WAIT: ACK seen (after FIN) | 125 | * CLOSE_WAIT: ACK seen (after FIN) |
126 | * LAST_ACK: FIN seen (after FIN) | 126 | * LAST_ACK: FIN seen (after FIN) |
127 | * TIME_WAIT: last ACK seen | 127 | * TIME_WAIT: last ACK seen |
128 | * CLOSE: closed connection | 128 | * CLOSE: closed connection (RST) |
129 | * | 129 | * |
130 | * LISTEN state is not used. | 130 | * LISTEN state is not used. |
131 | * | 131 | * |
@@ -824,7 +824,21 @@ static int tcp_packet(struct nf_conn *ct, | |||
824 | case TCP_CONNTRACK_SYN_SENT: | 824 | case TCP_CONNTRACK_SYN_SENT: |
825 | if (old_state < TCP_CONNTRACK_TIME_WAIT) | 825 | if (old_state < TCP_CONNTRACK_TIME_WAIT) |
826 | break; | 826 | break; |
827 | if ((ct->proto.tcp.seen[!dir].flags & IP_CT_TCP_FLAG_CLOSE_INIT) | 827 | /* RFC 1122: "When a connection is closed actively, |
828 | * it MUST linger in TIME-WAIT state for a time 2xMSL | ||
829 | * (Maximum Segment Lifetime). However, it MAY accept | ||
830 | * a new SYN from the remote TCP to reopen the connection | ||
831 | * directly from TIME-WAIT state, if..." | ||
832 | * We ignore the conditions because we are in the | ||
833 | * TIME-WAIT state anyway. | ||
834 | * | ||
835 | * Handle aborted connections: we and the server | ||
836 | * think there is an existing connection but the client | ||
837 | * aborts it and starts a new one. | ||
838 | */ | ||
839 | if (((ct->proto.tcp.seen[dir].flags | ||
840 | | ct->proto.tcp.seen[!dir].flags) | ||
841 | & IP_CT_TCP_FLAG_CLOSE_INIT) | ||
828 | || (ct->proto.tcp.last_dir == dir | 842 | || (ct->proto.tcp.last_dir == dir |
829 | && ct->proto.tcp.last_index == TCP_RST_SET)) { | 843 | && ct->proto.tcp.last_index == TCP_RST_SET)) { |
830 | /* Attempt to reopen a closed/aborted connection. | 844 | /* Attempt to reopen a closed/aborted connection. |
@@ -838,15 +852,22 @@ static int tcp_packet(struct nf_conn *ct, | |||
838 | case TCP_CONNTRACK_IGNORE: | 852 | case TCP_CONNTRACK_IGNORE: |
839 | /* Ignored packets: | 853 | /* Ignored packets: |
840 | * | 854 | * |
855 | * Our connection entry may be out of sync, so ignore | ||
856 | * packets which may signal the real connection between | ||
857 | * the client and the server. | ||
858 | * | ||
841 | * a) SYN in ORIGINAL | 859 | * a) SYN in ORIGINAL |
842 | * b) SYN/ACK in REPLY | 860 | * b) SYN/ACK in REPLY |
843 | * c) ACK in reply direction after initial SYN in original. | 861 | * c) ACK in reply direction after initial SYN in original. |
862 | * | ||
863 | * If the ignored packet is invalid, the receiver will send | ||
864 | * a RST we'll catch below. | ||
844 | */ | 865 | */ |
845 | if (index == TCP_SYNACK_SET | 866 | if (index == TCP_SYNACK_SET |
846 | && ct->proto.tcp.last_index == TCP_SYN_SET | 867 | && ct->proto.tcp.last_index == TCP_SYN_SET |
847 | && ct->proto.tcp.last_dir != dir | 868 | && ct->proto.tcp.last_dir != dir |
848 | && ntohl(th->ack_seq) == ct->proto.tcp.last_end) { | 869 | && ntohl(th->ack_seq) == ct->proto.tcp.last_end) { |
849 | /* This SYN/ACK acknowledges a SYN that we earlier | 870 | /* b) This SYN/ACK acknowledges a SYN that we earlier |
850 | * ignored as invalid. This means that the client and | 871 | * ignored as invalid. This means that the client and |
851 | * the server are both in sync, while the firewall is | 872 | * the server are both in sync, while the firewall is |
852 | * not. We kill this session and block the SYN/ACK so | 873 | * not. We kill this session and block the SYN/ACK so |
@@ -870,7 +891,7 @@ static int tcp_packet(struct nf_conn *ct, | |||
870 | write_unlock_bh(&tcp_lock); | 891 | write_unlock_bh(&tcp_lock); |
871 | if (LOG_INVALID(IPPROTO_TCP)) | 892 | if (LOG_INVALID(IPPROTO_TCP)) |
872 | nf_log_packet(pf, 0, skb, NULL, NULL, NULL, | 893 | nf_log_packet(pf, 0, skb, NULL, NULL, NULL, |
873 | "nf_ct_tcp: invalid packed ignored "); | 894 | "nf_ct_tcp: invalid packet ignored "); |
874 | return NF_ACCEPT; | 895 | return NF_ACCEPT; |
875 | case TCP_CONNTRACK_MAX: | 896 | case TCP_CONNTRACK_MAX: |
876 | /* Invalid packet */ | 897 | /* Invalid packet */ |
@@ -924,8 +945,7 @@ static int tcp_packet(struct nf_conn *ct, | |||
924 | 945 | ||
925 | ct->proto.tcp.state = new_state; | 946 | ct->proto.tcp.state = new_state; |
926 | if (old_state != new_state | 947 | if (old_state != new_state |
927 | && (new_state == TCP_CONNTRACK_FIN_WAIT | 948 | && new_state == TCP_CONNTRACK_CLOSE) |
928 | || new_state == TCP_CONNTRACK_CLOSE)) | ||
929 | ct->proto.tcp.seen[dir].flags |= IP_CT_TCP_FLAG_CLOSE_INIT; | 949 | ct->proto.tcp.seen[dir].flags |= IP_CT_TCP_FLAG_CLOSE_INIT; |
930 | timeout = ct->proto.tcp.retrans >= nf_ct_tcp_max_retrans | 950 | timeout = ct->proto.tcp.retrans >= nf_ct_tcp_max_retrans |
931 | && tcp_timeouts[new_state] > nf_ct_tcp_timeout_max_retrans | 951 | && tcp_timeouts[new_state] > nf_ct_tcp_timeout_max_retrans |
diff --git a/net/netfilter/xt_iprange.c b/net/netfilter/xt_iprange.c index 01035fc0e140..4f984dc60319 100644 --- a/net/netfilter/xt_iprange.c +++ b/net/netfilter/xt_iprange.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/ip.h> | 13 | #include <linux/ip.h> |
14 | #include <linux/ipv6.h> | 14 | #include <linux/ipv6.h> |
15 | #include <linux/netfilter/x_tables.h> | 15 | #include <linux/netfilter/x_tables.h> |
16 | #include <linux/netfilter/xt_iprange.h> | ||
16 | #include <linux/netfilter_ipv4/ipt_iprange.h> | 17 | #include <linux/netfilter_ipv4/ipt_iprange.h> |
17 | 18 | ||
18 | static bool | 19 | static bool |
@@ -148,7 +149,7 @@ static struct xt_match iprange_mt_reg[] __read_mostly = { | |||
148 | { | 149 | { |
149 | .name = "iprange", | 150 | .name = "iprange", |
150 | .revision = 1, | 151 | .revision = 1, |
151 | .family = AF_INET6, | 152 | .family = AF_INET, |
152 | .match = iprange_mt4, | 153 | .match = iprange_mt4, |
153 | .matchsize = sizeof(struct xt_iprange_mtinfo), | 154 | .matchsize = sizeof(struct xt_iprange_mtinfo), |
154 | .me = THIS_MODULE, | 155 | .me = THIS_MODULE, |
diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c index 5e82f1c0afbb..2d0c29c837f7 100644 --- a/net/rxrpc/af_rxrpc.c +++ b/net/rxrpc/af_rxrpc.c | |||
@@ -239,7 +239,7 @@ static struct rxrpc_transport *rxrpc_name_to_transport(struct socket *sock, | |||
239 | /* find a remote transport endpoint from the local one */ | 239 | /* find a remote transport endpoint from the local one */ |
240 | peer = rxrpc_get_peer(srx, gfp); | 240 | peer = rxrpc_get_peer(srx, gfp); |
241 | if (IS_ERR(peer)) | 241 | if (IS_ERR(peer)) |
242 | return ERR_PTR(PTR_ERR(peer)); | 242 | return ERR_CAST(peer); |
243 | 243 | ||
244 | /* find a transport */ | 244 | /* find a transport */ |
245 | trans = rxrpc_get_transport(rx->local, peer, gfp); | 245 | trans = rxrpc_get_transport(rx->local, peer, gfp); |
@@ -282,7 +282,7 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock, | |||
282 | trans = rxrpc_name_to_transport(sock, (struct sockaddr *) srx, | 282 | trans = rxrpc_name_to_transport(sock, (struct sockaddr *) srx, |
283 | sizeof(*srx), 0, gfp); | 283 | sizeof(*srx), 0, gfp); |
284 | if (IS_ERR(trans)) { | 284 | if (IS_ERR(trans)) { |
285 | call = ERR_PTR(PTR_ERR(trans)); | 285 | call = ERR_CAST(trans); |
286 | trans = NULL; | 286 | trans = NULL; |
287 | goto out; | 287 | goto out; |
288 | } | 288 | } |
@@ -306,7 +306,7 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock, | |||
306 | 306 | ||
307 | bundle = rxrpc_get_bundle(rx, trans, key, service_id, gfp); | 307 | bundle = rxrpc_get_bundle(rx, trans, key, service_id, gfp); |
308 | if (IS_ERR(bundle)) { | 308 | if (IS_ERR(bundle)) { |
309 | call = ERR_PTR(PTR_ERR(bundle)); | 309 | call = ERR_CAST(bundle); |
310 | goto out; | 310 | goto out; |
311 | } | 311 | } |
312 | 312 | ||
diff --git a/net/sched/cls_flow.c b/net/sched/cls_flow.c index 8d7698621f0a..971b867e0484 100644 --- a/net/sched/cls_flow.c +++ b/net/sched/cls_flow.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/in.h> | 19 | #include <linux/in.h> |
20 | #include <linux/ip.h> | 20 | #include <linux/ip.h> |
21 | #include <linux/ipv6.h> | 21 | #include <linux/ipv6.h> |
22 | #include <linux/if_vlan.h> | ||
22 | 23 | ||
23 | #include <net/pkt_cls.h> | 24 | #include <net/pkt_cls.h> |
24 | #include <net/ip.h> | 25 | #include <net/ip.h> |
@@ -270,6 +271,15 @@ static u32 flow_get_skgid(const struct sk_buff *skb) | |||
270 | return 0; | 271 | return 0; |
271 | } | 272 | } |
272 | 273 | ||
274 | static u32 flow_get_vlan_tag(const struct sk_buff *skb) | ||
275 | { | ||
276 | u16 uninitialized_var(tag); | ||
277 | |||
278 | if (vlan_get_tag(skb, &tag) < 0) | ||
279 | return 0; | ||
280 | return tag & VLAN_VID_MASK; | ||
281 | } | ||
282 | |||
273 | static u32 flow_key_get(const struct sk_buff *skb, int key) | 283 | static u32 flow_key_get(const struct sk_buff *skb, int key) |
274 | { | 284 | { |
275 | switch (key) { | 285 | switch (key) { |
@@ -305,6 +315,8 @@ static u32 flow_key_get(const struct sk_buff *skb, int key) | |||
305 | return flow_get_skuid(skb); | 315 | return flow_get_skuid(skb); |
306 | case FLOW_KEY_SKGID: | 316 | case FLOW_KEY_SKGID: |
307 | return flow_get_skgid(skb); | 317 | return flow_get_skgid(skb); |
318 | case FLOW_KEY_VLAN_TAG: | ||
319 | return flow_get_vlan_tag(skb); | ||
308 | default: | 320 | default: |
309 | WARN_ON(1); | 321 | WARN_ON(1); |
310 | return 0; | 322 | return 0; |
@@ -402,12 +414,13 @@ static int flow_change(struct tcf_proto *tp, unsigned long base, | |||
402 | 414 | ||
403 | if (tb[TCA_FLOW_KEYS]) { | 415 | if (tb[TCA_FLOW_KEYS]) { |
404 | keymask = nla_get_u32(tb[TCA_FLOW_KEYS]); | 416 | keymask = nla_get_u32(tb[TCA_FLOW_KEYS]); |
405 | if (fls(keymask) - 1 > FLOW_KEY_MAX) | ||
406 | return -EOPNOTSUPP; | ||
407 | 417 | ||
408 | nkeys = hweight32(keymask); | 418 | nkeys = hweight32(keymask); |
409 | if (nkeys == 0) | 419 | if (nkeys == 0) |
410 | return -EINVAL; | 420 | return -EINVAL; |
421 | |||
422 | if (fls(keymask) - 1 > FLOW_KEY_MAX) | ||
423 | return -EOPNOTSUPP; | ||
411 | } | 424 | } |
412 | 425 | ||
413 | err = tcf_exts_validate(tp, tb, tca[TCA_RATE], &e, &flow_ext_map); | 426 | err = tcf_exts_validate(tp, tb, tca[TCA_RATE], &e, &flow_ext_map); |
diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c index 9c2ec1992a2a..3da4129b89d1 100644 --- a/net/sched/em_meta.c +++ b/net/sched/em_meta.c | |||
@@ -176,7 +176,7 @@ META_COLLECTOR(var_dev) | |||
176 | 176 | ||
177 | META_COLLECTOR(int_vlan_tag) | 177 | META_COLLECTOR(int_vlan_tag) |
178 | { | 178 | { |
179 | unsigned short tag; | 179 | unsigned short uninitialized_var(tag); |
180 | if (vlan_get_tag(skb, &tag) < 0) | 180 | if (vlan_get_tag(skb, &tag) < 0) |
181 | *err = -1; | 181 | *err = -1; |
182 | else | 182 | else |
@@ -687,8 +687,8 @@ static inline struct meta_type_ops * meta_type_ops(struct meta_value *v) | |||
687 | * Core | 687 | * Core |
688 | **************************************************************************/ | 688 | **************************************************************************/ |
689 | 689 | ||
690 | static inline int meta_get(struct sk_buff *skb, struct tcf_pkt_info *info, | 690 | static int meta_get(struct sk_buff *skb, struct tcf_pkt_info *info, |
691 | struct meta_value *v, struct meta_obj *dst) | 691 | struct meta_value *v, struct meta_obj *dst) |
692 | { | 692 | { |
693 | int err = 0; | 693 | int err = 0; |
694 | 694 | ||
@@ -733,13 +733,15 @@ static int em_meta_match(struct sk_buff *skb, struct tcf_ematch *m, | |||
733 | return 0; | 733 | return 0; |
734 | } | 734 | } |
735 | 735 | ||
736 | static inline void meta_delete(struct meta_match *meta) | 736 | static void meta_delete(struct meta_match *meta) |
737 | { | 737 | { |
738 | struct meta_type_ops *ops = meta_type_ops(&meta->lvalue); | 738 | if (meta) { |
739 | struct meta_type_ops *ops = meta_type_ops(&meta->lvalue); | ||
739 | 740 | ||
740 | if (ops && ops->destroy) { | 741 | if (ops && ops->destroy) { |
741 | ops->destroy(&meta->lvalue); | 742 | ops->destroy(&meta->lvalue); |
742 | ops->destroy(&meta->rvalue); | 743 | ops->destroy(&meta->rvalue); |
744 | } | ||
743 | } | 745 | } |
744 | 746 | ||
745 | kfree(meta); | 747 | kfree(meta); |
diff --git a/net/sched/ematch.c b/net/sched/ematch.c index 74ff918455a2..5e6f82e0e6f3 100644 --- a/net/sched/ematch.c +++ b/net/sched/ematch.c | |||
@@ -312,10 +312,9 @@ int tcf_em_tree_validate(struct tcf_proto *tp, struct nlattr *nla, | |||
312 | struct tcf_ematch_tree_hdr *tree_hdr; | 312 | struct tcf_ematch_tree_hdr *tree_hdr; |
313 | struct tcf_ematch *em; | 313 | struct tcf_ematch *em; |
314 | 314 | ||
315 | if (!nla) { | 315 | memset(tree, 0, sizeof(*tree)); |
316 | memset(tree, 0, sizeof(*tree)); | 316 | if (!nla) |
317 | return 0; | 317 | return 0; |
318 | } | ||
319 | 318 | ||
320 | err = nla_parse_nested(tb, TCA_EMATCH_TREE_MAX, nla, em_policy); | 319 | err = nla_parse_nested(tb, TCA_EMATCH_TREE_MAX, nla, em_policy); |
321 | if (err < 0) | 320 | if (err < 0) |
@@ -410,7 +409,7 @@ void tcf_em_tree_destroy(struct tcf_proto *tp, struct tcf_ematch_tree *tree) | |||
410 | if (em->ops) { | 409 | if (em->ops) { |
411 | if (em->ops->destroy) | 410 | if (em->ops->destroy) |
412 | em->ops->destroy(tp, em); | 411 | em->ops->destroy(tp, em); |
413 | else if (!tcf_em_is_simple(em) && em->data) | 412 | else if (!tcf_em_is_simple(em)) |
414 | kfree((void *) em->data); | 413 | kfree((void *) em->data); |
415 | module_put(em->ops->owner); | 414 | module_put(em->ops->owner); |
416 | } | 415 | } |
@@ -418,6 +417,7 @@ void tcf_em_tree_destroy(struct tcf_proto *tp, struct tcf_ematch_tree *tree) | |||
418 | 417 | ||
419 | tree->hdr.nmatches = 0; | 418 | tree->hdr.nmatches = 0; |
420 | kfree(tree->matches); | 419 | kfree(tree->matches); |
420 | tree->matches = NULL; | ||
421 | } | 421 | } |
422 | EXPORT_SYMBOL(tcf_em_tree_destroy); | 422 | EXPORT_SYMBOL(tcf_em_tree_destroy); |
423 | 423 | ||
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c index e1a579efc215..795c761ad99f 100644 --- a/net/sched/sch_htb.c +++ b/net/sched/sch_htb.c | |||
@@ -609,14 +609,14 @@ static int htb_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
609 | /* TODO: requeuing packet charges it to policers again !! */ | 609 | /* TODO: requeuing packet charges it to policers again !! */ |
610 | static int htb_requeue(struct sk_buff *skb, struct Qdisc *sch) | 610 | static int htb_requeue(struct sk_buff *skb, struct Qdisc *sch) |
611 | { | 611 | { |
612 | int ret; | ||
612 | struct htb_sched *q = qdisc_priv(sch); | 613 | struct htb_sched *q = qdisc_priv(sch); |
613 | int ret = NET_XMIT_SUCCESS; | ||
614 | struct htb_class *cl = htb_classify(skb, sch, &ret); | 614 | struct htb_class *cl = htb_classify(skb, sch, &ret); |
615 | struct sk_buff *tskb; | 615 | struct sk_buff *tskb; |
616 | 616 | ||
617 | if (cl == HTB_DIRECT || !cl) { | 617 | if (cl == HTB_DIRECT) { |
618 | /* enqueue to helper queue */ | 618 | /* enqueue to helper queue */ |
619 | if (q->direct_queue.qlen < q->direct_qlen && cl) { | 619 | if (q->direct_queue.qlen < q->direct_qlen) { |
620 | __skb_queue_head(&q->direct_queue, skb); | 620 | __skb_queue_head(&q->direct_queue, skb); |
621 | } else { | 621 | } else { |
622 | __skb_queue_head(&q->direct_queue, skb); | 622 | __skb_queue_head(&q->direct_queue, skb); |
@@ -625,6 +625,13 @@ static int htb_requeue(struct sk_buff *skb, struct Qdisc *sch) | |||
625 | sch->qstats.drops++; | 625 | sch->qstats.drops++; |
626 | return NET_XMIT_CN; | 626 | return NET_XMIT_CN; |
627 | } | 627 | } |
628 | #ifdef CONFIG_NET_CLS_ACT | ||
629 | } else if (!cl) { | ||
630 | if (ret == NET_XMIT_BYPASS) | ||
631 | sch->qstats.drops++; | ||
632 | kfree_skb(skb); | ||
633 | return ret; | ||
634 | #endif | ||
628 | } else if (cl->un.leaf.q->ops->requeue(skb, cl->un.leaf.q) != | 635 | } else if (cl->un.leaf.q->ops->requeue(skb, cl->un.leaf.q) != |
629 | NET_XMIT_SUCCESS) { | 636 | NET_XMIT_SUCCESS) { |
630 | sch->qstats.drops++; | 637 | sch->qstats.drops++; |
diff --git a/net/sctp/associola.c b/net/sctp/associola.c index a016e78061f4..d29f792e0529 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c | |||
@@ -1,21 +1,21 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * (C) Copyright IBM Corp. 2001, 2004 | 2 | * (C) Copyright IBM Corp. 2001, 2004 |
3 | * Copyright (c) 1999-2000 Cisco, Inc. | 3 | * Copyright (c) 1999-2000 Cisco, Inc. |
4 | * Copyright (c) 1999-2001 Motorola, Inc. | 4 | * Copyright (c) 1999-2001 Motorola, Inc. |
5 | * Copyright (c) 2001 Intel Corp. | 5 | * Copyright (c) 2001 Intel Corp. |
6 | * Copyright (c) 2001 La Monte H.P. Yarroll | 6 | * Copyright (c) 2001 La Monte H.P. Yarroll |
7 | * | 7 | * |
8 | * This file is part of the SCTP kernel reference Implementation | 8 | * This file is part of the SCTP kernel implementation |
9 | * | 9 | * |
10 | * This module provides the abstraction for an SCTP association. | 10 | * This module provides the abstraction for an SCTP association. |
11 | * | 11 | * |
12 | * The SCTP reference implementation is free software; | 12 | * This SCTP implementation is free software; |
13 | * you can redistribute it and/or modify it under the terms of | 13 | * you can redistribute it and/or modify it under the terms of |
14 | * the GNU General Public License as published by | 14 | * the GNU General Public License as published by |
15 | * the Free Software Foundation; either version 2, or (at your option) | 15 | * the Free Software Foundation; either version 2, or (at your option) |
16 | * any later version. | 16 | * any later version. |
17 | * | 17 | * |
18 | * The SCTP reference implementation is distributed in the hope that it | 18 | * This SCTP implementation is distributed in the hope that it |
19 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 19 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
20 | * ************************ | 20 | * ************************ |
21 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 21 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
@@ -1525,7 +1525,7 @@ struct sctp_chunk *sctp_assoc_lookup_asconf_ack( | |||
1525 | const struct sctp_association *asoc, | 1525 | const struct sctp_association *asoc, |
1526 | __be32 serial) | 1526 | __be32 serial) |
1527 | { | 1527 | { |
1528 | struct sctp_chunk *ack = NULL; | 1528 | struct sctp_chunk *ack; |
1529 | 1529 | ||
1530 | /* Walk through the list of cached ASCONF-ACKs and find the | 1530 | /* Walk through the list of cached ASCONF-ACKs and find the |
1531 | * ack chunk whose serial number matches that of the request. | 1531 | * ack chunk whose serial number matches that of the request. |
@@ -1533,9 +1533,9 @@ struct sctp_chunk *sctp_assoc_lookup_asconf_ack( | |||
1533 | list_for_each_entry(ack, &asoc->asconf_ack_list, transmitted_list) { | 1533 | list_for_each_entry(ack, &asoc->asconf_ack_list, transmitted_list) { |
1534 | if (ack->subh.addip_hdr->serial == serial) { | 1534 | if (ack->subh.addip_hdr->serial == serial) { |
1535 | sctp_chunk_hold(ack); | 1535 | sctp_chunk_hold(ack); |
1536 | break; | 1536 | return ack; |
1537 | } | 1537 | } |
1538 | } | 1538 | } |
1539 | 1539 | ||
1540 | return ack; | 1540 | return NULL; |
1541 | } | 1541 | } |
diff --git a/net/sctp/auth.c b/net/sctp/auth.c index ae367c82e512..8bb79f281774 100644 --- a/net/sctp/auth.c +++ b/net/sctp/auth.c | |||
@@ -1,15 +1,15 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * (C) Copyright 2007 Hewlett-Packard Development Company, L.P. | 2 | * (C) Copyright 2007 Hewlett-Packard Development Company, L.P. |
3 | * | 3 | * |
4 | * This file is part of the SCTP kernel reference Implementation | 4 | * This file is part of the SCTP kernel implementation |
5 | * | 5 | * |
6 | * The SCTP reference implementation is free software; | 6 | * This SCTP implementation is free software; |
7 | * you can redistribute it and/or modify it under the terms of | 7 | * you can redistribute it and/or modify it under the terms of |
8 | * the GNU General Public License as published by | 8 | * the GNU General Public License as published by |
9 | * the Free Software Foundation; either version 2, or (at your option) | 9 | * the Free Software Foundation; either version 2, or (at your option) |
10 | * any later version. | 10 | * any later version. |
11 | * | 11 | * |
12 | * The SCTP reference implementation is distributed in the hope that it | 12 | * This SCTP implementation is distributed in the hope that it |
13 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 13 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
14 | * ************************ | 14 | * ************************ |
15 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 15 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
diff --git a/net/sctp/bind_addr.c b/net/sctp/bind_addr.c index 13fbfb449a55..a27511ebc4cb 100644 --- a/net/sctp/bind_addr.c +++ b/net/sctp/bind_addr.c | |||
@@ -1,20 +1,20 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * (C) Copyright IBM Corp. 2001, 2003 | 2 | * (C) Copyright IBM Corp. 2001, 2003 |
3 | * Copyright (c) Cisco 1999,2000 | 3 | * Copyright (c) Cisco 1999,2000 |
4 | * Copyright (c) Motorola 1999,2000,2001 | 4 | * Copyright (c) Motorola 1999,2000,2001 |
5 | * Copyright (c) La Monte H.P. Yarroll 2001 | 5 | * Copyright (c) La Monte H.P. Yarroll 2001 |
6 | * | 6 | * |
7 | * This file is part of the SCTP kernel reference implementation. | 7 | * This file is part of the SCTP kernel implementation. |
8 | * | 8 | * |
9 | * A collection class to handle the storage of transport addresses. | 9 | * A collection class to handle the storage of transport addresses. |
10 | * | 10 | * |
11 | * The SCTP reference implementation is free software; | 11 | * This SCTP implementation is free software; |
12 | * you can redistribute it and/or modify it under the terms of | 12 | * you can redistribute it and/or modify it under the terms of |
13 | * the GNU General Public License as published by | 13 | * the GNU General Public License as published by |
14 | * the Free Software Foundation; either version 2, or (at your option) | 14 | * the Free Software Foundation; either version 2, or (at your option) |
15 | * any later version. | 15 | * any later version. |
16 | * | 16 | * |
17 | * The SCTP reference implementation is distributed in the hope that it | 17 | * This SCTP implementation is distributed in the hope that it |
18 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 18 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
19 | * ************************ | 19 | * ************************ |
20 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 20 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
diff --git a/net/sctp/chunk.c b/net/sctp/chunk.c index 619d0f2dee51..4d3128f5ccc3 100644 --- a/net/sctp/chunk.c +++ b/net/sctp/chunk.c | |||
@@ -1,17 +1,17 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * (C) Copyright IBM Corp. 2003, 2004 | 2 | * (C) Copyright IBM Corp. 2003, 2004 |
3 | * | 3 | * |
4 | * This file is part of the SCTP kernel reference Implementation | 4 | * This file is part of the SCTP kernel implementation |
5 | * | 5 | * |
6 | * This file contains the code relating the chunk abstraction. | 6 | * This file contains the code relating the chunk abstraction. |
7 | * | 7 | * |
8 | * The SCTP reference implementation is free software; | 8 | * This SCTP implementation is free software; |
9 | * you can redistribute it and/or modify it under the terms of | 9 | * you can redistribute it and/or modify it under the terms of |
10 | * the GNU General Public License as published by | 10 | * the GNU General Public License as published by |
11 | * the Free Software Foundation; either version 2, or (at your option) | 11 | * the Free Software Foundation; either version 2, or (at your option) |
12 | * any later version. | 12 | * any later version. |
13 | * | 13 | * |
14 | * The SCTP reference implementation is distributed in the hope that it | 14 | * This SCTP implementation is distributed in the hope that it |
15 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
16 | * ************************ | 16 | * ************************ |
17 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 17 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
diff --git a/net/sctp/command.c b/net/sctp/command.c index 3ff804757f4a..bb977330002a 100644 --- a/net/sctp/command.c +++ b/net/sctp/command.c | |||
@@ -1,18 +1,18 @@ | |||
1 | /* SCTP kernel reference Implementation Copyright (C) 1999-2001 | 1 | /* SCTP kernel implementation Copyright (C) 1999-2001 |
2 | * Cisco, Motorola, and IBM | 2 | * Cisco, Motorola, and IBM |
3 | * Copyright 2001 La Monte H.P. Yarroll | 3 | * Copyright 2001 La Monte H.P. Yarroll |
4 | * | 4 | * |
5 | * This file is part of the SCTP kernel reference Implementation | 5 | * This file is part of the SCTP kernel implementation |
6 | * | 6 | * |
7 | * These functions manipulate sctp command sequences. | 7 | * These functions manipulate sctp command sequences. |
8 | * | 8 | * |
9 | * The SCTP reference implementation is free software; | 9 | * This SCTP implementation is free software; |
10 | * you can redistribute it and/or modify it under the terms of | 10 | * you can redistribute it and/or modify it under the terms of |
11 | * the GNU General Public License as published by | 11 | * the GNU General Public License as published by |
12 | * the Free Software Foundation; either version 2, or (at your option) | 12 | * the Free Software Foundation; either version 2, or (at your option) |
13 | * any later version. | 13 | * any later version. |
14 | * | 14 | * |
15 | * The SCTP reference implementation is distributed in the hope that it | 15 | * This SCTP implementation is distributed in the hope that it |
16 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 16 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
17 | * ************************ | 17 | * ************************ |
18 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 18 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
diff --git a/net/sctp/debug.c b/net/sctp/debug.c index 80f70aa53386..67715f4eb849 100644 --- a/net/sctp/debug.c +++ b/net/sctp/debug.c | |||
@@ -1,25 +1,21 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * (C) Copyright IBM Corp. 2001, 2004 | 2 | * (C) Copyright IBM Corp. 2001, 2004 |
3 | * Copyright (c) 1999-2000 Cisco, Inc. | 3 | * Copyright (c) 1999-2000 Cisco, Inc. |
4 | * Copyright (c) 1999-2001 Motorola, Inc. | 4 | * Copyright (c) 1999-2001 Motorola, Inc. |
5 | * Copyright (c) 2001 Intel Corp. | 5 | * Copyright (c) 2001 Intel Corp. |
6 | * | 6 | * |
7 | * This file is part of the SCTP kernel reference Implementation | 7 | * This file is part of the SCTP kernel implementation |
8 | * | ||
9 | * This file is part of the implementation of the add-IP extension, | ||
10 | * based on <draft-ietf-tsvwg-addip-sctp-02.txt> June 29, 2001, | ||
11 | * for the SCTP kernel reference Implementation. | ||
12 | * | 8 | * |
13 | * This file converts numerical ID value to alphabetical names for SCTP | 9 | * This file converts numerical ID value to alphabetical names for SCTP |
14 | * terms such as chunk type, parameter time, event type, etc. | 10 | * terms such as chunk type, parameter time, event type, etc. |
15 | * | 11 | * |
16 | * The SCTP reference implementation is free software; | 12 | * This SCTP implementation is free software; |
17 | * you can redistribute it and/or modify it under the terms of | 13 | * you can redistribute it and/or modify it under the terms of |
18 | * the GNU General Public License as published by | 14 | * the GNU General Public License as published by |
19 | * the Free Software Foundation; either version 2, or (at your option) | 15 | * the Free Software Foundation; either version 2, or (at your option) |
20 | * any later version. | 16 | * any later version. |
21 | * | 17 | * |
22 | * The SCTP reference implementation is distributed in the hope that it | 18 | * This SCTP implementation is distributed in the hope that it |
23 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 19 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
24 | * ************************ | 20 | * ************************ |
25 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 21 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c index de6f505d6ff8..e39a0cdef184 100644 --- a/net/sctp/endpointola.c +++ b/net/sctp/endpointola.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * Copyright (c) 1999-2000 Cisco, Inc. | 2 | * Copyright (c) 1999-2000 Cisco, Inc. |
3 | * Copyright (c) 1999-2001 Motorola, Inc. | 3 | * Copyright (c) 1999-2001 Motorola, Inc. |
4 | * Copyright (c) 2001-2002 International Business Machines, Corp. | 4 | * Copyright (c) 2001-2002 International Business Machines, Corp. |
@@ -6,21 +6,17 @@ | |||
6 | * Copyright (c) 2001 Nokia, Inc. | 6 | * Copyright (c) 2001 Nokia, Inc. |
7 | * Copyright (c) 2001 La Monte H.P. Yarroll | 7 | * Copyright (c) 2001 La Monte H.P. Yarroll |
8 | * | 8 | * |
9 | * This file is part of the SCTP kernel reference Implementation | 9 | * This file is part of the SCTP kernel implementation |
10 | * | 10 | * |
11 | * This abstraction represents an SCTP endpoint. | 11 | * This abstraction represents an SCTP endpoint. |
12 | * | 12 | * |
13 | * This file is part of the implementation of the add-IP extension, | 13 | * The SCTP implementation is free software; |
14 | * based on <draft-ietf-tsvwg-addip-sctp-02.txt> June 29, 2001, | ||
15 | * for the SCTP kernel reference Implementation. | ||
16 | * | ||
17 | * The SCTP reference implementation is free software; | ||
18 | * you can redistribute it and/or modify it under the terms of | 14 | * you can redistribute it and/or modify it under the terms of |
19 | * the GNU General Public License as published by | 15 | * the GNU General Public License as published by |
20 | * the Free Software Foundation; either version 2, or (at your option) | 16 | * the Free Software Foundation; either version 2, or (at your option) |
21 | * any later version. | 17 | * any later version. |
22 | * | 18 | * |
23 | * The SCTP reference implementation is distributed in the hope that it | 19 | * The SCTP implementation is distributed in the hope that it |
24 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 20 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
25 | * ************************ | 21 | * ************************ |
26 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 22 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
diff --git a/net/sctp/input.c b/net/sctp/input.c index d695f710fc77..57fe2f81eca8 100644 --- a/net/sctp/input.c +++ b/net/sctp/input.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * Copyright (c) 1999-2000 Cisco, Inc. | 2 | * Copyright (c) 1999-2000 Cisco, Inc. |
3 | * Copyright (c) 1999-2001 Motorola, Inc. | 3 | * Copyright (c) 1999-2001 Motorola, Inc. |
4 | * Copyright (c) 2001-2003 International Business Machines, Corp. | 4 | * Copyright (c) 2001-2003 International Business Machines, Corp. |
@@ -6,17 +6,17 @@ | |||
6 | * Copyright (c) 2001 Nokia, Inc. | 6 | * Copyright (c) 2001 Nokia, Inc. |
7 | * Copyright (c) 2001 La Monte H.P. Yarroll | 7 | * Copyright (c) 2001 La Monte H.P. Yarroll |
8 | * | 8 | * |
9 | * This file is part of the SCTP kernel reference Implementation | 9 | * This file is part of the SCTP kernel implementation |
10 | * | 10 | * |
11 | * These functions handle all input from the IP layer into SCTP. | 11 | * These functions handle all input from the IP layer into SCTP. |
12 | * | 12 | * |
13 | * The SCTP reference implementation is free software; | 13 | * This SCTP implementation is free software; |
14 | * you can redistribute it and/or modify it under the terms of | 14 | * you can redistribute it and/or modify it under the terms of |
15 | * the GNU General Public License as published by | 15 | * the GNU General Public License as published by |
16 | * the Free Software Foundation; either version 2, or (at your option) | 16 | * the Free Software Foundation; either version 2, or (at your option) |
17 | * any later version. | 17 | * any later version. |
18 | * | 18 | * |
19 | * The SCTP reference implementation is distributed in the hope that it | 19 | * This SCTP implementation is distributed in the hope that it |
20 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 20 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
21 | * ************************ | 21 | * ************************ |
22 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 22 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
diff --git a/net/sctp/inqueue.c b/net/sctp/inqueue.c index cf4b7eb023b3..bbf5dd2a97c4 100644 --- a/net/sctp/inqueue.c +++ b/net/sctp/inqueue.c | |||
@@ -1,9 +1,9 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * Copyright (c) 1999-2000 Cisco, Inc. | 2 | * Copyright (c) 1999-2000 Cisco, Inc. |
3 | * Copyright (c) 1999-2001 Motorola, Inc. | 3 | * Copyright (c) 1999-2001 Motorola, Inc. |
4 | * Copyright (c) 2002 International Business Machines, Corp. | 4 | * Copyright (c) 2002 International Business Machines, Corp. |
5 | * | 5 | * |
6 | * This file is part of the SCTP kernel reference Implementation | 6 | * This file is part of the SCTP kernel implementation |
7 | * | 7 | * |
8 | * These functions are the methods for accessing the SCTP inqueue. | 8 | * These functions are the methods for accessing the SCTP inqueue. |
9 | * | 9 | * |
@@ -11,13 +11,13 @@ | |||
11 | * (which might be bundles or fragments of chunks) and out of which you | 11 | * (which might be bundles or fragments of chunks) and out of which you |
12 | * pop SCTP whole chunks. | 12 | * pop SCTP whole chunks. |
13 | * | 13 | * |
14 | * The SCTP reference implementation is free software; | 14 | * This SCTP implementation is free software; |
15 | * you can redistribute it and/or modify it under the terms of | 15 | * you can redistribute it and/or modify it under the terms of |
16 | * the GNU General Public License as published by | 16 | * the GNU General Public License as published by |
17 | * the Free Software Foundation; either version 2, or (at your option) | 17 | * the Free Software Foundation; either version 2, or (at your option) |
18 | * any later version. | 18 | * any later version. |
19 | * | 19 | * |
20 | * The SCTP reference implementation is distributed in the hope that it | 20 | * This SCTP implementation is distributed in the hope that it |
21 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 21 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
22 | * ************************ | 22 | * ************************ |
23 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 23 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index 74f106a7a7e9..4d7ec961ae1d 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c | |||
@@ -1,20 +1,20 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * (C) Copyright IBM Corp. 2002, 2004 | 2 | * (C) Copyright IBM Corp. 2002, 2004 |
3 | * Copyright (c) 2001 Nokia, Inc. | 3 | * Copyright (c) 2001 Nokia, Inc. |
4 | * Copyright (c) 2001 La Monte H.P. Yarroll | 4 | * Copyright (c) 2001 La Monte H.P. Yarroll |
5 | * Copyright (c) 2002-2003 Intel Corp. | 5 | * Copyright (c) 2002-2003 Intel Corp. |
6 | * | 6 | * |
7 | * This file is part of the SCTP kernel reference Implementation | 7 | * This file is part of the SCTP kernel implementation |
8 | * | 8 | * |
9 | * SCTP over IPv6. | 9 | * SCTP over IPv6. |
10 | * | 10 | * |
11 | * The SCTP reference implementation is free software; | 11 | * This SCTP implementation is free software; |
12 | * you can redistribute it and/or modify it under the terms of | 12 | * you can redistribute it and/or modify it under the terms of |
13 | * the GNU General Public License as published by | 13 | * the GNU General Public License as published by |
14 | * the Free Software Foundation; either version 2, or (at your option) | 14 | * the Free Software Foundation; either version 2, or (at your option) |
15 | * any later version. | 15 | * any later version. |
16 | * | 16 | * |
17 | * The SCTP reference implementation is distributed in the hope that it | 17 | * This SCTP implementation is distributed in the hope that it |
18 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 18 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
19 | * ************************ | 19 | * ************************ |
20 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 20 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
diff --git a/net/sctp/objcnt.c b/net/sctp/objcnt.c index 2cf6ad6ff8ce..14e294e37626 100644 --- a/net/sctp/objcnt.c +++ b/net/sctp/objcnt.c | |||
@@ -1,19 +1,19 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * (C) Copyright IBM Corp. 2001, 2004 | 2 | * (C) Copyright IBM Corp. 2001, 2004 |
3 | * | 3 | * |
4 | * This file is part of the SCTP kernel reference Implementation | 4 | * This file is part of the SCTP kernel implementation |
5 | * | 5 | * |
6 | * Support for memory object debugging. This allows one to monitor the | 6 | * Support for memory object debugging. This allows one to monitor the |
7 | * object allocations/deallocations for types instrumented for this | 7 | * object allocations/deallocations for types instrumented for this |
8 | * via the proc fs. | 8 | * via the proc fs. |
9 | * | 9 | * |
10 | * The SCTP reference implementation is free software; | 10 | * This SCTP implementation is free software; |
11 | * you can redistribute it and/or modify it under the terms of | 11 | * you can redistribute it and/or modify it under the terms of |
12 | * the GNU General Public License as published by | 12 | * the GNU General Public License as published by |
13 | * the Free Software Foundation; either version 2, or (at your option) | 13 | * the Free Software Foundation; either version 2, or (at your option) |
14 | * any later version. | 14 | * any later version. |
15 | * | 15 | * |
16 | * The SCTP reference implementation is distributed in the hope that it | 16 | * This SCTP implementation is distributed in the hope that it |
17 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 17 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
18 | * ************************ | 18 | * ************************ |
19 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 19 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
@@ -80,61 +80,64 @@ static sctp_dbg_objcnt_entry_t sctp_dbg_objcnt[] = { | |||
80 | /* Callback from procfs to read out objcount information. | 80 | /* Callback from procfs to read out objcount information. |
81 | * Walk through the entries in the sctp_dbg_objcnt array, dumping | 81 | * Walk through the entries in the sctp_dbg_objcnt array, dumping |
82 | * the raw object counts for each monitored type. | 82 | * the raw object counts for each monitored type. |
83 | * | ||
84 | * This code was modified from similar code in route.c | ||
85 | */ | 83 | */ |
86 | static int sctp_dbg_objcnt_read(char *buffer, char **start, off_t offset, | 84 | static int sctp_objcnt_seq_show(struct seq_file *seq, void *v) |
87 | int length, int *eof, void *data) | ||
88 | { | 85 | { |
89 | int len = 0; | ||
90 | off_t pos = 0; | ||
91 | int entries; | ||
92 | int i; | 86 | int i; |
93 | char temp[128]; | 87 | char temp[128]; |
94 | 88 | ||
95 | /* How many entries? */ | 89 | i = (int)*(loff_t *)v; |
96 | entries = ARRAY_SIZE(sctp_dbg_objcnt); | 90 | sprintf(temp, "%s: %d", sctp_dbg_objcnt[i].label, |
97 | 91 | atomic_read(sctp_dbg_objcnt[i].counter)); | |
98 | /* Walk the entries and print out the debug information | 92 | seq_printf(seq, "%-127s\n", temp); |
99 | * for proc fs. | 93 | return 0; |
100 | */ | 94 | } |
101 | for (i = 0; i < entries; i++) { | 95 | |
102 | pos += 128; | 96 | static void *sctp_objcnt_seq_start(struct seq_file *seq, loff_t *pos) |
103 | 97 | { | |
104 | /* Skip ahead. */ | 98 | return (*pos >= ARRAY_SIZE(sctp_dbg_objcnt)) ? NULL : (void *)pos; |
105 | if (pos <= offset) { | 99 | } |
106 | len = 0; | 100 | |
107 | continue; | 101 | static void sctp_objcnt_seq_stop(struct seq_file *seq, void *v) |
108 | } | 102 | { |
109 | /* Print out each entry. */ | 103 | } |
110 | sprintf(temp, "%s: %d", | 104 | |
111 | sctp_dbg_objcnt[i].label, | 105 | static void * sctp_objcnt_seq_next(struct seq_file *seq, void *v, loff_t *pos) |
112 | atomic_read(sctp_dbg_objcnt[i].counter)); | 106 | { |
113 | 107 | ++*pos; | |
114 | sprintf(buffer + len, "%-127s\n", temp); | 108 | return (*pos >= ARRAY_SIZE(sctp_dbg_objcnt)) ? NULL : (void *)pos; |
115 | len += 128; | ||
116 | if (pos >= offset+length) | ||
117 | goto done; | ||
118 | } | ||
119 | |||
120 | done: | ||
121 | *start = buffer + len - (pos - offset); | ||
122 | len = pos - offset; | ||
123 | if (len > length) | ||
124 | len = length; | ||
125 | |||
126 | return len; | ||
127 | } | 109 | } |
128 | 110 | ||
111 | static const struct seq_operations sctp_objcnt_seq_ops = { | ||
112 | .start = sctp_objcnt_seq_start, | ||
113 | .next = sctp_objcnt_seq_next, | ||
114 | .stop = sctp_objcnt_seq_stop, | ||
115 | .show = sctp_objcnt_seq_show, | ||
116 | }; | ||
117 | |||
118 | static int sctp_objcnt_seq_open(struct inode *inode, struct file *file) | ||
119 | { | ||
120 | return seq_open(file, &sctp_objcnt_seq_ops); | ||
121 | } | ||
122 | |||
123 | static const struct file_operations sctp_objcnt_ops = { | ||
124 | .open = sctp_objcnt_seq_open, | ||
125 | .read = seq_read, | ||
126 | .llseek = seq_lseek, | ||
127 | .release = seq_release, | ||
128 | }; | ||
129 | |||
129 | /* Initialize the objcount in the proc filesystem. */ | 130 | /* Initialize the objcount in the proc filesystem. */ |
130 | void sctp_dbg_objcnt_init(void) | 131 | void sctp_dbg_objcnt_init(void) |
131 | { | 132 | { |
132 | struct proc_dir_entry *ent; | 133 | struct proc_dir_entry *ent; |
133 | ent = create_proc_read_entry("sctp_dbg_objcnt", 0, proc_net_sctp, | 134 | |
134 | sctp_dbg_objcnt_read, NULL); | 135 | ent = create_proc_entry("sctp_dbg_objcnt", 0, proc_net_sctp); |
135 | if (!ent) | 136 | if (!ent) |
136 | printk(KERN_WARNING | 137 | printk(KERN_WARNING |
137 | "sctp_dbg_objcnt: Unable to create /proc entry.\n"); | 138 | "sctp_dbg_objcnt: Unable to create /proc entry.\n"); |
139 | else | ||
140 | ent->proc_fops = &sctp_objcnt_ops; | ||
138 | } | 141 | } |
139 | 142 | ||
140 | /* Cleanup the objcount entry in the proc filesystem. */ | 143 | /* Cleanup the objcount entry in the proc filesystem. */ |
diff --git a/net/sctp/output.c b/net/sctp/output.c index 5e811b91f21c..aa700feea76c 100644 --- a/net/sctp/output.c +++ b/net/sctp/output.c | |||
@@ -1,19 +1,19 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * (C) Copyright IBM Corp. 2001, 2004 | 2 | * (C) Copyright IBM Corp. 2001, 2004 |
3 | * Copyright (c) 1999-2000 Cisco, Inc. | 3 | * Copyright (c) 1999-2000 Cisco, Inc. |
4 | * Copyright (c) 1999-2001 Motorola, Inc. | 4 | * Copyright (c) 1999-2001 Motorola, Inc. |
5 | * | 5 | * |
6 | * This file is part of the SCTP kernel reference Implementation | 6 | * This file is part of the SCTP kernel implementation |
7 | * | 7 | * |
8 | * These functions handle output processing. | 8 | * These functions handle output processing. |
9 | * | 9 | * |
10 | * The SCTP reference implementation is free software; | 10 | * This SCTP implementation is free software; |
11 | * you can redistribute it and/or modify it under the terms of | 11 | * you can redistribute it and/or modify it under the terms of |
12 | * the GNU General Public License as published by | 12 | * the GNU General Public License as published by |
13 | * the Free Software Foundation; either version 2, or (at your option) | 13 | * the Free Software Foundation; either version 2, or (at your option) |
14 | * any later version. | 14 | * any later version. |
15 | * | 15 | * |
16 | * The SCTP reference implementation is distributed in the hope that it | 16 | * This SCTP implementation is distributed in the hope that it |
17 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 17 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
18 | * ************************ | 18 | * ************************ |
19 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 19 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c index a42af865c2ef..1bb3c5c35d2a 100644 --- a/net/sctp/outqueue.c +++ b/net/sctp/outqueue.c | |||
@@ -1,21 +1,21 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * (C) Copyright IBM Corp. 2001, 2004 | 2 | * (C) Copyright IBM Corp. 2001, 2004 |
3 | * Copyright (c) 1999-2000 Cisco, Inc. | 3 | * Copyright (c) 1999-2000 Cisco, Inc. |
4 | * Copyright (c) 1999-2001 Motorola, Inc. | 4 | * Copyright (c) 1999-2001 Motorola, Inc. |
5 | * Copyright (c) 2001-2003 Intel Corp. | 5 | * Copyright (c) 2001-2003 Intel Corp. |
6 | * | 6 | * |
7 | * This file is part of the SCTP kernel reference Implementation | 7 | * This file is part of the SCTP kernel implementation |
8 | * | 8 | * |
9 | * These functions implement the sctp_outq class. The outqueue handles | 9 | * These functions implement the sctp_outq class. The outqueue handles |
10 | * bundling and queueing of outgoing SCTP chunks. | 10 | * bundling and queueing of outgoing SCTP chunks. |
11 | * | 11 | * |
12 | * The SCTP reference implementation is free software; | 12 | * This SCTP implementation is free software; |
13 | * you can redistribute it and/or modify it under the terms of | 13 | * you can redistribute it and/or modify it under the terms of |
14 | * the GNU General Public License as published by | 14 | * the GNU General Public License as published by |
15 | * the Free Software Foundation; either version 2, or (at your option) | 15 | * the Free Software Foundation; either version 2, or (at your option) |
16 | * any later version. | 16 | * any later version. |
17 | * | 17 | * |
18 | * The SCTP reference implementation is distributed in the hope that it | 18 | * This SCTP implementation is distributed in the hope that it |
19 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 19 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
20 | * ************************ | 20 | * ************************ |
21 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 21 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
@@ -1179,8 +1179,10 @@ int sctp_outq_sack(struct sctp_outq *q, struct sctp_sackhdr *sack) | |||
1179 | tchunk = list_entry(lchunk, struct sctp_chunk, | 1179 | tchunk = list_entry(lchunk, struct sctp_chunk, |
1180 | transmitted_list); | 1180 | transmitted_list); |
1181 | tsn = ntohl(tchunk->subh.data_hdr->tsn); | 1181 | tsn = ntohl(tchunk->subh.data_hdr->tsn); |
1182 | if (TSN_lte(tsn, ctsn)) | 1182 | if (TSN_lte(tsn, ctsn)) { |
1183 | list_del_init(&tchunk->transmitted_list); | ||
1183 | sctp_chunk_free(tchunk); | 1184 | sctp_chunk_free(tchunk); |
1185 | } | ||
1184 | } | 1186 | } |
1185 | 1187 | ||
1186 | /* ii) Set rwnd equal to the newly received a_rwnd minus the | 1188 | /* ii) Set rwnd equal to the newly received a_rwnd minus the |
diff --git a/net/sctp/primitive.c b/net/sctp/primitive.c index 1b2976d34ac7..8cb4f060bce6 100644 --- a/net/sctp/primitive.c +++ b/net/sctp/primitive.c | |||
@@ -1,8 +1,8 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * Copyright (c) 1999-2000 Cisco, Inc. | 2 | * Copyright (c) 1999-2000 Cisco, Inc. |
3 | * Copyright (c) 1999-2001 Motorola, Inc. | 3 | * Copyright (c) 1999-2001 Motorola, Inc. |
4 | * | 4 | * |
5 | * This file is part of the SCTP kernel reference Implementation | 5 | * This file is part of the SCTP kernel implementation |
6 | * | 6 | * |
7 | * These functions implement the SCTP primitive functions from Section 10. | 7 | * These functions implement the SCTP primitive functions from Section 10. |
8 | * | 8 | * |
@@ -10,13 +10,13 @@ | |||
10 | * functions--this file is the functions which populate the struct proto | 10 | * functions--this file is the functions which populate the struct proto |
11 | * for SCTP which is the BOTTOM of the sockets interface. | 11 | * for SCTP which is the BOTTOM of the sockets interface. |
12 | * | 12 | * |
13 | * The SCTP reference implementation is free software; | 13 | * This SCTP implementation is free software; |
14 | * you can redistribute it and/or modify it under the terms of | 14 | * you can redistribute it and/or modify it under the terms of |
15 | * the GNU General Public License as published by | 15 | * the GNU General Public License as published by |
16 | * the Free Software Foundation; either version 2, or (at your option) | 16 | * the Free Software Foundation; either version 2, or (at your option) |
17 | * any later version. | 17 | * any later version. |
18 | * | 18 | * |
19 | * The SCTP reference implementation is distributed in the hope that it | 19 | * This SCTP implementation is distributed in the hope that it |
20 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 20 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
21 | * ************************ | 21 | * ************************ |
22 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 22 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
diff --git a/net/sctp/proc.c b/net/sctp/proc.c index 249973204070..69bb5a63fd8b 100644 --- a/net/sctp/proc.c +++ b/net/sctp/proc.c | |||
@@ -1,15 +1,15 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * Copyright (c) 2003 International Business Machines, Corp. | 2 | * Copyright (c) 2003 International Business Machines, Corp. |
3 | * | 3 | * |
4 | * This file is part of the SCTP kernel reference Implementation | 4 | * This file is part of the SCTP kernel implementation |
5 | * | 5 | * |
6 | * The SCTP reference implementation is free software; | 6 | * This SCTP implementation is free software; |
7 | * you can redistribute it and/or modify it under the terms of | 7 | * you can redistribute it and/or modify it under the terms of |
8 | * the GNU General Public License as published by | 8 | * the GNU General Public License as published by |
9 | * the Free Software Foundation; either version 2, or (at your option) | 9 | * the Free Software Foundation; either version 2, or (at your option) |
10 | * any later version. | 10 | * any later version. |
11 | * | 11 | * |
12 | * The SCTP reference implementation is distributed in the hope that it | 12 | * This SCTP implementation is distributed in the hope that it |
13 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 13 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
14 | * ************************ | 14 | * ************************ |
15 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 15 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/seq_file.h> | 38 | #include <linux/seq_file.h> |
39 | #include <linux/init.h> | 39 | #include <linux/init.h> |
40 | #include <net/sctp/sctp.h> | 40 | #include <net/sctp/sctp.h> |
41 | #include <net/ip.h> /* for snmp_fold_field */ | ||
41 | 42 | ||
42 | static struct snmp_mib sctp_snmp_list[] = { | 43 | static struct snmp_mib sctp_snmp_list[] = { |
43 | SNMP_MIB_ITEM("SctpCurrEstab", SCTP_MIB_CURRESTAB), | 44 | SNMP_MIB_ITEM("SctpCurrEstab", SCTP_MIB_CURRESTAB), |
@@ -75,26 +76,6 @@ static struct snmp_mib sctp_snmp_list[] = { | |||
75 | SNMP_MIB_SENTINEL | 76 | SNMP_MIB_SENTINEL |
76 | }; | 77 | }; |
77 | 78 | ||
78 | /* Return the current value of a particular entry in the mib by adding its | ||
79 | * per cpu counters. | ||
80 | */ | ||
81 | static unsigned long | ||
82 | fold_field(void *mib[], int nr) | ||
83 | { | ||
84 | unsigned long res = 0; | ||
85 | int i; | ||
86 | |||
87 | for_each_possible_cpu(i) { | ||
88 | res += | ||
89 | *((unsigned long *) (((void *) per_cpu_ptr(mib[0], i)) + | ||
90 | sizeof (unsigned long) * nr)); | ||
91 | res += | ||
92 | *((unsigned long *) (((void *) per_cpu_ptr(mib[1], i)) + | ||
93 | sizeof (unsigned long) * nr)); | ||
94 | } | ||
95 | return res; | ||
96 | } | ||
97 | |||
98 | /* Display sctp snmp mib statistics(/proc/net/sctp/snmp). */ | 79 | /* Display sctp snmp mib statistics(/proc/net/sctp/snmp). */ |
99 | static int sctp_snmp_seq_show(struct seq_file *seq, void *v) | 80 | static int sctp_snmp_seq_show(struct seq_file *seq, void *v) |
100 | { | 81 | { |
@@ -102,7 +83,7 @@ static int sctp_snmp_seq_show(struct seq_file *seq, void *v) | |||
102 | 83 | ||
103 | for (i = 0; sctp_snmp_list[i].name != NULL; i++) | 84 | for (i = 0; sctp_snmp_list[i].name != NULL; i++) |
104 | seq_printf(seq, "%-32s\t%ld\n", sctp_snmp_list[i].name, | 85 | seq_printf(seq, "%-32s\t%ld\n", sctp_snmp_list[i].name, |
105 | fold_field((void **)sctp_statistics, | 86 | snmp_fold_field((void **)sctp_statistics, |
106 | sctp_snmp_list[i].entry)); | 87 | sctp_snmp_list[i].entry)); |
107 | 88 | ||
108 | return 0; | 89 | return 0; |
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 1339742e49f1..22a16571499c 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * (C) Copyright IBM Corp. 2001, 2004 | 2 | * (C) Copyright IBM Corp. 2001, 2004 |
3 | * Copyright (c) 1999-2000 Cisco, Inc. | 3 | * Copyright (c) 1999-2000 Cisco, Inc. |
4 | * Copyright (c) 1999-2001 Motorola, Inc. | 4 | * Copyright (c) 1999-2001 Motorola, Inc. |
@@ -6,17 +6,17 @@ | |||
6 | * Copyright (c) 2001 Nokia, Inc. | 6 | * Copyright (c) 2001 Nokia, Inc. |
7 | * Copyright (c) 2001 La Monte H.P. Yarroll | 7 | * Copyright (c) 2001 La Monte H.P. Yarroll |
8 | * | 8 | * |
9 | * This file is part of the SCTP kernel reference Implementation | 9 | * This file is part of the SCTP kernel implementation |
10 | * | 10 | * |
11 | * Initialization/cleanup for SCTP protocol support. | 11 | * Initialization/cleanup for SCTP protocol support. |
12 | * | 12 | * |
13 | * The SCTP reference implementation is free software; | 13 | * This SCTP implementation is free software; |
14 | * you can redistribute it and/or modify it under the terms of | 14 | * you can redistribute it and/or modify it under the terms of |
15 | * the GNU General Public License as published by | 15 | * the GNU General Public License as published by |
16 | * the Free Software Foundation; either version 2, or (at your option) | 16 | * the Free Software Foundation; either version 2, or (at your option) |
17 | * any later version. | 17 | * any later version. |
18 | * | 18 | * |
19 | * The SCTP reference implementation is distributed in the hope that it | 19 | * This SCTP implementation is distributed in the hope that it |
20 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 20 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
21 | * ************************ | 21 | * ************************ |
22 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 22 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index 77383e9b3988..e45be4e3f80d 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c | |||
@@ -1,22 +1,22 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * (C) Copyright IBM Corp. 2001, 2004 | 2 | * (C) Copyright IBM Corp. 2001, 2004 |
3 | * Copyright (c) 1999-2000 Cisco, Inc. | 3 | * Copyright (c) 1999-2000 Cisco, Inc. |
4 | * Copyright (c) 1999-2001 Motorola, Inc. | 4 | * Copyright (c) 1999-2001 Motorola, Inc. |
5 | * Copyright (c) 2001-2002 Intel Corp. | 5 | * Copyright (c) 2001-2002 Intel Corp. |
6 | * | 6 | * |
7 | * This file is part of the SCTP kernel reference Implementation | 7 | * This file is part of the SCTP kernel implementation |
8 | * | 8 | * |
9 | * These functions work with the state functions in sctp_sm_statefuns.c | 9 | * These functions work with the state functions in sctp_sm_statefuns.c |
10 | * to implement the state operations. These functions implement the | 10 | * to implement the state operations. These functions implement the |
11 | * steps which require modifying existing data structures. | 11 | * steps which require modifying existing data structures. |
12 | * | 12 | * |
13 | * The SCTP reference implementation is free software; | 13 | * This SCTP implementation is free software; |
14 | * you can redistribute it and/or modify it under the terms of | 14 | * you can redistribute it and/or modify it under the terms of |
15 | * the GNU General Public License as published by | 15 | * the GNU General Public License as published by |
16 | * the Free Software Foundation; either version 2, or (at your option) | 16 | * the Free Software Foundation; either version 2, or (at your option) |
17 | * any later version. | 17 | * any later version. |
18 | * | 18 | * |
19 | * The SCTP reference implementation is distributed in the hope that it | 19 | * This SCTP implementation is distributed in the hope that it |
20 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 20 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
21 | * ************************ | 21 | * ************************ |
22 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 22 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
@@ -3224,6 +3224,7 @@ int sctp_process_asconf_ack(struct sctp_association *asoc, | |||
3224 | } | 3224 | } |
3225 | 3225 | ||
3226 | /* Free the cached last sent asconf chunk. */ | 3226 | /* Free the cached last sent asconf chunk. */ |
3227 | list_del_init(&asconf->transmitted_list); | ||
3227 | sctp_chunk_free(asconf); | 3228 | sctp_chunk_free(asconf); |
3228 | asoc->addip_last_asconf = NULL; | 3229 | asoc->addip_last_asconf = NULL; |
3229 | 3230 | ||
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c index 78d1a8a49bd0..28eb38eb6083 100644 --- a/net/sctp/sm_sideeffect.c +++ b/net/sctp/sm_sideeffect.c | |||
@@ -1,21 +1,21 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * (C) Copyright IBM Corp. 2001, 2004 | 2 | * (C) Copyright IBM Corp. 2001, 2004 |
3 | * Copyright (c) 1999 Cisco, Inc. | 3 | * Copyright (c) 1999 Cisco, Inc. |
4 | * Copyright (c) 1999-2001 Motorola, Inc. | 4 | * Copyright (c) 1999-2001 Motorola, Inc. |
5 | * | 5 | * |
6 | * This file is part of the SCTP kernel reference Implementation | 6 | * This file is part of the SCTP kernel implementation |
7 | * | 7 | * |
8 | * These functions work with the state functions in sctp_sm_statefuns.c | 8 | * These functions work with the state functions in sctp_sm_statefuns.c |
9 | * to implement that state operations. These functions implement the | 9 | * to implement that state operations. These functions implement the |
10 | * steps which require modifying existing data structures. | 10 | * steps which require modifying existing data structures. |
11 | * | 11 | * |
12 | * The SCTP reference implementation is free software; | 12 | * This SCTP implementation is free software; |
13 | * you can redistribute it and/or modify it under the terms of | 13 | * you can redistribute it and/or modify it under the terms of |
14 | * the GNU General Public License as published by | 14 | * the GNU General Public License as published by |
15 | * the Free Software Foundation; either version 2, or (at your option) | 15 | * the Free Software Foundation; either version 2, or (at your option) |
16 | * any later version. | 16 | * any later version. |
17 | * | 17 | * |
18 | * The SCTP reference implementation is distributed in the hope that it | 18 | * This SCTP implementation is distributed in the hope that it |
19 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 19 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
20 | * ************************ | 20 | * ************************ |
21 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 21 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c index f98658782d4f..f2ed6473feef 100644 --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c | |||
@@ -1,23 +1,21 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * (C) Copyright IBM Corp. 2001, 2004 | 2 | * (C) Copyright IBM Corp. 2001, 2004 |
3 | * Copyright (c) 1999-2000 Cisco, Inc. | 3 | * Copyright (c) 1999-2000 Cisco, Inc. |
4 | * Copyright (c) 1999-2001 Motorola, Inc. | 4 | * Copyright (c) 1999-2001 Motorola, Inc. |
5 | * Copyright (c) 2001-2002 Intel Corp. | 5 | * Copyright (c) 2001-2002 Intel Corp. |
6 | * Copyright (c) 2002 Nokia Corp. | 6 | * Copyright (c) 2002 Nokia Corp. |
7 | * | 7 | * |
8 | * This file is part of the SCTP kernel reference Implementation | 8 | * This is part of the SCTP Linux Kernel Implementation. |
9 | * | ||
10 | * This is part of the SCTP Linux Kernel Reference Implementation. | ||
11 | * | 9 | * |
12 | * These are the state functions for the state machine. | 10 | * These are the state functions for the state machine. |
13 | * | 11 | * |
14 | * The SCTP reference implementation is free software; | 12 | * This SCTP implementation is free software; |
15 | * you can redistribute it and/or modify it under the terms of | 13 | * you can redistribute it and/or modify it under the terms of |
16 | * the GNU General Public License as published by | 14 | * the GNU General Public License as published by |
17 | * the Free Software Foundation; either version 2, or (at your option) | 15 | * the Free Software Foundation; either version 2, or (at your option) |
18 | * any later version. | 16 | * any later version. |
19 | * | 17 | * |
20 | * The SCTP reference implementation is distributed in the hope that it | 18 | * This SCTP implementation is distributed in the hope that it |
21 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 19 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
22 | * ************************ | 20 | * ************************ |
23 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 21 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
diff --git a/net/sctp/sm_statetable.c b/net/sctp/sm_statetable.c index e6016e41ffa0..d991237fb400 100644 --- a/net/sctp/sm_statetable.c +++ b/net/sctp/sm_statetable.c | |||
@@ -1,21 +1,21 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * (C) Copyright IBM Corp. 2001, 2004 | 2 | * (C) Copyright IBM Corp. 2001, 2004 |
3 | * Copyright (c) 1999-2000 Cisco, Inc. | 3 | * Copyright (c) 1999-2000 Cisco, Inc. |
4 | * Copyright (c) 1999-2001 Motorola, Inc. | 4 | * Copyright (c) 1999-2001 Motorola, Inc. |
5 | * Copyright (c) 2001 Intel Corp. | 5 | * Copyright (c) 2001 Intel Corp. |
6 | * Copyright (c) 2001 Nokia, Inc. | 6 | * Copyright (c) 2001 Nokia, Inc. |
7 | * | 7 | * |
8 | * This file is part of the SCTP kernel reference Implementation | 8 | * This file is part of the SCTP kernel implementation |
9 | * | 9 | * |
10 | * These are the state tables for the SCTP state machine. | 10 | * These are the state tables for the SCTP state machine. |
11 | * | 11 | * |
12 | * The SCTP reference implementation is free software; | 12 | * This SCTP implementation is free software; |
13 | * you can redistribute it and/or modify it under the terms of | 13 | * you can redistribute it and/or modify it under the terms of |
14 | * the GNU General Public License as published by | 14 | * the GNU General Public License as published by |
15 | * the Free Software Foundation; either version 2, or (at your option) | 15 | * the Free Software Foundation; either version 2, or (at your option) |
16 | * any later version. | 16 | * any later version. |
17 | * | 17 | * |
18 | * The SCTP reference implementation is distributed in the hope that it | 18 | * This SCTP implementation is distributed in the hope that it |
19 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 19 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
20 | * ************************ | 20 | * ************************ |
21 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 21 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 710df67a6785..d47d5787e2e5 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * (C) Copyright IBM Corp. 2001, 2004 | 2 | * (C) Copyright IBM Corp. 2001, 2004 |
3 | * Copyright (c) 1999-2000 Cisco, Inc. | 3 | * Copyright (c) 1999-2000 Cisco, Inc. |
4 | * Copyright (c) 1999-2001 Motorola, Inc. | 4 | * Copyright (c) 1999-2001 Motorola, Inc. |
@@ -6,7 +6,7 @@ | |||
6 | * Copyright (c) 2001-2002 Nokia, Inc. | 6 | * Copyright (c) 2001-2002 Nokia, Inc. |
7 | * Copyright (c) 2001 La Monte H.P. Yarroll | 7 | * Copyright (c) 2001 La Monte H.P. Yarroll |
8 | * | 8 | * |
9 | * This file is part of the SCTP kernel reference Implementation | 9 | * This file is part of the SCTP kernel implementation |
10 | * | 10 | * |
11 | * These functions interface with the sockets layer to implement the | 11 | * These functions interface with the sockets layer to implement the |
12 | * SCTP Extensions for the Sockets API. | 12 | * SCTP Extensions for the Sockets API. |
@@ -15,13 +15,13 @@ | |||
15 | * functions--this file is the functions which populate the struct proto | 15 | * functions--this file is the functions which populate the struct proto |
16 | * for SCTP which is the BOTTOM of the sockets interface. | 16 | * for SCTP which is the BOTTOM of the sockets interface. |
17 | * | 17 | * |
18 | * The SCTP reference implementation is free software; | 18 | * This SCTP implementation is free software; |
19 | * you can redistribute it and/or modify it under the terms of | 19 | * you can redistribute it and/or modify it under the terms of |
20 | * the GNU General Public License as published by | 20 | * the GNU General Public License as published by |
21 | * the Free Software Foundation; either version 2, or (at your option) | 21 | * the Free Software Foundation; either version 2, or (at your option) |
22 | * any later version. | 22 | * any later version. |
23 | * | 23 | * |
24 | * The SCTP reference implementation is distributed in the hope that it | 24 | * This SCTP implementation is distributed in the hope that it |
25 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 25 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
26 | * ************************ | 26 | * ************************ |
27 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 27 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
@@ -1911,7 +1911,8 @@ SCTP_STATIC int sctp_recvmsg(struct kiocb *iocb, struct sock *sk, | |||
1911 | * rwnd by that amount. If all the data in the skb is read, | 1911 | * rwnd by that amount. If all the data in the skb is read, |
1912 | * rwnd is updated when the event is freed. | 1912 | * rwnd is updated when the event is freed. |
1913 | */ | 1913 | */ |
1914 | sctp_assoc_rwnd_increase(event->asoc, copied); | 1914 | if (!sctp_ulpevent_is_notification(event)) |
1915 | sctp_assoc_rwnd_increase(event->asoc, copied); | ||
1915 | goto out; | 1916 | goto out; |
1916 | } else if ((event->msg_flags & MSG_NOTIFICATION) || | 1917 | } else if ((event->msg_flags & MSG_NOTIFICATION) || |
1917 | (event->msg_flags & MSG_EOR)) | 1918 | (event->msg_flags & MSG_EOR)) |
@@ -4314,6 +4315,9 @@ static int sctp_copy_laddrs_old(struct sock *sk, __u16 port, | |||
4314 | (AF_INET6 == addr->a.sa.sa_family)) | 4315 | (AF_INET6 == addr->a.sa.sa_family)) |
4315 | continue; | 4316 | continue; |
4316 | memcpy(&temp, &addr->a, sizeof(temp)); | 4317 | memcpy(&temp, &addr->a, sizeof(temp)); |
4318 | if (!temp.v4.sin_port) | ||
4319 | temp.v4.sin_port = htons(port); | ||
4320 | |||
4317 | sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk), | 4321 | sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk), |
4318 | &temp); | 4322 | &temp); |
4319 | addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; | 4323 | addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; |
@@ -4346,6 +4350,9 @@ static int sctp_copy_laddrs(struct sock *sk, __u16 port, void *to, | |||
4346 | (AF_INET6 == addr->a.sa.sa_family)) | 4350 | (AF_INET6 == addr->a.sa.sa_family)) |
4347 | continue; | 4351 | continue; |
4348 | memcpy(&temp, &addr->a, sizeof(temp)); | 4352 | memcpy(&temp, &addr->a, sizeof(temp)); |
4353 | if (!temp.v4.sin_port) | ||
4354 | temp.v4.sin_port = htons(port); | ||
4355 | |||
4349 | sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk), | 4356 | sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk), |
4350 | &temp); | 4357 | &temp); |
4351 | addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; | 4358 | addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; |
diff --git a/net/sctp/ssnmap.c b/net/sctp/ssnmap.c index cbe2513d2822..737d330e5ffc 100644 --- a/net/sctp/ssnmap.c +++ b/net/sctp/ssnmap.c | |||
@@ -1,17 +1,17 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * Copyright (c) 2003 International Business Machines, Corp. | 2 | * Copyright (c) 2003 International Business Machines, Corp. |
3 | * | 3 | * |
4 | * This file is part of the SCTP kernel reference Implementation | 4 | * This file is part of the SCTP kernel implementation |
5 | * | 5 | * |
6 | * These functions manipulate sctp SSN tracker. | 6 | * These functions manipulate sctp SSN tracker. |
7 | * | 7 | * |
8 | * The SCTP reference implementation is free software; | 8 | * This SCTP implementation is free software; |
9 | * you can redistribute it and/or modify it under the terms of | 9 | * you can redistribute it and/or modify it under the terms of |
10 | * the GNU General Public License as published by | 10 | * the GNU General Public License as published by |
11 | * the Free Software Foundation; either version 2, or (at your option) | 11 | * the Free Software Foundation; either version 2, or (at your option) |
12 | * any later version. | 12 | * any later version. |
13 | * | 13 | * |
14 | * The SCTP reference implementation is distributed in the hope that it | 14 | * This SCTP implementation is distributed in the hope that it |
15 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
16 | * ************************ | 16 | * ************************ |
17 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 17 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c index 5eb6ea829b54..52910697e104 100644 --- a/net/sctp/sysctl.c +++ b/net/sctp/sysctl.c | |||
@@ -1,18 +1,18 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * (C) Copyright IBM Corp. 2002, 2004 | 2 | * (C) Copyright IBM Corp. 2002, 2004 |
3 | * Copyright (c) 2002 Intel Corp. | 3 | * Copyright (c) 2002 Intel Corp. |
4 | * | 4 | * |
5 | * This file is part of the SCTP kernel reference Implementation | 5 | * This file is part of the SCTP kernel implementation |
6 | * | 6 | * |
7 | * Sysctl related interfaces for SCTP. | 7 | * Sysctl related interfaces for SCTP. |
8 | * | 8 | * |
9 | * The SCTP reference implementation is free software; | 9 | * This SCTP implementation is free software; |
10 | * you can redistribute it and/or modify it under the terms of | 10 | * you can redistribute it and/or modify it under the terms of |
11 | * the GNU General Public License as published by | 11 | * the GNU General Public License as published by |
12 | * the Free Software Foundation; either version 2, or (at your option) | 12 | * the Free Software Foundation; either version 2, or (at your option) |
13 | * any later version. | 13 | * any later version. |
14 | * | 14 | * |
15 | * The SCTP reference implementation is distributed in the hope that it | 15 | * This SCTP implementation is distributed in the hope that it |
16 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 16 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
17 | * ************************ | 17 | * ************************ |
18 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 18 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
diff --git a/net/sctp/transport.c b/net/sctp/transport.c index dfa109341aeb..d9f8af852b56 100644 --- a/net/sctp/transport.c +++ b/net/sctp/transport.c | |||
@@ -1,23 +1,23 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * Copyright (c) 1999-2000 Cisco, Inc. | 2 | * Copyright (c) 1999-2000 Cisco, Inc. |
3 | * Copyright (c) 1999-2001 Motorola, Inc. | 3 | * Copyright (c) 1999-2001 Motorola, Inc. |
4 | * Copyright (c) 2001-2003 International Business Machines Corp. | 4 | * Copyright (c) 2001-2003 International Business Machines Corp. |
5 | * Copyright (c) 2001 Intel Corp. | 5 | * Copyright (c) 2001 Intel Corp. |
6 | * Copyright (c) 2001 La Monte H.P. Yarroll | 6 | * Copyright (c) 2001 La Monte H.P. Yarroll |
7 | * | 7 | * |
8 | * This file is part of the SCTP kernel reference Implementation | 8 | * This file is part of the SCTP kernel implementation |
9 | * | 9 | * |
10 | * This module provides the abstraction for an SCTP tranport representing | 10 | * This module provides the abstraction for an SCTP tranport representing |
11 | * a remote transport address. For local transport addresses, we just use | 11 | * a remote transport address. For local transport addresses, we just use |
12 | * union sctp_addr. | 12 | * union sctp_addr. |
13 | * | 13 | * |
14 | * The SCTP reference implementation is free software; | 14 | * This SCTP implementation is free software; |
15 | * you can redistribute it and/or modify it under the terms of | 15 | * you can redistribute it and/or modify it under the terms of |
16 | * the GNU General Public License as published by | 16 | * the GNU General Public License as published by |
17 | * the Free Software Foundation; either version 2, or (at your option) | 17 | * the Free Software Foundation; either version 2, or (at your option) |
18 | * any later version. | 18 | * any later version. |
19 | * | 19 | * |
20 | * The SCTP reference implementation is distributed in the hope that it | 20 | * This SCTP implementation is distributed in the hope that it |
21 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 21 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
22 | * ************************ | 22 | * ************************ |
23 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 23 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
diff --git a/net/sctp/tsnmap.c b/net/sctp/tsnmap.c index 1ff0daade304..f3e58b275905 100644 --- a/net/sctp/tsnmap.c +++ b/net/sctp/tsnmap.c | |||
@@ -1,20 +1,20 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * (C) Copyright IBM Corp. 2001, 2004 | 2 | * (C) Copyright IBM Corp. 2001, 2004 |
3 | * Copyright (c) 1999-2000 Cisco, Inc. | 3 | * Copyright (c) 1999-2000 Cisco, Inc. |
4 | * Copyright (c) 1999-2001 Motorola, Inc. | 4 | * Copyright (c) 1999-2001 Motorola, Inc. |
5 | * Copyright (c) 2001 Intel Corp. | 5 | * Copyright (c) 2001 Intel Corp. |
6 | * | 6 | * |
7 | * This file is part of the SCTP kernel reference Implementation | 7 | * This file is part of the SCTP kernel implementation |
8 | * | 8 | * |
9 | * These functions manipulate sctp tsn mapping array. | 9 | * These functions manipulate sctp tsn mapping array. |
10 | * | 10 | * |
11 | * The SCTP reference implementation is free software; | 11 | * This SCTP implementation is free software; |
12 | * you can redistribute it and/or modify it under the terms of | 12 | * you can redistribute it and/or modify it under the terms of |
13 | * the GNU General Public License as published by | 13 | * the GNU General Public License as published by |
14 | * the Free Software Foundation; either version 2, or (at your option) | 14 | * the Free Software Foundation; either version 2, or (at your option) |
15 | * any later version. | 15 | * any later version. |
16 | * | 16 | * |
17 | * The SCTP reference implementation is distributed in the hope that it | 17 | * This SCTP implementation is distributed in the hope that it |
18 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 18 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
19 | * ************************ | 19 | * ************************ |
20 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 20 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
diff --git a/net/sctp/ulpevent.c b/net/sctp/ulpevent.c index 047c27df98f4..e27b11f18b7f 100644 --- a/net/sctp/ulpevent.c +++ b/net/sctp/ulpevent.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * (C) Copyright IBM Corp. 2001, 2004 | 2 | * (C) Copyright IBM Corp. 2001, 2004 |
3 | * Copyright (c) 1999-2000 Cisco, Inc. | 3 | * Copyright (c) 1999-2000 Cisco, Inc. |
4 | * Copyright (c) 1999-2001 Motorola, Inc. | 4 | * Copyright (c) 1999-2001 Motorola, Inc. |
@@ -8,13 +8,14 @@ | |||
8 | * | 8 | * |
9 | * These functions manipulate an sctp event. The struct ulpevent is used | 9 | * These functions manipulate an sctp event. The struct ulpevent is used |
10 | * to carry notifications and data to the ULP (sockets). | 10 | * to carry notifications and data to the ULP (sockets). |
11 | * The SCTP reference implementation is free software; | 11 | * |
12 | * This SCTP implementation is free software; | ||
12 | * you can redistribute it and/or modify it under the terms of | 13 | * you can redistribute it and/or modify it under the terms of |
13 | * the GNU General Public License as published by | 14 | * the GNU General Public License as published by |
14 | * the Free Software Foundation; either version 2, or (at your option) | 15 | * the Free Software Foundation; either version 2, or (at your option) |
15 | * any later version. | 16 | * any later version. |
16 | * | 17 | * |
17 | * The SCTP reference implementation is distributed in the hope that it | 18 | * This SCTP implementation is distributed in the hope that it |
18 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 19 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
19 | * ************************ | 20 | * ************************ |
20 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 21 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
diff --git a/net/sctp/ulpqueue.c b/net/sctp/ulpqueue.c index c25caefa3bcb..5061a26c5028 100644 --- a/net/sctp/ulpqueue.c +++ b/net/sctp/ulpqueue.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* SCTP kernel reference Implementation | 1 | /* SCTP kernel implementation |
2 | * (C) Copyright IBM Corp. 2001, 2004 | 2 | * (C) Copyright IBM Corp. 2001, 2004 |
3 | * Copyright (c) 1999-2000 Cisco, Inc. | 3 | * Copyright (c) 1999-2000 Cisco, Inc. |
4 | * Copyright (c) 1999-2001 Motorola, Inc. | 4 | * Copyright (c) 1999-2001 Motorola, Inc. |
@@ -8,13 +8,13 @@ | |||
8 | * | 8 | * |
9 | * This abstraction carries sctp events to the ULP (sockets). | 9 | * This abstraction carries sctp events to the ULP (sockets). |
10 | * | 10 | * |
11 | * The SCTP reference implementation is free software; | 11 | * This SCTP implementation is free software; |
12 | * you can redistribute it and/or modify it under the terms of | 12 | * you can redistribute it and/or modify it under the terms of |
13 | * the GNU General Public License as published by | 13 | * the GNU General Public License as published by |
14 | * the Free Software Foundation; either version 2, or (at your option) | 14 | * the Free Software Foundation; either version 2, or (at your option) |
15 | * any later version. | 15 | * any later version. |
16 | * | 16 | * |
17 | * The SCTP reference implementation is distributed in the hope that it | 17 | * This SCTP implementation is distributed in the hope that it |
18 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | 18 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
19 | * ************************ | 19 | * ************************ |
20 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 20 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
@@ -283,7 +283,7 @@ out_free: | |||
283 | /* 2nd Level Abstractions */ | 283 | /* 2nd Level Abstractions */ |
284 | 284 | ||
285 | /* Helper function to store chunks that need to be reassembled. */ | 285 | /* Helper function to store chunks that need to be reassembled. */ |
286 | static inline void sctp_ulpq_store_reasm(struct sctp_ulpq *ulpq, | 286 | static void sctp_ulpq_store_reasm(struct sctp_ulpq *ulpq, |
287 | struct sctp_ulpevent *event) | 287 | struct sctp_ulpevent *event) |
288 | { | 288 | { |
289 | struct sk_buff *pos; | 289 | struct sk_buff *pos; |
@@ -405,7 +405,7 @@ static struct sctp_ulpevent *sctp_make_reassembled_event(struct sk_buff_head *qu | |||
405 | /* Helper function to check if an incoming chunk has filled up the last | 405 | /* Helper function to check if an incoming chunk has filled up the last |
406 | * missing fragment in a SCTP datagram and return the corresponding event. | 406 | * missing fragment in a SCTP datagram and return the corresponding event. |
407 | */ | 407 | */ |
408 | static inline struct sctp_ulpevent *sctp_ulpq_retrieve_reassembled(struct sctp_ulpq *ulpq) | 408 | static struct sctp_ulpevent *sctp_ulpq_retrieve_reassembled(struct sctp_ulpq *ulpq) |
409 | { | 409 | { |
410 | struct sk_buff *pos; | 410 | struct sk_buff *pos; |
411 | struct sctp_ulpevent *cevent; | 411 | struct sctp_ulpevent *cevent; |
@@ -512,7 +512,7 @@ found: | |||
512 | } | 512 | } |
513 | 513 | ||
514 | /* Retrieve the next set of fragments of a partial message. */ | 514 | /* Retrieve the next set of fragments of a partial message. */ |
515 | static inline struct sctp_ulpevent *sctp_ulpq_retrieve_partial(struct sctp_ulpq *ulpq) | 515 | static struct sctp_ulpevent *sctp_ulpq_retrieve_partial(struct sctp_ulpq *ulpq) |
516 | { | 516 | { |
517 | struct sk_buff *pos, *last_frag, *first_frag; | 517 | struct sk_buff *pos, *last_frag, *first_frag; |
518 | struct sctp_ulpevent *cevent; | 518 | struct sctp_ulpevent *cevent; |
@@ -606,7 +606,7 @@ static struct sctp_ulpevent *sctp_ulpq_reasm(struct sctp_ulpq *ulpq, | |||
606 | } | 606 | } |
607 | 607 | ||
608 | /* Retrieve the first part (sequential fragments) for partial delivery. */ | 608 | /* Retrieve the first part (sequential fragments) for partial delivery. */ |
609 | static inline struct sctp_ulpevent *sctp_ulpq_retrieve_first(struct sctp_ulpq *ulpq) | 609 | static struct sctp_ulpevent *sctp_ulpq_retrieve_first(struct sctp_ulpq *ulpq) |
610 | { | 610 | { |
611 | struct sk_buff *pos, *last_frag, *first_frag; | 611 | struct sk_buff *pos, *last_frag, *first_frag; |
612 | struct sctp_ulpevent *cevent; | 612 | struct sctp_ulpevent *cevent; |
@@ -735,7 +735,7 @@ static void sctp_ulpq_reasm_drain(struct sctp_ulpq *ulpq) | |||
735 | /* Helper function to gather skbs that have possibly become | 735 | /* Helper function to gather skbs that have possibly become |
736 | * ordered by an an incoming chunk. | 736 | * ordered by an an incoming chunk. |
737 | */ | 737 | */ |
738 | static inline void sctp_ulpq_retrieve_ordered(struct sctp_ulpq *ulpq, | 738 | static void sctp_ulpq_retrieve_ordered(struct sctp_ulpq *ulpq, |
739 | struct sctp_ulpevent *event) | 739 | struct sctp_ulpevent *event) |
740 | { | 740 | { |
741 | struct sk_buff_head *event_list; | 741 | struct sk_buff_head *event_list; |
@@ -779,7 +779,7 @@ static inline void sctp_ulpq_retrieve_ordered(struct sctp_ulpq *ulpq, | |||
779 | } | 779 | } |
780 | 780 | ||
781 | /* Helper function to store chunks needing ordering. */ | 781 | /* Helper function to store chunks needing ordering. */ |
782 | static inline void sctp_ulpq_store_ordered(struct sctp_ulpq *ulpq, | 782 | static void sctp_ulpq_store_ordered(struct sctp_ulpq *ulpq, |
783 | struct sctp_ulpevent *event) | 783 | struct sctp_ulpevent *event) |
784 | { | 784 | { |
785 | struct sk_buff *pos; | 785 | struct sk_buff *pos; |
@@ -867,13 +867,14 @@ static struct sctp_ulpevent *sctp_ulpq_order(struct sctp_ulpq *ulpq, | |||
867 | /* Helper function to gather skbs that have possibly become | 867 | /* Helper function to gather skbs that have possibly become |
868 | * ordered by forward tsn skipping their dependencies. | 868 | * ordered by forward tsn skipping their dependencies. |
869 | */ | 869 | */ |
870 | static inline void sctp_ulpq_reap_ordered(struct sctp_ulpq *ulpq, __u16 sid) | 870 | static void sctp_ulpq_reap_ordered(struct sctp_ulpq *ulpq, __u16 sid) |
871 | { | 871 | { |
872 | struct sk_buff *pos, *tmp; | 872 | struct sk_buff *pos, *tmp; |
873 | struct sctp_ulpevent *cevent; | 873 | struct sctp_ulpevent *cevent; |
874 | struct sctp_ulpevent *event; | 874 | struct sctp_ulpevent *event; |
875 | struct sctp_stream *in; | 875 | struct sctp_stream *in; |
876 | struct sk_buff_head temp; | 876 | struct sk_buff_head temp; |
877 | struct sk_buff_head *lobby = &ulpq->lobby; | ||
877 | __u16 csid, cssn; | 878 | __u16 csid, cssn; |
878 | 879 | ||
879 | in = &ulpq->asoc->ssnmap->in; | 880 | in = &ulpq->asoc->ssnmap->in; |
@@ -881,7 +882,7 @@ static inline void sctp_ulpq_reap_ordered(struct sctp_ulpq *ulpq, __u16 sid) | |||
881 | /* We are holding the chunks by stream, by SSN. */ | 882 | /* We are holding the chunks by stream, by SSN. */ |
882 | skb_queue_head_init(&temp); | 883 | skb_queue_head_init(&temp); |
883 | event = NULL; | 884 | event = NULL; |
884 | sctp_skb_for_each(pos, &ulpq->lobby, tmp) { | 885 | sctp_skb_for_each(pos, lobby, tmp) { |
885 | cevent = (struct sctp_ulpevent *) pos->cb; | 886 | cevent = (struct sctp_ulpevent *) pos->cb; |
886 | csid = cevent->stream; | 887 | csid = cevent->stream; |
887 | cssn = cevent->ssn; | 888 | cssn = cevent->ssn; |
@@ -895,10 +896,10 @@ static inline void sctp_ulpq_reap_ordered(struct sctp_ulpq *ulpq, __u16 sid) | |||
895 | continue; | 896 | continue; |
896 | 897 | ||
897 | /* see if this ssn has been marked by skipping */ | 898 | /* see if this ssn has been marked by skipping */ |
898 | if (!SSN_lte(cssn, sctp_ssn_peek(in, csid))) | 899 | if (!SSN_lt(cssn, sctp_ssn_peek(in, csid))) |
899 | break; | 900 | break; |
900 | 901 | ||
901 | __skb_unlink(pos, &ulpq->lobby); | 902 | __skb_unlink(pos, lobby); |
902 | if (!event) | 903 | if (!event) |
903 | /* Create a temporary list to collect chunks on. */ | 904 | /* Create a temporary list to collect chunks on. */ |
904 | event = sctp_skb2event(pos); | 905 | event = sctp_skb2event(pos); |
@@ -907,6 +908,22 @@ static inline void sctp_ulpq_reap_ordered(struct sctp_ulpq *ulpq, __u16 sid) | |||
907 | __skb_queue_tail(&temp, pos); | 908 | __skb_queue_tail(&temp, pos); |
908 | } | 909 | } |
909 | 910 | ||
911 | /* If we didn't reap any data, see if the next expected SSN | ||
912 | * is next on the queue and if so, use that. | ||
913 | */ | ||
914 | if (event == NULL && pos != (struct sk_buff *)lobby) { | ||
915 | cevent = (struct sctp_ulpevent *) pos->cb; | ||
916 | csid = cevent->stream; | ||
917 | cssn = cevent->ssn; | ||
918 | |||
919 | if (csid == sid && cssn == sctp_ssn_peek(in, csid)) { | ||
920 | sctp_ssn_next(in, csid); | ||
921 | __skb_unlink(pos, lobby); | ||
922 | __skb_queue_tail(&temp, pos); | ||
923 | event = sctp_skb2event(pos); | ||
924 | } | ||
925 | } | ||
926 | |||
910 | /* Send event to the ULP. 'event' is the sctp_ulpevent for | 927 | /* Send event to the ULP. 'event' is the sctp_ulpevent for |
911 | * very first SKB on the 'temp' list. | 928 | * very first SKB on the 'temp' list. |
912 | */ | 929 | */ |
diff --git a/net/tipc/addr.h b/net/tipc/addr.h index e4bd5335e48d..3ba67e6ce03e 100644 --- a/net/tipc/addr.h +++ b/net/tipc/addr.h | |||
@@ -57,11 +57,6 @@ static inline int in_own_cluster(u32 addr) | |||
57 | return !((addr ^ tipc_own_addr) >> 12); | 57 | return !((addr ^ tipc_own_addr) >> 12); |
58 | } | 58 | } |
59 | 59 | ||
60 | static inline int in_own_zone(u32 addr) | ||
61 | { | ||
62 | return !((addr ^ tipc_own_addr) >> 24); | ||
63 | } | ||
64 | |||
65 | static inline int is_slave(u32 addr) | 60 | static inline int is_slave(u32 addr) |
66 | { | 61 | { |
67 | return addr & 0x800; | 62 | return addr & 0x800; |
diff --git a/net/tipc/bcast.h b/net/tipc/bcast.h index f910ed29d055..a2416fa6b906 100644 --- a/net/tipc/bcast.h +++ b/net/tipc/bcast.h | |||
@@ -74,19 +74,6 @@ extern char tipc_bclink_name[]; | |||
74 | 74 | ||
75 | 75 | ||
76 | /** | 76 | /** |
77 | * nmap_get - determine if node exists in a node map | ||
78 | */ | ||
79 | |||
80 | static inline int tipc_nmap_get(struct node_map *nm_ptr, u32 node) | ||
81 | { | ||
82 | int n = tipc_node(node); | ||
83 | int w = n / WSIZE; | ||
84 | int b = n % WSIZE; | ||
85 | |||
86 | return nm_ptr->map[w] & (1 << b); | ||
87 | } | ||
88 | |||
89 | /** | ||
90 | * nmap_add - add a node to a node map | 77 | * nmap_add - add a node to a node map |
91 | */ | 78 | */ |
92 | 79 | ||
diff --git a/net/tipc/msg.h b/net/tipc/msg.h index ce2659836374..e9ef6df26562 100644 --- a/net/tipc/msg.h +++ b/net/tipc/msg.h | |||
@@ -663,11 +663,6 @@ static inline void msg_set_remote_node(struct tipc_msg *m, u32 a) | |||
663 | msg_set_word(m, msg_hdr_sz(m)/4, a); | 663 | msg_set_word(m, msg_hdr_sz(m)/4, a); |
664 | } | 664 | } |
665 | 665 | ||
666 | static inline int msg_dataoctet(struct tipc_msg *m, u32 pos) | ||
667 | { | ||
668 | return(msg_data(m)[pos + 4] != 0); | ||
669 | } | ||
670 | |||
671 | static inline void msg_set_dataoctet(struct tipc_msg *m, u32 pos) | 666 | static inline void msg_set_dataoctet(struct tipc_msg *m, u32 pos) |
672 | { | 667 | { |
673 | msg_data(m)[pos + 4] = 1; | 668 | msg_data(m)[pos + 4] = 1; |
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index 24ddfd2ca38b..22909036b9bc 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
@@ -71,9 +71,9 @@ struct tipc_sock { | |||
71 | static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf); | 71 | static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf); |
72 | static void wakeupdispatch(struct tipc_port *tport); | 72 | static void wakeupdispatch(struct tipc_port *tport); |
73 | 73 | ||
74 | static struct proto_ops packet_ops; | 74 | static const struct proto_ops packet_ops; |
75 | static struct proto_ops stream_ops; | 75 | static const struct proto_ops stream_ops; |
76 | static struct proto_ops msg_ops; | 76 | static const struct proto_ops msg_ops; |
77 | 77 | ||
78 | static struct proto tipc_proto; | 78 | static struct proto tipc_proto; |
79 | 79 | ||
@@ -1615,7 +1615,7 @@ static int getsockopt(struct socket *sock, | |||
1615 | * Protocol switches for the various types of TIPC sockets | 1615 | * Protocol switches for the various types of TIPC sockets |
1616 | */ | 1616 | */ |
1617 | 1617 | ||
1618 | static struct proto_ops msg_ops = { | 1618 | static const struct proto_ops msg_ops = { |
1619 | .owner = THIS_MODULE, | 1619 | .owner = THIS_MODULE, |
1620 | .family = AF_TIPC, | 1620 | .family = AF_TIPC, |
1621 | .release = release, | 1621 | .release = release, |
@@ -1636,7 +1636,7 @@ static struct proto_ops msg_ops = { | |||
1636 | .sendpage = sock_no_sendpage | 1636 | .sendpage = sock_no_sendpage |
1637 | }; | 1637 | }; |
1638 | 1638 | ||
1639 | static struct proto_ops packet_ops = { | 1639 | static const struct proto_ops packet_ops = { |
1640 | .owner = THIS_MODULE, | 1640 | .owner = THIS_MODULE, |
1641 | .family = AF_TIPC, | 1641 | .family = AF_TIPC, |
1642 | .release = release, | 1642 | .release = release, |
@@ -1657,7 +1657,7 @@ static struct proto_ops packet_ops = { | |||
1657 | .sendpage = sock_no_sendpage | 1657 | .sendpage = sock_no_sendpage |
1658 | }; | 1658 | }; |
1659 | 1659 | ||
1660 | static struct proto_ops stream_ops = { | 1660 | static const struct proto_ops stream_ops = { |
1661 | .owner = THIS_MODULE, | 1661 | .owner = THIS_MODULE, |
1662 | .family = AF_TIPC, | 1662 | .family = AF_TIPC, |
1663 | .release = release, | 1663 | .release = release, |
@@ -1678,7 +1678,7 @@ static struct proto_ops stream_ops = { | |||
1678 | .sendpage = sock_no_sendpage | 1678 | .sendpage = sock_no_sendpage |
1679 | }; | 1679 | }; |
1680 | 1680 | ||
1681 | static struct net_proto_family tipc_family_ops = { | 1681 | static const struct net_proto_family tipc_family_ops = { |
1682 | .owner = THIS_MODULE, | 1682 | .owner = THIS_MODULE, |
1683 | .family = AF_TIPC, | 1683 | .family = AF_TIPC, |
1684 | .create = tipc_create | 1684 | .create = tipc_create |
diff --git a/net/xfrm/xfrm_algo.c b/net/xfrm/xfrm_algo.c index 6cc15250de69..8aa6440d689f 100644 --- a/net/xfrm/xfrm_algo.c +++ b/net/xfrm/xfrm_algo.c | |||
@@ -399,6 +399,23 @@ static struct xfrm_algo_desc ealg_list[] = { | |||
399 | .sadb_alg_maxbits = 256 | 399 | .sadb_alg_maxbits = 256 |
400 | } | 400 | } |
401 | }, | 401 | }, |
402 | { | ||
403 | .name = "rfc3686(ctr(aes))", | ||
404 | |||
405 | .uinfo = { | ||
406 | .encr = { | ||
407 | .blockbits = 128, | ||
408 | .defkeybits = 160, /* 128-bit key + 32-bit nonce */ | ||
409 | } | ||
410 | }, | ||
411 | |||
412 | .desc = { | ||
413 | .sadb_alg_id = SADB_X_EALG_AESCTR, | ||
414 | .sadb_alg_ivlen = 8, | ||
415 | .sadb_alg_minbits = 128, | ||
416 | .sadb_alg_maxbits = 256 | ||
417 | } | ||
418 | }, | ||
402 | }; | 419 | }; |
403 | 420 | ||
404 | static struct xfrm_algo_desc calg_list[] = { | 421 | static struct xfrm_algo_desc calg_list[] = { |