diff options
Diffstat (limited to 'net')
41 files changed, 696 insertions, 178 deletions
diff --git a/net/9p/Kconfig b/net/9p/Kconfig index bafc50c9e6ff..ff34c5acc130 100644 --- a/net/9p/Kconfig +++ b/net/9p/Kconfig | |||
@@ -13,16 +13,6 @@ menuconfig NET_9P | |||
13 | 13 | ||
14 | If unsure, say N. | 14 | If unsure, say N. |
15 | 15 | ||
16 | config NET_9P_FD | ||
17 | depends on NET_9P | ||
18 | default y if NET_9P | ||
19 | tristate "9P File Descriptor Transports (Experimental)" | ||
20 | help | ||
21 | This builds support for file descriptor transports for 9p | ||
22 | which includes support for TCP/IP, named pipes, or passed | ||
23 | file descriptors. TCP/IP is the default transport for 9p, | ||
24 | so if you are going to use 9p, you'll likely want this. | ||
25 | |||
26 | config NET_9P_VIRTIO | 16 | config NET_9P_VIRTIO |
27 | depends on NET_9P && EXPERIMENTAL && VIRTIO | 17 | depends on NET_9P && EXPERIMENTAL && VIRTIO |
28 | tristate "9P Virtio Transport (Experimental)" | 18 | tristate "9P Virtio Transport (Experimental)" |
diff --git a/net/9p/Makefile b/net/9p/Makefile index 8a1051101898..519219480db1 100644 --- a/net/9p/Makefile +++ b/net/9p/Makefile | |||
@@ -1,5 +1,4 @@ | |||
1 | obj-$(CONFIG_NET_9P) := 9pnet.o | 1 | obj-$(CONFIG_NET_9P) := 9pnet.o |
2 | obj-$(CONFIG_NET_9P_FD) += 9pnet_fd.o | ||
3 | obj-$(CONFIG_NET_9P_VIRTIO) += 9pnet_virtio.o | 2 | obj-$(CONFIG_NET_9P_VIRTIO) += 9pnet_virtio.o |
4 | 3 | ||
5 | 9pnet-objs := \ | 4 | 9pnet-objs := \ |
@@ -9,8 +8,6 @@ obj-$(CONFIG_NET_9P_VIRTIO) += 9pnet_virtio.o | |||
9 | error.o \ | 8 | error.o \ |
10 | fcprint.o \ | 9 | fcprint.o \ |
11 | util.o \ | 10 | util.o \ |
12 | |||
13 | 9pnet_fd-objs := \ | ||
14 | trans_fd.o \ | 11 | trans_fd.o \ |
15 | 12 | ||
16 | 9pnet_virtio-objs := \ | 13 | 9pnet_virtio-objs := \ |
diff --git a/net/9p/client.c b/net/9p/client.c index 84e087e24146..2ffe40cf2f01 100644 --- a/net/9p/client.c +++ b/net/9p/client.c | |||
@@ -64,21 +64,30 @@ static match_table_t tokens = { | |||
64 | * @options: options string passed from mount | 64 | * @options: options string passed from mount |
65 | * @v9ses: existing v9fs session information | 65 | * @v9ses: existing v9fs session information |
66 | * | 66 | * |
67 | * Return 0 upon success, -ERRNO upon failure | ||
67 | */ | 68 | */ |
68 | 69 | ||
69 | static void parse_opts(char *options, struct p9_client *clnt) | 70 | static int parse_opts(char *opts, struct p9_client *clnt) |
70 | { | 71 | { |
72 | char *options; | ||
71 | char *p; | 73 | char *p; |
72 | substring_t args[MAX_OPT_ARGS]; | 74 | substring_t args[MAX_OPT_ARGS]; |
73 | int option; | 75 | int option; |
74 | int ret; | 76 | int ret = 0; |
75 | 77 | ||
76 | clnt->trans_mod = v9fs_default_trans(); | 78 | clnt->trans_mod = v9fs_default_trans(); |
77 | clnt->dotu = 1; | 79 | clnt->dotu = 1; |
78 | clnt->msize = 8192; | 80 | clnt->msize = 8192; |
79 | 81 | ||
80 | if (!options) | 82 | if (!opts) |
81 | return; | 83 | return 0; |
84 | |||
85 | options = kstrdup(opts, GFP_KERNEL); | ||
86 | if (!options) { | ||
87 | P9_DPRINTK(P9_DEBUG_ERROR, | ||
88 | "failed to allocate copy of option string\n"); | ||
89 | return -ENOMEM; | ||
90 | } | ||
82 | 91 | ||
83 | while ((p = strsep(&options, ",")) != NULL) { | 92 | while ((p = strsep(&options, ",")) != NULL) { |
84 | int token; | 93 | int token; |
@@ -86,10 +95,11 @@ static void parse_opts(char *options, struct p9_client *clnt) | |||
86 | continue; | 95 | continue; |
87 | token = match_token(p, tokens, args); | 96 | token = match_token(p, tokens, args); |
88 | if (token < Opt_trans) { | 97 | if (token < Opt_trans) { |
89 | ret = match_int(&args[0], &option); | 98 | int r = match_int(&args[0], &option); |
90 | if (ret < 0) { | 99 | if (r < 0) { |
91 | P9_DPRINTK(P9_DEBUG_ERROR, | 100 | P9_DPRINTK(P9_DEBUG_ERROR, |
92 | "integer field, but no integer?\n"); | 101 | "integer field, but no integer?\n"); |
102 | ret = r; | ||
93 | continue; | 103 | continue; |
94 | } | 104 | } |
95 | } | 105 | } |
@@ -107,6 +117,8 @@ static void parse_opts(char *options, struct p9_client *clnt) | |||
107 | continue; | 117 | continue; |
108 | } | 118 | } |
109 | } | 119 | } |
120 | kfree(options); | ||
121 | return ret; | ||
110 | } | 122 | } |
111 | 123 | ||
112 | 124 | ||
@@ -138,16 +150,20 @@ struct p9_client *p9_client_create(const char *dev_name, char *options) | |||
138 | if (!clnt) | 150 | if (!clnt) |
139 | return ERR_PTR(-ENOMEM); | 151 | return ERR_PTR(-ENOMEM); |
140 | 152 | ||
153 | clnt->trans = NULL; | ||
141 | spin_lock_init(&clnt->lock); | 154 | spin_lock_init(&clnt->lock); |
142 | INIT_LIST_HEAD(&clnt->fidlist); | 155 | INIT_LIST_HEAD(&clnt->fidlist); |
143 | clnt->fidpool = p9_idpool_create(); | 156 | clnt->fidpool = p9_idpool_create(); |
144 | if (!clnt->fidpool) { | 157 | if (IS_ERR(clnt->fidpool)) { |
145 | err = PTR_ERR(clnt->fidpool); | 158 | err = PTR_ERR(clnt->fidpool); |
146 | clnt->fidpool = NULL; | 159 | clnt->fidpool = NULL; |
147 | goto error; | 160 | goto error; |
148 | } | 161 | } |
149 | 162 | ||
150 | parse_opts(options, clnt); | 163 | err = parse_opts(options, clnt); |
164 | if (err < 0) | ||
165 | goto error; | ||
166 | |||
151 | if (clnt->trans_mod == NULL) { | 167 | if (clnt->trans_mod == NULL) { |
152 | err = -EPROTONOSUPPORT; | 168 | err = -EPROTONOSUPPORT; |
153 | P9_DPRINTK(P9_DEBUG_ERROR, | 169 | P9_DPRINTK(P9_DEBUG_ERROR, |
diff --git a/net/9p/conv.c b/net/9p/conv.c index 3fe35d532c87..44547201f5bc 100644 --- a/net/9p/conv.c +++ b/net/9p/conv.c | |||
@@ -197,7 +197,7 @@ static void buf_get_qid(struct cbuf *bufp, struct p9_qid *qid) | |||
197 | 197 | ||
198 | /** | 198 | /** |
199 | * p9_size_wstat - calculate the size of a variable length stat struct | 199 | * p9_size_wstat - calculate the size of a variable length stat struct |
200 | * @stat: metadata (stat) structure | 200 | * @wstat: metadata (stat) structure |
201 | * @dotu: non-zero if 9P2000.u | 201 | * @dotu: non-zero if 9P2000.u |
202 | * | 202 | * |
203 | */ | 203 | */ |
@@ -511,6 +511,12 @@ p9_create_common(struct cbuf *bufp, u32 size, u8 id) | |||
511 | return fc; | 511 | return fc; |
512 | } | 512 | } |
513 | 513 | ||
514 | /** | ||
515 | * p9_set_tag - set the tag field of an &p9_fcall structure | ||
516 | * @fc: fcall structure to set tag within | ||
517 | * @tag: tag id to set | ||
518 | */ | ||
519 | |||
514 | void p9_set_tag(struct p9_fcall *fc, u16 tag) | 520 | void p9_set_tag(struct p9_fcall *fc, u16 tag) |
515 | { | 521 | { |
516 | fc->tag = tag; | 522 | fc->tag = tag; |
@@ -518,6 +524,12 @@ void p9_set_tag(struct p9_fcall *fc, u16 tag) | |||
518 | } | 524 | } |
519 | EXPORT_SYMBOL(p9_set_tag); | 525 | EXPORT_SYMBOL(p9_set_tag); |
520 | 526 | ||
527 | /** | ||
528 | * p9_create_tversion - allocates and creates a T_VERSION request | ||
529 | * @msize: requested maximum data size | ||
530 | * @version: version string to negotiate | ||
531 | * | ||
532 | */ | ||
521 | struct p9_fcall *p9_create_tversion(u32 msize, char *version) | 533 | struct p9_fcall *p9_create_tversion(u32 msize, char *version) |
522 | { | 534 | { |
523 | int size; | 535 | int size; |
@@ -542,6 +554,16 @@ error: | |||
542 | } | 554 | } |
543 | EXPORT_SYMBOL(p9_create_tversion); | 555 | EXPORT_SYMBOL(p9_create_tversion); |
544 | 556 | ||
557 | /** | ||
558 | * p9_create_tauth - allocates and creates a T_AUTH request | ||
559 | * @afid: handle to use for authentication protocol | ||
560 | * @uname: user name attempting to authenticate | ||
561 | * @aname: mount specifier for remote server | ||
562 | * @n_uname: numeric id for user attempting to authneticate | ||
563 | * @dotu: 9P2000.u extension flag | ||
564 | * | ||
565 | */ | ||
566 | |||
545 | struct p9_fcall *p9_create_tauth(u32 afid, char *uname, char *aname, | 567 | struct p9_fcall *p9_create_tauth(u32 afid, char *uname, char *aname, |
546 | u32 n_uname, int dotu) | 568 | u32 n_uname, int dotu) |
547 | { | 569 | { |
@@ -580,6 +602,18 @@ error: | |||
580 | } | 602 | } |
581 | EXPORT_SYMBOL(p9_create_tauth); | 603 | EXPORT_SYMBOL(p9_create_tauth); |
582 | 604 | ||
605 | /** | ||
606 | * p9_create_tattach - allocates and creates a T_ATTACH request | ||
607 | * @fid: handle to use for the new mount point | ||
608 | * @afid: handle to use for authentication protocol | ||
609 | * @uname: user name attempting to attach | ||
610 | * @aname: mount specifier for remote server | ||
611 | * @n_uname: numeric id for user attempting to attach | ||
612 | * @n_uname: numeric id for user attempting to attach | ||
613 | * @dotu: 9P2000.u extension flag | ||
614 | * | ||
615 | */ | ||
616 | |||
583 | struct p9_fcall * | 617 | struct p9_fcall * |
584 | p9_create_tattach(u32 fid, u32 afid, char *uname, char *aname, | 618 | p9_create_tattach(u32 fid, u32 afid, char *uname, char *aname, |
585 | u32 n_uname, int dotu) | 619 | u32 n_uname, int dotu) |
@@ -616,6 +650,12 @@ error: | |||
616 | } | 650 | } |
617 | EXPORT_SYMBOL(p9_create_tattach); | 651 | EXPORT_SYMBOL(p9_create_tattach); |
618 | 652 | ||
653 | /** | ||
654 | * p9_create_tflush - allocates and creates a T_FLUSH request | ||
655 | * @oldtag: tag id for the transaction we are attempting to cancel | ||
656 | * | ||
657 | */ | ||
658 | |||
619 | struct p9_fcall *p9_create_tflush(u16 oldtag) | 659 | struct p9_fcall *p9_create_tflush(u16 oldtag) |
620 | { | 660 | { |
621 | int size; | 661 | int size; |
@@ -639,6 +679,15 @@ error: | |||
639 | } | 679 | } |
640 | EXPORT_SYMBOL(p9_create_tflush); | 680 | EXPORT_SYMBOL(p9_create_tflush); |
641 | 681 | ||
682 | /** | ||
683 | * p9_create_twalk - allocates and creates a T_FLUSH request | ||
684 | * @fid: handle we are traversing from | ||
685 | * @newfid: a new handle for this transaction | ||
686 | * @nwname: number of path elements to traverse | ||
687 | * @wnames: array of path elements | ||
688 | * | ||
689 | */ | ||
690 | |||
642 | struct p9_fcall *p9_create_twalk(u32 fid, u32 newfid, u16 nwname, | 691 | struct p9_fcall *p9_create_twalk(u32 fid, u32 newfid, u16 nwname, |
643 | char **wnames) | 692 | char **wnames) |
644 | { | 693 | { |
@@ -677,6 +726,13 @@ error: | |||
677 | } | 726 | } |
678 | EXPORT_SYMBOL(p9_create_twalk); | 727 | EXPORT_SYMBOL(p9_create_twalk); |
679 | 728 | ||
729 | /** | ||
730 | * p9_create_topen - allocates and creates a T_OPEN request | ||
731 | * @fid: handle we are trying to open | ||
732 | * @mode: what mode we are trying to open the file in | ||
733 | * | ||
734 | */ | ||
735 | |||
680 | struct p9_fcall *p9_create_topen(u32 fid, u8 mode) | 736 | struct p9_fcall *p9_create_topen(u32 fid, u8 mode) |
681 | { | 737 | { |
682 | int size; | 738 | int size; |
@@ -701,6 +757,19 @@ error: | |||
701 | } | 757 | } |
702 | EXPORT_SYMBOL(p9_create_topen); | 758 | EXPORT_SYMBOL(p9_create_topen); |
703 | 759 | ||
760 | /** | ||
761 | * p9_create_tcreate - allocates and creates a T_CREATE request | ||
762 | * @fid: handle of directory we are trying to create in | ||
763 | * @name: name of the file we are trying to create | ||
764 | * @perm: permissions for the file we are trying to create | ||
765 | * @mode: what mode we are trying to open the file in | ||
766 | * @extension: 9p2000.u extension string (for special files) | ||
767 | * @dotu: 9p2000.u enabled flag | ||
768 | * | ||
769 | * Note: Plan 9 create semantics include opening the resulting file | ||
770 | * which is why mode is included. | ||
771 | */ | ||
772 | |||
704 | struct p9_fcall *p9_create_tcreate(u32 fid, char *name, u32 perm, u8 mode, | 773 | struct p9_fcall *p9_create_tcreate(u32 fid, char *name, u32 perm, u8 mode, |
705 | char *extension, int dotu) | 774 | char *extension, int dotu) |
706 | { | 775 | { |
@@ -736,6 +805,13 @@ error: | |||
736 | } | 805 | } |
737 | EXPORT_SYMBOL(p9_create_tcreate); | 806 | EXPORT_SYMBOL(p9_create_tcreate); |
738 | 807 | ||
808 | /** | ||
809 | * p9_create_tread - allocates and creates a T_READ request | ||
810 | * @fid: handle of the file we are trying to read | ||
811 | * @offset: offset to start reading from | ||
812 | * @count: how many bytes to read | ||
813 | */ | ||
814 | |||
739 | struct p9_fcall *p9_create_tread(u32 fid, u64 offset, u32 count) | 815 | struct p9_fcall *p9_create_tread(u32 fid, u64 offset, u32 count) |
740 | { | 816 | { |
741 | int size; | 817 | int size; |
@@ -761,6 +837,17 @@ error: | |||
761 | } | 837 | } |
762 | EXPORT_SYMBOL(p9_create_tread); | 838 | EXPORT_SYMBOL(p9_create_tread); |
763 | 839 | ||
840 | /** | ||
841 | * p9_create_twrite - allocates and creates a T_WRITE request from the kernel | ||
842 | * @fid: handle of the file we are trying to write | ||
843 | * @offset: offset to start writing at | ||
844 | * @count: how many bytes to write | ||
845 | * @data: data to write | ||
846 | * | ||
847 | * This function will create a requst with data buffers from the kernel | ||
848 | * such as the page cache. | ||
849 | */ | ||
850 | |||
764 | struct p9_fcall *p9_create_twrite(u32 fid, u64 offset, u32 count, | 851 | struct p9_fcall *p9_create_twrite(u32 fid, u64 offset, u32 count, |
765 | const char *data) | 852 | const char *data) |
766 | { | 853 | { |
@@ -794,6 +881,16 @@ error: | |||
794 | } | 881 | } |
795 | EXPORT_SYMBOL(p9_create_twrite); | 882 | EXPORT_SYMBOL(p9_create_twrite); |
796 | 883 | ||
884 | /** | ||
885 | * p9_create_twrite_u - allocates and creates a T_WRITE request from userspace | ||
886 | * @fid: handle of the file we are trying to write | ||
887 | * @offset: offset to start writing at | ||
888 | * @count: how many bytes to write | ||
889 | * @data: data to write | ||
890 | * | ||
891 | * This function will create a request with data buffers from userspace | ||
892 | */ | ||
893 | |||
797 | struct p9_fcall *p9_create_twrite_u(u32 fid, u64 offset, u32 count, | 894 | struct p9_fcall *p9_create_twrite_u(u32 fid, u64 offset, u32 count, |
798 | const char __user *data) | 895 | const char __user *data) |
799 | { | 896 | { |
@@ -827,6 +924,14 @@ error: | |||
827 | } | 924 | } |
828 | EXPORT_SYMBOL(p9_create_twrite_u); | 925 | EXPORT_SYMBOL(p9_create_twrite_u); |
829 | 926 | ||
927 | /** | ||
928 | * p9_create_tclunk - allocate a request to forget about a file handle | ||
929 | * @fid: handle of the file we closing or forgetting about | ||
930 | * | ||
931 | * clunk is used both to close open files and to discard transient handles | ||
932 | * which may be created during meta-data operations and hierarchy traversal. | ||
933 | */ | ||
934 | |||
830 | struct p9_fcall *p9_create_tclunk(u32 fid) | 935 | struct p9_fcall *p9_create_tclunk(u32 fid) |
831 | { | 936 | { |
832 | int size; | 937 | int size; |
@@ -850,6 +955,12 @@ error: | |||
850 | } | 955 | } |
851 | EXPORT_SYMBOL(p9_create_tclunk); | 956 | EXPORT_SYMBOL(p9_create_tclunk); |
852 | 957 | ||
958 | /** | ||
959 | * p9_create_tremove - allocate and create a request to remove a file | ||
960 | * @fid: handle of the file or directory we are removing | ||
961 | * | ||
962 | */ | ||
963 | |||
853 | struct p9_fcall *p9_create_tremove(u32 fid) | 964 | struct p9_fcall *p9_create_tremove(u32 fid) |
854 | { | 965 | { |
855 | int size; | 966 | int size; |
@@ -873,6 +984,12 @@ error: | |||
873 | } | 984 | } |
874 | EXPORT_SYMBOL(p9_create_tremove); | 985 | EXPORT_SYMBOL(p9_create_tremove); |
875 | 986 | ||
987 | /** | ||
988 | * p9_create_tstat - allocate and populate a request for attributes | ||
989 | * @fid: handle of the file or directory we are trying to get the attributes of | ||
990 | * | ||
991 | */ | ||
992 | |||
876 | struct p9_fcall *p9_create_tstat(u32 fid) | 993 | struct p9_fcall *p9_create_tstat(u32 fid) |
877 | { | 994 | { |
878 | int size; | 995 | int size; |
@@ -896,6 +1013,14 @@ error: | |||
896 | } | 1013 | } |
897 | EXPORT_SYMBOL(p9_create_tstat); | 1014 | EXPORT_SYMBOL(p9_create_tstat); |
898 | 1015 | ||
1016 | /** | ||
1017 | * p9_create_tstat - allocate and populate a request to change attributes | ||
1018 | * @fid: handle of the file or directory we are trying to change | ||
1019 | * @wstat: &p9_stat structure with attributes we wish to set | ||
1020 | * @dotu: 9p2000.u enabled flag | ||
1021 | * | ||
1022 | */ | ||
1023 | |||
899 | struct p9_fcall *p9_create_twstat(u32 fid, struct p9_wstat *wstat, | 1024 | struct p9_fcall *p9_create_twstat(u32 fid, struct p9_wstat *wstat, |
900 | int dotu) | 1025 | int dotu) |
901 | { | 1026 | { |
@@ -922,3 +1047,4 @@ error: | |||
922 | return fc; | 1047 | return fc; |
923 | } | 1048 | } |
924 | EXPORT_SYMBOL(p9_create_twstat); | 1049 | EXPORT_SYMBOL(p9_create_twstat); |
1050 | |||
diff --git a/net/9p/error.c b/net/9p/error.c index 64104b9cb422..fdebe4314062 100644 --- a/net/9p/error.c +++ b/net/9p/error.c | |||
@@ -33,6 +33,13 @@ | |||
33 | #include <linux/errno.h> | 33 | #include <linux/errno.h> |
34 | #include <net/9p/9p.h> | 34 | #include <net/9p/9p.h> |
35 | 35 | ||
36 | /** | ||
37 | * struct errormap - map string errors from Plan 9 to Linux numeric ids | ||
38 | * @name: string sent over 9P | ||
39 | * @val: numeric id most closely representing @name | ||
40 | * @namelen: length of string | ||
41 | * @list: hash-table list for string lookup | ||
42 | */ | ||
36 | struct errormap { | 43 | struct errormap { |
37 | char *name; | 44 | char *name; |
38 | int val; | 45 | int val; |
@@ -177,8 +184,7 @@ static struct errormap errmap[] = { | |||
177 | }; | 184 | }; |
178 | 185 | ||
179 | /** | 186 | /** |
180 | * p9_error_init - preload | 187 | * p9_error_init - preload mappings into hash list |
181 | * @errstr: error string | ||
182 | * | 188 | * |
183 | */ | 189 | */ |
184 | 190 | ||
@@ -206,6 +212,7 @@ EXPORT_SYMBOL(p9_error_init); | |||
206 | /** | 212 | /** |
207 | * errstr2errno - convert error string to error number | 213 | * errstr2errno - convert error string to error number |
208 | * @errstr: error string | 214 | * @errstr: error string |
215 | * @len: length of error string | ||
209 | * | 216 | * |
210 | */ | 217 | */ |
211 | 218 | ||
@@ -230,8 +237,8 @@ int p9_errstr2errno(char *errstr, int len) | |||
230 | if (errno == 0) { | 237 | if (errno == 0) { |
231 | /* TODO: if error isn't found, add it dynamically */ | 238 | /* TODO: if error isn't found, add it dynamically */ |
232 | errstr[len] = 0; | 239 | errstr[len] = 0; |
233 | printk(KERN_ERR "%s: errstr :%s: not found\n", __func__, | 240 | printk(KERN_ERR "%s: server reported unknown error %s\n", |
234 | errstr); | 241 | __func__, errstr); |
235 | errno = 1; | 242 | errno = 1; |
236 | } | 243 | } |
237 | 244 | ||
diff --git a/net/9p/fcprint.c b/net/9p/fcprint.c index 40244fbd9b0d..53dd8e28dd8a 100644 --- a/net/9p/fcprint.c +++ b/net/9p/fcprint.c | |||
@@ -142,6 +142,14 @@ p9_printdata(char *buf, int buflen, u8 *data, int datalen) | |||
142 | return p9_dumpdata(buf, buflen, data, datalen < 16?datalen:16); | 142 | return p9_dumpdata(buf, buflen, data, datalen < 16?datalen:16); |
143 | } | 143 | } |
144 | 144 | ||
145 | /** | ||
146 | * p9_printfcall - decode and print a protocol structure into a buffer | ||
147 | * @buf: buffer to deposit decoded structure into | ||
148 | * @buflen: available space in buffer | ||
149 | * @fc: protocol rpc structure of type &p9_fcall | ||
150 | * @extended: whether or not session is operating with extended protocol | ||
151 | */ | ||
152 | |||
145 | int | 153 | int |
146 | p9_printfcall(char *buf, int buflen, struct p9_fcall *fc, int extended) | 154 | p9_printfcall(char *buf, int buflen, struct p9_fcall *fc, int extended) |
147 | { | 155 | { |
diff --git a/net/9p/mod.c b/net/9p/mod.c index c285aab2af04..bdee1fb7cc62 100644 --- a/net/9p/mod.c +++ b/net/9p/mod.c | |||
@@ -39,9 +39,6 @@ module_param_named(debug, p9_debug_level, uint, 0); | |||
39 | MODULE_PARM_DESC(debug, "9P debugging level"); | 39 | MODULE_PARM_DESC(debug, "9P debugging level"); |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | extern int p9_mux_global_init(void); | ||
43 | extern void p9_mux_global_exit(void); | ||
44 | |||
45 | /* | 42 | /* |
46 | * Dynamic Transport Registration Routines | 43 | * Dynamic Transport Registration Routines |
47 | * | 44 | * |
@@ -52,7 +49,7 @@ static struct p9_trans_module *v9fs_default_transport; | |||
52 | 49 | ||
53 | /** | 50 | /** |
54 | * v9fs_register_trans - register a new transport with 9p | 51 | * v9fs_register_trans - register a new transport with 9p |
55 | * @m - structure describing the transport module and entry points | 52 | * @m: structure describing the transport module and entry points |
56 | * | 53 | * |
57 | */ | 54 | */ |
58 | void v9fs_register_trans(struct p9_trans_module *m) | 55 | void v9fs_register_trans(struct p9_trans_module *m) |
@@ -65,7 +62,7 @@ EXPORT_SYMBOL(v9fs_register_trans); | |||
65 | 62 | ||
66 | /** | 63 | /** |
67 | * v9fs_match_trans - match transport versus registered transports | 64 | * v9fs_match_trans - match transport versus registered transports |
68 | * @arg: string identifying transport | 65 | * @name: string identifying transport |
69 | * | 66 | * |
70 | */ | 67 | */ |
71 | struct p9_trans_module *v9fs_match_trans(const substring_t *name) | 68 | struct p9_trans_module *v9fs_match_trans(const substring_t *name) |
@@ -110,6 +107,7 @@ static int __init init_p9(void) | |||
110 | 107 | ||
111 | p9_error_init(); | 108 | p9_error_init(); |
112 | printk(KERN_INFO "Installing 9P2000 support\n"); | 109 | printk(KERN_INFO "Installing 9P2000 support\n"); |
110 | p9_trans_fd_init(); | ||
113 | 111 | ||
114 | return ret; | 112 | return ret; |
115 | } | 113 | } |
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c index f624dff76852..4507f744f44e 100644 --- a/net/9p/trans_fd.c +++ b/net/9p/trans_fd.c | |||
@@ -47,12 +47,29 @@ | |||
47 | #define SCHED_TIMEOUT 10 | 47 | #define SCHED_TIMEOUT 10 |
48 | #define MAXPOLLWADDR 2 | 48 | #define MAXPOLLWADDR 2 |
49 | 49 | ||
50 | /** | ||
51 | * struct p9_fd_opts - per-transport options | ||
52 | * @rfd: file descriptor for reading (trans=fd) | ||
53 | * @wfd: file descriptor for writing (trans=fd) | ||
54 | * @port: port to connect to (trans=tcp) | ||
55 | * | ||
56 | */ | ||
57 | |||
50 | struct p9_fd_opts { | 58 | struct p9_fd_opts { |
51 | int rfd; | 59 | int rfd; |
52 | int wfd; | 60 | int wfd; |
53 | u16 port; | 61 | u16 port; |
54 | }; | 62 | }; |
55 | 63 | ||
64 | |||
65 | /** | ||
66 | * struct p9_trans_fd - transport state | ||
67 | * @rd: reference to file to read from | ||
68 | * @wr: reference of file to write to | ||
69 | * @conn: connection state reference | ||
70 | * | ||
71 | */ | ||
72 | |||
56 | struct p9_trans_fd { | 73 | struct p9_trans_fd { |
57 | struct file *rd; | 74 | struct file *rd; |
58 | struct file *wr; | 75 | struct file *wr; |
@@ -90,10 +107,24 @@ enum { | |||
90 | }; | 107 | }; |
91 | 108 | ||
92 | struct p9_req; | 109 | struct p9_req; |
93 | |||
94 | typedef void (*p9_conn_req_callback)(struct p9_req *req, void *a); | 110 | typedef void (*p9_conn_req_callback)(struct p9_req *req, void *a); |
111 | |||
112 | /** | ||
113 | * struct p9_req - fd mux encoding of an rpc transaction | ||
114 | * @lock: protects req_list | ||
115 | * @tag: numeric tag for rpc transaction | ||
116 | * @tcall: request &p9_fcall structure | ||
117 | * @rcall: response &p9_fcall structure | ||
118 | * @err: error state | ||
119 | * @cb: callback for when response is received | ||
120 | * @cba: argument to pass to callback | ||
121 | * @flush: flag to indicate RPC has been flushed | ||
122 | * @req_list: list link for higher level objects to chain requests | ||
123 | * | ||
124 | */ | ||
125 | |||
95 | struct p9_req { | 126 | struct p9_req { |
96 | spinlock_t lock; /* protect request structure */ | 127 | spinlock_t lock; |
97 | int tag; | 128 | int tag; |
98 | struct p9_fcall *tcall; | 129 | struct p9_fcall *tcall; |
99 | struct p9_fcall *rcall; | 130 | struct p9_fcall *rcall; |
@@ -104,7 +135,39 @@ struct p9_req { | |||
104 | struct list_head req_list; | 135 | struct list_head req_list; |
105 | }; | 136 | }; |
106 | 137 | ||
107 | struct p9_mux_poll_task; | 138 | struct p9_mux_poll_task { |
139 | struct task_struct *task; | ||
140 | struct list_head mux_list; | ||
141 | int muxnum; | ||
142 | }; | ||
143 | |||
144 | /** | ||
145 | * struct p9_conn - fd mux connection state information | ||
146 | * @lock: protects mux_list (?) | ||
147 | * @mux_list: list link for mux to manage multiple connections (?) | ||
148 | * @poll_task: task polling on this connection | ||
149 | * @msize: maximum size for connection (dup) | ||
150 | * @extended: 9p2000.u flag (dup) | ||
151 | * @trans: reference to transport instance for this connection | ||
152 | * @tagpool: id accounting for transactions | ||
153 | * @err: error state | ||
154 | * @equeue: event wait_q (?) | ||
155 | * @req_list: accounting for requests which have been sent | ||
156 | * @unsent_req_list: accounting for requests that haven't been sent | ||
157 | * @rcall: current response &p9_fcall structure | ||
158 | * @rpos: read position in current frame | ||
159 | * @rbuf: current read buffer | ||
160 | * @wpos: write position for current frame | ||
161 | * @wsize: amount of data to write for current frame | ||
162 | * @wbuf: current write buffer | ||
163 | * @poll_wait: array of wait_q's for various worker threads | ||
164 | * @poll_waddr: ???? | ||
165 | * @pt: poll state | ||
166 | * @rq: current read work | ||
167 | * @wq: current write work | ||
168 | * @wsched: ???? | ||
169 | * | ||
170 | */ | ||
108 | 171 | ||
109 | struct p9_conn { | 172 | struct p9_conn { |
110 | spinlock_t lock; /* protect lock structure */ | 173 | spinlock_t lock; /* protect lock structure */ |
@@ -132,11 +195,16 @@ struct p9_conn { | |||
132 | unsigned long wsched; | 195 | unsigned long wsched; |
133 | }; | 196 | }; |
134 | 197 | ||
135 | struct p9_mux_poll_task { | 198 | /** |
136 | struct task_struct *task; | 199 | * struct p9_mux_rpc - fd mux rpc accounting structure |
137 | struct list_head mux_list; | 200 | * @m: connection this request was issued on |
138 | int muxnum; | 201 | * @err: error state |
139 | }; | 202 | * @tcall: request &p9_fcall |
203 | * @rcall: response &p9_fcall | ||
204 | * @wqueue: wait queue that client is blocked on for this rpc | ||
205 | * | ||
206 | * Bug: isn't this information duplicated elsewhere like &p9_req | ||
207 | */ | ||
140 | 208 | ||
141 | struct p9_mux_rpc { | 209 | struct p9_mux_rpc { |
142 | struct p9_conn *m; | 210 | struct p9_conn *m; |
@@ -207,10 +275,12 @@ static void p9_mux_put_tag(struct p9_conn *m, u16 tag) | |||
207 | 275 | ||
208 | /** | 276 | /** |
209 | * p9_mux_calc_poll_procs - calculates the number of polling procs | 277 | * p9_mux_calc_poll_procs - calculates the number of polling procs |
210 | * based on the number of mounted v9fs filesystems. | 278 | * @muxnum: number of mounts |
211 | * | 279 | * |
280 | * Calculation is based on the number of mounted v9fs filesystems. | ||
212 | * The current implementation returns sqrt of the number of mounts. | 281 | * The current implementation returns sqrt of the number of mounts. |
213 | */ | 282 | */ |
283 | |||
214 | static int p9_mux_calc_poll_procs(int muxnum) | 284 | static int p9_mux_calc_poll_procs(int muxnum) |
215 | { | 285 | { |
216 | int n; | 286 | int n; |
@@ -331,12 +401,11 @@ static void p9_mux_poll_stop(struct p9_conn *m) | |||
331 | 401 | ||
332 | /** | 402 | /** |
333 | * p9_conn_create - allocate and initialize the per-session mux data | 403 | * p9_conn_create - allocate and initialize the per-session mux data |
334 | * Creates the polling task if this is the first session. | 404 | * @trans: transport structure |
335 | * | 405 | * |
336 | * @trans - transport structure | 406 | * Note: Creates the polling task if this is the first session. |
337 | * @msize - maximum message size | ||
338 | * @extended - extended flag | ||
339 | */ | 407 | */ |
408 | |||
340 | static struct p9_conn *p9_conn_create(struct p9_trans *trans) | 409 | static struct p9_conn *p9_conn_create(struct p9_trans *trans) |
341 | { | 410 | { |
342 | int i, n; | 411 | int i, n; |
@@ -406,7 +475,10 @@ static struct p9_conn *p9_conn_create(struct p9_trans *trans) | |||
406 | 475 | ||
407 | /** | 476 | /** |
408 | * p9_mux_destroy - cancels all pending requests and frees mux resources | 477 | * p9_mux_destroy - cancels all pending requests and frees mux resources |
478 | * @m: mux to destroy | ||
479 | * | ||
409 | */ | 480 | */ |
481 | |||
410 | static void p9_conn_destroy(struct p9_conn *m) | 482 | static void p9_conn_destroy(struct p9_conn *m) |
411 | { | 483 | { |
412 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p prev %p next %p\n", m, | 484 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p prev %p next %p\n", m, |
@@ -429,9 +501,14 @@ static void p9_conn_destroy(struct p9_conn *m) | |||
429 | } | 501 | } |
430 | 502 | ||
431 | /** | 503 | /** |
432 | * p9_pollwait - called by files poll operation to add v9fs-poll task | 504 | * p9_pollwait - add poll task to the wait queue |
433 | * to files wait queue | 505 | * @filp: file pointer being polled |
506 | * @wait_address: wait_q to block on | ||
507 | * @p: poll state | ||
508 | * | ||
509 | * called by files poll operation to add v9fs-poll task to files wait queue | ||
434 | */ | 510 | */ |
511 | |||
435 | static void | 512 | static void |
436 | p9_pollwait(struct file *filp, wait_queue_head_t *wait_address, poll_table *p) | 513 | p9_pollwait(struct file *filp, wait_queue_head_t *wait_address, poll_table *p) |
437 | { | 514 | { |
@@ -462,7 +539,10 @@ p9_pollwait(struct file *filp, wait_queue_head_t *wait_address, poll_table *p) | |||
462 | 539 | ||
463 | /** | 540 | /** |
464 | * p9_poll_mux - polls a mux and schedules read or write works if necessary | 541 | * p9_poll_mux - polls a mux and schedules read or write works if necessary |
542 | * @m: connection to poll | ||
543 | * | ||
465 | */ | 544 | */ |
545 | |||
466 | static void p9_poll_mux(struct p9_conn *m) | 546 | static void p9_poll_mux(struct p9_conn *m) |
467 | { | 547 | { |
468 | int n; | 548 | int n; |
@@ -499,9 +579,14 @@ static void p9_poll_mux(struct p9_conn *m) | |||
499 | } | 579 | } |
500 | 580 | ||
501 | /** | 581 | /** |
502 | * p9_poll_proc - polls all v9fs transports for new events and queues | 582 | * p9_poll_proc - poll worker thread |
503 | * the appropriate work to the work queue | 583 | * @a: thread state and arguments |
584 | * | ||
585 | * polls all v9fs transports for new events and queues the appropriate | ||
586 | * work to the work queue | ||
587 | * | ||
504 | */ | 588 | */ |
589 | |||
505 | static int p9_poll_proc(void *a) | 590 | static int p9_poll_proc(void *a) |
506 | { | 591 | { |
507 | struct p9_conn *m, *mtmp; | 592 | struct p9_conn *m, *mtmp; |
@@ -527,7 +612,10 @@ static int p9_poll_proc(void *a) | |||
527 | 612 | ||
528 | /** | 613 | /** |
529 | * p9_write_work - called when a transport can send some data | 614 | * p9_write_work - called when a transport can send some data |
615 | * @work: container for work to be done | ||
616 | * | ||
530 | */ | 617 | */ |
618 | |||
531 | static void p9_write_work(struct work_struct *work) | 619 | static void p9_write_work(struct work_struct *work) |
532 | { | 620 | { |
533 | int n, err; | 621 | int n, err; |
@@ -638,7 +726,10 @@ static void process_request(struct p9_conn *m, struct p9_req *req) | |||
638 | 726 | ||
639 | /** | 727 | /** |
640 | * p9_read_work - called when there is some data to be read from a transport | 728 | * p9_read_work - called when there is some data to be read from a transport |
729 | * @work: container of work to be done | ||
730 | * | ||
641 | */ | 731 | */ |
732 | |||
642 | static void p9_read_work(struct work_struct *work) | 733 | static void p9_read_work(struct work_struct *work) |
643 | { | 734 | { |
644 | int n, err; | 735 | int n, err; |
@@ -793,7 +884,9 @@ error: | |||
793 | * @tc: request to be sent | 884 | * @tc: request to be sent |
794 | * @cb: callback function to call when response is received | 885 | * @cb: callback function to call when response is received |
795 | * @cba: parameter to pass to the callback function | 886 | * @cba: parameter to pass to the callback function |
887 | * | ||
796 | */ | 888 | */ |
889 | |||
797 | static struct p9_req *p9_send_request(struct p9_conn *m, | 890 | static struct p9_req *p9_send_request(struct p9_conn *m, |
798 | struct p9_fcall *tc, | 891 | struct p9_fcall *tc, |
799 | p9_conn_req_callback cb, void *cba) | 892 | p9_conn_req_callback cb, void *cba) |
@@ -961,10 +1054,12 @@ p9_conn_rpc_cb(struct p9_req *req, void *a) | |||
961 | /** | 1054 | /** |
962 | * p9_fd_rpc- sends 9P request and waits until a response is available. | 1055 | * p9_fd_rpc- sends 9P request and waits until a response is available. |
963 | * The function can be interrupted. | 1056 | * The function can be interrupted. |
964 | * @m: mux data | 1057 | * @t: transport data |
965 | * @tc: request to be sent | 1058 | * @tc: request to be sent |
966 | * @rc: pointer where a pointer to the response is stored | 1059 | * @rc: pointer where a pointer to the response is stored |
1060 | * | ||
967 | */ | 1061 | */ |
1062 | |||
968 | int | 1063 | int |
969 | p9_fd_rpc(struct p9_trans *t, struct p9_fcall *tc, struct p9_fcall **rc) | 1064 | p9_fd_rpc(struct p9_trans *t, struct p9_fcall *tc, struct p9_fcall **rc) |
970 | { | 1065 | { |
@@ -1041,8 +1136,10 @@ p9_fd_rpc(struct p9_trans *t, struct p9_fcall *tc, struct p9_fcall **rc) | |||
1041 | * @m: mux data | 1136 | * @m: mux data |
1042 | * @tc: request to be sent | 1137 | * @tc: request to be sent |
1043 | * @cb: callback function to be called when response arrives | 1138 | * @cb: callback function to be called when response arrives |
1044 | * @cba: value to pass to the callback function | 1139 | * @a: value to pass to the callback function |
1140 | * | ||
1045 | */ | 1141 | */ |
1142 | |||
1046 | int p9_conn_rpcnb(struct p9_conn *m, struct p9_fcall *tc, | 1143 | int p9_conn_rpcnb(struct p9_conn *m, struct p9_fcall *tc, |
1047 | p9_conn_req_callback cb, void *a) | 1144 | p9_conn_req_callback cb, void *a) |
1048 | { | 1145 | { |
@@ -1065,7 +1162,9 @@ int p9_conn_rpcnb(struct p9_conn *m, struct p9_fcall *tc, | |||
1065 | * p9_conn_cancel - cancel all pending requests with error | 1162 | * p9_conn_cancel - cancel all pending requests with error |
1066 | * @m: mux data | 1163 | * @m: mux data |
1067 | * @err: error code | 1164 | * @err: error code |
1165 | * | ||
1068 | */ | 1166 | */ |
1167 | |||
1069 | void p9_conn_cancel(struct p9_conn *m, int err) | 1168 | void p9_conn_cancel(struct p9_conn *m, int err) |
1070 | { | 1169 | { |
1071 | struct p9_req *req, *rtmp; | 1170 | struct p9_req *req, *rtmp; |
@@ -1097,35 +1196,46 @@ void p9_conn_cancel(struct p9_conn *m, int err) | |||
1097 | } | 1196 | } |
1098 | 1197 | ||
1099 | /** | 1198 | /** |
1100 | * v9fs_parse_options - parse mount options into session structure | 1199 | * parse_options - parse mount options into session structure |
1101 | * @options: options string passed from mount | 1200 | * @options: options string passed from mount |
1102 | * @v9ses: existing v9fs session information | 1201 | * @opts: transport-specific structure to parse options into |
1103 | * | 1202 | * |
1203 | * Returns 0 upon success, -ERRNO upon failure | ||
1104 | */ | 1204 | */ |
1105 | 1205 | ||
1106 | static void parse_opts(char *options, struct p9_fd_opts *opts) | 1206 | static int parse_opts(char *params, struct p9_fd_opts *opts) |
1107 | { | 1207 | { |
1108 | char *p; | 1208 | char *p; |
1109 | substring_t args[MAX_OPT_ARGS]; | 1209 | substring_t args[MAX_OPT_ARGS]; |
1110 | int option; | 1210 | int option; |
1211 | char *options; | ||
1111 | int ret; | 1212 | int ret; |
1112 | 1213 | ||
1113 | opts->port = P9_PORT; | 1214 | opts->port = P9_PORT; |
1114 | opts->rfd = ~0; | 1215 | opts->rfd = ~0; |
1115 | opts->wfd = ~0; | 1216 | opts->wfd = ~0; |
1116 | 1217 | ||
1117 | if (!options) | 1218 | if (!params) |
1118 | return; | 1219 | return 0; |
1220 | |||
1221 | options = kstrdup(params, GFP_KERNEL); | ||
1222 | if (!options) { | ||
1223 | P9_DPRINTK(P9_DEBUG_ERROR, | ||
1224 | "failed to allocate copy of option string\n"); | ||
1225 | return -ENOMEM; | ||
1226 | } | ||
1119 | 1227 | ||
1120 | while ((p = strsep(&options, ",")) != NULL) { | 1228 | while ((p = strsep(&options, ",")) != NULL) { |
1121 | int token; | 1229 | int token; |
1230 | int r; | ||
1122 | if (!*p) | 1231 | if (!*p) |
1123 | continue; | 1232 | continue; |
1124 | token = match_token(p, tokens, args); | 1233 | token = match_token(p, tokens, args); |
1125 | ret = match_int(&args[0], &option); | 1234 | r = match_int(&args[0], &option); |
1126 | if (ret < 0) { | 1235 | if (r < 0) { |
1127 | P9_DPRINTK(P9_DEBUG_ERROR, | 1236 | P9_DPRINTK(P9_DEBUG_ERROR, |
1128 | "integer field, but no integer?\n"); | 1237 | "integer field, but no integer?\n"); |
1238 | ret = r; | ||
1129 | continue; | 1239 | continue; |
1130 | } | 1240 | } |
1131 | switch (token) { | 1241 | switch (token) { |
@@ -1142,6 +1252,8 @@ static void parse_opts(char *options, struct p9_fd_opts *opts) | |||
1142 | continue; | 1252 | continue; |
1143 | } | 1253 | } |
1144 | } | 1254 | } |
1255 | kfree(options); | ||
1256 | return 0; | ||
1145 | } | 1257 | } |
1146 | 1258 | ||
1147 | static int p9_fd_open(struct p9_trans *trans, int rfd, int wfd) | 1259 | static int p9_fd_open(struct p9_trans *trans, int rfd, int wfd) |
@@ -1193,11 +1305,12 @@ static int p9_socket_open(struct p9_trans *trans, struct socket *csocket) | |||
1193 | 1305 | ||
1194 | /** | 1306 | /** |
1195 | * p9_fd_read- read from a fd | 1307 | * p9_fd_read- read from a fd |
1196 | * @v9ses: session information | 1308 | * @trans: transport instance state |
1197 | * @v: buffer to receive data into | 1309 | * @v: buffer to receive data into |
1198 | * @len: size of receive buffer | 1310 | * @len: size of receive buffer |
1199 | * | 1311 | * |
1200 | */ | 1312 | */ |
1313 | |||
1201 | static int p9_fd_read(struct p9_trans *trans, void *v, int len) | 1314 | static int p9_fd_read(struct p9_trans *trans, void *v, int len) |
1202 | { | 1315 | { |
1203 | int ret; | 1316 | int ret; |
@@ -1220,11 +1333,12 @@ static int p9_fd_read(struct p9_trans *trans, void *v, int len) | |||
1220 | 1333 | ||
1221 | /** | 1334 | /** |
1222 | * p9_fd_write - write to a socket | 1335 | * p9_fd_write - write to a socket |
1223 | * @v9ses: session information | 1336 | * @trans: transport instance state |
1224 | * @v: buffer to send data from | 1337 | * @v: buffer to send data from |
1225 | * @len: size of send buffer | 1338 | * @len: size of send buffer |
1226 | * | 1339 | * |
1227 | */ | 1340 | */ |
1341 | |||
1228 | static int p9_fd_write(struct p9_trans *trans, void *v, int len) | 1342 | static int p9_fd_write(struct p9_trans *trans, void *v, int len) |
1229 | { | 1343 | { |
1230 | int ret; | 1344 | int ret; |
@@ -1296,6 +1410,7 @@ end: | |||
1296 | * @trans: private socket structure | 1410 | * @trans: private socket structure |
1297 | * | 1411 | * |
1298 | */ | 1412 | */ |
1413 | |||
1299 | static void p9_fd_close(struct p9_trans *trans) | 1414 | static void p9_fd_close(struct p9_trans *trans) |
1300 | { | 1415 | { |
1301 | struct p9_trans_fd *ts; | 1416 | struct p9_trans_fd *ts; |
@@ -1318,6 +1433,23 @@ static void p9_fd_close(struct p9_trans *trans) | |||
1318 | kfree(ts); | 1433 | kfree(ts); |
1319 | } | 1434 | } |
1320 | 1435 | ||
1436 | /* | ||
1437 | * stolen from NFS - maybe should be made a generic function? | ||
1438 | */ | ||
1439 | static inline int valid_ipaddr4(const char *buf) | ||
1440 | { | ||
1441 | int rc, count, in[4]; | ||
1442 | |||
1443 | rc = sscanf(buf, "%d.%d.%d.%d", &in[0], &in[1], &in[2], &in[3]); | ||
1444 | if (rc != 4) | ||
1445 | return -EINVAL; | ||
1446 | for (count = 0; count < 4; count++) { | ||
1447 | if (in[count] > 255) | ||
1448 | return -EINVAL; | ||
1449 | } | ||
1450 | return 0; | ||
1451 | } | ||
1452 | |||
1321 | static struct p9_trans * | 1453 | static struct p9_trans * |
1322 | p9_trans_create_tcp(const char *addr, char *args, int msize, unsigned char dotu) | 1454 | p9_trans_create_tcp(const char *addr, char *args, int msize, unsigned char dotu) |
1323 | { | 1455 | { |
@@ -1328,7 +1460,12 @@ p9_trans_create_tcp(const char *addr, char *args, int msize, unsigned char dotu) | |||
1328 | struct p9_fd_opts opts; | 1460 | struct p9_fd_opts opts; |
1329 | struct p9_trans_fd *p; | 1461 | struct p9_trans_fd *p; |
1330 | 1462 | ||
1331 | parse_opts(args, &opts); | 1463 | err = parse_opts(args, &opts); |
1464 | if (err < 0) | ||
1465 | return ERR_PTR(err); | ||
1466 | |||
1467 | if (valid_ipaddr4(addr) < 0) | ||
1468 | return ERR_PTR(-EINVAL); | ||
1332 | 1469 | ||
1333 | csocket = NULL; | 1470 | csocket = NULL; |
1334 | trans = kmalloc(sizeof(struct p9_trans), GFP_KERNEL); | 1471 | trans = kmalloc(sizeof(struct p9_trans), GFP_KERNEL); |
@@ -1508,7 +1645,7 @@ static struct p9_trans_module p9_fd_trans = { | |||
1508 | .create = p9_trans_create_fd, | 1645 | .create = p9_trans_create_fd, |
1509 | }; | 1646 | }; |
1510 | 1647 | ||
1511 | static int __init p9_trans_fd_init(void) | 1648 | int p9_trans_fd_init(void) |
1512 | { | 1649 | { |
1513 | int ret = p9_mux_global_init(); | 1650 | int ret = p9_mux_global_init(); |
1514 | if (ret) { | 1651 | if (ret) { |
@@ -1522,9 +1659,4 @@ static int __init p9_trans_fd_init(void) | |||
1522 | 1659 | ||
1523 | return 0; | 1660 | return 0; |
1524 | } | 1661 | } |
1525 | 1662 | EXPORT_SYMBOL(p9_trans_fd_init); | |
1526 | module_init(p9_trans_fd_init); | ||
1527 | |||
1528 | MODULE_AUTHOR("Latchesar Ionkov <lucho@ionkov.net>"); | ||
1529 | MODULE_AUTHOR("Eric Van Hensbergen <ericvh@gmail.com>"); | ||
1530 | MODULE_LICENSE("GPL"); | ||
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c index de7a9f532edc..42adc052b149 100644 --- a/net/9p/trans_virtio.c +++ b/net/9p/trans_virtio.c | |||
@@ -49,29 +49,75 @@ | |||
49 | #define VIRTQUEUE_NUM 128 | 49 | #define VIRTQUEUE_NUM 128 |
50 | 50 | ||
51 | /* a single mutex to manage channel initialization and attachment */ | 51 | /* a single mutex to manage channel initialization and attachment */ |
52 | static DECLARE_MUTEX(virtio_9p_lock); | 52 | static DEFINE_MUTEX(virtio_9p_lock); |
53 | /* global which tracks highest initialized channel */ | 53 | /* global which tracks highest initialized channel */ |
54 | static int chan_index; | 54 | static int chan_index; |
55 | 55 | ||
56 | #define P9_INIT_MAXTAG 16 | 56 | #define P9_INIT_MAXTAG 16 |
57 | 57 | ||
58 | #define REQ_STATUS_IDLE 0 | 58 | |
59 | #define REQ_STATUS_SENT 1 | 59 | /** |
60 | #define REQ_STATUS_RCVD 2 | 60 | * enum p9_req_status_t - virtio request status |
61 | #define REQ_STATUS_FLSH 3 | 61 | * @REQ_STATUS_IDLE: request slot unused |
62 | * @REQ_STATUS_SENT: request sent to server | ||
63 | * @REQ_STATUS_RCVD: response received from server | ||
64 | * @REQ_STATUS_FLSH: request has been flushed | ||
65 | * | ||
66 | * The @REQ_STATUS_IDLE state is used to mark a request slot as unused | ||
67 | * but use is actually tracked by the idpool structure which handles tag | ||
68 | * id allocation. | ||
69 | * | ||
70 | */ | ||
71 | |||
72 | enum p9_req_status_t { | ||
73 | REQ_STATUS_IDLE, | ||
74 | REQ_STATUS_SENT, | ||
75 | REQ_STATUS_RCVD, | ||
76 | REQ_STATUS_FLSH, | ||
77 | }; | ||
78 | |||
79 | /** | ||
80 | * struct p9_req_t - virtio request slots | ||
81 | * @status: status of this request slot | ||
82 | * @wq: wait_queue for the client to block on for this request | ||
83 | * | ||
84 | * The virtio transport uses an array to track outstanding requests | ||
85 | * instead of a list. While this may incurr overhead during initial | ||
86 | * allocation or expansion, it makes request lookup much easier as the | ||
87 | * tag id is a index into an array. (We use tag+1 so that we can accomodate | ||
88 | * the -1 tag for the T_VERSION request). | ||
89 | * This also has the nice effect of only having to allocate wait_queues | ||
90 | * once, instead of constantly allocating and freeing them. Its possible | ||
91 | * other resources could benefit from this scheme as well. | ||
92 | * | ||
93 | */ | ||
62 | 94 | ||
63 | struct p9_req_t { | 95 | struct p9_req_t { |
64 | int status; | 96 | int status; |
65 | wait_queue_head_t *wq; | 97 | wait_queue_head_t *wq; |
66 | }; | 98 | }; |
67 | 99 | ||
68 | /* We keep all per-channel information in a structure. | 100 | /** |
101 | * struct virtio_chan - per-instance transport information | ||
102 | * @initialized: whether the channel is initialized | ||
103 | * @inuse: whether the channel is in use | ||
104 | * @lock: protects multiple elements within this structure | ||
105 | * @vdev: virtio dev associated with this channel | ||
106 | * @vq: virtio queue associated with this channel | ||
107 | * @tagpool: accounting for tag ids (and request slots) | ||
108 | * @reqs: array of request slots | ||
109 | * @max_tag: current number of request_slots allocated | ||
110 | * @sg: scatter gather list which is used to pack a request (protected?) | ||
111 | * | ||
112 | * We keep all per-channel information in a structure. | ||
69 | * This structure is allocated within the devices dev->mem space. | 113 | * This structure is allocated within the devices dev->mem space. |
70 | * A pointer to the structure will get put in the transport private. | 114 | * A pointer to the structure will get put in the transport private. |
115 | * | ||
71 | */ | 116 | */ |
117 | |||
72 | static struct virtio_chan { | 118 | static struct virtio_chan { |
73 | bool initialized; /* channel is initialized */ | 119 | bool initialized; |
74 | bool inuse; /* channel is in use */ | 120 | bool inuse; |
75 | 121 | ||
76 | spinlock_t lock; | 122 | spinlock_t lock; |
77 | 123 | ||
@@ -86,7 +132,19 @@ static struct virtio_chan { | |||
86 | struct scatterlist sg[VIRTQUEUE_NUM]; | 132 | struct scatterlist sg[VIRTQUEUE_NUM]; |
87 | } channels[MAX_9P_CHAN]; | 133 | } channels[MAX_9P_CHAN]; |
88 | 134 | ||
89 | /* Lookup requests by tag */ | 135 | /** |
136 | * p9_lookup_tag - Lookup requests by tag | ||
137 | * @c: virtio channel to lookup tag within | ||
138 | * @tag: numeric id for transaction | ||
139 | * | ||
140 | * this is a simple array lookup, but will grow the | ||
141 | * request_slots as necessary to accomodate transaction | ||
142 | * ids which did not previously have a slot. | ||
143 | * | ||
144 | * Bugs: there is currently no upper limit on request slots set | ||
145 | * here, but that should be constrained by the id accounting. | ||
146 | */ | ||
147 | |||
90 | static struct p9_req_t *p9_lookup_tag(struct virtio_chan *c, u16 tag) | 148 | static struct p9_req_t *p9_lookup_tag(struct virtio_chan *c, u16 tag) |
91 | { | 149 | { |
92 | /* This looks up the original request by tag so we know which | 150 | /* This looks up the original request by tag so we know which |
@@ -130,11 +188,20 @@ static unsigned int rest_of_page(void *data) | |||
130 | return PAGE_SIZE - ((unsigned long)data % PAGE_SIZE); | 188 | return PAGE_SIZE - ((unsigned long)data % PAGE_SIZE); |
131 | } | 189 | } |
132 | 190 | ||
191 | /** | ||
192 | * p9_virtio_close - reclaim resources of a channel | ||
193 | * @trans: transport state | ||
194 | * | ||
195 | * This reclaims a channel by freeing its resources and | ||
196 | * reseting its inuse flag. | ||
197 | * | ||
198 | */ | ||
199 | |||
133 | static void p9_virtio_close(struct p9_trans *trans) | 200 | static void p9_virtio_close(struct p9_trans *trans) |
134 | { | 201 | { |
135 | struct virtio_chan *chan = trans->priv; | 202 | struct virtio_chan *chan = trans->priv; |
136 | int count; | 203 | int count; |
137 | unsigned int flags; | 204 | unsigned long flags; |
138 | 205 | ||
139 | spin_lock_irqsave(&chan->lock, flags); | 206 | spin_lock_irqsave(&chan->lock, flags); |
140 | p9_idpool_destroy(chan->tagpool); | 207 | p9_idpool_destroy(chan->tagpool); |
@@ -144,13 +211,26 @@ static void p9_virtio_close(struct p9_trans *trans) | |||
144 | chan->max_tag = 0; | 211 | chan->max_tag = 0; |
145 | spin_unlock_irqrestore(&chan->lock, flags); | 212 | spin_unlock_irqrestore(&chan->lock, flags); |
146 | 213 | ||
147 | down(&virtio_9p_lock); | 214 | mutex_lock(&virtio_9p_lock); |
148 | chan->inuse = false; | 215 | chan->inuse = false; |
149 | up(&virtio_9p_lock); | 216 | mutex_unlock(&virtio_9p_lock); |
150 | 217 | ||
151 | kfree(trans); | 218 | kfree(trans); |
152 | } | 219 | } |
153 | 220 | ||
221 | /** | ||
222 | * req_done - callback which signals activity from the server | ||
223 | * @vq: virtio queue activity was received on | ||
224 | * | ||
225 | * This notifies us that the server has triggered some activity | ||
226 | * on the virtio channel - most likely a response to request we | ||
227 | * sent. Figure out which requests now have responses and wake up | ||
228 | * those threads. | ||
229 | * | ||
230 | * Bugs: could do with some additional sanity checking, but appears to work. | ||
231 | * | ||
232 | */ | ||
233 | |||
154 | static void req_done(struct virtqueue *vq) | 234 | static void req_done(struct virtqueue *vq) |
155 | { | 235 | { |
156 | struct virtio_chan *chan = vq->vdev->priv; | 236 | struct virtio_chan *chan = vq->vdev->priv; |
@@ -169,6 +249,20 @@ static void req_done(struct virtqueue *vq) | |||
169 | spin_unlock_irqrestore(&chan->lock, flags); | 249 | spin_unlock_irqrestore(&chan->lock, flags); |
170 | } | 250 | } |
171 | 251 | ||
252 | /** | ||
253 | * pack_sg_list - pack a scatter gather list from a linear buffer | ||
254 | * @sg: scatter/gather list to pack into | ||
255 | * @start: which segment of the sg_list to start at | ||
256 | * @limit: maximum segment to pack data to | ||
257 | * @data: data to pack into scatter/gather list | ||
258 | * @count: amount of data to pack into the scatter/gather list | ||
259 | * | ||
260 | * sg_lists have multiple segments of various sizes. This will pack | ||
261 | * arbitrary data into an existing scatter gather list, segmenting the | ||
262 | * data as necessary within constraints. | ||
263 | * | ||
264 | */ | ||
265 | |||
172 | static int | 266 | static int |
173 | pack_sg_list(struct scatterlist *sg, int start, int limit, char *data, | 267 | pack_sg_list(struct scatterlist *sg, int start, int limit, char *data, |
174 | int count) | 268 | int count) |
@@ -189,6 +283,14 @@ pack_sg_list(struct scatterlist *sg, int start, int limit, char *data, | |||
189 | return index-start; | 283 | return index-start; |
190 | } | 284 | } |
191 | 285 | ||
286 | /** | ||
287 | * p9_virtio_rpc - issue a request and wait for a response | ||
288 | * @t: transport state | ||
289 | * @tc: &p9_fcall request to transmit | ||
290 | * @rc: &p9_fcall to put reponse into | ||
291 | * | ||
292 | */ | ||
293 | |||
192 | static int | 294 | static int |
193 | p9_virtio_rpc(struct p9_trans *t, struct p9_fcall *tc, struct p9_fcall **rc) | 295 | p9_virtio_rpc(struct p9_trans *t, struct p9_fcall *tc, struct p9_fcall **rc) |
194 | { | 296 | { |
@@ -263,16 +365,26 @@ p9_virtio_rpc(struct p9_trans *t, struct p9_fcall *tc, struct p9_fcall **rc) | |||
263 | return 0; | 365 | return 0; |
264 | } | 366 | } |
265 | 367 | ||
368 | /** | ||
369 | * p9_virtio_probe - probe for existence of 9P virtio channels | ||
370 | * @vdev: virtio device to probe | ||
371 | * | ||
372 | * This probes for existing virtio channels. At present only | ||
373 | * a single channel is in use, so in the future more work may need | ||
374 | * to be done here. | ||
375 | * | ||
376 | */ | ||
377 | |||
266 | static int p9_virtio_probe(struct virtio_device *vdev) | 378 | static int p9_virtio_probe(struct virtio_device *vdev) |
267 | { | 379 | { |
268 | int err; | 380 | int err; |
269 | struct virtio_chan *chan; | 381 | struct virtio_chan *chan; |
270 | int index; | 382 | int index; |
271 | 383 | ||
272 | down(&virtio_9p_lock); | 384 | mutex_lock(&virtio_9p_lock); |
273 | index = chan_index++; | 385 | index = chan_index++; |
274 | chan = &channels[index]; | 386 | chan = &channels[index]; |
275 | up(&virtio_9p_lock); | 387 | mutex_unlock(&virtio_9p_lock); |
276 | 388 | ||
277 | if (chan_index > MAX_9P_CHAN) { | 389 | if (chan_index > MAX_9P_CHAN) { |
278 | printk(KERN_ERR "9p: virtio: Maximum channels exceeded\n"); | 390 | printk(KERN_ERR "9p: virtio: Maximum channels exceeded\n"); |
@@ -301,17 +413,34 @@ static int p9_virtio_probe(struct virtio_device *vdev) | |||
301 | out_free_vq: | 413 | out_free_vq: |
302 | vdev->config->del_vq(chan->vq); | 414 | vdev->config->del_vq(chan->vq); |
303 | fail: | 415 | fail: |
304 | down(&virtio_9p_lock); | 416 | mutex_lock(&virtio_9p_lock); |
305 | chan_index--; | 417 | chan_index--; |
306 | up(&virtio_9p_lock); | 418 | mutex_unlock(&virtio_9p_lock); |
307 | return err; | 419 | return err; |
308 | } | 420 | } |
309 | 421 | ||
310 | /* This sets up a transport channel for 9p communication. Right now | 422 | |
423 | /** | ||
424 | * p9_virtio_create - allocate a new virtio channel | ||
425 | * @devname: string identifying the channel to connect to (unused) | ||
426 | * @args: args passed from sys_mount() for per-transport options (unused) | ||
427 | * @msize: requested maximum packet size | ||
428 | * @extended: 9p2000.u enabled flag | ||
429 | * | ||
430 | * This sets up a transport channel for 9p communication. Right now | ||
311 | * we only match the first available channel, but eventually we couldlook up | 431 | * we only match the first available channel, but eventually we couldlook up |
312 | * alternate channels by matching devname versus a virtio_config entry. | 432 | * alternate channels by matching devname versus a virtio_config entry. |
313 | * We use a simple reference count mechanism to ensure that only a single | 433 | * We use a simple reference count mechanism to ensure that only a single |
314 | * mount has a channel open at a time. */ | 434 | * mount has a channel open at a time. |
435 | * | ||
436 | * Bugs: doesn't allow identification of a specific channel | ||
437 | * to allocate, channels are allocated sequentially. This was | ||
438 | * a pragmatic decision to get things rolling, but ideally some | ||
439 | * way of identifying the channel to attach to would be nice | ||
440 | * if we are going to support multiple channels. | ||
441 | * | ||
442 | */ | ||
443 | |||
315 | static struct p9_trans * | 444 | static struct p9_trans * |
316 | p9_virtio_create(const char *devname, char *args, int msize, | 445 | p9_virtio_create(const char *devname, char *args, int msize, |
317 | unsigned char extended) | 446 | unsigned char extended) |
@@ -320,7 +449,7 @@ p9_virtio_create(const char *devname, char *args, int msize, | |||
320 | struct virtio_chan *chan = channels; | 449 | struct virtio_chan *chan = channels; |
321 | int index = 0; | 450 | int index = 0; |
322 | 451 | ||
323 | down(&virtio_9p_lock); | 452 | mutex_lock(&virtio_9p_lock); |
324 | while (index < MAX_9P_CHAN) { | 453 | while (index < MAX_9P_CHAN) { |
325 | if (chan->initialized && !chan->inuse) { | 454 | if (chan->initialized && !chan->inuse) { |
326 | chan->inuse = true; | 455 | chan->inuse = true; |
@@ -330,7 +459,7 @@ p9_virtio_create(const char *devname, char *args, int msize, | |||
330 | chan = &channels[index]; | 459 | chan = &channels[index]; |
331 | } | 460 | } |
332 | } | 461 | } |
333 | up(&virtio_9p_lock); | 462 | mutex_unlock(&virtio_9p_lock); |
334 | 463 | ||
335 | if (index >= MAX_9P_CHAN) { | 464 | if (index >= MAX_9P_CHAN) { |
336 | printk(KERN_ERR "9p: no channels available\n"); | 465 | printk(KERN_ERR "9p: no channels available\n"); |
@@ -360,6 +489,12 @@ p9_virtio_create(const char *devname, char *args, int msize, | |||
360 | return trans; | 489 | return trans; |
361 | } | 490 | } |
362 | 491 | ||
492 | /** | ||
493 | * p9_virtio_remove - clean up resources associated with a virtio device | ||
494 | * @vdev: virtio device to remove | ||
495 | * | ||
496 | */ | ||
497 | |||
363 | static void p9_virtio_remove(struct virtio_device *vdev) | 498 | static void p9_virtio_remove(struct virtio_device *vdev) |
364 | { | 499 | { |
365 | struct virtio_chan *chan = vdev->priv; | 500 | struct virtio_chan *chan = vdev->priv; |
diff --git a/net/9p/util.c b/net/9p/util.c index ef7215565d88..958fc58cd1ff 100644 --- a/net/9p/util.c +++ b/net/9p/util.c | |||
@@ -32,11 +32,23 @@ | |||
32 | #include <linux/idr.h> | 32 | #include <linux/idr.h> |
33 | #include <net/9p/9p.h> | 33 | #include <net/9p/9p.h> |
34 | 34 | ||
35 | /** | ||
36 | * struct p9_idpool - per-connection accounting for tag idpool | ||
37 | * @lock: protects the pool | ||
38 | * @pool: idr to allocate tag id from | ||
39 | * | ||
40 | */ | ||
41 | |||
35 | struct p9_idpool { | 42 | struct p9_idpool { |
36 | spinlock_t lock; | 43 | spinlock_t lock; |
37 | struct idr pool; | 44 | struct idr pool; |
38 | }; | 45 | }; |
39 | 46 | ||
47 | /** | ||
48 | * p9_idpool_create - create a new per-connection id pool | ||
49 | * | ||
50 | */ | ||
51 | |||
40 | struct p9_idpool *p9_idpool_create(void) | 52 | struct p9_idpool *p9_idpool_create(void) |
41 | { | 53 | { |
42 | struct p9_idpool *p; | 54 | struct p9_idpool *p; |
@@ -52,6 +64,11 @@ struct p9_idpool *p9_idpool_create(void) | |||
52 | } | 64 | } |
53 | EXPORT_SYMBOL(p9_idpool_create); | 65 | EXPORT_SYMBOL(p9_idpool_create); |
54 | 66 | ||
67 | /** | ||
68 | * p9_idpool_destroy - create a new per-connection id pool | ||
69 | * @p: idpool to destory | ||
70 | */ | ||
71 | |||
55 | void p9_idpool_destroy(struct p9_idpool *p) | 72 | void p9_idpool_destroy(struct p9_idpool *p) |
56 | { | 73 | { |
57 | idr_destroy(&p->pool); | 74 | idr_destroy(&p->pool); |
@@ -61,9 +78,9 @@ EXPORT_SYMBOL(p9_idpool_destroy); | |||
61 | 78 | ||
62 | /** | 79 | /** |
63 | * p9_idpool_get - allocate numeric id from pool | 80 | * p9_idpool_get - allocate numeric id from pool |
64 | * @p - pool to allocate from | 81 | * @p: pool to allocate from |
65 | * | 82 | * |
66 | * XXX - This seems to be an awful generic function, should it be in idr.c with | 83 | * Bugs: This seems to be an awful generic function, should it be in idr.c with |
67 | * the lock included in struct idr? | 84 | * the lock included in struct idr? |
68 | */ | 85 | */ |
69 | 86 | ||
@@ -71,7 +88,7 @@ int p9_idpool_get(struct p9_idpool *p) | |||
71 | { | 88 | { |
72 | int i = 0; | 89 | int i = 0; |
73 | int error; | 90 | int error; |
74 | unsigned int flags; | 91 | unsigned long flags; |
75 | 92 | ||
76 | retry: | 93 | retry: |
77 | if (idr_pre_get(&p->pool, GFP_KERNEL) == 0) | 94 | if (idr_pre_get(&p->pool, GFP_KERNEL) == 0) |
@@ -94,15 +111,16 @@ EXPORT_SYMBOL(p9_idpool_get); | |||
94 | 111 | ||
95 | /** | 112 | /** |
96 | * p9_idpool_put - release numeric id from pool | 113 | * p9_idpool_put - release numeric id from pool |
97 | * @p - pool to allocate from | 114 | * @id: numeric id which is being released |
115 | * @p: pool to release id into | ||
98 | * | 116 | * |
99 | * XXX - This seems to be an awful generic function, should it be in idr.c with | 117 | * Bugs: This seems to be an awful generic function, should it be in idr.c with |
100 | * the lock included in struct idr? | 118 | * the lock included in struct idr? |
101 | */ | 119 | */ |
102 | 120 | ||
103 | void p9_idpool_put(int id, struct p9_idpool *p) | 121 | void p9_idpool_put(int id, struct p9_idpool *p) |
104 | { | 122 | { |
105 | unsigned int flags; | 123 | unsigned long flags; |
106 | spin_lock_irqsave(&p->lock, flags); | 124 | spin_lock_irqsave(&p->lock, flags); |
107 | idr_remove(&p->pool, id); | 125 | idr_remove(&p->pool, id); |
108 | spin_unlock_irqrestore(&p->lock, flags); | 126 | spin_unlock_irqrestore(&p->lock, flags); |
@@ -111,11 +129,13 @@ EXPORT_SYMBOL(p9_idpool_put); | |||
111 | 129 | ||
112 | /** | 130 | /** |
113 | * p9_idpool_check - check if the specified id is available | 131 | * p9_idpool_check - check if the specified id is available |
114 | * @id - id to check | 132 | * @id: id to check |
115 | * @p - pool | 133 | * @p: pool to check |
116 | */ | 134 | */ |
135 | |||
117 | int p9_idpool_check(int id, struct p9_idpool *p) | 136 | int p9_idpool_check(int id, struct p9_idpool *p) |
118 | { | 137 | { |
119 | return idr_find(&p->pool, id) != NULL; | 138 | return idr_find(&p->pool, id) != NULL; |
120 | } | 139 | } |
121 | EXPORT_SYMBOL(p9_idpool_check); | 140 | EXPORT_SYMBOL(p9_idpool_check); |
141 | |||
diff --git a/net/core/netpoll.c b/net/core/netpoll.c index b04d643fc3c7..8fb134da0346 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c | |||
@@ -419,7 +419,7 @@ static void arp_reply(struct sk_buff *skb) | |||
419 | return; | 419 | return; |
420 | 420 | ||
421 | size = arp_hdr_len(skb->dev); | 421 | size = arp_hdr_len(skb->dev); |
422 | send_skb = find_skb(np, size + LL_RESERVED_SPACE(np->dev), | 422 | send_skb = find_skb(np, size + LL_ALLOCATED_SPACE(np->dev), |
423 | LL_RESERVED_SPACE(np->dev)); | 423 | LL_RESERVED_SPACE(np->dev)); |
424 | 424 | ||
425 | if (!send_skb) | 425 | if (!send_skb) |
diff --git a/net/core/sock.c b/net/core/sock.c index fa76f04fa9c6..88094cb09c06 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -270,7 +270,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) | |||
270 | int err = 0; | 270 | int err = 0; |
271 | int skb_len; | 271 | int skb_len; |
272 | 272 | ||
273 | /* Cast skb->rcvbuf to unsigned... It's pointless, but reduces | 273 | /* Cast sk->rcvbuf to unsigned... It's pointless, but reduces |
274 | number of warnings when compiling with -W --ANK | 274 | number of warnings when compiling with -W --ANK |
275 | */ | 275 | */ |
276 | if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >= | 276 | if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >= |
diff --git a/net/econet/af_econet.c b/net/econet/af_econet.c index 68d154480043..7c9bb13b1539 100644 --- a/net/econet/af_econet.c +++ b/net/econet/af_econet.c | |||
@@ -340,7 +340,7 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
340 | 340 | ||
341 | dev_hold(dev); | 341 | dev_hold(dev); |
342 | 342 | ||
343 | skb = sock_alloc_send_skb(sk, len+LL_RESERVED_SPACE(dev), | 343 | skb = sock_alloc_send_skb(sk, len+LL_ALLOCATED_SPACE(dev), |
344 | msg->msg_flags & MSG_DONTWAIT, &err); | 344 | msg->msg_flags & MSG_DONTWAIT, &err); |
345 | if (skb==NULL) | 345 | if (skb==NULL) |
346 | goto out_unlock; | 346 | goto out_unlock; |
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index 68b72a7a1806..418862f1bf22 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c | |||
@@ -570,7 +570,7 @@ struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip, | |||
570 | * Allocate a buffer | 570 | * Allocate a buffer |
571 | */ | 571 | */ |
572 | 572 | ||
573 | skb = alloc_skb(arp_hdr_len(dev) + LL_RESERVED_SPACE(dev), GFP_ATOMIC); | 573 | skb = alloc_skb(arp_hdr_len(dev) + LL_ALLOCATED_SPACE(dev), GFP_ATOMIC); |
574 | if (skb == NULL) | 574 | if (skb == NULL) |
575 | return NULL; | 575 | return NULL; |
576 | 576 | ||
diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c index 05afb576d935..2c0e4572cc90 100644 --- a/net/ipv4/cipso_ipv4.c +++ b/net/ipv4/cipso_ipv4.c | |||
@@ -338,7 +338,7 @@ static int cipso_v4_cache_check(const unsigned char *key, | |||
338 | return -ENOENT; | 338 | return -ENOENT; |
339 | 339 | ||
340 | hash = cipso_v4_map_cache_hash(key, key_len); | 340 | hash = cipso_v4_map_cache_hash(key, key_len); |
341 | bkt = hash & (CIPSO_V4_CACHE_BUCKETBITS - 1); | 341 | bkt = hash & (CIPSO_V4_CACHE_BUCKETS - 1); |
342 | spin_lock_bh(&cipso_v4_cache[bkt].lock); | 342 | spin_lock_bh(&cipso_v4_cache[bkt].lock); |
343 | list_for_each_entry(entry, &cipso_v4_cache[bkt].list, list) { | 343 | list_for_each_entry(entry, &cipso_v4_cache[bkt].list, list) { |
344 | if (entry->hash == hash && | 344 | if (entry->hash == hash && |
@@ -417,7 +417,7 @@ int cipso_v4_cache_add(const struct sk_buff *skb, | |||
417 | atomic_inc(&secattr->cache->refcount); | 417 | atomic_inc(&secattr->cache->refcount); |
418 | entry->lsm_data = secattr->cache; | 418 | entry->lsm_data = secattr->cache; |
419 | 419 | ||
420 | bkt = entry->hash & (CIPSO_V4_CACHE_BUCKETBITS - 1); | 420 | bkt = entry->hash & (CIPSO_V4_CACHE_BUCKETS - 1); |
421 | spin_lock_bh(&cipso_v4_cache[bkt].lock); | 421 | spin_lock_bh(&cipso_v4_cache[bkt].lock); |
422 | if (cipso_v4_cache[bkt].size < cipso_v4_cache_bucketsize) { | 422 | if (cipso_v4_cache[bkt].size < cipso_v4_cache_bucketsize) { |
423 | list_add(&entry->list, &cipso_v4_cache[bkt].list); | 423 | list_add(&entry->list, &cipso_v4_cache[bkt].list); |
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 6250f4239b61..2769dc4a4c84 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c | |||
@@ -292,7 +292,7 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size) | |||
292 | struct iphdr *pip; | 292 | struct iphdr *pip; |
293 | struct igmpv3_report *pig; | 293 | struct igmpv3_report *pig; |
294 | 294 | ||
295 | skb = alloc_skb(size + LL_RESERVED_SPACE(dev), GFP_ATOMIC); | 295 | skb = alloc_skb(size + LL_ALLOCATED_SPACE(dev), GFP_ATOMIC); |
296 | if (skb == NULL) | 296 | if (skb == NULL) |
297 | return NULL; | 297 | return NULL; |
298 | 298 | ||
@@ -653,7 +653,7 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc, | |||
653 | return -1; | 653 | return -1; |
654 | } | 654 | } |
655 | 655 | ||
656 | skb=alloc_skb(IGMP_SIZE+LL_RESERVED_SPACE(dev), GFP_ATOMIC); | 656 | skb=alloc_skb(IGMP_SIZE+LL_ALLOCATED_SPACE(dev), GFP_ATOMIC); |
657 | if (skb == NULL) { | 657 | if (skb == NULL) { |
658 | ip_rt_put(rt); | 658 | ip_rt_put(rt); |
659 | return -1; | 659 | return -1; |
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 89dee4346f60..ed45037ce9be 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c | |||
@@ -710,14 +710,14 @@ static void __init ic_bootp_send_if(struct ic_device *d, unsigned long jiffies_d | |||
710 | struct net_device *dev = d->dev; | 710 | struct net_device *dev = d->dev; |
711 | struct sk_buff *skb; | 711 | struct sk_buff *skb; |
712 | struct bootp_pkt *b; | 712 | struct bootp_pkt *b; |
713 | int hh_len = LL_RESERVED_SPACE(dev); | ||
714 | struct iphdr *h; | 713 | struct iphdr *h; |
715 | 714 | ||
716 | /* Allocate packet */ | 715 | /* Allocate packet */ |
717 | skb = alloc_skb(sizeof(struct bootp_pkt) + hh_len + 15, GFP_KERNEL); | 716 | skb = alloc_skb(sizeof(struct bootp_pkt) + LL_ALLOCATED_SPACE(dev) + 15, |
717 | GFP_KERNEL); | ||
718 | if (!skb) | 718 | if (!skb) |
719 | return; | 719 | return; |
720 | skb_reserve(skb, hh_len); | 720 | skb_reserve(skb, LL_RESERVED_SPACE(dev)); |
721 | b = (struct bootp_pkt *) skb_put(skb, sizeof(struct bootp_pkt)); | 721 | b = (struct bootp_pkt *) skb_put(skb, sizeof(struct bootp_pkt)); |
722 | memset(b, 0, sizeof(struct bootp_pkt)); | 722 | memset(b, 0, sizeof(struct bootp_pkt)); |
723 | 723 | ||
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index 11d7f753a820..fead049daf43 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c | |||
@@ -322,7 +322,6 @@ static int raw_send_hdrinc(struct sock *sk, void *from, size_t length, | |||
322 | unsigned int flags) | 322 | unsigned int flags) |
323 | { | 323 | { |
324 | struct inet_sock *inet = inet_sk(sk); | 324 | struct inet_sock *inet = inet_sk(sk); |
325 | int hh_len; | ||
326 | struct iphdr *iph; | 325 | struct iphdr *iph; |
327 | struct sk_buff *skb; | 326 | struct sk_buff *skb; |
328 | unsigned int iphlen; | 327 | unsigned int iphlen; |
@@ -336,13 +335,12 @@ static int raw_send_hdrinc(struct sock *sk, void *from, size_t length, | |||
336 | if (flags&MSG_PROBE) | 335 | if (flags&MSG_PROBE) |
337 | goto out; | 336 | goto out; |
338 | 337 | ||
339 | hh_len = LL_RESERVED_SPACE(rt->u.dst.dev); | 338 | skb = sock_alloc_send_skb(sk, |
340 | 339 | length + LL_ALLOCATED_SPACE(rt->u.dst.dev) + 15, | |
341 | skb = sock_alloc_send_skb(sk, length+hh_len+15, | 340 | flags & MSG_DONTWAIT, &err); |
342 | flags&MSG_DONTWAIT, &err); | ||
343 | if (skb == NULL) | 341 | if (skb == NULL) |
344 | goto error; | 342 | goto error; |
345 | skb_reserve(skb, hh_len); | 343 | skb_reserve(skb, LL_RESERVED_SPACE(rt->u.dst.dev)); |
346 | 344 | ||
347 | skb->priority = sk->sk_priority; | 345 | skb->priority = sk->sk_priority; |
348 | skb->mark = sk->sk_mark; | 346 | skb->mark = sk->sk_mark; |
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 26c936930e92..b54d9d37b636 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -1842,9 +1842,16 @@ static void tcp_enter_frto_loss(struct sock *sk, int allowed_segments, int flag) | |||
1842 | TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_RETRANS; | 1842 | TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_RETRANS; |
1843 | } | 1843 | } |
1844 | 1844 | ||
1845 | /* Don't lost mark skbs that were fwd transmitted after RTO */ | 1845 | /* Marking forward transmissions that were made after RTO lost |
1846 | if (!(TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_ACKED) && | 1846 | * can cause unnecessary retransmissions in some scenarios, |
1847 | !after(TCP_SKB_CB(skb)->end_seq, tp->frto_highmark)) { | 1847 | * SACK blocks will mitigate that in some but not in all cases. |
1848 | * We used to not mark them but it was causing break-ups with | ||
1849 | * receivers that do only in-order receival. | ||
1850 | * | ||
1851 | * TODO: we could detect presence of such receiver and select | ||
1852 | * different behavior per flow. | ||
1853 | */ | ||
1854 | if (!(TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_ACKED)) { | ||
1848 | TCP_SKB_CB(skb)->sacked |= TCPCB_LOST; | 1855 | TCP_SKB_CB(skb)->sacked |= TCPCB_LOST; |
1849 | tp->lost_out += tcp_skb_pcount(skb); | 1856 | tp->lost_out += tcp_skb_pcount(skb); |
1850 | } | 1857 | } |
@@ -1860,7 +1867,7 @@ static void tcp_enter_frto_loss(struct sock *sk, int allowed_segments, int flag) | |||
1860 | tp->reordering = min_t(unsigned int, tp->reordering, | 1867 | tp->reordering = min_t(unsigned int, tp->reordering, |
1861 | sysctl_tcp_reordering); | 1868 | sysctl_tcp_reordering); |
1862 | tcp_set_ca_state(sk, TCP_CA_Loss); | 1869 | tcp_set_ca_state(sk, TCP_CA_Loss); |
1863 | tp->high_seq = tp->frto_highmark; | 1870 | tp->high_seq = tp->snd_nxt; |
1864 | TCP_ECN_queue_cwr(tp); | 1871 | TCP_ECN_queue_cwr(tp); |
1865 | 1872 | ||
1866 | tcp_clear_retrans_hints_partial(tp); | 1873 | tcp_clear_retrans_hints_partial(tp); |
@@ -2482,7 +2489,7 @@ static void tcp_try_to_open(struct sock *sk, int flag) | |||
2482 | 2489 | ||
2483 | tcp_verify_left_out(tp); | 2490 | tcp_verify_left_out(tp); |
2484 | 2491 | ||
2485 | if (tp->retrans_out == 0) | 2492 | if (!tp->frto_counter && tp->retrans_out == 0) |
2486 | tp->retrans_stamp = 0; | 2493 | tp->retrans_stamp = 0; |
2487 | 2494 | ||
2488 | if (flag & FLAG_ECE) | 2495 | if (flag & FLAG_ECE) |
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 0af2e055f883..48cdce9c696c 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
@@ -780,7 +780,7 @@ slow_path: | |||
780 | * Allocate buffer. | 780 | * Allocate buffer. |
781 | */ | 781 | */ |
782 | 782 | ||
783 | if ((frag = alloc_skb(len+hlen+sizeof(struct frag_hdr)+LL_RESERVED_SPACE(rt->u.dst.dev), GFP_ATOMIC)) == NULL) { | 783 | if ((frag = alloc_skb(len+hlen+sizeof(struct frag_hdr)+LL_ALLOCATED_SPACE(rt->u.dst.dev), GFP_ATOMIC)) == NULL) { |
784 | NETDEBUG(KERN_INFO "IPv6: frag: no memory for new fragment!\n"); | 784 | NETDEBUG(KERN_INFO "IPv6: frag: no memory for new fragment!\n"); |
785 | IP6_INC_STATS(ip6_dst_idev(skb->dst), | 785 | IP6_INC_STATS(ip6_dst_idev(skb->dst), |
786 | IPSTATS_MIB_FRAGFAILS); | 786 | IPSTATS_MIB_FRAGFAILS); |
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c index 54f91efdae58..fd632dd7f98d 100644 --- a/net/ipv6/mcast.c +++ b/net/ipv6/mcast.c | |||
@@ -1411,7 +1411,7 @@ static struct sk_buff *mld_newpack(struct net_device *dev, int size) | |||
1411 | IPV6_TLV_PADN, 0 }; | 1411 | IPV6_TLV_PADN, 0 }; |
1412 | 1412 | ||
1413 | /* we assume size > sizeof(ra) here */ | 1413 | /* we assume size > sizeof(ra) here */ |
1414 | skb = sock_alloc_send_skb(sk, size + LL_RESERVED_SPACE(dev), 1, &err); | 1414 | skb = sock_alloc_send_skb(sk, size + LL_ALLOCATED_SPACE(dev), 1, &err); |
1415 | 1415 | ||
1416 | if (!skb) | 1416 | if (!skb) |
1417 | return NULL; | 1417 | return NULL; |
@@ -1790,7 +1790,7 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type) | |||
1790 | payload_len = len + sizeof(ra); | 1790 | payload_len = len + sizeof(ra); |
1791 | full_len = sizeof(struct ipv6hdr) + payload_len; | 1791 | full_len = sizeof(struct ipv6hdr) + payload_len; |
1792 | 1792 | ||
1793 | skb = sock_alloc_send_skb(sk, LL_RESERVED_SPACE(dev) + full_len, 1, &err); | 1793 | skb = sock_alloc_send_skb(sk, LL_ALLOCATED_SPACE(dev) + full_len, 1, &err); |
1794 | 1794 | ||
1795 | if (skb == NULL) { | 1795 | if (skb == NULL) { |
1796 | rcu_read_lock(); | 1796 | rcu_read_lock(); |
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index 2c74885f8355..a55fc05b8125 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c | |||
@@ -479,7 +479,7 @@ static void __ndisc_send(struct net_device *dev, | |||
479 | 479 | ||
480 | skb = sock_alloc_send_skb(sk, | 480 | skb = sock_alloc_send_skb(sk, |
481 | (MAX_HEADER + sizeof(struct ipv6hdr) + | 481 | (MAX_HEADER + sizeof(struct ipv6hdr) + |
482 | len + LL_RESERVED_SPACE(dev)), | 482 | len + LL_ALLOCATED_SPACE(dev)), |
483 | 1, &err); | 483 | 1, &err); |
484 | if (!skb) { | 484 | if (!skb) { |
485 | ND_PRINTK0(KERN_ERR | 485 | ND_PRINTK0(KERN_ERR |
@@ -1521,7 +1521,7 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh, | |||
1521 | 1521 | ||
1522 | buff = sock_alloc_send_skb(sk, | 1522 | buff = sock_alloc_send_skb(sk, |
1523 | (MAX_HEADER + sizeof(struct ipv6hdr) + | 1523 | (MAX_HEADER + sizeof(struct ipv6hdr) + |
1524 | len + LL_RESERVED_SPACE(dev)), | 1524 | len + LL_ALLOCATED_SPACE(dev)), |
1525 | 1, &err); | 1525 | 1, &err); |
1526 | if (buff == NULL) { | 1526 | if (buff == NULL) { |
1527 | ND_PRINTK0(KERN_ERR | 1527 | ND_PRINTK0(KERN_ERR |
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index 396f0ea11090..232e0dc45bf5 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c | |||
@@ -609,7 +609,6 @@ static int rawv6_send_hdrinc(struct sock *sk, void *from, int length, | |||
609 | struct ipv6_pinfo *np = inet6_sk(sk); | 609 | struct ipv6_pinfo *np = inet6_sk(sk); |
610 | struct ipv6hdr *iph; | 610 | struct ipv6hdr *iph; |
611 | struct sk_buff *skb; | 611 | struct sk_buff *skb; |
612 | unsigned int hh_len; | ||
613 | int err; | 612 | int err; |
614 | 613 | ||
615 | if (length > rt->u.dst.dev->mtu) { | 614 | if (length > rt->u.dst.dev->mtu) { |
@@ -619,13 +618,12 @@ static int rawv6_send_hdrinc(struct sock *sk, void *from, int length, | |||
619 | if (flags&MSG_PROBE) | 618 | if (flags&MSG_PROBE) |
620 | goto out; | 619 | goto out; |
621 | 620 | ||
622 | hh_len = LL_RESERVED_SPACE(rt->u.dst.dev); | 621 | skb = sock_alloc_send_skb(sk, |
623 | 622 | length + LL_ALLOCATED_SPACE(rt->u.dst.dev) + 15, | |
624 | skb = sock_alloc_send_skb(sk, length+hh_len+15, | 623 | flags & MSG_DONTWAIT, &err); |
625 | flags&MSG_DONTWAIT, &err); | ||
626 | if (skb == NULL) | 624 | if (skb == NULL) |
627 | goto error; | 625 | goto error; |
628 | skb_reserve(skb, hh_len); | 626 | skb_reserve(skb, LL_RESERVED_SPACE(rt->u.dst.dev)); |
629 | 627 | ||
630 | skb->priority = sk->sk_priority; | 628 | skb->priority = sk->sk_priority; |
631 | skb->mark = sk->sk_mark; | 629 | skb->mark = sk->sk_mark; |
diff --git a/net/irda/discovery.c b/net/irda/discovery.c index bfacef8b76f4..a6f99b5a1499 100644 --- a/net/irda/discovery.c +++ b/net/irda/discovery.c | |||
@@ -40,6 +40,8 @@ | |||
40 | 40 | ||
41 | #include <net/irda/discovery.h> | 41 | #include <net/irda/discovery.h> |
42 | 42 | ||
43 | #include <asm/unaligned.h> | ||
44 | |||
43 | /* | 45 | /* |
44 | * Function irlmp_add_discovery (cachelog, discovery) | 46 | * Function irlmp_add_discovery (cachelog, discovery) |
45 | * | 47 | * |
@@ -87,7 +89,7 @@ void irlmp_add_discovery(hashbin_t *cachelog, discovery_t *new) | |||
87 | */ | 89 | */ |
88 | hashbin_remove_this(cachelog, (irda_queue_t *) node); | 90 | hashbin_remove_this(cachelog, (irda_queue_t *) node); |
89 | /* Check if hints bits are unchanged */ | 91 | /* Check if hints bits are unchanged */ |
90 | if(u16ho(node->data.hints) == u16ho(new->data.hints)) | 92 | if (get_unaligned((__u16 *)node->data.hints) == get_unaligned((__u16 *)new->data.hints)) |
91 | /* Set time of first discovery for this node */ | 93 | /* Set time of first discovery for this node */ |
92 | new->firststamp = node->firststamp; | 94 | new->firststamp = node->firststamp; |
93 | kfree(node); | 95 | kfree(node); |
@@ -281,9 +283,9 @@ struct irda_device_info *irlmp_copy_discoveries(hashbin_t *log, int *pn, | |||
281 | /* Mask out the ones we don't want : | 283 | /* Mask out the ones we don't want : |
282 | * We want to match the discovery mask, and to get only | 284 | * We want to match the discovery mask, and to get only |
283 | * the most recent one (unless we want old ones) */ | 285 | * the most recent one (unless we want old ones) */ |
284 | if ((u16ho(discovery->data.hints) & mask) && | 286 | if ((get_unaligned((__u16 *)discovery->data.hints) & mask) && |
285 | ((old_entries) || | 287 | ((old_entries) || |
286 | ((jiffies - discovery->firststamp) < j_timeout)) ) { | 288 | ((jiffies - discovery->firststamp) < j_timeout))) { |
287 | /* Create buffer as needed. | 289 | /* Create buffer as needed. |
288 | * As this function get called a lot and most time | 290 | * As this function get called a lot and most time |
289 | * we don't have anything to put in the log (we are | 291 | * we don't have anything to put in the log (we are |
diff --git a/net/irda/irlmp.c b/net/irda/irlmp.c index 1f81f8e7c61d..7bf5b913828b 100644 --- a/net/irda/irlmp.c +++ b/net/irda/irlmp.c | |||
@@ -1062,7 +1062,8 @@ void irlmp_discovery_expiry(discinfo_t *expiries, int number) | |||
1062 | for(i = 0; i < number; i++) { | 1062 | for(i = 0; i < number; i++) { |
1063 | /* Check if we should notify client */ | 1063 | /* Check if we should notify client */ |
1064 | if ((client->expir_callback) && | 1064 | if ((client->expir_callback) && |
1065 | (client->hint_mask.word & u16ho(expiries[i].hints) | 1065 | (client->hint_mask.word & |
1066 | get_unaligned((__u16 *)expiries[i].hints) | ||
1066 | & 0x7f7f) ) | 1067 | & 0x7f7f) ) |
1067 | client->expir_callback(&(expiries[i]), | 1068 | client->expir_callback(&(expiries[i]), |
1068 | EXPIRY_TIMEOUT, | 1069 | EXPIRY_TIMEOUT, |
@@ -1086,7 +1087,7 @@ discovery_t *irlmp_get_discovery_response(void) | |||
1086 | 1087 | ||
1087 | IRDA_ASSERT(irlmp != NULL, return NULL;); | 1088 | IRDA_ASSERT(irlmp != NULL, return NULL;); |
1088 | 1089 | ||
1089 | u16ho(irlmp->discovery_rsp.data.hints) = irlmp->hints.word; | 1090 | put_unaligned(irlmp->hints.word, (__u16 *)irlmp->discovery_rsp.data.hints); |
1090 | 1091 | ||
1091 | /* | 1092 | /* |
1092 | * Set character set for device name (we use ASCII), and | 1093 | * Set character set for device name (we use ASCII), and |
diff --git a/net/irda/irnet/irnet_irda.c b/net/irda/irnet/irnet_irda.c index 75497e55927d..cf9a4b531a98 100644 --- a/net/irda/irnet/irnet_irda.c +++ b/net/irda/irnet/irnet_irda.c | |||
@@ -10,6 +10,7 @@ | |||
10 | 10 | ||
11 | #include "irnet_irda.h" /* Private header */ | 11 | #include "irnet_irda.h" /* Private header */ |
12 | #include <linux/seq_file.h> | 12 | #include <linux/seq_file.h> |
13 | #include <asm/unaligned.h> | ||
13 | 14 | ||
14 | /* | 15 | /* |
15 | * PPP disconnect work: we need to make sure we're in | 16 | * PPP disconnect work: we need to make sure we're in |
@@ -1673,7 +1674,7 @@ irnet_discovery_indication(discinfo_t * discovery, | |||
1673 | /* Notify the control channel */ | 1674 | /* Notify the control channel */ |
1674 | irnet_post_event(NULL, IRNET_DISCOVER, | 1675 | irnet_post_event(NULL, IRNET_DISCOVER, |
1675 | discovery->saddr, discovery->daddr, discovery->info, | 1676 | discovery->saddr, discovery->daddr, discovery->info, |
1676 | u16ho(discovery->hints)); | 1677 | get_unaligned((__u16 *)discovery->hints)); |
1677 | 1678 | ||
1678 | DEXIT(IRDA_OCB_TRACE, "\n"); | 1679 | DEXIT(IRDA_OCB_TRACE, "\n"); |
1679 | } | 1680 | } |
@@ -1704,7 +1705,7 @@ irnet_expiry_indication(discinfo_t * expiry, | |||
1704 | /* Notify the control channel */ | 1705 | /* Notify the control channel */ |
1705 | irnet_post_event(NULL, IRNET_EXPIRE, | 1706 | irnet_post_event(NULL, IRNET_EXPIRE, |
1706 | expiry->saddr, expiry->daddr, expiry->info, | 1707 | expiry->saddr, expiry->daddr, expiry->info, |
1707 | u16ho(expiry->hints)); | 1708 | get_unaligned((__u16 *)expiry->hints)); |
1708 | 1709 | ||
1709 | DEXIT(IRDA_OCB_TRACE, "\n"); | 1710 | DEXIT(IRDA_OCB_TRACE, "\n"); |
1710 | } | 1711 | } |
diff --git a/net/mac80211/debugfs_key.c b/net/mac80211/debugfs_key.c index 879e7210458a..19efc3a6a932 100644 --- a/net/mac80211/debugfs_key.c +++ b/net/mac80211/debugfs_key.c | |||
@@ -255,14 +255,23 @@ void ieee80211_debugfs_key_remove(struct ieee80211_key *key) | |||
255 | void ieee80211_debugfs_key_add_default(struct ieee80211_sub_if_data *sdata) | 255 | void ieee80211_debugfs_key_add_default(struct ieee80211_sub_if_data *sdata) |
256 | { | 256 | { |
257 | char buf[50]; | 257 | char buf[50]; |
258 | struct ieee80211_key *key; | ||
258 | 259 | ||
259 | if (!sdata->debugfsdir) | 260 | if (!sdata->debugfsdir) |
260 | return; | 261 | return; |
261 | 262 | ||
262 | sprintf(buf, "../keys/%d", sdata->default_key->debugfs.cnt); | 263 | /* this is running under the key lock */ |
263 | sdata->debugfs.default_key = | 264 | |
264 | debugfs_create_symlink("default_key", sdata->debugfsdir, buf); | 265 | key = sdata->default_key; |
266 | if (key) { | ||
267 | sprintf(buf, "../keys/%d", key->debugfs.cnt); | ||
268 | sdata->debugfs.default_key = | ||
269 | debugfs_create_symlink("default_key", | ||
270 | sdata->debugfsdir, buf); | ||
271 | } else | ||
272 | ieee80211_debugfs_key_remove_default(sdata); | ||
265 | } | 273 | } |
274 | |||
266 | void ieee80211_debugfs_key_remove_default(struct ieee80211_sub_if_data *sdata) | 275 | void ieee80211_debugfs_key_remove_default(struct ieee80211_sub_if_data *sdata) |
267 | { | 276 | { |
268 | if (!sdata) | 277 | if (!sdata) |
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 80954a512185..06e88a5a036d 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c | |||
@@ -54,6 +54,15 @@ int ieee80211_if_add(struct net_device *dev, const char *name, | |||
54 | if (!ndev) | 54 | if (!ndev) |
55 | return -ENOMEM; | 55 | return -ENOMEM; |
56 | 56 | ||
57 | ndev->needed_headroom = local->tx_headroom + | ||
58 | 4*6 /* four MAC addresses */ | ||
59 | + 2 + 2 + 2 + 2 /* ctl, dur, seq, qos */ | ||
60 | + 6 /* mesh */ | ||
61 | + 8 /* rfc1042/bridge tunnel */ | ||
62 | - ETH_HLEN /* ethernet hard_header_len */ | ||
63 | + IEEE80211_ENCRYPT_HEADROOM; | ||
64 | ndev->needed_tailroom = IEEE80211_ENCRYPT_TAILROOM; | ||
65 | |||
57 | ret = dev_alloc_name(ndev, ndev->name); | 66 | ret = dev_alloc_name(ndev, ndev->name); |
58 | if (ret < 0) | 67 | if (ret < 0) |
59 | goto fail; | 68 | goto fail; |
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index f76bc26ae4d2..697ef67f96b6 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c | |||
@@ -397,7 +397,7 @@ int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr, | |||
397 | put_unaligned(cpu_to_le32(sdata->u.sta.mesh_seqnum), &meshhdr->seqnum); | 397 | put_unaligned(cpu_to_le32(sdata->u.sta.mesh_seqnum), &meshhdr->seqnum); |
398 | sdata->u.sta.mesh_seqnum++; | 398 | sdata->u.sta.mesh_seqnum++; |
399 | 399 | ||
400 | return 5; | 400 | return 6; |
401 | } | 401 | } |
402 | 402 | ||
403 | void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata) | 403 | void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata) |
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c index 3df809222d1c..af0cd1e3e213 100644 --- a/net/mac80211/mesh_hwmp.c +++ b/net/mac80211/mesh_hwmp.c | |||
@@ -120,7 +120,7 @@ static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags, | |||
120 | *pos++ = WLAN_EID_PREP; | 120 | *pos++ = WLAN_EID_PREP; |
121 | break; | 121 | break; |
122 | default: | 122 | default: |
123 | kfree(skb); | 123 | kfree_skb(skb); |
124 | return -ENOTSUPP; | 124 | return -ENOTSUPP; |
125 | break; | 125 | break; |
126 | } | 126 | } |
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c index 5845dc21ce85..99c2d360888e 100644 --- a/net/mac80211/mesh_pathtbl.c +++ b/net/mac80211/mesh_pathtbl.c | |||
@@ -158,19 +158,25 @@ int mesh_path_add(u8 *dst, struct net_device *dev) | |||
158 | if (atomic_add_unless(&sdata->u.sta.mpaths, 1, MESH_MAX_MPATHS) == 0) | 158 | if (atomic_add_unless(&sdata->u.sta.mpaths, 1, MESH_MAX_MPATHS) == 0) |
159 | return -ENOSPC; | 159 | return -ENOSPC; |
160 | 160 | ||
161 | read_lock(&pathtbl_resize_lock); | ||
162 | |||
163 | new_mpath = kzalloc(sizeof(struct mesh_path), GFP_KERNEL); | 161 | new_mpath = kzalloc(sizeof(struct mesh_path), GFP_KERNEL); |
164 | if (!new_mpath) { | 162 | if (!new_mpath) { |
165 | atomic_dec(&sdata->u.sta.mpaths); | 163 | atomic_dec(&sdata->u.sta.mpaths); |
166 | err = -ENOMEM; | 164 | err = -ENOMEM; |
167 | goto endadd2; | 165 | goto endadd2; |
168 | } | 166 | } |
167 | new_node = kmalloc(sizeof(struct mpath_node), GFP_KERNEL); | ||
168 | if (!new_node) { | ||
169 | kfree(new_mpath); | ||
170 | atomic_dec(&sdata->u.sta.mpaths); | ||
171 | err = -ENOMEM; | ||
172 | goto endadd2; | ||
173 | } | ||
174 | |||
175 | read_lock(&pathtbl_resize_lock); | ||
169 | memcpy(new_mpath->dst, dst, ETH_ALEN); | 176 | memcpy(new_mpath->dst, dst, ETH_ALEN); |
170 | new_mpath->dev = dev; | 177 | new_mpath->dev = dev; |
171 | new_mpath->flags = 0; | 178 | new_mpath->flags = 0; |
172 | skb_queue_head_init(&new_mpath->frame_queue); | 179 | skb_queue_head_init(&new_mpath->frame_queue); |
173 | new_node = kmalloc(sizeof(struct mpath_node), GFP_KERNEL); | ||
174 | new_node->mpath = new_mpath; | 180 | new_node->mpath = new_mpath; |
175 | new_mpath->timer.data = (unsigned long) new_mpath; | 181 | new_mpath->timer.data = (unsigned long) new_mpath; |
176 | new_mpath->timer.function = mesh_path_timer; | 182 | new_mpath->timer.function = mesh_path_timer; |
@@ -202,7 +208,6 @@ int mesh_path_add(u8 *dst, struct net_device *dev) | |||
202 | 208 | ||
203 | endadd: | 209 | endadd: |
204 | spin_unlock(&mesh_paths->hashwlock[hash_idx]); | 210 | spin_unlock(&mesh_paths->hashwlock[hash_idx]); |
205 | endadd2: | ||
206 | read_unlock(&pathtbl_resize_lock); | 211 | read_unlock(&pathtbl_resize_lock); |
207 | if (!err && grow) { | 212 | if (!err && grow) { |
208 | struct mesh_table *oldtbl, *newtbl; | 213 | struct mesh_table *oldtbl, *newtbl; |
@@ -215,10 +220,12 @@ endadd2: | |||
215 | return -ENOMEM; | 220 | return -ENOMEM; |
216 | } | 221 | } |
217 | rcu_assign_pointer(mesh_paths, newtbl); | 222 | rcu_assign_pointer(mesh_paths, newtbl); |
223 | write_unlock(&pathtbl_resize_lock); | ||
224 | |||
218 | synchronize_rcu(); | 225 | synchronize_rcu(); |
219 | mesh_table_free(oldtbl, false); | 226 | mesh_table_free(oldtbl, false); |
220 | write_unlock(&pathtbl_resize_lock); | ||
221 | } | 227 | } |
228 | endadd2: | ||
222 | return err; | 229 | return err; |
223 | } | 230 | } |
224 | 231 | ||
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index a5e5c31c23ab..4adba09e80ca 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -665,6 +665,26 @@ static void ieee80211_authenticate(struct net_device *dev, | |||
665 | mod_timer(&ifsta->timer, jiffies + IEEE80211_AUTH_TIMEOUT); | 665 | mod_timer(&ifsta->timer, jiffies + IEEE80211_AUTH_TIMEOUT); |
666 | } | 666 | } |
667 | 667 | ||
668 | static int ieee80211_compatible_rates(struct ieee80211_sta_bss *bss, | ||
669 | struct ieee80211_supported_band *sband, | ||
670 | u64 *rates) | ||
671 | { | ||
672 | int i, j, count; | ||
673 | *rates = 0; | ||
674 | count = 0; | ||
675 | for (i = 0; i < bss->supp_rates_len; i++) { | ||
676 | int rate = (bss->supp_rates[i] & 0x7F) * 5; | ||
677 | |||
678 | for (j = 0; j < sband->n_bitrates; j++) | ||
679 | if (sband->bitrates[j].bitrate == rate) { | ||
680 | *rates |= BIT(j); | ||
681 | count++; | ||
682 | break; | ||
683 | } | ||
684 | } | ||
685 | |||
686 | return count; | ||
687 | } | ||
668 | 688 | ||
669 | static void ieee80211_send_assoc(struct net_device *dev, | 689 | static void ieee80211_send_assoc(struct net_device *dev, |
670 | struct ieee80211_if_sta *ifsta) | 690 | struct ieee80211_if_sta *ifsta) |
@@ -673,11 +693,12 @@ static void ieee80211_send_assoc(struct net_device *dev, | |||
673 | struct sk_buff *skb; | 693 | struct sk_buff *skb; |
674 | struct ieee80211_mgmt *mgmt; | 694 | struct ieee80211_mgmt *mgmt; |
675 | u8 *pos, *ies; | 695 | u8 *pos, *ies; |
676 | int i, len; | 696 | int i, len, count, rates_len, supp_rates_len; |
677 | u16 capab; | 697 | u16 capab; |
678 | struct ieee80211_sta_bss *bss; | 698 | struct ieee80211_sta_bss *bss; |
679 | int wmm = 0; | 699 | int wmm = 0; |
680 | struct ieee80211_supported_band *sband; | 700 | struct ieee80211_supported_band *sband; |
701 | u64 rates = 0; | ||
681 | 702 | ||
682 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + | 703 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + |
683 | sizeof(*mgmt) + 200 + ifsta->extra_ie_len + | 704 | sizeof(*mgmt) + 200 + ifsta->extra_ie_len + |
@@ -740,24 +761,39 @@ static void ieee80211_send_assoc(struct net_device *dev, | |||
740 | *pos++ = ifsta->ssid_len; | 761 | *pos++ = ifsta->ssid_len; |
741 | memcpy(pos, ifsta->ssid, ifsta->ssid_len); | 762 | memcpy(pos, ifsta->ssid, ifsta->ssid_len); |
742 | 763 | ||
764 | /* all supported rates should be added here but some APs | ||
765 | * (e.g. D-Link DAP 1353 in b-only mode) don't like that | ||
766 | * Therefore only add rates the AP supports */ | ||
767 | rates_len = ieee80211_compatible_rates(bss, sband, &rates); | ||
768 | supp_rates_len = rates_len; | ||
769 | if (supp_rates_len > 8) | ||
770 | supp_rates_len = 8; | ||
771 | |||
743 | len = sband->n_bitrates; | 772 | len = sband->n_bitrates; |
744 | if (len > 8) | 773 | pos = skb_put(skb, supp_rates_len + 2); |
745 | len = 8; | ||
746 | pos = skb_put(skb, len + 2); | ||
747 | *pos++ = WLAN_EID_SUPP_RATES; | 774 | *pos++ = WLAN_EID_SUPP_RATES; |
748 | *pos++ = len; | 775 | *pos++ = supp_rates_len; |
749 | for (i = 0; i < len; i++) { | ||
750 | int rate = sband->bitrates[i].bitrate; | ||
751 | *pos++ = (u8) (rate / 5); | ||
752 | } | ||
753 | 776 | ||
754 | if (sband->n_bitrates > len) { | 777 | count = 0; |
755 | pos = skb_put(skb, sband->n_bitrates - len + 2); | 778 | for (i = 0; i < sband->n_bitrates; i++) { |
756 | *pos++ = WLAN_EID_EXT_SUPP_RATES; | 779 | if (BIT(i) & rates) { |
757 | *pos++ = sband->n_bitrates - len; | ||
758 | for (i = len; i < sband->n_bitrates; i++) { | ||
759 | int rate = sband->bitrates[i].bitrate; | 780 | int rate = sband->bitrates[i].bitrate; |
760 | *pos++ = (u8) (rate / 5); | 781 | *pos++ = (u8) (rate / 5); |
782 | if (++count == 8) | ||
783 | break; | ||
784 | } | ||
785 | } | ||
786 | |||
787 | if (count == 8) { | ||
788 | pos = skb_put(skb, rates_len - count + 2); | ||
789 | *pos++ = WLAN_EID_EXT_SUPP_RATES; | ||
790 | *pos++ = rates_len - count; | ||
791 | |||
792 | for (i++; i < sband->n_bitrates; i++) { | ||
793 | if (BIT(i) & rates) { | ||
794 | int rate = sband->bitrates[i].bitrate; | ||
795 | *pos++ = (u8) (rate / 5); | ||
796 | } | ||
761 | } | 797 | } |
762 | } | 798 | } |
763 | 799 | ||
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 02f436a86061..1958bfb361c6 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
@@ -1305,11 +1305,11 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx) | |||
1305 | if (is_multicast_ether_addr(skb->data)) { | 1305 | if (is_multicast_ether_addr(skb->data)) { |
1306 | if (*mesh_ttl > 0) { | 1306 | if (*mesh_ttl > 0) { |
1307 | xmit_skb = skb_copy(skb, GFP_ATOMIC); | 1307 | xmit_skb = skb_copy(skb, GFP_ATOMIC); |
1308 | if (!xmit_skb && net_ratelimit()) | 1308 | if (xmit_skb) |
1309 | xmit_skb->pkt_type = PACKET_OTHERHOST; | ||
1310 | else if (net_ratelimit()) | ||
1309 | printk(KERN_DEBUG "%s: failed to clone " | 1311 | printk(KERN_DEBUG "%s: failed to clone " |
1310 | "multicast frame\n", dev->name); | 1312 | "multicast frame\n", dev->name); |
1311 | else | ||
1312 | xmit_skb->pkt_type = PACKET_OTHERHOST; | ||
1313 | } else | 1313 | } else |
1314 | IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.sta, | 1314 | IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.sta, |
1315 | dropped_frames_ttl); | 1315 | dropped_frames_ttl); |
@@ -1395,7 +1395,7 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) | |||
1395 | padding = ((4 - subframe_len) & 0x3); | 1395 | padding = ((4 - subframe_len) & 0x3); |
1396 | /* the last MSDU has no padding */ | 1396 | /* the last MSDU has no padding */ |
1397 | if (subframe_len > remaining) { | 1397 | if (subframe_len > remaining) { |
1398 | printk(KERN_DEBUG "%s: wrong buffer size", dev->name); | 1398 | printk(KERN_DEBUG "%s: wrong buffer size\n", dev->name); |
1399 | return RX_DROP_UNUSABLE; | 1399 | return RX_DROP_UNUSABLE; |
1400 | } | 1400 | } |
1401 | 1401 | ||
@@ -1418,7 +1418,7 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) | |||
1418 | eth = (struct ethhdr *) skb_pull(skb, ntohs(len) + | 1418 | eth = (struct ethhdr *) skb_pull(skb, ntohs(len) + |
1419 | padding); | 1419 | padding); |
1420 | if (!eth) { | 1420 | if (!eth) { |
1421 | printk(KERN_DEBUG "%s: wrong buffer size ", | 1421 | printk(KERN_DEBUG "%s: wrong buffer size\n", |
1422 | dev->name); | 1422 | dev->name); |
1423 | dev_kfree_skb(frame); | 1423 | dev_kfree_skb(frame); |
1424 | return RX_DROP_UNUSABLE; | 1424 | return RX_DROP_UNUSABLE; |
@@ -1952,7 +1952,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
1952 | if (!skb_new) { | 1952 | if (!skb_new) { |
1953 | if (net_ratelimit()) | 1953 | if (net_ratelimit()) |
1954 | printk(KERN_DEBUG "%s: failed to copy " | 1954 | printk(KERN_DEBUG "%s: failed to copy " |
1955 | "multicast frame for %s", | 1955 | "multicast frame for %s\n", |
1956 | wiphy_name(local->hw.wiphy), | 1956 | wiphy_name(local->hw.wiphy), |
1957 | prev->dev->name); | 1957 | prev->dev->name); |
1958 | continue; | 1958 | continue; |
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index f35eaea98e73..1d7dd54aacef 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c | |||
@@ -1562,13 +1562,13 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1562 | * be cloned. This could happen, e.g., with Linux bridge code passing | 1562 | * be cloned. This could happen, e.g., with Linux bridge code passing |
1563 | * us broadcast frames. */ | 1563 | * us broadcast frames. */ |
1564 | 1564 | ||
1565 | if (head_need > 0 || skb_cloned(skb)) { | 1565 | if (head_need > 0 || skb_header_cloned(skb)) { |
1566 | #if 0 | 1566 | #if 0 |
1567 | printk(KERN_DEBUG "%s: need to reallocate buffer for %d bytes " | 1567 | printk(KERN_DEBUG "%s: need to reallocate buffer for %d bytes " |
1568 | "of headroom\n", dev->name, head_need); | 1568 | "of headroom\n", dev->name, head_need); |
1569 | #endif | 1569 | #endif |
1570 | 1570 | ||
1571 | if (skb_cloned(skb)) | 1571 | if (skb_header_cloned(skb)) |
1572 | I802_DEBUG_INC(local->tx_expand_skb_head_cloned); | 1572 | I802_DEBUG_INC(local->tx_expand_skb_head_cloned); |
1573 | else | 1573 | else |
1574 | I802_DEBUG_INC(local->tx_expand_skb_head); | 1574 | I802_DEBUG_INC(local->tx_expand_skb_head); |
@@ -1898,6 +1898,7 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, | |||
1898 | control->flags |= IEEE80211_TXCTL_SHORT_PREAMBLE; | 1898 | control->flags |= IEEE80211_TXCTL_SHORT_PREAMBLE; |
1899 | control->antenna_sel_tx = local->hw.conf.antenna_sel_tx; | 1899 | control->antenna_sel_tx = local->hw.conf.antenna_sel_tx; |
1900 | control->flags |= IEEE80211_TXCTL_NO_ACK; | 1900 | control->flags |= IEEE80211_TXCTL_NO_ACK; |
1901 | control->flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT; | ||
1901 | control->retry_limit = 1; | 1902 | control->retry_limit = 1; |
1902 | control->flags |= IEEE80211_TXCTL_CLEAR_PS_FILT; | 1903 | control->flags |= IEEE80211_TXCTL_CLEAR_PS_FILT; |
1903 | } | 1904 | } |
diff --git a/net/mac80211/util.c b/net/mac80211/util.c index cc9f715c7bfc..24a465c4df09 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c | |||
@@ -153,15 +153,15 @@ int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr) | |||
153 | /* 7.1.3.5a.2 */ | 153 | /* 7.1.3.5a.2 */ |
154 | switch (ae) { | 154 | switch (ae) { |
155 | case 0: | 155 | case 0: |
156 | return 5; | 156 | return 6; |
157 | case 1: | 157 | case 1: |
158 | return 11; | 158 | return 12; |
159 | case 2: | 159 | case 2: |
160 | return 17; | 160 | return 18; |
161 | case 3: | 161 | case 3: |
162 | return 23; | 162 | return 24; |
163 | default: | 163 | default: |
164 | return 5; | 164 | return 6; |
165 | } | 165 | } |
166 | } | 166 | } |
167 | 167 | ||
diff --git a/net/mac80211/wme.c b/net/mac80211/wme.c index 64faa3dc488f..dc1598b86004 100644 --- a/net/mac80211/wme.c +++ b/net/mac80211/wme.c | |||
@@ -394,7 +394,8 @@ static int wme_qdiscop_init(struct Qdisc *qd, struct nlattr *opt) | |||
394 | qd->handle); | 394 | qd->handle); |
395 | if (!q->queues[i]) { | 395 | if (!q->queues[i]) { |
396 | q->queues[i] = &noop_qdisc; | 396 | q->queues[i] = &noop_qdisc; |
397 | printk(KERN_ERR "%s child qdisc %i creation failed", dev->name, i); | 397 | printk(KERN_ERR "%s child qdisc %i creation failed\n", |
398 | dev->name, i); | ||
398 | } | 399 | } |
399 | } | 400 | } |
400 | 401 | ||
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index 16774ecd1c4e..0edefcfc5949 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c | |||
@@ -472,6 +472,9 @@ static int ctnetlink_conntrack_event(struct notifier_block *this, | |||
472 | goto nla_put_failure; | 472 | goto nla_put_failure; |
473 | nla_nest_end(skb, nest_parms); | 473 | nla_nest_end(skb, nest_parms); |
474 | 474 | ||
475 | if (ctnetlink_dump_id(skb, ct) < 0) | ||
476 | goto nla_put_failure; | ||
477 | |||
475 | if (events & IPCT_DESTROY) { | 478 | if (events & IPCT_DESTROY) { |
476 | if (ctnetlink_dump_counters(skb, ct, IP_CT_DIR_ORIGINAL) < 0 || | 479 | if (ctnetlink_dump_counters(skb, ct, IP_CT_DIR_ORIGINAL) < 0 || |
477 | ctnetlink_dump_counters(skb, ct, IP_CT_DIR_REPLY) < 0) | 480 | ctnetlink_dump_counters(skb, ct, IP_CT_DIR_REPLY) < 0) |
diff --git a/net/netfilter/xt_iprange.c b/net/netfilter/xt_iprange.c index 500528d60cd7..c63e9333c755 100644 --- a/net/netfilter/xt_iprange.c +++ b/net/netfilter/xt_iprange.c | |||
@@ -179,3 +179,5 @@ module_exit(iprange_mt_exit); | |||
179 | MODULE_LICENSE("GPL"); | 179 | MODULE_LICENSE("GPL"); |
180 | MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>, Jan Engelhardt <jengelh@computergmbh.de>"); | 180 | MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>, Jan Engelhardt <jengelh@computergmbh.de>"); |
181 | MODULE_DESCRIPTION("Xtables: arbitrary IPv4 range matching"); | 181 | MODULE_DESCRIPTION("Xtables: arbitrary IPv4 range matching"); |
182 | MODULE_ALIAS("ipt_iprange"); | ||
183 | MODULE_ALIAS("ip6t_iprange"); | ||
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 25070240d4ae..2cee87da4441 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -743,7 +743,7 @@ static int packet_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
743 | if (len > dev->mtu+reserve) | 743 | if (len > dev->mtu+reserve) |
744 | goto out_unlock; | 744 | goto out_unlock; |
745 | 745 | ||
746 | skb = sock_alloc_send_skb(sk, len + LL_RESERVED_SPACE(dev), | 746 | skb = sock_alloc_send_skb(sk, len + LL_ALLOCATED_SPACE(dev), |
747 | msg->msg_flags & MSG_DONTWAIT, &err); | 747 | msg->msg_flags & MSG_DONTWAIT, &err); |
748 | if (skb==NULL) | 748 | if (skb==NULL) |
749 | goto out_unlock; | 749 | goto out_unlock; |
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index 81b606424e12..bbc7107c86cf 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c | |||
@@ -2418,7 +2418,8 @@ static int sctp_process_param(struct sctp_association *asoc, | |||
2418 | break; | 2418 | break; |
2419 | 2419 | ||
2420 | case SCTP_PARAM_IPV6_ADDRESS: | 2420 | case SCTP_PARAM_IPV6_ADDRESS: |
2421 | asoc->peer.ipv6_address = 1; | 2421 | if (PF_INET6 == asoc->base.sk->sk_family) |
2422 | asoc->peer.ipv6_address = 1; | ||
2422 | break; | 2423 | break; |
2423 | 2424 | ||
2424 | case SCTP_PARAM_HOST_NAME_ADDRESS: | 2425 | case SCTP_PARAM_HOST_NAME_ADDRESS: |
@@ -2829,6 +2830,19 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc, | |||
2829 | addr_param = (union sctp_addr_param *) | 2830 | addr_param = (union sctp_addr_param *) |
2830 | ((void *)asconf_param + sizeof(sctp_addip_param_t)); | 2831 | ((void *)asconf_param + sizeof(sctp_addip_param_t)); |
2831 | 2832 | ||
2833 | switch (addr_param->v4.param_hdr.type) { | ||
2834 | case SCTP_PARAM_IPV6_ADDRESS: | ||
2835 | if (!asoc->peer.ipv6_address) | ||
2836 | return SCTP_ERROR_INV_PARAM; | ||
2837 | break; | ||
2838 | case SCTP_PARAM_IPV4_ADDRESS: | ||
2839 | if (!asoc->peer.ipv4_address) | ||
2840 | return SCTP_ERROR_INV_PARAM; | ||
2841 | break; | ||
2842 | default: | ||
2843 | return SCTP_ERROR_INV_PARAM; | ||
2844 | } | ||
2845 | |||
2832 | af = sctp_get_af_specific(param_type2af(addr_param->v4.param_hdr.type)); | 2846 | af = sctp_get_af_specific(param_type2af(addr_param->v4.param_hdr.type)); |
2833 | if (unlikely(!af)) | 2847 | if (unlikely(!af)) |
2834 | return SCTP_ERROR_INV_PARAM; | 2848 | return SCTP_ERROR_INV_PARAM; |
diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c index 09cd9c0c2d80..3f964db908a7 100644 --- a/net/xfrm/xfrm_output.c +++ b/net/xfrm/xfrm_output.c | |||
@@ -25,11 +25,11 @@ static int xfrm_state_check_space(struct xfrm_state *x, struct sk_buff *skb) | |||
25 | struct dst_entry *dst = skb->dst; | 25 | struct dst_entry *dst = skb->dst; |
26 | int nhead = dst->header_len + LL_RESERVED_SPACE(dst->dev) | 26 | int nhead = dst->header_len + LL_RESERVED_SPACE(dst->dev) |
27 | - skb_headroom(skb); | 27 | - skb_headroom(skb); |
28 | int ntail = dst->dev->needed_tailroom - skb_tailroom(skb); | ||
28 | 29 | ||
29 | if (nhead > 0) | 30 | if (nhead > 0 || ntail > 0) |
30 | return pskb_expand_head(skb, nhead, 0, GFP_ATOMIC); | 31 | return pskb_expand_head(skb, nhead, ntail, GFP_ATOMIC); |
31 | 32 | ||
32 | /* Check tail too... */ | ||
33 | return 0; | 33 | return 0; |
34 | } | 34 | } |
35 | 35 | ||