diff options
Diffstat (limited to 'net')
60 files changed, 828 insertions, 272 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/atm/br2684.c b/net/atm/br2684.c index 1b228065e745..9d52ebfc1962 100644 --- a/net/atm/br2684.c +++ b/net/atm/br2684.c | |||
@@ -346,9 +346,9 @@ static void br2684_push(struct atm_vcc *atmvcc, struct sk_buff *skb) | |||
346 | /* skb==NULL means VCC is being destroyed */ | 346 | /* skb==NULL means VCC is being destroyed */ |
347 | br2684_close_vcc(brvcc); | 347 | br2684_close_vcc(brvcc); |
348 | if (list_empty(&brdev->brvccs)) { | 348 | if (list_empty(&brdev->brvccs)) { |
349 | read_lock(&devs_lock); | 349 | write_lock_irq(&devs_lock); |
350 | list_del(&brdev->br2684_devs); | 350 | list_del(&brdev->br2684_devs); |
351 | read_unlock(&devs_lock); | 351 | write_unlock_irq(&devs_lock); |
352 | unregister_netdev(net_dev); | 352 | unregister_netdev(net_dev); |
353 | free_netdev(net_dev); | 353 | free_netdev(net_dev); |
354 | } | 354 | } |
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index 77a981a1ee52..c2397f503b0f 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c | |||
@@ -273,15 +273,13 @@ int br_add_bridge(const char *name) | |||
273 | rtnl_lock(); | 273 | rtnl_lock(); |
274 | if (strchr(dev->name, '%')) { | 274 | if (strchr(dev->name, '%')) { |
275 | ret = dev_alloc_name(dev, dev->name); | 275 | ret = dev_alloc_name(dev, dev->name); |
276 | if (ret < 0) { | 276 | if (ret < 0) |
277 | free_netdev(dev); | 277 | goto out_free; |
278 | goto out; | ||
279 | } | ||
280 | } | 278 | } |
281 | 279 | ||
282 | ret = register_netdevice(dev); | 280 | ret = register_netdevice(dev); |
283 | if (ret) | 281 | if (ret) |
284 | goto out; | 282 | goto out_free; |
285 | 283 | ||
286 | ret = br_sysfs_addbr(dev); | 284 | ret = br_sysfs_addbr(dev); |
287 | if (ret) | 285 | if (ret) |
@@ -289,6 +287,10 @@ int br_add_bridge(const char *name) | |||
289 | out: | 287 | out: |
290 | rtnl_unlock(); | 288 | rtnl_unlock(); |
291 | return ret; | 289 | return ret; |
290 | |||
291 | out_free: | ||
292 | free_netdev(dev); | ||
293 | goto out; | ||
292 | } | 294 | } |
293 | 295 | ||
294 | int br_del_bridge(const char *name) | 296 | int br_del_bridge(const char *name) |
diff --git a/net/can/af_can.c b/net/can/af_can.c index 2759b76f731c..7e8ca2836452 100644 --- a/net/can/af_can.c +++ b/net/can/af_can.c | |||
@@ -208,6 +208,7 @@ static int can_create(struct net *net, struct socket *sock, int protocol) | |||
208 | */ | 208 | */ |
209 | int can_send(struct sk_buff *skb, int loop) | 209 | int can_send(struct sk_buff *skb, int loop) |
210 | { | 210 | { |
211 | struct sk_buff *newskb = NULL; | ||
211 | int err; | 212 | int err; |
212 | 213 | ||
213 | if (skb->dev->type != ARPHRD_CAN) { | 214 | if (skb->dev->type != ARPHRD_CAN) { |
@@ -244,8 +245,7 @@ int can_send(struct sk_buff *skb, int loop) | |||
244 | * If the interface is not capable to do loopback | 245 | * If the interface is not capable to do loopback |
245 | * itself, we do it here. | 246 | * itself, we do it here. |
246 | */ | 247 | */ |
247 | struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC); | 248 | newskb = skb_clone(skb, GFP_ATOMIC); |
248 | |||
249 | if (!newskb) { | 249 | if (!newskb) { |
250 | kfree_skb(skb); | 250 | kfree_skb(skb); |
251 | return -ENOMEM; | 251 | return -ENOMEM; |
@@ -254,7 +254,6 @@ int can_send(struct sk_buff *skb, int loop) | |||
254 | newskb->sk = skb->sk; | 254 | newskb->sk = skb->sk; |
255 | newskb->ip_summed = CHECKSUM_UNNECESSARY; | 255 | newskb->ip_summed = CHECKSUM_UNNECESSARY; |
256 | newskb->pkt_type = PACKET_BROADCAST; | 256 | newskb->pkt_type = PACKET_BROADCAST; |
257 | netif_rx(newskb); | ||
258 | } | 257 | } |
259 | } else { | 258 | } else { |
260 | /* indication for the CAN driver: no loopback required */ | 259 | /* indication for the CAN driver: no loopback required */ |
@@ -266,11 +265,20 @@ int can_send(struct sk_buff *skb, int loop) | |||
266 | if (err > 0) | 265 | if (err > 0) |
267 | err = net_xmit_errno(err); | 266 | err = net_xmit_errno(err); |
268 | 267 | ||
268 | if (err) { | ||
269 | if (newskb) | ||
270 | kfree_skb(newskb); | ||
271 | return err; | ||
272 | } | ||
273 | |||
274 | if (newskb) | ||
275 | netif_rx(newskb); | ||
276 | |||
269 | /* update statistics */ | 277 | /* update statistics */ |
270 | can_stats.tx_frames++; | 278 | can_stats.tx_frames++; |
271 | can_stats.tx_frames_delta++; | 279 | can_stats.tx_frames_delta++; |
272 | 280 | ||
273 | return err; | 281 | return 0; |
274 | } | 282 | } |
275 | EXPORT_SYMBOL(can_send); | 283 | EXPORT_SYMBOL(can_send); |
276 | 284 | ||
diff --git a/net/core/dev.c b/net/core/dev.c index d334446a8eaf..ce88c0d3e354 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -903,7 +903,11 @@ int dev_change_name(struct net_device *dev, char *newname) | |||
903 | strlcpy(dev->name, newname, IFNAMSIZ); | 903 | strlcpy(dev->name, newname, IFNAMSIZ); |
904 | 904 | ||
905 | rollback: | 905 | rollback: |
906 | device_rename(&dev->dev, dev->name); | 906 | err = device_rename(&dev->dev, dev->name); |
907 | if (err) { | ||
908 | memcpy(dev->name, oldname, IFNAMSIZ); | ||
909 | return err; | ||
910 | } | ||
907 | 911 | ||
908 | write_lock_bh(&dev_base_lock); | 912 | write_lock_bh(&dev_base_lock); |
909 | hlist_del(&dev->name_hlist); | 913 | hlist_del(&dev->name_hlist); |
@@ -994,6 +998,8 @@ int dev_open(struct net_device *dev) | |||
994 | { | 998 | { |
995 | int ret = 0; | 999 | int ret = 0; |
996 | 1000 | ||
1001 | ASSERT_RTNL(); | ||
1002 | |||
997 | /* | 1003 | /* |
998 | * Is it already up? | 1004 | * Is it already up? |
999 | */ | 1005 | */ |
@@ -1060,6 +1066,8 @@ int dev_open(struct net_device *dev) | |||
1060 | */ | 1066 | */ |
1061 | int dev_close(struct net_device *dev) | 1067 | int dev_close(struct net_device *dev) |
1062 | { | 1068 | { |
1069 | ASSERT_RTNL(); | ||
1070 | |||
1063 | might_sleep(); | 1071 | might_sleep(); |
1064 | 1072 | ||
1065 | if (!(dev->flags & IFF_UP)) | 1073 | if (!(dev->flags & IFF_UP)) |
@@ -4480,17 +4488,19 @@ static void __net_exit default_device_exit(struct net *net) | |||
4480 | rtnl_lock(); | 4488 | rtnl_lock(); |
4481 | for_each_netdev_safe(net, dev, next) { | 4489 | for_each_netdev_safe(net, dev, next) { |
4482 | int err; | 4490 | int err; |
4491 | char fb_name[IFNAMSIZ]; | ||
4483 | 4492 | ||
4484 | /* Ignore unmoveable devices (i.e. loopback) */ | 4493 | /* Ignore unmoveable devices (i.e. loopback) */ |
4485 | if (dev->features & NETIF_F_NETNS_LOCAL) | 4494 | if (dev->features & NETIF_F_NETNS_LOCAL) |
4486 | continue; | 4495 | continue; |
4487 | 4496 | ||
4488 | /* Push remaing network devices to init_net */ | 4497 | /* Push remaing network devices to init_net */ |
4489 | err = dev_change_net_namespace(dev, &init_net, "dev%d"); | 4498 | snprintf(fb_name, IFNAMSIZ, "dev%d", dev->ifindex); |
4499 | err = dev_change_net_namespace(dev, &init_net, fb_name); | ||
4490 | if (err) { | 4500 | if (err) { |
4491 | printk(KERN_WARNING "%s: failed to move %s to init_net: %d\n", | 4501 | printk(KERN_EMERG "%s: failed to move %s to init_net: %d\n", |
4492 | __func__, dev->name, err); | 4502 | __func__, dev->name, err); |
4493 | unregister_netdevice(dev); | 4503 | BUG(); |
4494 | } | 4504 | } |
4495 | } | 4505 | } |
4496 | rtnl_unlock(); | 4506 | rtnl_unlock(); |
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/skbuff.c b/net/core/skbuff.c index 4fe605fa6f8a..5c459f2b7985 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
@@ -200,7 +200,9 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask, | |||
200 | goto nodata; | 200 | goto nodata; |
201 | 201 | ||
202 | /* | 202 | /* |
203 | * See comment in sk_buff definition, just before the 'tail' member | 203 | * Only clear those fields we need to clear, not those that we will |
204 | * actually initialise below. Hence, don't put any more fields after | ||
205 | * the tail pointer in struct sk_buff! | ||
204 | */ | 206 | */ |
205 | memset(skb, 0, offsetof(struct sk_buff, tail)); | 207 | memset(skb, 0, offsetof(struct sk_buff, tail)); |
206 | skb->truesize = size + sizeof(struct sk_buff); | 208 | skb->truesize = size + sizeof(struct sk_buff); |
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/dccp/feat.c b/net/dccp/feat.c index 4a4f6ce4498d..933a0ecf8d46 100644 --- a/net/dccp/feat.c +++ b/net/dccp/feat.c | |||
@@ -32,7 +32,7 @@ int dccp_feat_change(struct dccp_minisock *dmsk, u8 type, u8 feature, | |||
32 | 32 | ||
33 | if (len > 3) { | 33 | if (len > 3) { |
34 | DCCP_WARN("invalid length %d\n", len); | 34 | DCCP_WARN("invalid length %d\n", len); |
35 | return 1; | 35 | return -EINVAL; |
36 | } | 36 | } |
37 | /* XXX add further sanity checks */ | 37 | /* XXX add further sanity checks */ |
38 | 38 | ||
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c index 2f665a516476..f50e88bf2661 100644 --- a/net/decnet/dn_route.c +++ b/net/decnet/dn_route.c | |||
@@ -235,14 +235,14 @@ static void dn_dst_update_pmtu(struct dst_entry *dst, u32 mtu) | |||
235 | else | 235 | else |
236 | min_mtu -= 21; | 236 | min_mtu -= 21; |
237 | 237 | ||
238 | if (dst->metrics[RTAX_MTU-1] > mtu && mtu >= min_mtu) { | 238 | if (dst_metric(dst, RTAX_MTU) > mtu && mtu >= min_mtu) { |
239 | if (!(dst_metric_locked(dst, RTAX_MTU))) { | 239 | if (!(dst_metric_locked(dst, RTAX_MTU))) { |
240 | dst->metrics[RTAX_MTU-1] = mtu; | 240 | dst->metrics[RTAX_MTU-1] = mtu; |
241 | dst_set_expires(dst, dn_rt_mtu_expires); | 241 | dst_set_expires(dst, dn_rt_mtu_expires); |
242 | } | 242 | } |
243 | if (!(dst_metric_locked(dst, RTAX_ADVMSS))) { | 243 | if (!(dst_metric_locked(dst, RTAX_ADVMSS))) { |
244 | u32 mss = mtu - DN_MAX_NSP_DATA_HEADER; | 244 | u32 mss = mtu - DN_MAX_NSP_DATA_HEADER; |
245 | if (dst->metrics[RTAX_ADVMSS-1] > mss) | 245 | if (dst_metric(dst, RTAX_ADVMSS) > mss) |
246 | dst->metrics[RTAX_ADVMSS-1] = mss; | 246 | dst->metrics[RTAX_ADVMSS-1] = mss; |
247 | } | 247 | } |
248 | } | 248 | } |
@@ -805,12 +805,12 @@ static int dn_rt_set_next_hop(struct dn_route *rt, struct dn_fib_res *res) | |||
805 | rt->u.dst.neighbour = n; | 805 | rt->u.dst.neighbour = n; |
806 | } | 806 | } |
807 | 807 | ||
808 | if (rt->u.dst.metrics[RTAX_MTU-1] == 0 || | 808 | if (dst_metric(&rt->u.dst, RTAX_MTU) == 0 || |
809 | rt->u.dst.metrics[RTAX_MTU-1] > rt->u.dst.dev->mtu) | 809 | dst_metric(&rt->u.dst, RTAX_MTU) > rt->u.dst.dev->mtu) |
810 | rt->u.dst.metrics[RTAX_MTU-1] = rt->u.dst.dev->mtu; | 810 | rt->u.dst.metrics[RTAX_MTU-1] = rt->u.dst.dev->mtu; |
811 | mss = dn_mss_from_pmtu(dev, dst_mtu(&rt->u.dst)); | 811 | mss = dn_mss_from_pmtu(dev, dst_mtu(&rt->u.dst)); |
812 | if (rt->u.dst.metrics[RTAX_ADVMSS-1] == 0 || | 812 | if (dst_metric(&rt->u.dst, RTAX_ADVMSS) == 0 || |
813 | rt->u.dst.metrics[RTAX_ADVMSS-1] > mss) | 813 | dst_metric(&rt->u.dst, RTAX_ADVMSS) > mss) |
814 | rt->u.dst.metrics[RTAX_ADVMSS-1] = mss; | 814 | rt->u.dst.metrics[RTAX_ADVMSS-1] = mss; |
815 | return 0; | 815 | return 0; |
816 | } | 816 | } |
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/ip_input.c b/net/ipv4/ip_input.c index 7b4bad6d572f..ff77a4a7f9ec 100644 --- a/net/ipv4/ip_input.c +++ b/net/ipv4/ip_input.c | |||
@@ -397,7 +397,7 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, | |||
397 | iph = ip_hdr(skb); | 397 | iph = ip_hdr(skb); |
398 | 398 | ||
399 | /* | 399 | /* |
400 | * RFC1122: 3.1.2.2 MUST silently discard any IP frame that fails the checksum. | 400 | * RFC1122: 3.2.1.2 MUST silently discard any IP frame that fails the checksum. |
401 | * | 401 | * |
402 | * Is the datagram acceptable? | 402 | * Is the datagram acceptable? |
403 | * | 403 | * |
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/route.c b/net/ipv4/route.c index 5e3685c5c407..92f90ae46f4a 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -1468,14 +1468,14 @@ unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph, | |||
1468 | 1468 | ||
1469 | /* BSD 4.2 compatibility hack :-( */ | 1469 | /* BSD 4.2 compatibility hack :-( */ |
1470 | if (mtu == 0 && | 1470 | if (mtu == 0 && |
1471 | old_mtu >= rth->u.dst.metrics[RTAX_MTU-1] && | 1471 | old_mtu >= dst_metric(&rth->u.dst, RTAX_MTU) && |
1472 | old_mtu >= 68 + (iph->ihl << 2)) | 1472 | old_mtu >= 68 + (iph->ihl << 2)) |
1473 | old_mtu -= iph->ihl << 2; | 1473 | old_mtu -= iph->ihl << 2; |
1474 | 1474 | ||
1475 | mtu = guess_mtu(old_mtu); | 1475 | mtu = guess_mtu(old_mtu); |
1476 | } | 1476 | } |
1477 | if (mtu <= rth->u.dst.metrics[RTAX_MTU-1]) { | 1477 | if (mtu <= dst_metric(&rth->u.dst, RTAX_MTU)) { |
1478 | if (mtu < rth->u.dst.metrics[RTAX_MTU-1]) { | 1478 | if (mtu < dst_metric(&rth->u.dst, RTAX_MTU)) { |
1479 | dst_confirm(&rth->u.dst); | 1479 | dst_confirm(&rth->u.dst); |
1480 | if (mtu < ip_rt_min_pmtu) { | 1480 | if (mtu < ip_rt_min_pmtu) { |
1481 | mtu = ip_rt_min_pmtu; | 1481 | mtu = ip_rt_min_pmtu; |
@@ -1497,7 +1497,7 @@ unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph, | |||
1497 | 1497 | ||
1498 | static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu) | 1498 | static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu) |
1499 | { | 1499 | { |
1500 | if (dst->metrics[RTAX_MTU-1] > mtu && mtu >= 68 && | 1500 | if (dst_metric(dst, RTAX_MTU) > mtu && mtu >= 68 && |
1501 | !(dst_metric_locked(dst, RTAX_MTU))) { | 1501 | !(dst_metric_locked(dst, RTAX_MTU))) { |
1502 | if (mtu < ip_rt_min_pmtu) { | 1502 | if (mtu < ip_rt_min_pmtu) { |
1503 | mtu = ip_rt_min_pmtu; | 1503 | mtu = ip_rt_min_pmtu; |
@@ -1613,7 +1613,7 @@ static void rt_set_nexthop(struct rtable *rt, struct fib_result *res, u32 itag) | |||
1613 | sizeof(rt->u.dst.metrics)); | 1613 | sizeof(rt->u.dst.metrics)); |
1614 | if (fi->fib_mtu == 0) { | 1614 | if (fi->fib_mtu == 0) { |
1615 | rt->u.dst.metrics[RTAX_MTU-1] = rt->u.dst.dev->mtu; | 1615 | rt->u.dst.metrics[RTAX_MTU-1] = rt->u.dst.dev->mtu; |
1616 | if (rt->u.dst.metrics[RTAX_LOCK-1] & (1 << RTAX_MTU) && | 1616 | if (dst_metric_locked(&rt->u.dst, RTAX_MTU) && |
1617 | rt->rt_gateway != rt->rt_dst && | 1617 | rt->rt_gateway != rt->rt_dst && |
1618 | rt->u.dst.dev->mtu > 576) | 1618 | rt->u.dst.dev->mtu > 576) |
1619 | rt->u.dst.metrics[RTAX_MTU-1] = 576; | 1619 | rt->u.dst.metrics[RTAX_MTU-1] = 576; |
@@ -1624,14 +1624,14 @@ static void rt_set_nexthop(struct rtable *rt, struct fib_result *res, u32 itag) | |||
1624 | } else | 1624 | } else |
1625 | rt->u.dst.metrics[RTAX_MTU-1]= rt->u.dst.dev->mtu; | 1625 | rt->u.dst.metrics[RTAX_MTU-1]= rt->u.dst.dev->mtu; |
1626 | 1626 | ||
1627 | if (rt->u.dst.metrics[RTAX_HOPLIMIT-1] == 0) | 1627 | if (dst_metric(&rt->u.dst, RTAX_HOPLIMIT) == 0) |
1628 | rt->u.dst.metrics[RTAX_HOPLIMIT-1] = sysctl_ip_default_ttl; | 1628 | rt->u.dst.metrics[RTAX_HOPLIMIT-1] = sysctl_ip_default_ttl; |
1629 | if (rt->u.dst.metrics[RTAX_MTU-1] > IP_MAX_MTU) | 1629 | if (dst_metric(&rt->u.dst, RTAX_MTU) > IP_MAX_MTU) |
1630 | rt->u.dst.metrics[RTAX_MTU-1] = IP_MAX_MTU; | 1630 | rt->u.dst.metrics[RTAX_MTU-1] = IP_MAX_MTU; |
1631 | if (rt->u.dst.metrics[RTAX_ADVMSS-1] == 0) | 1631 | if (dst_metric(&rt->u.dst, RTAX_ADVMSS) == 0) |
1632 | rt->u.dst.metrics[RTAX_ADVMSS-1] = max_t(unsigned int, rt->u.dst.dev->mtu - 40, | 1632 | rt->u.dst.metrics[RTAX_ADVMSS-1] = max_t(unsigned int, rt->u.dst.dev->mtu - 40, |
1633 | ip_rt_min_advmss); | 1633 | ip_rt_min_advmss); |
1634 | if (rt->u.dst.metrics[RTAX_ADVMSS-1] > 65535 - 40) | 1634 | if (dst_metric(&rt->u.dst, RTAX_ADVMSS) > 65535 - 40) |
1635 | rt->u.dst.metrics[RTAX_ADVMSS-1] = 65535 - 40; | 1635 | rt->u.dst.metrics[RTAX_ADVMSS-1] = 65535 - 40; |
1636 | 1636 | ||
1637 | #ifdef CONFIG_NET_CLS_ROUTE | 1637 | #ifdef CONFIG_NET_CLS_ROUTE |
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index eda4f4a233f3..b54d9d37b636 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -66,6 +66,7 @@ | |||
66 | #include <linux/mm.h> | 66 | #include <linux/mm.h> |
67 | #include <linux/module.h> | 67 | #include <linux/module.h> |
68 | #include <linux/sysctl.h> | 68 | #include <linux/sysctl.h> |
69 | #include <net/dst.h> | ||
69 | #include <net/tcp.h> | 70 | #include <net/tcp.h> |
70 | #include <net/inet_common.h> | 71 | #include <net/inet_common.h> |
71 | #include <linux/ipsec.h> | 72 | #include <linux/ipsec.h> |
@@ -113,8 +114,6 @@ int sysctl_tcp_abc __read_mostly; | |||
113 | #define FLAG_FORWARD_PROGRESS (FLAG_ACKED|FLAG_DATA_SACKED) | 114 | #define FLAG_FORWARD_PROGRESS (FLAG_ACKED|FLAG_DATA_SACKED) |
114 | #define FLAG_ANY_PROGRESS (FLAG_FORWARD_PROGRESS|FLAG_SND_UNA_ADVANCED) | 115 | #define FLAG_ANY_PROGRESS (FLAG_FORWARD_PROGRESS|FLAG_SND_UNA_ADVANCED) |
115 | 116 | ||
116 | #define IsSackFrto() (sysctl_tcp_frto == 0x2) | ||
117 | |||
118 | #define TCP_REMNANT (TCP_FLAG_FIN|TCP_FLAG_URG|TCP_FLAG_SYN|TCP_FLAG_PSH) | 117 | #define TCP_REMNANT (TCP_FLAG_FIN|TCP_FLAG_URG|TCP_FLAG_SYN|TCP_FLAG_PSH) |
119 | #define TCP_HP_BITS (~(TCP_RESERVED_BITS|TCP_FLAG_PSH)) | 118 | #define TCP_HP_BITS (~(TCP_RESERVED_BITS|TCP_FLAG_PSH)) |
120 | 119 | ||
@@ -605,7 +604,7 @@ static u32 tcp_rto_min(struct sock *sk) | |||
605 | u32 rto_min = TCP_RTO_MIN; | 604 | u32 rto_min = TCP_RTO_MIN; |
606 | 605 | ||
607 | if (dst && dst_metric_locked(dst, RTAX_RTO_MIN)) | 606 | if (dst && dst_metric_locked(dst, RTAX_RTO_MIN)) |
608 | rto_min = dst->metrics[RTAX_RTO_MIN - 1]; | 607 | rto_min = dst_metric(dst, RTAX_RTO_MIN); |
609 | return rto_min; | 608 | return rto_min; |
610 | } | 609 | } |
611 | 610 | ||
@@ -769,7 +768,7 @@ void tcp_update_metrics(struct sock *sk) | |||
769 | dst->metrics[RTAX_RTTVAR - 1] = m; | 768 | dst->metrics[RTAX_RTTVAR - 1] = m; |
770 | else | 769 | else |
771 | dst->metrics[RTAX_RTTVAR-1] -= | 770 | dst->metrics[RTAX_RTTVAR-1] -= |
772 | (dst->metrics[RTAX_RTTVAR-1] - m)>>2; | 771 | (dst_metric(dst, RTAX_RTTVAR) - m)>>2; |
773 | } | 772 | } |
774 | 773 | ||
775 | if (tp->snd_ssthresh >= 0xFFFF) { | 774 | if (tp->snd_ssthresh >= 0xFFFF) { |
@@ -788,21 +787,21 @@ void tcp_update_metrics(struct sock *sk) | |||
788 | dst->metrics[RTAX_SSTHRESH-1] = | 787 | dst->metrics[RTAX_SSTHRESH-1] = |
789 | max(tp->snd_cwnd >> 1, tp->snd_ssthresh); | 788 | max(tp->snd_cwnd >> 1, tp->snd_ssthresh); |
790 | if (!dst_metric_locked(dst, RTAX_CWND)) | 789 | if (!dst_metric_locked(dst, RTAX_CWND)) |
791 | dst->metrics[RTAX_CWND-1] = (dst->metrics[RTAX_CWND-1] + tp->snd_cwnd) >> 1; | 790 | dst->metrics[RTAX_CWND-1] = (dst_metric(dst, RTAX_CWND) + tp->snd_cwnd) >> 1; |
792 | } else { | 791 | } else { |
793 | /* Else slow start did not finish, cwnd is non-sense, | 792 | /* Else slow start did not finish, cwnd is non-sense, |
794 | ssthresh may be also invalid. | 793 | ssthresh may be also invalid. |
795 | */ | 794 | */ |
796 | if (!dst_metric_locked(dst, RTAX_CWND)) | 795 | if (!dst_metric_locked(dst, RTAX_CWND)) |
797 | dst->metrics[RTAX_CWND-1] = (dst->metrics[RTAX_CWND-1] + tp->snd_ssthresh) >> 1; | 796 | dst->metrics[RTAX_CWND-1] = (dst_metric(dst, RTAX_CWND) + tp->snd_ssthresh) >> 1; |
798 | if (dst->metrics[RTAX_SSTHRESH-1] && | 797 | if (dst_metric(dst, RTAX_SSTHRESH) && |
799 | !dst_metric_locked(dst, RTAX_SSTHRESH) && | 798 | !dst_metric_locked(dst, RTAX_SSTHRESH) && |
800 | tp->snd_ssthresh > dst->metrics[RTAX_SSTHRESH-1]) | 799 | tp->snd_ssthresh > dst_metric(dst, RTAX_SSTHRESH)) |
801 | dst->metrics[RTAX_SSTHRESH-1] = tp->snd_ssthresh; | 800 | dst->metrics[RTAX_SSTHRESH-1] = tp->snd_ssthresh; |
802 | } | 801 | } |
803 | 802 | ||
804 | if (!dst_metric_locked(dst, RTAX_REORDERING)) { | 803 | if (!dst_metric_locked(dst, RTAX_REORDERING)) { |
805 | if (dst->metrics[RTAX_REORDERING-1] < tp->reordering && | 804 | if (dst_metric(dst, RTAX_REORDERING) < tp->reordering && |
806 | tp->reordering != sysctl_tcp_reordering) | 805 | tp->reordering != sysctl_tcp_reordering) |
807 | dst->metrics[RTAX_REORDERING-1] = tp->reordering; | 806 | dst->metrics[RTAX_REORDERING-1] = tp->reordering; |
808 | } | 807 | } |
@@ -1685,6 +1684,11 @@ static inline void tcp_reset_reno_sack(struct tcp_sock *tp) | |||
1685 | tp->sacked_out = 0; | 1684 | tp->sacked_out = 0; |
1686 | } | 1685 | } |
1687 | 1686 | ||
1687 | static int tcp_is_sackfrto(const struct tcp_sock *tp) | ||
1688 | { | ||
1689 | return (sysctl_tcp_frto == 0x2) && !tcp_is_reno(tp); | ||
1690 | } | ||
1691 | |||
1688 | /* F-RTO can only be used if TCP has never retransmitted anything other than | 1692 | /* F-RTO can only be used if TCP has never retransmitted anything other than |
1689 | * head (SACK enhanced variant from Appendix B of RFC4138 is more robust here) | 1693 | * head (SACK enhanced variant from Appendix B of RFC4138 is more robust here) |
1690 | */ | 1694 | */ |
@@ -1701,7 +1705,7 @@ int tcp_use_frto(struct sock *sk) | |||
1701 | if (icsk->icsk_mtup.probe_size) | 1705 | if (icsk->icsk_mtup.probe_size) |
1702 | return 0; | 1706 | return 0; |
1703 | 1707 | ||
1704 | if (IsSackFrto()) | 1708 | if (tcp_is_sackfrto(tp)) |
1705 | return 1; | 1709 | return 1; |
1706 | 1710 | ||
1707 | /* Avoid expensive walking of rexmit queue if possible */ | 1711 | /* Avoid expensive walking of rexmit queue if possible */ |
@@ -1791,7 +1795,7 @@ void tcp_enter_frto(struct sock *sk) | |||
1791 | /* Earlier loss recovery underway (see RFC4138; Appendix B). | 1795 | /* Earlier loss recovery underway (see RFC4138; Appendix B). |
1792 | * The last condition is necessary at least in tp->frto_counter case. | 1796 | * The last condition is necessary at least in tp->frto_counter case. |
1793 | */ | 1797 | */ |
1794 | if (IsSackFrto() && (tp->frto_counter || | 1798 | if (tcp_is_sackfrto(tp) && (tp->frto_counter || |
1795 | ((1 << icsk->icsk_ca_state) & (TCPF_CA_Recovery|TCPF_CA_Loss))) && | 1799 | ((1 << icsk->icsk_ca_state) & (TCPF_CA_Recovery|TCPF_CA_Loss))) && |
1796 | after(tp->high_seq, tp->snd_una)) { | 1800 | after(tp->high_seq, tp->snd_una)) { |
1797 | tp->frto_highmark = tp->high_seq; | 1801 | tp->frto_highmark = tp->high_seq; |
@@ -1838,9 +1842,16 @@ static void tcp_enter_frto_loss(struct sock *sk, int allowed_segments, int flag) | |||
1838 | TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_RETRANS; | 1842 | TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_RETRANS; |
1839 | } | 1843 | } |
1840 | 1844 | ||
1841 | /* Don't lost mark skbs that were fwd transmitted after RTO */ | 1845 | /* Marking forward transmissions that were made after RTO lost |
1842 | if (!(TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_ACKED) && | 1846 | * can cause unnecessary retransmissions in some scenarios, |
1843 | !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)) { | ||
1844 | TCP_SKB_CB(skb)->sacked |= TCPCB_LOST; | 1855 | TCP_SKB_CB(skb)->sacked |= TCPCB_LOST; |
1845 | tp->lost_out += tcp_skb_pcount(skb); | 1856 | tp->lost_out += tcp_skb_pcount(skb); |
1846 | } | 1857 | } |
@@ -1856,7 +1867,7 @@ static void tcp_enter_frto_loss(struct sock *sk, int allowed_segments, int flag) | |||
1856 | tp->reordering = min_t(unsigned int, tp->reordering, | 1867 | tp->reordering = min_t(unsigned int, tp->reordering, |
1857 | sysctl_tcp_reordering); | 1868 | sysctl_tcp_reordering); |
1858 | tcp_set_ca_state(sk, TCP_CA_Loss); | 1869 | tcp_set_ca_state(sk, TCP_CA_Loss); |
1859 | tp->high_seq = tp->frto_highmark; | 1870 | tp->high_seq = tp->snd_nxt; |
1860 | TCP_ECN_queue_cwr(tp); | 1871 | TCP_ECN_queue_cwr(tp); |
1861 | 1872 | ||
1862 | tcp_clear_retrans_hints_partial(tp); | 1873 | tcp_clear_retrans_hints_partial(tp); |
@@ -2478,7 +2489,7 @@ static void tcp_try_to_open(struct sock *sk, int flag) | |||
2478 | 2489 | ||
2479 | tcp_verify_left_out(tp); | 2490 | tcp_verify_left_out(tp); |
2480 | 2491 | ||
2481 | if (tp->retrans_out == 0) | 2492 | if (!tp->frto_counter && tp->retrans_out == 0) |
2482 | tp->retrans_stamp = 0; | 2493 | tp->retrans_stamp = 0; |
2483 | 2494 | ||
2484 | if (flag & FLAG_ECE) | 2495 | if (flag & FLAG_ECE) |
@@ -3123,7 +3134,7 @@ static int tcp_process_frto(struct sock *sk, int flag) | |||
3123 | return 1; | 3134 | return 1; |
3124 | } | 3135 | } |
3125 | 3136 | ||
3126 | if (!IsSackFrto() || tcp_is_reno(tp)) { | 3137 | if (!tcp_is_sackfrto(tp)) { |
3127 | /* RFC4138 shortcoming in step 2; should also have case c): | 3138 | /* RFC4138 shortcoming in step 2; should also have case c): |
3128 | * ACK isn't duplicate nor advances window, e.g., opposite dir | 3139 | * ACK isn't duplicate nor advances window, e.g., opposite dir |
3129 | * data, winupdate | 3140 | * data, winupdate |
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/ipv6/route.c b/net/ipv6/route.c index a493ad9b8914..12bba0880345 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -1243,11 +1243,11 @@ install_route: | |||
1243 | } | 1243 | } |
1244 | } | 1244 | } |
1245 | 1245 | ||
1246 | if (rt->u.dst.metrics[RTAX_HOPLIMIT-1] == 0) | 1246 | if (dst_metric(&rt->u.dst, RTAX_HOPLIMIT) == 0) |
1247 | rt->u.dst.metrics[RTAX_HOPLIMIT-1] = -1; | 1247 | rt->u.dst.metrics[RTAX_HOPLIMIT-1] = -1; |
1248 | if (!rt->u.dst.metrics[RTAX_MTU-1]) | 1248 | if (!dst_metric(&rt->u.dst, RTAX_MTU)) |
1249 | rt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(dev); | 1249 | rt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(dev); |
1250 | if (!rt->u.dst.metrics[RTAX_ADVMSS-1]) | 1250 | if (!dst_metric(&rt->u.dst, RTAX_ADVMSS)) |
1251 | rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(net, dst_mtu(&rt->u.dst)); | 1251 | rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(net, dst_mtu(&rt->u.dst)); |
1252 | rt->u.dst.dev = dev; | 1252 | rt->u.dst.dev = dev; |
1253 | rt->rt6i_idev = idev; | 1253 | rt->rt6i_idev = idev; |
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index 4b2f1033994e..5a6fab95569f 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c | |||
@@ -596,9 +596,9 @@ static int ipip6_rcv(struct sk_buff *skb) | |||
596 | } | 596 | } |
597 | 597 | ||
598 | icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0); | 598 | icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0); |
599 | kfree_skb(skb); | ||
600 | read_unlock(&ipip6_lock); | 599 | read_unlock(&ipip6_lock); |
601 | out: | 600 | out: |
601 | kfree_skb(skb); | ||
602 | return 0; | 602 | return 0; |
603 | } | 603 | } |
604 | 604 | ||
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 f41c7e0de622..4a8062f8b1cc 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c | |||
@@ -53,6 +53,15 @@ int ieee80211_if_add(struct net_device *dev, const char *name, | |||
53 | if (!ndev) | 53 | if (!ndev) |
54 | return -ENOMEM; | 54 | return -ENOMEM; |
55 | 55 | ||
56 | ndev->needed_headroom = local->tx_headroom + | ||
57 | 4*6 /* four MAC addresses */ | ||
58 | + 2 + 2 + 2 + 2 /* ctl, dur, seq, qos */ | ||
59 | + 6 /* mesh */ | ||
60 | + 8 /* rfc1042/bridge tunnel */ | ||
61 | - ETH_HLEN /* ethernet hard_header_len */ | ||
62 | + IEEE80211_ENCRYPT_HEADROOM; | ||
63 | ndev->needed_tailroom = IEEE80211_ENCRYPT_TAILROOM; | ||
64 | |||
56 | ret = dev_alloc_name(ndev, ndev->name); | 65 | ret = dev_alloc_name(ndev, ndev->name); |
57 | if (ret < 0) | 66 | if (ret < 0) |
58 | goto fail; | 67 | goto fail; |
diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 55e76117da9e..eb347eca30b5 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c | |||
@@ -1771,6 +1771,7 @@ fail_wep: | |||
1771 | fail_rate: | 1771 | fail_rate: |
1772 | ieee80211_debugfs_remove_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev)); | 1772 | ieee80211_debugfs_remove_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev)); |
1773 | unregister_netdevice(local->mdev); | 1773 | unregister_netdevice(local->mdev); |
1774 | local->mdev = NULL; | ||
1774 | fail_dev: | 1775 | fail_dev: |
1775 | rtnl_unlock(); | 1776 | rtnl_unlock(); |
1776 | sta_info_stop(local); | 1777 | sta_info_stop(local); |
@@ -1778,8 +1779,10 @@ fail_sta_info: | |||
1778 | debugfs_hw_del(local); | 1779 | debugfs_hw_del(local); |
1779 | destroy_workqueue(local->hw.workqueue); | 1780 | destroy_workqueue(local->hw.workqueue); |
1780 | fail_workqueue: | 1781 | fail_workqueue: |
1781 | ieee80211_if_free(local->mdev); | 1782 | if (local->mdev != NULL) { |
1782 | local->mdev = NULL; | 1783 | ieee80211_if_free(local->mdev); |
1784 | local->mdev = NULL; | ||
1785 | } | ||
1783 | fail_mdev_alloc: | 1786 | fail_mdev_alloc: |
1784 | wiphy_unregister(local->hw.wiphy); | 1787 | wiphy_unregister(local->hw.wiphy); |
1785 | return result; | 1788 | return result; |
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 55b85ae5bc11..5d7719f44bea 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -651,6 +651,26 @@ static void ieee80211_authenticate(struct net_device *dev, | |||
651 | mod_timer(&ifsta->timer, jiffies + IEEE80211_AUTH_TIMEOUT); | 651 | mod_timer(&ifsta->timer, jiffies + IEEE80211_AUTH_TIMEOUT); |
652 | } | 652 | } |
653 | 653 | ||
654 | static int ieee80211_compatible_rates(struct ieee80211_sta_bss *bss, | ||
655 | struct ieee80211_supported_band *sband, | ||
656 | u64 *rates) | ||
657 | { | ||
658 | int i, j, count; | ||
659 | *rates = 0; | ||
660 | count = 0; | ||
661 | for (i = 0; i < bss->supp_rates_len; i++) { | ||
662 | int rate = (bss->supp_rates[i] & 0x7F) * 5; | ||
663 | |||
664 | for (j = 0; j < sband->n_bitrates; j++) | ||
665 | if (sband->bitrates[j].bitrate == rate) { | ||
666 | *rates |= BIT(j); | ||
667 | count++; | ||
668 | break; | ||
669 | } | ||
670 | } | ||
671 | |||
672 | return count; | ||
673 | } | ||
654 | 674 | ||
655 | static void ieee80211_send_assoc(struct net_device *dev, | 675 | static void ieee80211_send_assoc(struct net_device *dev, |
656 | struct ieee80211_if_sta *ifsta) | 676 | struct ieee80211_if_sta *ifsta) |
@@ -659,11 +679,12 @@ static void ieee80211_send_assoc(struct net_device *dev, | |||
659 | struct sk_buff *skb; | 679 | struct sk_buff *skb; |
660 | struct ieee80211_mgmt *mgmt; | 680 | struct ieee80211_mgmt *mgmt; |
661 | u8 *pos, *ies; | 681 | u8 *pos, *ies; |
662 | int i, len; | 682 | int i, len, count, rates_len, supp_rates_len; |
663 | u16 capab; | 683 | u16 capab; |
664 | struct ieee80211_sta_bss *bss; | 684 | struct ieee80211_sta_bss *bss; |
665 | int wmm = 0; | 685 | int wmm = 0; |
666 | struct ieee80211_supported_band *sband; | 686 | struct ieee80211_supported_band *sband; |
687 | u64 rates = 0; | ||
667 | 688 | ||
668 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + | 689 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + |
669 | sizeof(*mgmt) + 200 + ifsta->extra_ie_len + | 690 | sizeof(*mgmt) + 200 + ifsta->extra_ie_len + |
@@ -725,24 +746,39 @@ static void ieee80211_send_assoc(struct net_device *dev, | |||
725 | *pos++ = ifsta->ssid_len; | 746 | *pos++ = ifsta->ssid_len; |
726 | memcpy(pos, ifsta->ssid, ifsta->ssid_len); | 747 | memcpy(pos, ifsta->ssid, ifsta->ssid_len); |
727 | 748 | ||
749 | /* all supported rates should be added here but some APs | ||
750 | * (e.g. D-Link DAP 1353 in b-only mode) don't like that | ||
751 | * Therefore only add rates the AP supports */ | ||
752 | rates_len = ieee80211_compatible_rates(bss, sband, &rates); | ||
753 | supp_rates_len = rates_len; | ||
754 | if (supp_rates_len > 8) | ||
755 | supp_rates_len = 8; | ||
756 | |||
728 | len = sband->n_bitrates; | 757 | len = sband->n_bitrates; |
729 | if (len > 8) | 758 | pos = skb_put(skb, supp_rates_len + 2); |
730 | len = 8; | ||
731 | pos = skb_put(skb, len + 2); | ||
732 | *pos++ = WLAN_EID_SUPP_RATES; | 759 | *pos++ = WLAN_EID_SUPP_RATES; |
733 | *pos++ = len; | 760 | *pos++ = supp_rates_len; |
734 | for (i = 0; i < len; i++) { | ||
735 | int rate = sband->bitrates[i].bitrate; | ||
736 | *pos++ = (u8) (rate / 5); | ||
737 | } | ||
738 | 761 | ||
739 | if (sband->n_bitrates > len) { | 762 | count = 0; |
740 | pos = skb_put(skb, sband->n_bitrates - len + 2); | 763 | for (i = 0; i < sband->n_bitrates; i++) { |
741 | *pos++ = WLAN_EID_EXT_SUPP_RATES; | 764 | if (BIT(i) & rates) { |
742 | *pos++ = sband->n_bitrates - len; | ||
743 | for (i = len; i < sband->n_bitrates; i++) { | ||
744 | int rate = sband->bitrates[i].bitrate; | 765 | int rate = sband->bitrates[i].bitrate; |
745 | *pos++ = (u8) (rate / 5); | 766 | *pos++ = (u8) (rate / 5); |
767 | if (++count == 8) | ||
768 | break; | ||
769 | } | ||
770 | } | ||
771 | |||
772 | if (count == 8) { | ||
773 | pos = skb_put(skb, rates_len - count + 2); | ||
774 | *pos++ = WLAN_EID_EXT_SUPP_RATES; | ||
775 | *pos++ = rates_len - count; | ||
776 | |||
777 | for (i++; i < sband->n_bitrates; i++) { | ||
778 | if (BIT(i) & rates) { | ||
779 | int rate = sband->bitrates[i].bitrate; | ||
780 | *pos++ = (u8) (rate / 5); | ||
781 | } | ||
746 | } | 782 | } |
747 | } | 783 | } |
748 | 784 | ||
diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c index ae75d4178739..ff5c380f3c13 100644 --- a/net/mac80211/rc80211_pid_debugfs.c +++ b/net/mac80211/rc80211_pid_debugfs.c | |||
@@ -85,7 +85,7 @@ static int rate_control_pid_events_open(struct inode *inode, struct file *file) | |||
85 | struct rc_pid_sta_info *sinfo = inode->i_private; | 85 | struct rc_pid_sta_info *sinfo = inode->i_private; |
86 | struct rc_pid_event_buffer *events = &sinfo->events; | 86 | struct rc_pid_event_buffer *events = &sinfo->events; |
87 | struct rc_pid_events_file_info *file_info; | 87 | struct rc_pid_events_file_info *file_info; |
88 | unsigned int status; | 88 | unsigned long status; |
89 | 89 | ||
90 | /* Allocate a state struct */ | 90 | /* Allocate a state struct */ |
91 | file_info = kmalloc(sizeof(*file_info), GFP_KERNEL); | 91 | file_info = kmalloc(sizeof(*file_info), GFP_KERNEL); |
@@ -135,7 +135,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf, | |||
135 | char pb[RC_PID_PRINT_BUF_SIZE]; | 135 | char pb[RC_PID_PRINT_BUF_SIZE]; |
136 | int ret; | 136 | int ret; |
137 | int p; | 137 | int p; |
138 | unsigned int status; | 138 | unsigned long status; |
139 | 139 | ||
140 | /* Check if there is something to read. */ | 140 | /* Check if there is something to read. */ |
141 | if (events->next_entry == file_info->next_entry) { | 141 | if (events->next_entry == file_info->next_entry) { |
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index e8b89c89e875..9b5a3cbec265 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
@@ -1300,11 +1300,11 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx) | |||
1300 | if (is_multicast_ether_addr(skb->data)) { | 1300 | if (is_multicast_ether_addr(skb->data)) { |
1301 | if (*mesh_ttl > 0) { | 1301 | if (*mesh_ttl > 0) { |
1302 | xmit_skb = skb_copy(skb, GFP_ATOMIC); | 1302 | xmit_skb = skb_copy(skb, GFP_ATOMIC); |
1303 | if (!xmit_skb && net_ratelimit()) | 1303 | if (xmit_skb) |
1304 | xmit_skb->pkt_type = PACKET_OTHERHOST; | ||
1305 | else if (net_ratelimit()) | ||
1304 | printk(KERN_DEBUG "%s: failed to clone " | 1306 | printk(KERN_DEBUG "%s: failed to clone " |
1305 | "multicast frame\n", dev->name); | 1307 | "multicast frame\n", dev->name); |
1306 | else | ||
1307 | xmit_skb->pkt_type = PACKET_OTHERHOST; | ||
1308 | } else | 1308 | } else |
1309 | IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.sta, | 1309 | IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.sta, |
1310 | dropped_frames_ttl); | 1310 | dropped_frames_ttl); |
@@ -1390,7 +1390,7 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) | |||
1390 | padding = ((4 - subframe_len) & 0x3); | 1390 | padding = ((4 - subframe_len) & 0x3); |
1391 | /* the last MSDU has no padding */ | 1391 | /* the last MSDU has no padding */ |
1392 | if (subframe_len > remaining) { | 1392 | if (subframe_len > remaining) { |
1393 | printk(KERN_DEBUG "%s: wrong buffer size", dev->name); | 1393 | printk(KERN_DEBUG "%s: wrong buffer size\n", dev->name); |
1394 | return RX_DROP_UNUSABLE; | 1394 | return RX_DROP_UNUSABLE; |
1395 | } | 1395 | } |
1396 | 1396 | ||
@@ -1413,7 +1413,7 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) | |||
1413 | eth = (struct ethhdr *) skb_pull(skb, ntohs(len) + | 1413 | eth = (struct ethhdr *) skb_pull(skb, ntohs(len) + |
1414 | padding); | 1414 | padding); |
1415 | if (!eth) { | 1415 | if (!eth) { |
1416 | printk(KERN_DEBUG "%s: wrong buffer size ", | 1416 | printk(KERN_DEBUG "%s: wrong buffer size\n", |
1417 | dev->name); | 1417 | dev->name); |
1418 | dev_kfree_skb(frame); | 1418 | dev_kfree_skb(frame); |
1419 | return RX_DROP_UNUSABLE; | 1419 | return RX_DROP_UNUSABLE; |
@@ -1947,7 +1947,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
1947 | if (!skb_new) { | 1947 | if (!skb_new) { |
1948 | if (net_ratelimit()) | 1948 | if (net_ratelimit()) |
1949 | printk(KERN_DEBUG "%s: failed to copy " | 1949 | printk(KERN_DEBUG "%s: failed to copy " |
1950 | "multicast frame for %s", | 1950 | "multicast frame for %s\n", |
1951 | wiphy_name(local->hw.wiphy), | 1951 | wiphy_name(local->hw.wiphy), |
1952 | prev->dev->name); | 1952 | prev->dev->name); |
1953 | continue; | 1953 | 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 8ffff27fe000..c87baf4ce979 100644 --- a/net/mac80211/wme.c +++ b/net/mac80211/wme.c | |||
@@ -379,7 +379,8 @@ static int wme_qdiscop_init(struct Qdisc *qd, struct nlattr *opt) | |||
379 | qd->handle); | 379 | qd->handle); |
380 | if (!q->queues[i]) { | 380 | if (!q->queues[i]) { |
381 | q->queues[i] = &noop_qdisc; | 381 | q->queues[i] = &noop_qdisc; |
382 | printk(KERN_ERR "%s child qdisc %i creation failed", dev->name, i); | 382 | printk(KERN_ERR "%s child qdisc %i creation failed\n", |
383 | dev->name, i); | ||
383 | } | 384 | } |
384 | } | 385 | } |
385 | 386 | ||
diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig index c1fc0f1a641c..aa8d80c35e28 100644 --- a/net/netfilter/Kconfig +++ b/net/netfilter/Kconfig | |||
@@ -90,6 +90,7 @@ config NF_CT_PROTO_DCCP | |||
90 | tristate 'DCCP protocol connection tracking support (EXPERIMENTAL)' | 90 | tristate 'DCCP protocol connection tracking support (EXPERIMENTAL)' |
91 | depends on EXPERIMENTAL && NF_CONNTRACK | 91 | depends on EXPERIMENTAL && NF_CONNTRACK |
92 | depends on NETFILTER_ADVANCED | 92 | depends on NETFILTER_ADVANCED |
93 | default IP_DCCP | ||
93 | help | 94 | help |
94 | With this option enabled, the layer 3 independent connection | 95 | With this option enabled, the layer 3 independent connection |
95 | tracking code will be able to do state tracking on DCCP connections. | 96 | tracking code will be able to do state tracking on DCCP connections. |
@@ -104,6 +105,7 @@ config NF_CT_PROTO_SCTP | |||
104 | tristate 'SCTP protocol connection tracking support (EXPERIMENTAL)' | 105 | tristate 'SCTP protocol connection tracking support (EXPERIMENTAL)' |
105 | depends on EXPERIMENTAL && NF_CONNTRACK | 106 | depends on EXPERIMENTAL && NF_CONNTRACK |
106 | depends on NETFILTER_ADVANCED | 107 | depends on NETFILTER_ADVANCED |
108 | default IP_SCTP | ||
107 | help | 109 | help |
108 | With this option enabled, the layer 3 independent connection | 110 | With this option enabled, the layer 3 independent connection |
109 | tracking code will be able to do state tracking on SCTP connections. | 111 | tracking code will be able to do state tracking on SCTP connections. |
@@ -532,6 +534,7 @@ config NETFILTER_XT_MATCH_DCCP | |||
532 | tristate '"dccp" protocol match support' | 534 | tristate '"dccp" protocol match support' |
533 | depends on NETFILTER_XTABLES | 535 | depends on NETFILTER_XTABLES |
534 | depends on NETFILTER_ADVANCED | 536 | depends on NETFILTER_ADVANCED |
537 | default IP_DCCP | ||
535 | help | 538 | help |
536 | With this option enabled, you will be able to use the iptables | 539 | With this option enabled, you will be able to use the iptables |
537 | `dccp' match in order to match on DCCP source/destination ports | 540 | `dccp' match in order to match on DCCP source/destination ports |
@@ -725,6 +728,7 @@ config NETFILTER_XT_MATCH_SCTP | |||
725 | tristate '"sctp" protocol match support (EXPERIMENTAL)' | 728 | tristate '"sctp" protocol match support (EXPERIMENTAL)' |
726 | depends on NETFILTER_XTABLES && EXPERIMENTAL | 729 | depends on NETFILTER_XTABLES && EXPERIMENTAL |
727 | depends on NETFILTER_ADVANCED | 730 | depends on NETFILTER_ADVANCED |
731 | default IP_SCTP | ||
728 | help | 732 | help |
729 | With this option enabled, you will be able to use the | 733 | With this option enabled, you will be able to use the |
730 | `sctp' match in order to match on SCTP source/destination ports | 734 | `sctp' match in order to match on SCTP source/destination ports |
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/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c index 9f4900069561..2f9bbc058b48 100644 --- a/net/netfilter/nf_conntrack_sip.c +++ b/net/netfilter/nf_conntrack_sip.c | |||
@@ -870,6 +870,7 @@ static int process_sdp(struct sk_buff *skb, | |||
870 | { | 870 | { |
871 | enum ip_conntrack_info ctinfo; | 871 | enum ip_conntrack_info ctinfo; |
872 | struct nf_conn *ct = nf_ct_get(skb, &ctinfo); | 872 | struct nf_conn *ct = nf_ct_get(skb, &ctinfo); |
873 | struct nf_conn_help *help = nfct_help(ct); | ||
873 | unsigned int matchoff, matchlen; | 874 | unsigned int matchoff, matchlen; |
874 | unsigned int mediaoff, medialen; | 875 | unsigned int mediaoff, medialen; |
875 | unsigned int sdpoff; | 876 | unsigned int sdpoff; |
@@ -959,6 +960,9 @@ static int process_sdp(struct sk_buff *skb, | |||
959 | if (nf_nat_sdp_session && ct->status & IPS_NAT_MASK) | 960 | if (nf_nat_sdp_session && ct->status & IPS_NAT_MASK) |
960 | ret = nf_nat_sdp_session(skb, dptr, sdpoff, datalen, &rtp_addr); | 961 | ret = nf_nat_sdp_session(skb, dptr, sdpoff, datalen, &rtp_addr); |
961 | 962 | ||
963 | if (ret == NF_ACCEPT && i > 0) | ||
964 | help->help.ct_sip_info.invite_cseq = cseq; | ||
965 | |||
962 | return ret; | 966 | return ret; |
963 | } | 967 | } |
964 | static int process_invite_response(struct sk_buff *skb, | 968 | static int process_invite_response(struct sk_buff *skb, |
@@ -967,14 +971,14 @@ static int process_invite_response(struct sk_buff *skb, | |||
967 | { | 971 | { |
968 | enum ip_conntrack_info ctinfo; | 972 | enum ip_conntrack_info ctinfo; |
969 | struct nf_conn *ct = nf_ct_get(skb, &ctinfo); | 973 | struct nf_conn *ct = nf_ct_get(skb, &ctinfo); |
974 | struct nf_conn_help *help = nfct_help(ct); | ||
970 | 975 | ||
971 | if ((code >= 100 && code <= 199) || | 976 | if ((code >= 100 && code <= 199) || |
972 | (code >= 200 && code <= 299)) | 977 | (code >= 200 && code <= 299)) |
973 | return process_sdp(skb, dptr, datalen, cseq); | 978 | return process_sdp(skb, dptr, datalen, cseq); |
974 | else { | 979 | else if (help->help.ct_sip_info.invite_cseq == cseq) |
975 | flush_expectations(ct, true); | 980 | flush_expectations(ct, true); |
976 | return NF_ACCEPT; | 981 | return NF_ACCEPT; |
977 | } | ||
978 | } | 982 | } |
979 | 983 | ||
980 | static int process_update_response(struct sk_buff *skb, | 984 | static int process_update_response(struct sk_buff *skb, |
@@ -983,14 +987,14 @@ static int process_update_response(struct sk_buff *skb, | |||
983 | { | 987 | { |
984 | enum ip_conntrack_info ctinfo; | 988 | enum ip_conntrack_info ctinfo; |
985 | struct nf_conn *ct = nf_ct_get(skb, &ctinfo); | 989 | struct nf_conn *ct = nf_ct_get(skb, &ctinfo); |
990 | struct nf_conn_help *help = nfct_help(ct); | ||
986 | 991 | ||
987 | if ((code >= 100 && code <= 199) || | 992 | if ((code >= 100 && code <= 199) || |
988 | (code >= 200 && code <= 299)) | 993 | (code >= 200 && code <= 299)) |
989 | return process_sdp(skb, dptr, datalen, cseq); | 994 | return process_sdp(skb, dptr, datalen, cseq); |
990 | else { | 995 | else if (help->help.ct_sip_info.invite_cseq == cseq) |
991 | flush_expectations(ct, true); | 996 | flush_expectations(ct, true); |
992 | return NF_ACCEPT; | 997 | return NF_ACCEPT; |
993 | } | ||
994 | } | 998 | } |
995 | 999 | ||
996 | static int process_prack_response(struct sk_buff *skb, | 1000 | static int process_prack_response(struct sk_buff *skb, |
@@ -999,14 +1003,14 @@ static int process_prack_response(struct sk_buff *skb, | |||
999 | { | 1003 | { |
1000 | enum ip_conntrack_info ctinfo; | 1004 | enum ip_conntrack_info ctinfo; |
1001 | struct nf_conn *ct = nf_ct_get(skb, &ctinfo); | 1005 | struct nf_conn *ct = nf_ct_get(skb, &ctinfo); |
1006 | struct nf_conn_help *help = nfct_help(ct); | ||
1002 | 1007 | ||
1003 | if ((code >= 100 && code <= 199) || | 1008 | if ((code >= 100 && code <= 199) || |
1004 | (code >= 200 && code <= 299)) | 1009 | (code >= 200 && code <= 299)) |
1005 | return process_sdp(skb, dptr, datalen, cseq); | 1010 | return process_sdp(skb, dptr, datalen, cseq); |
1006 | else { | 1011 | else if (help->help.ct_sip_info.invite_cseq == cseq) |
1007 | flush_expectations(ct, true); | 1012 | flush_expectations(ct, true); |
1008 | return NF_ACCEPT; | 1013 | return NF_ACCEPT; |
1009 | } | ||
1010 | } | 1014 | } |
1011 | 1015 | ||
1012 | static int process_bye_request(struct sk_buff *skb, | 1016 | static int process_bye_request(struct sk_buff *skb, |
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/sched/act_simple.c b/net/sched/act_simple.c index 64b2d136c78e..1d421d059caf 100644 --- a/net/sched/act_simple.c +++ b/net/sched/act_simple.c | |||
@@ -6,7 +6,7 @@ | |||
6 | * as published by the Free Software Foundation; either version | 6 | * as published by the Free Software Foundation; either version |
7 | * 2 of the License, or (at your option) any later version. | 7 | * 2 of the License, or (at your option) any later version. |
8 | * | 8 | * |
9 | * Authors: Jamal Hadi Salim (2005) | 9 | * Authors: Jamal Hadi Salim (2005-8) |
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
@@ -34,6 +34,7 @@ static struct tcf_hashinfo simp_hash_info = { | |||
34 | .lock = &simp_lock, | 34 | .lock = &simp_lock, |
35 | }; | 35 | }; |
36 | 36 | ||
37 | #define SIMP_MAX_DATA 32 | ||
37 | static int tcf_simp(struct sk_buff *skb, struct tc_action *a, struct tcf_result *res) | 38 | static int tcf_simp(struct sk_buff *skb, struct tc_action *a, struct tcf_result *res) |
38 | { | 39 | { |
39 | struct tcf_defact *d = a->priv; | 40 | struct tcf_defact *d = a->priv; |
@@ -69,23 +70,28 @@ static int tcf_simp_release(struct tcf_defact *d, int bind) | |||
69 | return ret; | 70 | return ret; |
70 | } | 71 | } |
71 | 72 | ||
72 | static int alloc_defdata(struct tcf_defact *d, u32 datalen, void *defdata) | 73 | static int alloc_defdata(struct tcf_defact *d, char *defdata) |
73 | { | 74 | { |
74 | d->tcfd_defdata = kmemdup(defdata, datalen, GFP_KERNEL); | 75 | d->tcfd_defdata = kstrndup(defdata, SIMP_MAX_DATA, GFP_KERNEL); |
75 | if (unlikely(!d->tcfd_defdata)) | 76 | if (unlikely(!d->tcfd_defdata)) |
76 | return -ENOMEM; | 77 | return -ENOMEM; |
77 | d->tcfd_datalen = datalen; | 78 | |
78 | return 0; | 79 | return 0; |
79 | } | 80 | } |
80 | 81 | ||
81 | static int realloc_defdata(struct tcf_defact *d, u32 datalen, void *defdata) | 82 | static void reset_policy(struct tcf_defact *d, char *defdata, |
83 | struct tc_defact *p) | ||
82 | { | 84 | { |
83 | kfree(d->tcfd_defdata); | 85 | spin_lock_bh(&d->tcf_lock); |
84 | return alloc_defdata(d, datalen, defdata); | 86 | d->tcf_action = p->action; |
87 | memset(d->tcfd_defdata, 0, SIMP_MAX_DATA); | ||
88 | strlcpy(d->tcfd_defdata, defdata, SIMP_MAX_DATA); | ||
89 | spin_unlock_bh(&d->tcf_lock); | ||
85 | } | 90 | } |
86 | 91 | ||
87 | static const struct nla_policy simple_policy[TCA_DEF_MAX + 1] = { | 92 | static const struct nla_policy simple_policy[TCA_DEF_MAX + 1] = { |
88 | [TCA_DEF_PARMS] = { .len = sizeof(struct tc_defact) }, | 93 | [TCA_DEF_PARMS] = { .len = sizeof(struct tc_defact) }, |
94 | [TCA_DEF_DATA] = { .type = NLA_STRING, .len = SIMP_MAX_DATA }, | ||
89 | }; | 95 | }; |
90 | 96 | ||
91 | static int tcf_simp_init(struct nlattr *nla, struct nlattr *est, | 97 | static int tcf_simp_init(struct nlattr *nla, struct nlattr *est, |
@@ -95,28 +101,24 @@ static int tcf_simp_init(struct nlattr *nla, struct nlattr *est, | |||
95 | struct tc_defact *parm; | 101 | struct tc_defact *parm; |
96 | struct tcf_defact *d; | 102 | struct tcf_defact *d; |
97 | struct tcf_common *pc; | 103 | struct tcf_common *pc; |
98 | void *defdata; | 104 | char *defdata; |
99 | u32 datalen = 0; | ||
100 | int ret = 0, err; | 105 | int ret = 0, err; |
101 | 106 | ||
102 | if (nla == NULL) | 107 | if (nla == NULL) |
103 | return -EINVAL; | 108 | return -EINVAL; |
104 | 109 | ||
105 | err = nla_parse_nested(tb, TCA_DEF_MAX, nla, NULL); | 110 | err = nla_parse_nested(tb, TCA_DEF_MAX, nla, simple_policy); |
106 | if (err < 0) | 111 | if (err < 0) |
107 | return err; | 112 | return err; |
108 | 113 | ||
109 | if (tb[TCA_DEF_PARMS] == NULL) | 114 | if (tb[TCA_DEF_PARMS] == NULL) |
110 | return -EINVAL; | 115 | return -EINVAL; |
111 | 116 | ||
112 | parm = nla_data(tb[TCA_DEF_PARMS]); | 117 | if (tb[TCA_DEF_DATA] == NULL) |
113 | defdata = nla_data(tb[TCA_DEF_DATA]); | ||
114 | if (defdata == NULL) | ||
115 | return -EINVAL; | 118 | return -EINVAL; |
116 | 119 | ||
117 | datalen = nla_len(tb[TCA_DEF_DATA]); | 120 | parm = nla_data(tb[TCA_DEF_PARMS]); |
118 | if (datalen == 0) | 121 | defdata = nla_data(tb[TCA_DEF_DATA]); |
119 | return -EINVAL; | ||
120 | 122 | ||
121 | pc = tcf_hash_check(parm->index, a, bind, &simp_hash_info); | 123 | pc = tcf_hash_check(parm->index, a, bind, &simp_hash_info); |
122 | if (!pc) { | 124 | if (!pc) { |
@@ -126,11 +128,12 @@ static int tcf_simp_init(struct nlattr *nla, struct nlattr *est, | |||
126 | return -ENOMEM; | 128 | return -ENOMEM; |
127 | 129 | ||
128 | d = to_defact(pc); | 130 | d = to_defact(pc); |
129 | ret = alloc_defdata(d, datalen, defdata); | 131 | ret = alloc_defdata(d, defdata); |
130 | if (ret < 0) { | 132 | if (ret < 0) { |
131 | kfree(pc); | 133 | kfree(pc); |
132 | return ret; | 134 | return ret; |
133 | } | 135 | } |
136 | d->tcf_action = parm->action; | ||
134 | ret = ACT_P_CREATED; | 137 | ret = ACT_P_CREATED; |
135 | } else { | 138 | } else { |
136 | d = to_defact(pc); | 139 | d = to_defact(pc); |
@@ -138,13 +141,9 @@ static int tcf_simp_init(struct nlattr *nla, struct nlattr *est, | |||
138 | tcf_simp_release(d, bind); | 141 | tcf_simp_release(d, bind); |
139 | return -EEXIST; | 142 | return -EEXIST; |
140 | } | 143 | } |
141 | realloc_defdata(d, datalen, defdata); | 144 | reset_policy(d, defdata, parm); |
142 | } | 145 | } |
143 | 146 | ||
144 | spin_lock_bh(&d->tcf_lock); | ||
145 | d->tcf_action = parm->action; | ||
146 | spin_unlock_bh(&d->tcf_lock); | ||
147 | |||
148 | if (ret == ACT_P_CREATED) | 147 | if (ret == ACT_P_CREATED) |
149 | tcf_hash_insert(pc, &simp_hash_info); | 148 | tcf_hash_insert(pc, &simp_hash_info); |
150 | return ret; | 149 | return ret; |
@@ -172,7 +171,7 @@ static inline int tcf_simp_dump(struct sk_buff *skb, struct tc_action *a, | |||
172 | opt.bindcnt = d->tcf_bindcnt - bind; | 171 | opt.bindcnt = d->tcf_bindcnt - bind; |
173 | opt.action = d->tcf_action; | 172 | opt.action = d->tcf_action; |
174 | NLA_PUT(skb, TCA_DEF_PARMS, sizeof(opt), &opt); | 173 | NLA_PUT(skb, TCA_DEF_PARMS, sizeof(opt), &opt); |
175 | NLA_PUT(skb, TCA_DEF_DATA, d->tcfd_datalen, d->tcfd_defdata); | 174 | NLA_PUT_STRING(skb, TCA_DEF_DATA, d->tcfd_defdata); |
176 | t.install = jiffies_to_clock_t(jiffies - d->tcf_tm.install); | 175 | t.install = jiffies_to_clock_t(jiffies - d->tcf_tm.install); |
177 | t.lastuse = jiffies_to_clock_t(jiffies - d->tcf_tm.lastuse); | 176 | t.lastuse = jiffies_to_clock_t(jiffies - d->tcf_tm.lastuse); |
178 | t.expires = jiffies_to_clock_t(d->tcf_tm.expires); | 177 | t.expires = jiffies_to_clock_t(d->tcf_tm.expires); |
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c index 66148cc4759e..5bc1ed490180 100644 --- a/net/sched/sch_htb.c +++ b/net/sched/sch_htb.c | |||
@@ -1197,12 +1197,16 @@ static inline int htb_parent_last_child(struct htb_class *cl) | |||
1197 | return 1; | 1197 | return 1; |
1198 | } | 1198 | } |
1199 | 1199 | ||
1200 | static void htb_parent_to_leaf(struct htb_class *cl, struct Qdisc *new_q) | 1200 | static void htb_parent_to_leaf(struct htb_sched *q, struct htb_class *cl, |
1201 | struct Qdisc *new_q) | ||
1201 | { | 1202 | { |
1202 | struct htb_class *parent = cl->parent; | 1203 | struct htb_class *parent = cl->parent; |
1203 | 1204 | ||
1204 | BUG_TRAP(!cl->level && cl->un.leaf.q && !cl->prio_activity); | 1205 | BUG_TRAP(!cl->level && cl->un.leaf.q && !cl->prio_activity); |
1205 | 1206 | ||
1207 | if (parent->cmode != HTB_CAN_SEND) | ||
1208 | htb_safe_rb_erase(&parent->pq_node, q->wait_pq + parent->level); | ||
1209 | |||
1206 | parent->level = 0; | 1210 | parent->level = 0; |
1207 | memset(&parent->un.inner, 0, sizeof(parent->un.inner)); | 1211 | memset(&parent->un.inner, 0, sizeof(parent->un.inner)); |
1208 | INIT_LIST_HEAD(&parent->un.leaf.drop_list); | 1212 | INIT_LIST_HEAD(&parent->un.leaf.drop_list); |
@@ -1300,7 +1304,7 @@ static int htb_delete(struct Qdisc *sch, unsigned long arg) | |||
1300 | htb_deactivate(q, cl); | 1304 | htb_deactivate(q, cl); |
1301 | 1305 | ||
1302 | if (last_child) | 1306 | if (last_child) |
1303 | htb_parent_to_leaf(cl, new_q); | 1307 | htb_parent_to_leaf(q, cl, new_q); |
1304 | 1308 | ||
1305 | if (--cl->refcnt == 0) | 1309 | if (--cl->refcnt == 0) |
1306 | htb_destroy_class(sch, cl); | 1310 | htb_destroy_class(sch, cl); |
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/sunrpc/svc.c b/net/sunrpc/svc.c index d74c2d269539..01c7e311b904 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/mm.h> | 18 | #include <linux/mm.h> |
19 | #include <linux/interrupt.h> | 19 | #include <linux/interrupt.h> |
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/sched.h> | ||
22 | 21 | ||
23 | #include <linux/sunrpc/types.h> | 22 | #include <linux/sunrpc/types.h> |
24 | #include <linux/sunrpc/xdr.h> | 23 | #include <linux/sunrpc/xdr.h> |
diff --git a/net/tipc/core.h b/net/tipc/core.h index 0d783bcc6f9a..bd78d1705c0f 100644 --- a/net/tipc/core.h +++ b/net/tipc/core.h | |||
@@ -303,15 +303,14 @@ static inline void k_term_timer(struct timer_list *timer) | |||
303 | /* | 303 | /* |
304 | * TIPC message buffer code | 304 | * TIPC message buffer code |
305 | * | 305 | * |
306 | * TIPC message buffer headroom reserves space for a link-level header | 306 | * TIPC message buffer headroom reserves space for the worst-case |
307 | * (in case the message is sent off-node), | 307 | * link-level device header (in case the message is sent off-node). |
308 | * while ensuring TIPC header is word aligned for quicker access | ||
309 | * | 308 | * |
310 | * The largest header currently supported is 18 bytes, which is used when | 309 | * Note: Headroom should be a multiple of 4 to ensure the TIPC header fields |
311 | * the standard 14 byte Ethernet header has 4 added bytes for VLAN info | 310 | * are word aligned for quicker access |
312 | */ | 311 | */ |
313 | 312 | ||
314 | #define BUF_HEADROOM 20u | 313 | #define BUF_HEADROOM LL_MAX_HEADER |
315 | 314 | ||
316 | struct tipc_skb_cb { | 315 | struct tipc_skb_cb { |
317 | void *handle; | 316 | void *handle; |
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 | ||