Contents of /trunk/kernel-magellan/patches-3.12/0103-3.12.4-all-fixes.patch
Parent Directory | Revision Log
Revision 2384 -
(show annotations)
(download)
Tue Jan 28 08:29:00 2014 UTC (10 years, 8 months ago) by niro
File size: 152481 byte(s)
Tue Jan 28 08:29:00 2014 UTC (10 years, 8 months ago) by niro
File size: 152481 byte(s)
-linux-3.12.4
1 | diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt |
2 | index a46d78583ae1..7d8dc93fe2eb 100644 |
3 | --- a/Documentation/networking/ip-sysctl.txt |
4 | +++ b/Documentation/networking/ip-sysctl.txt |
5 | @@ -588,9 +588,6 @@ tcp_limit_output_bytes - INTEGER |
6 | typical pfifo_fast qdiscs. |
7 | tcp_limit_output_bytes limits the number of bytes on qdisc |
8 | or device to reduce artificial RTT/cwnd and reduce bufferbloat. |
9 | - Note: For GSO/TSO enabled flows, we try to have at least two |
10 | - packets in flight. Reducing tcp_limit_output_bytes might also |
11 | - reduce the size of individual GSO packet (64KB being the max) |
12 | Default: 131072 |
13 | |
14 | tcp_challenge_ack_limit - INTEGER |
15 | diff --git a/Makefile b/Makefile |
16 | index b28bc57d1769..3b7165eb4734 100644 |
17 | --- a/Makefile |
18 | +++ b/Makefile |
19 | @@ -1,6 +1,6 @@ |
20 | VERSION = 3 |
21 | PATCHLEVEL = 12 |
22 | -SUBLEVEL = 3 |
23 | +SUBLEVEL = 4 |
24 | EXTRAVERSION = |
25 | NAME = One Giant Leap for Frogkind |
26 | |
27 | diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c |
28 | index 516593e1ce33..26328e800869 100644 |
29 | --- a/arch/x86/net/bpf_jit_comp.c |
30 | +++ b/arch/x86/net/bpf_jit_comp.c |
31 | @@ -788,5 +788,7 @@ void bpf_jit_free(struct sk_filter *fp) |
32 | if (fp->bpf_func != sk_run_filter) { |
33 | INIT_WORK(&fp->work, bpf_jit_free_deferred); |
34 | schedule_work(&fp->work); |
35 | + } else { |
36 | + kfree(fp); |
37 | } |
38 | } |
39 | diff --git a/block/blk-core.c b/block/blk-core.c |
40 | index 0c611d89d748..fce4b9387f36 100644 |
41 | --- a/block/blk-core.c |
42 | +++ b/block/blk-core.c |
43 | @@ -741,9 +741,17 @@ blk_init_allocated_queue(struct request_queue *q, request_fn_proc *rfn, |
44 | |
45 | q->sg_reserved_size = INT_MAX; |
46 | |
47 | + /* Protect q->elevator from elevator_change */ |
48 | + mutex_lock(&q->sysfs_lock); |
49 | + |
50 | /* init elevator */ |
51 | - if (elevator_init(q, NULL)) |
52 | + if (elevator_init(q, NULL)) { |
53 | + mutex_unlock(&q->sysfs_lock); |
54 | return NULL; |
55 | + } |
56 | + |
57 | + mutex_unlock(&q->sysfs_lock); |
58 | + |
59 | return q; |
60 | } |
61 | EXPORT_SYMBOL(blk_init_allocated_queue); |
62 | diff --git a/block/elevator.c b/block/elevator.c |
63 | index 2bcbd8cc14d4..b7ff2861b6bd 100644 |
64 | --- a/block/elevator.c |
65 | +++ b/block/elevator.c |
66 | @@ -186,6 +186,12 @@ int elevator_init(struct request_queue *q, char *name) |
67 | struct elevator_type *e = NULL; |
68 | int err; |
69 | |
70 | + /* |
71 | + * q->sysfs_lock must be held to provide mutual exclusion between |
72 | + * elevator_switch() and here. |
73 | + */ |
74 | + lockdep_assert_held(&q->sysfs_lock); |
75 | + |
76 | if (unlikely(q->elevator)) |
77 | return 0; |
78 | |
79 | @@ -959,7 +965,7 @@ fail_init: |
80 | /* |
81 | * Switch this queue to the given IO scheduler. |
82 | */ |
83 | -int elevator_change(struct request_queue *q, const char *name) |
84 | +static int __elevator_change(struct request_queue *q, const char *name) |
85 | { |
86 | char elevator_name[ELV_NAME_MAX]; |
87 | struct elevator_type *e; |
88 | @@ -981,6 +987,18 @@ int elevator_change(struct request_queue *q, const char *name) |
89 | |
90 | return elevator_switch(q, e); |
91 | } |
92 | + |
93 | +int elevator_change(struct request_queue *q, const char *name) |
94 | +{ |
95 | + int ret; |
96 | + |
97 | + /* Protect q->elevator from elevator_init() */ |
98 | + mutex_lock(&q->sysfs_lock); |
99 | + ret = __elevator_change(q, name); |
100 | + mutex_unlock(&q->sysfs_lock); |
101 | + |
102 | + return ret; |
103 | +} |
104 | EXPORT_SYMBOL(elevator_change); |
105 | |
106 | ssize_t elv_iosched_store(struct request_queue *q, const char *name, |
107 | @@ -991,7 +1009,7 @@ ssize_t elv_iosched_store(struct request_queue *q, const char *name, |
108 | if (!q->elevator) |
109 | return count; |
110 | |
111 | - ret = elevator_change(q, name); |
112 | + ret = __elevator_change(q, name); |
113 | if (!ret) |
114 | return count; |
115 | |
116 | diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c |
117 | index 0262210cad38..850246206b12 100644 |
118 | --- a/crypto/algif_hash.c |
119 | +++ b/crypto/algif_hash.c |
120 | @@ -114,6 +114,9 @@ static ssize_t hash_sendpage(struct socket *sock, struct page *page, |
121 | struct hash_ctx *ctx = ask->private; |
122 | int err; |
123 | |
124 | + if (flags & MSG_SENDPAGE_NOTLAST) |
125 | + flags |= MSG_MORE; |
126 | + |
127 | lock_sock(sk); |
128 | sg_init_table(ctx->sgl.sg, 1); |
129 | sg_set_page(ctx->sgl.sg, page, size, offset); |
130 | @@ -161,8 +164,6 @@ static int hash_recvmsg(struct kiocb *unused, struct socket *sock, |
131 | else if (len < ds) |
132 | msg->msg_flags |= MSG_TRUNC; |
133 | |
134 | - msg->msg_namelen = 0; |
135 | - |
136 | lock_sock(sk); |
137 | if (ctx->more) { |
138 | ctx->more = 0; |
139 | diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c |
140 | index a1c4f0a55583..a19c027b29bd 100644 |
141 | --- a/crypto/algif_skcipher.c |
142 | +++ b/crypto/algif_skcipher.c |
143 | @@ -378,6 +378,9 @@ static ssize_t skcipher_sendpage(struct socket *sock, struct page *page, |
144 | struct skcipher_sg_list *sgl; |
145 | int err = -EINVAL; |
146 | |
147 | + if (flags & MSG_SENDPAGE_NOTLAST) |
148 | + flags |= MSG_MORE; |
149 | + |
150 | lock_sock(sk); |
151 | if (!ctx->more && ctx->used) |
152 | goto unlock; |
153 | @@ -432,7 +435,6 @@ static int skcipher_recvmsg(struct kiocb *unused, struct socket *sock, |
154 | long copied = 0; |
155 | |
156 | lock_sock(sk); |
157 | - msg->msg_namelen = 0; |
158 | for (iov = msg->msg_iov, iovlen = msg->msg_iovlen; iovlen > 0; |
159 | iovlen--, iov++) { |
160 | unsigned long seglen = iov->iov_len; |
161 | diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c |
162 | index 272f00927761..1bdf104e90bb 100644 |
163 | --- a/drivers/atm/idt77252.c |
164 | +++ b/drivers/atm/idt77252.c |
165 | @@ -3511,7 +3511,7 @@ static int init_card(struct atm_dev *dev) |
166 | tmp = dev_get_by_name(&init_net, tname); /* jhs: was "tmp = dev_get(tname);" */ |
167 | if (tmp) { |
168 | memcpy(card->atmdev->esi, tmp->dev_addr, 6); |
169 | - |
170 | + dev_put(tmp); |
171 | printk("%s: ESI %pM\n", card->name, card->atmdev->esi); |
172 | } |
173 | /* |
174 | diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c |
175 | index c73fc2b74de2..18c5b9b16645 100644 |
176 | --- a/drivers/connector/cn_proc.c |
177 | +++ b/drivers/connector/cn_proc.c |
178 | @@ -32,11 +32,23 @@ |
179 | #include <linux/atomic.h> |
180 | #include <linux/pid_namespace.h> |
181 | |
182 | -#include <asm/unaligned.h> |
183 | - |
184 | #include <linux/cn_proc.h> |
185 | |
186 | -#define CN_PROC_MSG_SIZE (sizeof(struct cn_msg) + sizeof(struct proc_event)) |
187 | +/* |
188 | + * Size of a cn_msg followed by a proc_event structure. Since the |
189 | + * sizeof struct cn_msg is a multiple of 4 bytes, but not 8 bytes, we |
190 | + * add one 4-byte word to the size here, and then start the actual |
191 | + * cn_msg structure 4 bytes into the stack buffer. The result is that |
192 | + * the immediately following proc_event structure is aligned to 8 bytes. |
193 | + */ |
194 | +#define CN_PROC_MSG_SIZE (sizeof(struct cn_msg) + sizeof(struct proc_event) + 4) |
195 | + |
196 | +/* See comment above; we test our assumption about sizeof struct cn_msg here. */ |
197 | +static inline struct cn_msg *buffer_to_cn_msg(__u8 *buffer) |
198 | +{ |
199 | + BUILD_BUG_ON(sizeof(struct cn_msg) != 20); |
200 | + return (struct cn_msg *)(buffer + 4); |
201 | +} |
202 | |
203 | static atomic_t proc_event_num_listeners = ATOMIC_INIT(0); |
204 | static struct cb_id cn_proc_event_id = { CN_IDX_PROC, CN_VAL_PROC }; |
205 | @@ -56,19 +68,19 @@ void proc_fork_connector(struct task_struct *task) |
206 | { |
207 | struct cn_msg *msg; |
208 | struct proc_event *ev; |
209 | - __u8 buffer[CN_PROC_MSG_SIZE]; |
210 | + __u8 buffer[CN_PROC_MSG_SIZE] __aligned(8); |
211 | struct timespec ts; |
212 | struct task_struct *parent; |
213 | |
214 | if (atomic_read(&proc_event_num_listeners) < 1) |
215 | return; |
216 | |
217 | - msg = (struct cn_msg *)buffer; |
218 | + msg = buffer_to_cn_msg(buffer); |
219 | ev = (struct proc_event *)msg->data; |
220 | memset(&ev->event_data, 0, sizeof(ev->event_data)); |
221 | get_seq(&msg->seq, &ev->cpu); |
222 | ktime_get_ts(&ts); /* get high res monotonic timestamp */ |
223 | - put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); |
224 | + ev->timestamp_ns = timespec_to_ns(&ts); |
225 | ev->what = PROC_EVENT_FORK; |
226 | rcu_read_lock(); |
227 | parent = rcu_dereference(task->real_parent); |
228 | @@ -91,17 +103,17 @@ void proc_exec_connector(struct task_struct *task) |
229 | struct cn_msg *msg; |
230 | struct proc_event *ev; |
231 | struct timespec ts; |
232 | - __u8 buffer[CN_PROC_MSG_SIZE]; |
233 | + __u8 buffer[CN_PROC_MSG_SIZE] __aligned(8); |
234 | |
235 | if (atomic_read(&proc_event_num_listeners) < 1) |
236 | return; |
237 | |
238 | - msg = (struct cn_msg *)buffer; |
239 | + msg = buffer_to_cn_msg(buffer); |
240 | ev = (struct proc_event *)msg->data; |
241 | memset(&ev->event_data, 0, sizeof(ev->event_data)); |
242 | get_seq(&msg->seq, &ev->cpu); |
243 | ktime_get_ts(&ts); /* get high res monotonic timestamp */ |
244 | - put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); |
245 | + ev->timestamp_ns = timespec_to_ns(&ts); |
246 | ev->what = PROC_EVENT_EXEC; |
247 | ev->event_data.exec.process_pid = task->pid; |
248 | ev->event_data.exec.process_tgid = task->tgid; |
249 | @@ -117,14 +129,14 @@ void proc_id_connector(struct task_struct *task, int which_id) |
250 | { |
251 | struct cn_msg *msg; |
252 | struct proc_event *ev; |
253 | - __u8 buffer[CN_PROC_MSG_SIZE]; |
254 | + __u8 buffer[CN_PROC_MSG_SIZE] __aligned(8); |
255 | struct timespec ts; |
256 | const struct cred *cred; |
257 | |
258 | if (atomic_read(&proc_event_num_listeners) < 1) |
259 | return; |
260 | |
261 | - msg = (struct cn_msg *)buffer; |
262 | + msg = buffer_to_cn_msg(buffer); |
263 | ev = (struct proc_event *)msg->data; |
264 | memset(&ev->event_data, 0, sizeof(ev->event_data)); |
265 | ev->what = which_id; |
266 | @@ -145,7 +157,7 @@ void proc_id_connector(struct task_struct *task, int which_id) |
267 | rcu_read_unlock(); |
268 | get_seq(&msg->seq, &ev->cpu); |
269 | ktime_get_ts(&ts); /* get high res monotonic timestamp */ |
270 | - put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); |
271 | + ev->timestamp_ns = timespec_to_ns(&ts); |
272 | |
273 | memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); |
274 | msg->ack = 0; /* not used */ |
275 | @@ -159,17 +171,17 @@ void proc_sid_connector(struct task_struct *task) |
276 | struct cn_msg *msg; |
277 | struct proc_event *ev; |
278 | struct timespec ts; |
279 | - __u8 buffer[CN_PROC_MSG_SIZE]; |
280 | + __u8 buffer[CN_PROC_MSG_SIZE] __aligned(8); |
281 | |
282 | if (atomic_read(&proc_event_num_listeners) < 1) |
283 | return; |
284 | |
285 | - msg = (struct cn_msg *)buffer; |
286 | + msg = buffer_to_cn_msg(buffer); |
287 | ev = (struct proc_event *)msg->data; |
288 | memset(&ev->event_data, 0, sizeof(ev->event_data)); |
289 | get_seq(&msg->seq, &ev->cpu); |
290 | ktime_get_ts(&ts); /* get high res monotonic timestamp */ |
291 | - put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); |
292 | + ev->timestamp_ns = timespec_to_ns(&ts); |
293 | ev->what = PROC_EVENT_SID; |
294 | ev->event_data.sid.process_pid = task->pid; |
295 | ev->event_data.sid.process_tgid = task->tgid; |
296 | @@ -186,17 +198,17 @@ void proc_ptrace_connector(struct task_struct *task, int ptrace_id) |
297 | struct cn_msg *msg; |
298 | struct proc_event *ev; |
299 | struct timespec ts; |
300 | - __u8 buffer[CN_PROC_MSG_SIZE]; |
301 | + __u8 buffer[CN_PROC_MSG_SIZE] __aligned(8); |
302 | |
303 | if (atomic_read(&proc_event_num_listeners) < 1) |
304 | return; |
305 | |
306 | - msg = (struct cn_msg *)buffer; |
307 | + msg = buffer_to_cn_msg(buffer); |
308 | ev = (struct proc_event *)msg->data; |
309 | memset(&ev->event_data, 0, sizeof(ev->event_data)); |
310 | get_seq(&msg->seq, &ev->cpu); |
311 | ktime_get_ts(&ts); /* get high res monotonic timestamp */ |
312 | - put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); |
313 | + ev->timestamp_ns = timespec_to_ns(&ts); |
314 | ev->what = PROC_EVENT_PTRACE; |
315 | ev->event_data.ptrace.process_pid = task->pid; |
316 | ev->event_data.ptrace.process_tgid = task->tgid; |
317 | @@ -221,17 +233,17 @@ void proc_comm_connector(struct task_struct *task) |
318 | struct cn_msg *msg; |
319 | struct proc_event *ev; |
320 | struct timespec ts; |
321 | - __u8 buffer[CN_PROC_MSG_SIZE]; |
322 | + __u8 buffer[CN_PROC_MSG_SIZE] __aligned(8); |
323 | |
324 | if (atomic_read(&proc_event_num_listeners) < 1) |
325 | return; |
326 | |
327 | - msg = (struct cn_msg *)buffer; |
328 | + msg = buffer_to_cn_msg(buffer); |
329 | ev = (struct proc_event *)msg->data; |
330 | memset(&ev->event_data, 0, sizeof(ev->event_data)); |
331 | get_seq(&msg->seq, &ev->cpu); |
332 | ktime_get_ts(&ts); /* get high res monotonic timestamp */ |
333 | - put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); |
334 | + ev->timestamp_ns = timespec_to_ns(&ts); |
335 | ev->what = PROC_EVENT_COMM; |
336 | ev->event_data.comm.process_pid = task->pid; |
337 | ev->event_data.comm.process_tgid = task->tgid; |
338 | @@ -248,18 +260,18 @@ void proc_coredump_connector(struct task_struct *task) |
339 | { |
340 | struct cn_msg *msg; |
341 | struct proc_event *ev; |
342 | - __u8 buffer[CN_PROC_MSG_SIZE]; |
343 | + __u8 buffer[CN_PROC_MSG_SIZE] __aligned(8); |
344 | struct timespec ts; |
345 | |
346 | if (atomic_read(&proc_event_num_listeners) < 1) |
347 | return; |
348 | |
349 | - msg = (struct cn_msg *)buffer; |
350 | + msg = buffer_to_cn_msg(buffer); |
351 | ev = (struct proc_event *)msg->data; |
352 | memset(&ev->event_data, 0, sizeof(ev->event_data)); |
353 | get_seq(&msg->seq, &ev->cpu); |
354 | ktime_get_ts(&ts); /* get high res monotonic timestamp */ |
355 | - put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); |
356 | + ev->timestamp_ns = timespec_to_ns(&ts); |
357 | ev->what = PROC_EVENT_COREDUMP; |
358 | ev->event_data.coredump.process_pid = task->pid; |
359 | ev->event_data.coredump.process_tgid = task->tgid; |
360 | @@ -275,18 +287,18 @@ void proc_exit_connector(struct task_struct *task) |
361 | { |
362 | struct cn_msg *msg; |
363 | struct proc_event *ev; |
364 | - __u8 buffer[CN_PROC_MSG_SIZE]; |
365 | + __u8 buffer[CN_PROC_MSG_SIZE] __aligned(8); |
366 | struct timespec ts; |
367 | |
368 | if (atomic_read(&proc_event_num_listeners) < 1) |
369 | return; |
370 | |
371 | - msg = (struct cn_msg *)buffer; |
372 | + msg = buffer_to_cn_msg(buffer); |
373 | ev = (struct proc_event *)msg->data; |
374 | memset(&ev->event_data, 0, sizeof(ev->event_data)); |
375 | get_seq(&msg->seq, &ev->cpu); |
376 | ktime_get_ts(&ts); /* get high res monotonic timestamp */ |
377 | - put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); |
378 | + ev->timestamp_ns = timespec_to_ns(&ts); |
379 | ev->what = PROC_EVENT_EXIT; |
380 | ev->event_data.exit.process_pid = task->pid; |
381 | ev->event_data.exit.process_tgid = task->tgid; |
382 | @@ -312,18 +324,18 @@ static void cn_proc_ack(int err, int rcvd_seq, int rcvd_ack) |
383 | { |
384 | struct cn_msg *msg; |
385 | struct proc_event *ev; |
386 | - __u8 buffer[CN_PROC_MSG_SIZE]; |
387 | + __u8 buffer[CN_PROC_MSG_SIZE] __aligned(8); |
388 | struct timespec ts; |
389 | |
390 | if (atomic_read(&proc_event_num_listeners) < 1) |
391 | return; |
392 | |
393 | - msg = (struct cn_msg *)buffer; |
394 | + msg = buffer_to_cn_msg(buffer); |
395 | ev = (struct proc_event *)msg->data; |
396 | memset(&ev->event_data, 0, sizeof(ev->event_data)); |
397 | msg->seq = rcvd_seq; |
398 | ktime_get_ts(&ts); /* get high res monotonic timestamp */ |
399 | - put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); |
400 | + ev->timestamp_ns = timespec_to_ns(&ts); |
401 | ev->cpu = -1; |
402 | ev->what = PROC_EVENT_NONE; |
403 | ev->event_data.ack.err = err; |
404 | diff --git a/drivers/gpu/drm/radeon/r600_hdmi.c b/drivers/gpu/drm/radeon/r600_hdmi.c |
405 | index 06022e3b9c3b..615c5b290e78 100644 |
406 | --- a/drivers/gpu/drm/radeon/r600_hdmi.c |
407 | +++ b/drivers/gpu/drm/radeon/r600_hdmi.c |
408 | @@ -24,6 +24,7 @@ |
409 | * Authors: Christian König |
410 | */ |
411 | #include <linux/hdmi.h> |
412 | +#include <linux/gcd.h> |
413 | #include <drm/drmP.h> |
414 | #include <drm/radeon_drm.h> |
415 | #include "radeon.h" |
416 | @@ -57,35 +58,57 @@ enum r600_hdmi_iec_status_bits { |
417 | static const struct radeon_hdmi_acr r600_hdmi_predefined_acr[] = { |
418 | /* 32kHz 44.1kHz 48kHz */ |
419 | /* Clock N CTS N CTS N CTS */ |
420 | - { 25175, 4576, 28125, 7007, 31250, 6864, 28125 }, /* 25,20/1.001 MHz */ |
421 | + { 25175, 4096, 25175, 28224, 125875, 6144, 25175 }, /* 25,20/1.001 MHz */ |
422 | { 25200, 4096, 25200, 6272, 28000, 6144, 25200 }, /* 25.20 MHz */ |
423 | { 27000, 4096, 27000, 6272, 30000, 6144, 27000 }, /* 27.00 MHz */ |
424 | { 27027, 4096, 27027, 6272, 30030, 6144, 27027 }, /* 27.00*1.001 MHz */ |
425 | { 54000, 4096, 54000, 6272, 60000, 6144, 54000 }, /* 54.00 MHz */ |
426 | { 54054, 4096, 54054, 6272, 60060, 6144, 54054 }, /* 54.00*1.001 MHz */ |
427 | - { 74176, 11648, 210937, 17836, 234375, 11648, 140625 }, /* 74.25/1.001 MHz */ |
428 | + { 74176, 4096, 74176, 5733, 75335, 6144, 74176 }, /* 74.25/1.001 MHz */ |
429 | { 74250, 4096, 74250, 6272, 82500, 6144, 74250 }, /* 74.25 MHz */ |
430 | - { 148352, 11648, 421875, 8918, 234375, 5824, 140625 }, /* 148.50/1.001 MHz */ |
431 | + { 148352, 4096, 148352, 5733, 150670, 6144, 148352 }, /* 148.50/1.001 MHz */ |
432 | { 148500, 4096, 148500, 6272, 165000, 6144, 148500 }, /* 148.50 MHz */ |
433 | - { 0, 4096, 0, 6272, 0, 6144, 0 } /* Other */ |
434 | }; |
435 | |
436 | + |
437 | /* |
438 | - * calculate CTS value if it's not found in the table |
439 | + * calculate CTS and N values if they are not found in the table |
440 | */ |
441 | -static void r600_hdmi_calc_cts(uint32_t clock, int *CTS, int N, int freq) |
442 | +static void r600_hdmi_calc_cts(uint32_t clock, int *CTS, int *N, int freq) |
443 | { |
444 | - u64 n; |
445 | - u32 d; |
446 | - |
447 | - if (*CTS == 0) { |
448 | - n = (u64)clock * (u64)N * 1000ULL; |
449 | - d = 128 * freq; |
450 | - do_div(n, d); |
451 | - *CTS = n; |
452 | - } |
453 | - DRM_DEBUG("Using ACR timing N=%d CTS=%d for frequency %d\n", |
454 | - N, *CTS, freq); |
455 | + int n, cts; |
456 | + unsigned long div, mul; |
457 | + |
458 | + /* Safe, but overly large values */ |
459 | + n = 128 * freq; |
460 | + cts = clock * 1000; |
461 | + |
462 | + /* Smallest valid fraction */ |
463 | + div = gcd(n, cts); |
464 | + |
465 | + n /= div; |
466 | + cts /= div; |
467 | + |
468 | + /* |
469 | + * The optimal N is 128*freq/1000. Calculate the closest larger |
470 | + * value that doesn't truncate any bits. |
471 | + */ |
472 | + mul = ((128*freq/1000) + (n-1))/n; |
473 | + |
474 | + n *= mul; |
475 | + cts *= mul; |
476 | + |
477 | + /* Check that we are in spec (not always possible) */ |
478 | + if (n < (128*freq/1500)) |
479 | + printk(KERN_WARNING "Calculated ACR N value is too small. You may experience audio problems.\n"); |
480 | + if (n > (128*freq/300)) |
481 | + printk(KERN_WARNING "Calculated ACR N value is too large. You may experience audio problems.\n"); |
482 | + |
483 | + *N = n; |
484 | + *CTS = cts; |
485 | + |
486 | + DRM_DEBUG("Calculated ACR timing N=%d CTS=%d for frequency %d\n", |
487 | + *N, *CTS, freq); |
488 | } |
489 | |
490 | struct radeon_hdmi_acr r600_hdmi_acr(uint32_t clock) |
491 | @@ -93,15 +116,16 @@ struct radeon_hdmi_acr r600_hdmi_acr(uint32_t clock) |
492 | struct radeon_hdmi_acr res; |
493 | u8 i; |
494 | |
495 | - for (i = 0; r600_hdmi_predefined_acr[i].clock != clock && |
496 | - r600_hdmi_predefined_acr[i].clock != 0; i++) |
497 | - ; |
498 | - res = r600_hdmi_predefined_acr[i]; |
499 | + /* Precalculated values for common clocks */ |
500 | + for (i = 0; i < ARRAY_SIZE(r600_hdmi_predefined_acr); i++) { |
501 | + if (r600_hdmi_predefined_acr[i].clock == clock) |
502 | + return r600_hdmi_predefined_acr[i]; |
503 | + } |
504 | |
505 | - /* In case some CTS are missing */ |
506 | - r600_hdmi_calc_cts(clock, &res.cts_32khz, res.n_32khz, 32000); |
507 | - r600_hdmi_calc_cts(clock, &res.cts_44_1khz, res.n_44_1khz, 44100); |
508 | - r600_hdmi_calc_cts(clock, &res.cts_48khz, res.n_48khz, 48000); |
509 | + /* And odd clocks get manually calculated */ |
510 | + r600_hdmi_calc_cts(clock, &res.cts_32khz, &res.n_32khz, 32000); |
511 | + r600_hdmi_calc_cts(clock, &res.cts_44_1khz, &res.n_44_1khz, 44100); |
512 | + r600_hdmi_calc_cts(clock, &res.cts_48khz, &res.n_48khz, 48000); |
513 | |
514 | return res; |
515 | } |
516 | diff --git a/drivers/hid/hid-elo.c b/drivers/hid/hid-elo.c |
517 | index f042a6cf8b18..55e4920f967b 100644 |
518 | --- a/drivers/hid/hid-elo.c |
519 | +++ b/drivers/hid/hid-elo.c |
520 | @@ -181,7 +181,40 @@ fail: |
521 | */ |
522 | static bool elo_broken_firmware(struct usb_device *dev) |
523 | { |
524 | - return use_fw_quirk && le16_to_cpu(dev->descriptor.bcdDevice) == 0x10d; |
525 | + struct usb_device *hub = dev->parent; |
526 | + struct usb_device *child = NULL; |
527 | + u16 fw_lvl = le16_to_cpu(dev->descriptor.bcdDevice); |
528 | + u16 child_vid, child_pid; |
529 | + int i; |
530 | + |
531 | + if (!use_fw_quirk) |
532 | + return false; |
533 | + if (fw_lvl != 0x10d) |
534 | + return false; |
535 | + |
536 | + /* iterate sibling devices of the touch controller */ |
537 | + usb_hub_for_each_child(hub, i, child) { |
538 | + child_vid = le16_to_cpu(child->descriptor.idVendor); |
539 | + child_pid = le16_to_cpu(child->descriptor.idProduct); |
540 | + |
541 | + /* |
542 | + * If one of the devices below is present attached as a sibling of |
543 | + * the touch controller then this is a newer IBM 4820 monitor that |
544 | + * does not need the IBM-requested workaround if fw level is |
545 | + * 0x010d - aka 'M'. |
546 | + * No other HW can have this combination. |
547 | + */ |
548 | + if (child_vid==0x04b3) { |
549 | + switch (child_pid) { |
550 | + case 0x4676: /* 4820 21x Video */ |
551 | + case 0x4677: /* 4820 51x Video */ |
552 | + case 0x4678: /* 4820 2Lx Video */ |
553 | + case 0x4679: /* 4820 5Lx Video */ |
554 | + return false; |
555 | + } |
556 | + } |
557 | + } |
558 | + return true; |
559 | } |
560 | |
561 | static int elo_probe(struct hid_device *hdev, const struct hid_device_id *id) |
562 | diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c |
563 | index 1bfd292cac8f..06eb45fa6331 100644 |
564 | --- a/drivers/hid/hid-lg.c |
565 | +++ b/drivers/hid/hid-lg.c |
566 | @@ -47,6 +47,7 @@ |
567 | #define DFP_RDESC_ORIG_SIZE 97 |
568 | #define FV_RDESC_ORIG_SIZE 130 |
569 | #define MOMO_RDESC_ORIG_SIZE 87 |
570 | +#define MOMO2_RDESC_ORIG_SIZE 87 |
571 | |
572 | /* Fixed report descriptors for Logitech Driving Force (and Pro) |
573 | * wheel controllers |
574 | @@ -284,6 +285,54 @@ static __u8 momo_rdesc_fixed[] = { |
575 | 0xC0 /* End Collection */ |
576 | }; |
577 | |
578 | +static __u8 momo2_rdesc_fixed[] = { |
579 | +0x05, 0x01, /* Usage Page (Desktop), */ |
580 | +0x09, 0x04, /* Usage (Joystik), */ |
581 | +0xA1, 0x01, /* Collection (Application), */ |
582 | +0xA1, 0x02, /* Collection (Logical), */ |
583 | +0x95, 0x01, /* Report Count (1), */ |
584 | +0x75, 0x0A, /* Report Size (10), */ |
585 | +0x15, 0x00, /* Logical Minimum (0), */ |
586 | +0x26, 0xFF, 0x03, /* Logical Maximum (1023), */ |
587 | +0x35, 0x00, /* Physical Minimum (0), */ |
588 | +0x46, 0xFF, 0x03, /* Physical Maximum (1023), */ |
589 | +0x09, 0x30, /* Usage (X), */ |
590 | +0x81, 0x02, /* Input (Variable), */ |
591 | +0x95, 0x0A, /* Report Count (10), */ |
592 | +0x75, 0x01, /* Report Size (1), */ |
593 | +0x25, 0x01, /* Logical Maximum (1), */ |
594 | +0x45, 0x01, /* Physical Maximum (1), */ |
595 | +0x05, 0x09, /* Usage Page (Button), */ |
596 | +0x19, 0x01, /* Usage Minimum (01h), */ |
597 | +0x29, 0x0A, /* Usage Maximum (0Ah), */ |
598 | +0x81, 0x02, /* Input (Variable), */ |
599 | +0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ |
600 | +0x09, 0x00, /* Usage (00h), */ |
601 | +0x95, 0x04, /* Report Count (4), */ |
602 | +0x81, 0x02, /* Input (Variable), */ |
603 | +0x95, 0x01, /* Report Count (1), */ |
604 | +0x75, 0x08, /* Report Size (8), */ |
605 | +0x26, 0xFF, 0x00, /* Logical Maximum (255), */ |
606 | +0x46, 0xFF, 0x00, /* Physical Maximum (255), */ |
607 | +0x09, 0x01, /* Usage (01h), */ |
608 | +0x81, 0x02, /* Input (Variable), */ |
609 | +0x05, 0x01, /* Usage Page (Desktop), */ |
610 | +0x09, 0x31, /* Usage (Y), */ |
611 | +0x81, 0x02, /* Input (Variable), */ |
612 | +0x09, 0x32, /* Usage (Z), */ |
613 | +0x81, 0x02, /* Input (Variable), */ |
614 | +0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ |
615 | +0x09, 0x00, /* Usage (00h), */ |
616 | +0x81, 0x02, /* Input (Variable), */ |
617 | +0xC0, /* End Collection, */ |
618 | +0xA1, 0x02, /* Collection (Logical), */ |
619 | +0x09, 0x02, /* Usage (02h), */ |
620 | +0x95, 0x07, /* Report Count (7), */ |
621 | +0x91, 0x02, /* Output (Variable), */ |
622 | +0xC0, /* End Collection, */ |
623 | +0xC0 /* End Collection */ |
624 | +}; |
625 | + |
626 | /* |
627 | * Certain Logitech keyboards send in report #3 keys which are far |
628 | * above the logical maximum described in descriptor. This extends |
629 | @@ -343,6 +392,15 @@ static __u8 *lg_report_fixup(struct hid_device *hdev, __u8 *rdesc, |
630 | } |
631 | break; |
632 | |
633 | + case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2: |
634 | + if (*rsize == MOMO2_RDESC_ORIG_SIZE) { |
635 | + hid_info(hdev, |
636 | + "fixing up Logitech Momo Racing Force (Black) report descriptor\n"); |
637 | + rdesc = momo2_rdesc_fixed; |
638 | + *rsize = sizeof(momo2_rdesc_fixed); |
639 | + } |
640 | + break; |
641 | + |
642 | case USB_DEVICE_ID_LOGITECH_VIBRATION_WHEEL: |
643 | if (*rsize == FV_RDESC_ORIG_SIZE) { |
644 | hid_info(hdev, |
645 | diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c |
646 | index 15e9b57e9cf0..40203ada635e 100644 |
647 | --- a/drivers/iommu/intel-iommu.c |
648 | +++ b/drivers/iommu/intel-iommu.c |
649 | @@ -782,7 +782,11 @@ static struct dma_pte *pfn_to_dma_pte(struct dmar_domain *domain, |
650 | int offset; |
651 | |
652 | BUG_ON(!domain->pgd); |
653 | - BUG_ON(addr_width < BITS_PER_LONG && pfn >> addr_width); |
654 | + |
655 | + if (addr_width < BITS_PER_LONG && pfn >> addr_width) |
656 | + /* Address beyond IOMMU's addressing capabilities. */ |
657 | + return NULL; |
658 | + |
659 | parent = domain->pgd; |
660 | |
661 | while (level > 0) { |
662 | diff --git a/drivers/iommu/intel_irq_remapping.c b/drivers/iommu/intel_irq_remapping.c |
663 | index f71673dbb23d..b97d70b1abe0 100644 |
664 | --- a/drivers/iommu/intel_irq_remapping.c |
665 | +++ b/drivers/iommu/intel_irq_remapping.c |
666 | @@ -525,12 +525,13 @@ static int __init intel_irq_remapping_supported(void) |
667 | if (disable_irq_remap) |
668 | return 0; |
669 | if (irq_remap_broken) { |
670 | - WARN_TAINT(1, TAINT_FIRMWARE_WORKAROUND, |
671 | - "This system BIOS has enabled interrupt remapping\n" |
672 | - "on a chipset that contains an erratum making that\n" |
673 | - "feature unstable. To maintain system stability\n" |
674 | - "interrupt remapping is being disabled. Please\n" |
675 | - "contact your BIOS vendor for an update\n"); |
676 | + printk(KERN_WARNING |
677 | + "This system BIOS has enabled interrupt remapping\n" |
678 | + "on a chipset that contains an erratum making that\n" |
679 | + "feature unstable. To maintain system stability\n" |
680 | + "interrupt remapping is being disabled. Please\n" |
681 | + "contact your BIOS vendor for an update\n"); |
682 | + add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_STILL_OK); |
683 | disable_irq_remap = 1; |
684 | return 0; |
685 | } |
686 | diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c |
687 | index baf2686aa8eb..02125e6a9109 100644 |
688 | --- a/drivers/isdn/isdnloop/isdnloop.c |
689 | +++ b/drivers/isdn/isdnloop/isdnloop.c |
690 | @@ -1083,8 +1083,10 @@ isdnloop_start(isdnloop_card *card, isdnloop_sdef *sdefp) |
691 | spin_unlock_irqrestore(&card->isdnloop_lock, flags); |
692 | return -ENOMEM; |
693 | } |
694 | - for (i = 0; i < 3; i++) |
695 | - strcpy(card->s0num[i], sdef.num[i]); |
696 | + for (i = 0; i < 3; i++) { |
697 | + strlcpy(card->s0num[i], sdef.num[i], |
698 | + sizeof(card->s0num[0])); |
699 | + } |
700 | break; |
701 | case ISDN_PTYPE_1TR6: |
702 | if (isdnloop_fake(card, "DRV1.04TC-1TR6-CAPI-CNS-BASIS-29.11.95", |
703 | @@ -1097,7 +1099,7 @@ isdnloop_start(isdnloop_card *card, isdnloop_sdef *sdefp) |
704 | spin_unlock_irqrestore(&card->isdnloop_lock, flags); |
705 | return -ENOMEM; |
706 | } |
707 | - strcpy(card->s0num[0], sdef.num[0]); |
708 | + strlcpy(card->s0num[0], sdef.num[0], sizeof(card->s0num[0])); |
709 | card->s0num[1][0] = '\0'; |
710 | card->s0num[2][0] = '\0'; |
711 | break; |
712 | diff --git a/drivers/isdn/mISDN/socket.c b/drivers/isdn/mISDN/socket.c |
713 | index e47dcb9d1e91..5cefb479c707 100644 |
714 | --- a/drivers/isdn/mISDN/socket.c |
715 | +++ b/drivers/isdn/mISDN/socket.c |
716 | @@ -117,7 +117,6 @@ mISDN_sock_recvmsg(struct kiocb *iocb, struct socket *sock, |
717 | { |
718 | struct sk_buff *skb; |
719 | struct sock *sk = sock->sk; |
720 | - struct sockaddr_mISDN *maddr; |
721 | |
722 | int copied, err; |
723 | |
724 | @@ -135,9 +134,9 @@ mISDN_sock_recvmsg(struct kiocb *iocb, struct socket *sock, |
725 | if (!skb) |
726 | return err; |
727 | |
728 | - if (msg->msg_namelen >= sizeof(struct sockaddr_mISDN)) { |
729 | - msg->msg_namelen = sizeof(struct sockaddr_mISDN); |
730 | - maddr = (struct sockaddr_mISDN *)msg->msg_name; |
731 | + if (msg->msg_name) { |
732 | + struct sockaddr_mISDN *maddr = msg->msg_name; |
733 | + |
734 | maddr->family = AF_ISDN; |
735 | maddr->dev = _pms(sk)->dev->id; |
736 | if ((sk->sk_protocol == ISDN_P_LAPD_TE) || |
737 | @@ -150,11 +149,7 @@ mISDN_sock_recvmsg(struct kiocb *iocb, struct socket *sock, |
738 | maddr->sapi = _pms(sk)->ch.addr & 0xFF; |
739 | maddr->tei = (_pms(sk)->ch.addr >> 8) & 0xFF; |
740 | } |
741 | - } else { |
742 | - if (msg->msg_namelen) |
743 | - printk(KERN_WARNING "%s: too small namelen %d\n", |
744 | - __func__, msg->msg_namelen); |
745 | - msg->msg_namelen = 0; |
746 | + msg->msg_namelen = sizeof(*maddr); |
747 | } |
748 | |
749 | copied = skb->len + MISDN_HEADER_LEN; |
750 | diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c |
751 | index e4109f618c7b..8a0665d04567 100644 |
752 | --- a/drivers/md/raid5.c |
753 | +++ b/drivers/md/raid5.c |
754 | @@ -5214,15 +5214,18 @@ raid5_show_group_thread_cnt(struct mddev *mddev, char *page) |
755 | return 0; |
756 | } |
757 | |
758 | -static int alloc_thread_groups(struct r5conf *conf, int cnt); |
759 | +static int alloc_thread_groups(struct r5conf *conf, int cnt, |
760 | + int *group_cnt, |
761 | + int *worker_cnt_per_group, |
762 | + struct r5worker_group **worker_groups); |
763 | static ssize_t |
764 | raid5_store_group_thread_cnt(struct mddev *mddev, const char *page, size_t len) |
765 | { |
766 | struct r5conf *conf = mddev->private; |
767 | unsigned long new; |
768 | int err; |
769 | - struct r5worker_group *old_groups; |
770 | - int old_group_cnt; |
771 | + struct r5worker_group *new_groups, *old_groups; |
772 | + int group_cnt, worker_cnt_per_group; |
773 | |
774 | if (len >= PAGE_SIZE) |
775 | return -EINVAL; |
776 | @@ -5238,17 +5241,19 @@ raid5_store_group_thread_cnt(struct mddev *mddev, const char *page, size_t len) |
777 | mddev_suspend(mddev); |
778 | |
779 | old_groups = conf->worker_groups; |
780 | - old_group_cnt = conf->worker_cnt_per_group; |
781 | - |
782 | if (old_groups) |
783 | flush_workqueue(raid5_wq); |
784 | |
785 | - conf->worker_groups = NULL; |
786 | - err = alloc_thread_groups(conf, new); |
787 | - if (err) { |
788 | - conf->worker_groups = old_groups; |
789 | - conf->worker_cnt_per_group = old_group_cnt; |
790 | - } else { |
791 | + err = alloc_thread_groups(conf, new, |
792 | + &group_cnt, &worker_cnt_per_group, |
793 | + &new_groups); |
794 | + if (!err) { |
795 | + spin_lock_irq(&conf->device_lock); |
796 | + conf->group_cnt = group_cnt; |
797 | + conf->worker_cnt_per_group = worker_cnt_per_group; |
798 | + conf->worker_groups = new_groups; |
799 | + spin_unlock_irq(&conf->device_lock); |
800 | + |
801 | if (old_groups) |
802 | kfree(old_groups[0].workers); |
803 | kfree(old_groups); |
804 | @@ -5278,33 +5283,36 @@ static struct attribute_group raid5_attrs_group = { |
805 | .attrs = raid5_attrs, |
806 | }; |
807 | |
808 | -static int alloc_thread_groups(struct r5conf *conf, int cnt) |
809 | +static int alloc_thread_groups(struct r5conf *conf, int cnt, |
810 | + int *group_cnt, |
811 | + int *worker_cnt_per_group, |
812 | + struct r5worker_group **worker_groups) |
813 | { |
814 | int i, j; |
815 | ssize_t size; |
816 | struct r5worker *workers; |
817 | |
818 | - conf->worker_cnt_per_group = cnt; |
819 | + *worker_cnt_per_group = cnt; |
820 | if (cnt == 0) { |
821 | - conf->worker_groups = NULL; |
822 | + *group_cnt = 0; |
823 | + *worker_groups = NULL; |
824 | return 0; |
825 | } |
826 | - conf->group_cnt = num_possible_nodes(); |
827 | + *group_cnt = num_possible_nodes(); |
828 | size = sizeof(struct r5worker) * cnt; |
829 | - workers = kzalloc(size * conf->group_cnt, GFP_NOIO); |
830 | - conf->worker_groups = kzalloc(sizeof(struct r5worker_group) * |
831 | - conf->group_cnt, GFP_NOIO); |
832 | - if (!conf->worker_groups || !workers) { |
833 | + workers = kzalloc(size * *group_cnt, GFP_NOIO); |
834 | + *worker_groups = kzalloc(sizeof(struct r5worker_group) * |
835 | + *group_cnt, GFP_NOIO); |
836 | + if (!*worker_groups || !workers) { |
837 | kfree(workers); |
838 | - kfree(conf->worker_groups); |
839 | - conf->worker_groups = NULL; |
840 | + kfree(*worker_groups); |
841 | return -ENOMEM; |
842 | } |
843 | |
844 | - for (i = 0; i < conf->group_cnt; i++) { |
845 | + for (i = 0; i < *group_cnt; i++) { |
846 | struct r5worker_group *group; |
847 | |
848 | - group = &conf->worker_groups[i]; |
849 | + group = &(*worker_groups)[i]; |
850 | INIT_LIST_HEAD(&group->handle_list); |
851 | group->conf = conf; |
852 | group->workers = workers + i * cnt; |
853 | @@ -5462,6 +5470,8 @@ static struct r5conf *setup_conf(struct mddev *mddev) |
854 | struct md_rdev *rdev; |
855 | struct disk_info *disk; |
856 | char pers_name[6]; |
857 | + int group_cnt, worker_cnt_per_group; |
858 | + struct r5worker_group *new_group; |
859 | |
860 | if (mddev->new_level != 5 |
861 | && mddev->new_level != 4 |
862 | @@ -5496,7 +5506,12 @@ static struct r5conf *setup_conf(struct mddev *mddev) |
863 | if (conf == NULL) |
864 | goto abort; |
865 | /* Don't enable multi-threading by default*/ |
866 | - if (alloc_thread_groups(conf, 0)) |
867 | + if (!alloc_thread_groups(conf, 0, &group_cnt, &worker_cnt_per_group, |
868 | + &new_group)) { |
869 | + conf->group_cnt = group_cnt; |
870 | + conf->worker_cnt_per_group = worker_cnt_per_group; |
871 | + conf->worker_groups = new_group; |
872 | + } else |
873 | goto abort; |
874 | spin_lock_init(&conf->device_lock); |
875 | seqcount_init(&conf->gen_lock); |
876 | diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c |
877 | index e883bfe2e727..dd8057d0bae7 100644 |
878 | --- a/drivers/net/bonding/bond_main.c |
879 | +++ b/drivers/net/bonding/bond_main.c |
880 | @@ -3395,20 +3395,20 @@ static void bond_set_rx_mode(struct net_device *bond_dev) |
881 | struct bonding *bond = netdev_priv(bond_dev); |
882 | struct slave *slave; |
883 | |
884 | - ASSERT_RTNL(); |
885 | - |
886 | + rcu_read_lock(); |
887 | if (USES_PRIMARY(bond->params.mode)) { |
888 | - slave = rtnl_dereference(bond->curr_active_slave); |
889 | + slave = rcu_dereference(bond->curr_active_slave); |
890 | if (slave) { |
891 | dev_uc_sync(slave->dev, bond_dev); |
892 | dev_mc_sync(slave->dev, bond_dev); |
893 | } |
894 | } else { |
895 | - bond_for_each_slave(bond, slave) { |
896 | + bond_for_each_slave_rcu(bond, slave) { |
897 | dev_uc_sync_multiple(slave->dev, bond_dev); |
898 | dev_mc_sync_multiple(slave->dev, bond_dev); |
899 | } |
900 | } |
901 | + rcu_read_unlock(); |
902 | } |
903 | |
904 | static int bond_neigh_init(struct neighbour *n) |
905 | diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c |
906 | index c29b836749b6..b60f95b2196e 100644 |
907 | --- a/drivers/net/bonding/bond_sysfs.c |
908 | +++ b/drivers/net/bonding/bond_sysfs.c |
909 | @@ -587,8 +587,9 @@ static ssize_t bonding_store_arp_interval(struct device *d, |
910 | goto out; |
911 | } |
912 | if (bond->params.mode == BOND_MODE_ALB || |
913 | - bond->params.mode == BOND_MODE_TLB) { |
914 | - pr_info("%s: ARP monitoring cannot be used with ALB/TLB. Only MII monitoring is supported on %s.\n", |
915 | + bond->params.mode == BOND_MODE_TLB || |
916 | + bond->params.mode == BOND_MODE_8023AD) { |
917 | + pr_info("%s: ARP monitoring cannot be used with ALB/TLB/802.3ad. Only MII monitoring is supported on %s.\n", |
918 | bond->dev->name, bond->dev->name); |
919 | ret = -EINVAL; |
920 | goto out; |
921 | @@ -759,6 +760,8 @@ static ssize_t bonding_store_downdelay(struct device *d, |
922 | int new_value, ret = count; |
923 | struct bonding *bond = to_bond(d); |
924 | |
925 | + if (!rtnl_trylock()) |
926 | + return restart_syscall(); |
927 | if (!(bond->params.miimon)) { |
928 | pr_err("%s: Unable to set down delay as MII monitoring is disabled\n", |
929 | bond->dev->name); |
930 | @@ -792,6 +795,7 @@ static ssize_t bonding_store_downdelay(struct device *d, |
931 | } |
932 | |
933 | out: |
934 | + rtnl_unlock(); |
935 | return ret; |
936 | } |
937 | static DEVICE_ATTR(downdelay, S_IRUGO | S_IWUSR, |
938 | @@ -814,6 +818,8 @@ static ssize_t bonding_store_updelay(struct device *d, |
939 | int new_value, ret = count; |
940 | struct bonding *bond = to_bond(d); |
941 | |
942 | + if (!rtnl_trylock()) |
943 | + return restart_syscall(); |
944 | if (!(bond->params.miimon)) { |
945 | pr_err("%s: Unable to set up delay as MII monitoring is disabled\n", |
946 | bond->dev->name); |
947 | @@ -847,6 +853,7 @@ static ssize_t bonding_store_updelay(struct device *d, |
948 | } |
949 | |
950 | out: |
951 | + rtnl_unlock(); |
952 | return ret; |
953 | } |
954 | static DEVICE_ATTR(updelay, S_IRUGO | S_IWUSR, |
955 | diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c |
956 | index 2c210ec35d59..f2f6d85f3788 100644 |
957 | --- a/drivers/net/ethernet/marvell/mv643xx_eth.c |
958 | +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c |
959 | @@ -2890,6 +2890,8 @@ static int mv643xx_eth_probe(struct platform_device *pdev) |
960 | PHY_INTERFACE_MODE_GMII); |
961 | if (!mp->phy) |
962 | err = -ENODEV; |
963 | + else |
964 | + phy_addr_set(mp, mp->phy->addr); |
965 | } else if (pd->phy_addr != MV643XX_ETH_PHY_NONE) { |
966 | mp->phy = phy_scan(mp, pd->phy_addr); |
967 | |
968 | diff --git a/drivers/net/ethernet/mellanox/mlx4/en_main.c b/drivers/net/ethernet/mellanox/mlx4/en_main.c |
969 | index a071cda2dd04..0d087b03a7b0 100644 |
970 | --- a/drivers/net/ethernet/mellanox/mlx4/en_main.c |
971 | +++ b/drivers/net/ethernet/mellanox/mlx4/en_main.c |
972 | @@ -264,6 +264,10 @@ static void *mlx4_en_add(struct mlx4_dev *dev) |
973 | mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_ETH) |
974 | mdev->port_cnt++; |
975 | |
976 | + /* Initialize time stamp mechanism */ |
977 | + if (mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_TS) |
978 | + mlx4_en_init_timestamp(mdev); |
979 | + |
980 | mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_ETH) { |
981 | if (!dev->caps.comp_pool) { |
982 | mdev->profile.prof[i].rx_ring_num = |
983 | @@ -301,10 +305,6 @@ static void *mlx4_en_add(struct mlx4_dev *dev) |
984 | mdev->pndev[i] = NULL; |
985 | } |
986 | |
987 | - /* Initialize time stamp mechanism */ |
988 | - if (mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_TS) |
989 | - mlx4_en_init_timestamp(mdev); |
990 | - |
991 | return mdev; |
992 | |
993 | err_mr: |
994 | diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c |
995 | index d2e591955bdd..0095af50fb81 100644 |
996 | --- a/drivers/net/ethernet/realtek/8139cp.c |
997 | +++ b/drivers/net/ethernet/realtek/8139cp.c |
998 | @@ -678,9 +678,6 @@ static void cp_tx (struct cp_private *cp) |
999 | le32_to_cpu(txd->opts1) & 0xffff, |
1000 | PCI_DMA_TODEVICE); |
1001 | |
1002 | - bytes_compl += skb->len; |
1003 | - pkts_compl++; |
1004 | - |
1005 | if (status & LastFrag) { |
1006 | if (status & (TxError | TxFIFOUnder)) { |
1007 | netif_dbg(cp, tx_err, cp->dev, |
1008 | @@ -702,6 +699,8 @@ static void cp_tx (struct cp_private *cp) |
1009 | netif_dbg(cp, tx_done, cp->dev, |
1010 | "tx done, slot %d\n", tx_tail); |
1011 | } |
1012 | + bytes_compl += skb->len; |
1013 | + pkts_compl++; |
1014 | dev_kfree_skb_irq(skb); |
1015 | } |
1016 | |
1017 | diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c |
1018 | index 3397cee89777..fb3f8dc1b8b1 100644 |
1019 | --- a/drivers/net/ethernet/realtek/r8169.c |
1020 | +++ b/drivers/net/ethernet/realtek/r8169.c |
1021 | @@ -3465,6 +3465,11 @@ static void rtl8168g_1_hw_phy_config(struct rtl8169_private *tp) |
1022 | rtl_writephy(tp, 0x14, 0x9065); |
1023 | rtl_writephy(tp, 0x14, 0x1065); |
1024 | |
1025 | + /* Check ALDPS bit, disable it if enabled */ |
1026 | + rtl_writephy(tp, 0x1f, 0x0a43); |
1027 | + if (rtl_readphy(tp, 0x10) & 0x0004) |
1028 | + rtl_w1w0_phy(tp, 0x10, 0x0000, 0x0004); |
1029 | + |
1030 | rtl_writephy(tp, 0x1f, 0x0000); |
1031 | } |
1032 | |
1033 | diff --git a/drivers/net/ethernet/smsc/smc91x.h b/drivers/net/ethernet/smsc/smc91x.h |
1034 | index 98eedb90cdc3..fc3e25ca7135 100644 |
1035 | --- a/drivers/net/ethernet/smsc/smc91x.h |
1036 | +++ b/drivers/net/ethernet/smsc/smc91x.h |
1037 | @@ -46,7 +46,8 @@ |
1038 | defined(CONFIG_MACH_LITTLETON) ||\ |
1039 | defined(CONFIG_MACH_ZYLONITE2) ||\ |
1040 | defined(CONFIG_ARCH_VIPER) ||\ |
1041 | - defined(CONFIG_MACH_STARGATE2) |
1042 | + defined(CONFIG_MACH_STARGATE2) ||\ |
1043 | + defined(CONFIG_ARCH_VERSATILE) |
1044 | |
1045 | #include <asm/mach-types.h> |
1046 | |
1047 | @@ -154,6 +155,8 @@ static inline void SMC_outw(u16 val, void __iomem *ioaddr, int reg) |
1048 | #define SMC_outl(v, a, r) writel(v, (a) + (r)) |
1049 | #define SMC_insl(a, r, p, l) readsl((a) + (r), p, l) |
1050 | #define SMC_outsl(a, r, p, l) writesl((a) + (r), p, l) |
1051 | +#define SMC_insw(a, r, p, l) readsw((a) + (r), p, l) |
1052 | +#define SMC_outsw(a, r, p, l) writesw((a) + (r), p, l) |
1053 | #define SMC_IRQ_FLAGS (-1) /* from resource */ |
1054 | |
1055 | /* We actually can't write halfwords properly if not word aligned */ |
1056 | @@ -206,23 +209,6 @@ SMC_outw(u16 val, void __iomem *ioaddr, int reg) |
1057 | #define RPC_LSA_DEFAULT RPC_LED_TX_RX |
1058 | #define RPC_LSB_DEFAULT RPC_LED_100_10 |
1059 | |
1060 | -#elif defined(CONFIG_ARCH_VERSATILE) |
1061 | - |
1062 | -#define SMC_CAN_USE_8BIT 1 |
1063 | -#define SMC_CAN_USE_16BIT 1 |
1064 | -#define SMC_CAN_USE_32BIT 1 |
1065 | -#define SMC_NOWAIT 1 |
1066 | - |
1067 | -#define SMC_inb(a, r) readb((a) + (r)) |
1068 | -#define SMC_inw(a, r) readw((a) + (r)) |
1069 | -#define SMC_inl(a, r) readl((a) + (r)) |
1070 | -#define SMC_outb(v, a, r) writeb(v, (a) + (r)) |
1071 | -#define SMC_outw(v, a, r) writew(v, (a) + (r)) |
1072 | -#define SMC_outl(v, a, r) writel(v, (a) + (r)) |
1073 | -#define SMC_insl(a, r, p, l) readsl((a) + (r), p, l) |
1074 | -#define SMC_outsl(a, r, p, l) writesl((a) + (r), p, l) |
1075 | -#define SMC_IRQ_FLAGS (-1) /* from resource */ |
1076 | - |
1077 | #elif defined(CONFIG_MN10300) |
1078 | |
1079 | /* |
1080 | diff --git a/drivers/net/ethernet/via/via-velocity.c b/drivers/net/ethernet/via/via-velocity.c |
1081 | index d022bf936572..ad61d26a44f3 100644 |
1082 | --- a/drivers/net/ethernet/via/via-velocity.c |
1083 | +++ b/drivers/net/ethernet/via/via-velocity.c |
1084 | @@ -2172,16 +2172,13 @@ static int velocity_poll(struct napi_struct *napi, int budget) |
1085 | unsigned int rx_done; |
1086 | unsigned long flags; |
1087 | |
1088 | - spin_lock_irqsave(&vptr->lock, flags); |
1089 | /* |
1090 | * Do rx and tx twice for performance (taken from the VIA |
1091 | * out-of-tree driver). |
1092 | */ |
1093 | - rx_done = velocity_rx_srv(vptr, budget / 2); |
1094 | - velocity_tx_srv(vptr); |
1095 | - rx_done += velocity_rx_srv(vptr, budget - rx_done); |
1096 | + rx_done = velocity_rx_srv(vptr, budget); |
1097 | + spin_lock_irqsave(&vptr->lock, flags); |
1098 | velocity_tx_srv(vptr); |
1099 | - |
1100 | /* If budget not fully consumed, exit the polling mode */ |
1101 | if (rx_done < budget) { |
1102 | napi_complete(napi); |
1103 | @@ -2342,6 +2339,8 @@ static int velocity_change_mtu(struct net_device *dev, int new_mtu) |
1104 | if (ret < 0) |
1105 | goto out_free_tmp_vptr_1; |
1106 | |
1107 | + napi_disable(&vptr->napi); |
1108 | + |
1109 | spin_lock_irqsave(&vptr->lock, flags); |
1110 | |
1111 | netif_stop_queue(dev); |
1112 | @@ -2362,6 +2361,8 @@ static int velocity_change_mtu(struct net_device *dev, int new_mtu) |
1113 | |
1114 | velocity_give_many_rx_descs(vptr); |
1115 | |
1116 | + napi_enable(&vptr->napi); |
1117 | + |
1118 | mac_enable_int(vptr->mac_regs); |
1119 | netif_start_queue(dev); |
1120 | |
1121 | diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c |
1122 | index 9dccb1edfd2a..dc76670c2f2a 100644 |
1123 | --- a/drivers/net/macvtap.c |
1124 | +++ b/drivers/net/macvtap.c |
1125 | @@ -628,6 +628,7 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, |
1126 | const struct iovec *iv, unsigned long total_len, |
1127 | size_t count, int noblock) |
1128 | { |
1129 | + int good_linear = SKB_MAX_HEAD(NET_IP_ALIGN); |
1130 | struct sk_buff *skb; |
1131 | struct macvlan_dev *vlan; |
1132 | unsigned long len = total_len; |
1133 | @@ -670,6 +671,8 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, |
1134 | |
1135 | if (m && m->msg_control && sock_flag(&q->sk, SOCK_ZEROCOPY)) { |
1136 | copylen = vnet_hdr.hdr_len ? vnet_hdr.hdr_len : GOODCOPY_LEN; |
1137 | + if (copylen > good_linear) |
1138 | + copylen = good_linear; |
1139 | linear = copylen; |
1140 | if (iov_pages(iv, vnet_hdr_len + copylen, count) |
1141 | <= MAX_SKB_FRAGS) |
1142 | @@ -678,7 +681,10 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, |
1143 | |
1144 | if (!zerocopy) { |
1145 | copylen = len; |
1146 | - linear = vnet_hdr.hdr_len; |
1147 | + if (vnet_hdr.hdr_len > good_linear) |
1148 | + linear = good_linear; |
1149 | + else |
1150 | + linear = vnet_hdr.hdr_len; |
1151 | } |
1152 | |
1153 | skb = macvtap_alloc_skb(&q->sk, NET_IP_ALIGN, copylen, |
1154 | diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c |
1155 | index 5f66e30d9823..82ee6ed954cb 100644 |
1156 | --- a/drivers/net/ppp/pppoe.c |
1157 | +++ b/drivers/net/ppp/pppoe.c |
1158 | @@ -979,8 +979,6 @@ static int pppoe_recvmsg(struct kiocb *iocb, struct socket *sock, |
1159 | if (error < 0) |
1160 | goto end; |
1161 | |
1162 | - m->msg_namelen = 0; |
1163 | - |
1164 | if (skb) { |
1165 | total_len = min_t(size_t, total_len, skb->len); |
1166 | error = skb_copy_datagram_iovec(skb, 0, m->msg_iov, total_len); |
1167 | diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c |
1168 | index 50e43e64d51d..6327df255404 100644 |
1169 | --- a/drivers/net/team/team.c |
1170 | +++ b/drivers/net/team/team.c |
1171 | @@ -1366,6 +1366,8 @@ static int team_user_linkup_option_get(struct team *team, |
1172 | return 0; |
1173 | } |
1174 | |
1175 | +static void __team_carrier_check(struct team *team); |
1176 | + |
1177 | static int team_user_linkup_option_set(struct team *team, |
1178 | struct team_gsetter_ctx *ctx) |
1179 | { |
1180 | @@ -1373,6 +1375,7 @@ static int team_user_linkup_option_set(struct team *team, |
1181 | |
1182 | port->user.linkup = ctx->data.bool_val; |
1183 | team_refresh_port_linkup(port); |
1184 | + __team_carrier_check(port->team); |
1185 | return 0; |
1186 | } |
1187 | |
1188 | @@ -1392,6 +1395,7 @@ static int team_user_linkup_en_option_set(struct team *team, |
1189 | |
1190 | port->user.linkup_enabled = ctx->data.bool_val; |
1191 | team_refresh_port_linkup(port); |
1192 | + __team_carrier_check(port->team); |
1193 | return 0; |
1194 | } |
1195 | |
1196 | diff --git a/drivers/net/tun.c b/drivers/net/tun.c |
1197 | index 7cb105c103fe..782e38bfc1ee 100644 |
1198 | --- a/drivers/net/tun.c |
1199 | +++ b/drivers/net/tun.c |
1200 | @@ -981,6 +981,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, |
1201 | struct sk_buff *skb; |
1202 | size_t len = total_len, align = NET_SKB_PAD, linear; |
1203 | struct virtio_net_hdr gso = { 0 }; |
1204 | + int good_linear; |
1205 | int offset = 0; |
1206 | int copylen; |
1207 | bool zerocopy = false; |
1208 | @@ -1021,12 +1022,16 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, |
1209 | return -EINVAL; |
1210 | } |
1211 | |
1212 | + good_linear = SKB_MAX_HEAD(align); |
1213 | + |
1214 | if (msg_control) { |
1215 | /* There are 256 bytes to be copied in skb, so there is |
1216 | * enough room for skb expand head in case it is used. |
1217 | * The rest of the buffer is mapped from userspace. |
1218 | */ |
1219 | copylen = gso.hdr_len ? gso.hdr_len : GOODCOPY_LEN; |
1220 | + if (copylen > good_linear) |
1221 | + copylen = good_linear; |
1222 | linear = copylen; |
1223 | if (iov_pages(iv, offset + copylen, count) <= MAX_SKB_FRAGS) |
1224 | zerocopy = true; |
1225 | @@ -1034,7 +1039,10 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, |
1226 | |
1227 | if (!zerocopy) { |
1228 | copylen = len; |
1229 | - linear = gso.hdr_len; |
1230 | + if (gso.hdr_len > good_linear) |
1231 | + linear = good_linear; |
1232 | + else |
1233 | + linear = gso.hdr_len; |
1234 | } |
1235 | |
1236 | skb = tun_alloc_skb(tfile, align, copylen, linear, noblock); |
1237 | diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c |
1238 | index 90a429b7ebad..8494bb53ebdc 100644 |
1239 | --- a/drivers/net/usb/usbnet.c |
1240 | +++ b/drivers/net/usb/usbnet.c |
1241 | @@ -204,9 +204,6 @@ static void intr_complete (struct urb *urb) |
1242 | break; |
1243 | } |
1244 | |
1245 | - if (!netif_running (dev->net)) |
1246 | - return; |
1247 | - |
1248 | status = usb_submit_urb (urb, GFP_ATOMIC); |
1249 | if (status != 0) |
1250 | netif_err(dev, timer, dev->net, |
1251 | diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h |
1252 | index fa33b5edf931..e3eb95292a7f 100644 |
1253 | --- a/drivers/net/wireless/rt2x00/rt2800.h |
1254 | +++ b/drivers/net/wireless/rt2x00/rt2800.h |
1255 | @@ -52,6 +52,7 @@ |
1256 | * RF3322 2.4G 2T2R(RT3352/RT3371/RT3372/RT3391/RT3392) |
1257 | * RF3053 2.4G/5G 3T3R(RT3883/RT3563/RT3573/RT3593/RT3662) |
1258 | * RF5592 2.4G/5G 2T2R |
1259 | + * RF3070 2.4G 1T1R |
1260 | * RF5360 2.4G 1T1R |
1261 | * RF5370 2.4G 1T1R |
1262 | * RF5390 2.4G 1T1R |
1263 | @@ -70,6 +71,7 @@ |
1264 | #define RF3322 0x000c |
1265 | #define RF3053 0x000d |
1266 | #define RF5592 0x000f |
1267 | +#define RF3070 0x3070 |
1268 | #define RF3290 0x3290 |
1269 | #define RF5360 0x5360 |
1270 | #define RF5370 0x5370 |
1271 | diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c |
1272 | index 14007870302b..446eadeaaef6 100644 |
1273 | --- a/drivers/net/wireless/rt2x00/rt2800lib.c |
1274 | +++ b/drivers/net/wireless/rt2x00/rt2800lib.c |
1275 | @@ -3152,6 +3152,7 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev, |
1276 | case RF3322: |
1277 | rt2800_config_channel_rf3322(rt2x00dev, conf, rf, info); |
1278 | break; |
1279 | + case RF3070: |
1280 | case RF5360: |
1281 | case RF5370: |
1282 | case RF5372: |
1283 | @@ -3166,7 +3167,8 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev, |
1284 | rt2800_config_channel_rf2xxx(rt2x00dev, conf, rf, info); |
1285 | } |
1286 | |
1287 | - if (rt2x00_rf(rt2x00dev, RF3290) || |
1288 | + if (rt2x00_rf(rt2x00dev, RF3070) || |
1289 | + rt2x00_rf(rt2x00dev, RF3290) || |
1290 | rt2x00_rf(rt2x00dev, RF3322) || |
1291 | rt2x00_rf(rt2x00dev, RF5360) || |
1292 | rt2x00_rf(rt2x00dev, RF5370) || |
1293 | @@ -4264,6 +4266,7 @@ void rt2800_vco_calibration(struct rt2x00_dev *rt2x00dev) |
1294 | rt2800_rfcsr_write(rt2x00dev, 7, rfcsr); |
1295 | break; |
1296 | case RF3053: |
1297 | + case RF3070: |
1298 | case RF3290: |
1299 | case RF5360: |
1300 | case RF5370: |
1301 | @@ -7024,6 +7027,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev) |
1302 | case RF3022: |
1303 | case RF3052: |
1304 | case RF3053: |
1305 | + case RF3070: |
1306 | case RF3290: |
1307 | case RF3320: |
1308 | case RF3322: |
1309 | @@ -7546,6 +7550,7 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev) |
1310 | rt2x00_rf(rt2x00dev, RF2020) || |
1311 | rt2x00_rf(rt2x00dev, RF3021) || |
1312 | rt2x00_rf(rt2x00dev, RF3022) || |
1313 | + rt2x00_rf(rt2x00dev, RF3070) || |
1314 | rt2x00_rf(rt2x00dev, RF3290) || |
1315 | rt2x00_rf(rt2x00dev, RF3320) || |
1316 | rt2x00_rf(rt2x00dev, RF3322) || |
1317 | @@ -7674,6 +7679,7 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev) |
1318 | case RF3320: |
1319 | case RF3052: |
1320 | case RF3053: |
1321 | + case RF3070: |
1322 | case RF3290: |
1323 | case RF5360: |
1324 | case RF5370: |
1325 | diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c |
1326 | index 900da4b243ad..625585034ef4 100644 |
1327 | --- a/drivers/net/xen-netback/netback.c |
1328 | +++ b/drivers/net/xen-netback/netback.c |
1329 | @@ -39,6 +39,7 @@ |
1330 | #include <linux/udp.h> |
1331 | |
1332 | #include <net/tcp.h> |
1333 | +#include <net/ip6_checksum.h> |
1334 | |
1335 | #include <xen/xen.h> |
1336 | #include <xen/events.h> |
1337 | diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c |
1338 | index ed0834e2b72e..ab69245f86dc 100644 |
1339 | --- a/drivers/usb/musb/davinci.c |
1340 | +++ b/drivers/usb/musb/davinci.c |
1341 | @@ -509,7 +509,7 @@ static u64 davinci_dmamask = DMA_BIT_MASK(32); |
1342 | |
1343 | static int davinci_probe(struct platform_device *pdev) |
1344 | { |
1345 | - struct resource musb_resources[2]; |
1346 | + struct resource musb_resources[3]; |
1347 | struct musb_hdrc_platform_data *pdata = dev_get_platdata(&pdev->dev); |
1348 | struct platform_device *musb; |
1349 | struct davinci_glue *glue; |
1350 | @@ -567,6 +567,15 @@ static int davinci_probe(struct platform_device *pdev) |
1351 | musb_resources[1].end = pdev->resource[1].end; |
1352 | musb_resources[1].flags = pdev->resource[1].flags; |
1353 | |
1354 | + /* |
1355 | + * For DM6467 3 resources are passed. A placeholder for the 3rd |
1356 | + * resource is always there, so it's safe to always copy it... |
1357 | + */ |
1358 | + musb_resources[2].name = pdev->resource[2].name; |
1359 | + musb_resources[2].start = pdev->resource[2].start; |
1360 | + musb_resources[2].end = pdev->resource[2].end; |
1361 | + musb_resources[2].flags = pdev->resource[2].flags; |
1362 | + |
1363 | ret = platform_device_add_resources(musb, musb_resources, |
1364 | ARRAY_SIZE(musb_resources)); |
1365 | if (ret) { |
1366 | diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c |
1367 | index 6ad02f57c366..3dcf66f345e9 100644 |
1368 | --- a/drivers/usb/wusbcore/wa-xfer.c |
1369 | +++ b/drivers/usb/wusbcore/wa-xfer.c |
1370 | @@ -91,7 +91,8 @@ |
1371 | #include "wusbhc.h" |
1372 | |
1373 | enum { |
1374 | - WA_SEGS_MAX = 255, |
1375 | + /* [WUSB] section 8.3.3 allocates 7 bits for the segment index. */ |
1376 | + WA_SEGS_MAX = 128, |
1377 | }; |
1378 | |
1379 | enum wa_seg_status { |
1380 | @@ -446,7 +447,7 @@ static ssize_t __wa_xfer_setup_sizes(struct wa_xfer *xfer, |
1381 | } |
1382 | xfer->seg_size = (xfer->seg_size / maxpktsize) * maxpktsize; |
1383 | xfer->segs = DIV_ROUND_UP(urb->transfer_buffer_length, xfer->seg_size); |
1384 | - if (xfer->segs >= WA_SEGS_MAX) { |
1385 | + if (xfer->segs > WA_SEGS_MAX) { |
1386 | dev_err(dev, "BUG? ops, number of segments %d bigger than %d\n", |
1387 | (int)(urb->transfer_buffer_length / xfer->seg_size), |
1388 | WA_SEGS_MAX); |
1389 | diff --git a/drivers/video/kyro/fbdev.c b/drivers/video/kyro/fbdev.c |
1390 | index 6157f74ac600..ec7fc87fa5ab 100644 |
1391 | --- a/drivers/video/kyro/fbdev.c |
1392 | +++ b/drivers/video/kyro/fbdev.c |
1393 | @@ -625,15 +625,15 @@ static int kyrofb_ioctl(struct fb_info *info, |
1394 | } |
1395 | break; |
1396 | case KYRO_IOCTL_UVSTRIDE: |
1397 | - if (copy_to_user(argp, &deviceInfo.ulOverlayUVStride, sizeof(unsigned long))) |
1398 | + if (copy_to_user(argp, &deviceInfo.ulOverlayUVStride, sizeof(deviceInfo.ulOverlayUVStride))) |
1399 | return -EFAULT; |
1400 | break; |
1401 | case KYRO_IOCTL_STRIDE: |
1402 | - if (copy_to_user(argp, &deviceInfo.ulOverlayStride, sizeof(unsigned long))) |
1403 | + if (copy_to_user(argp, &deviceInfo.ulOverlayStride, sizeof(deviceInfo.ulOverlayStride))) |
1404 | return -EFAULT; |
1405 | break; |
1406 | case KYRO_IOCTL_OVERLAY_OFFSET: |
1407 | - if (copy_to_user(argp, &deviceInfo.ulOverlayOffset, sizeof(unsigned long))) |
1408 | + if (copy_to_user(argp, &deviceInfo.ulOverlayOffset, sizeof(deviceInfo.ulOverlayOffset))) |
1409 | return -EFAULT; |
1410 | break; |
1411 | } |
1412 | diff --git a/fs/aio.c b/fs/aio.c |
1413 | index 067e3d340c35..6efb7f6cb22e 100644 |
1414 | --- a/fs/aio.c |
1415 | +++ b/fs/aio.c |
1416 | @@ -36,10 +36,10 @@ |
1417 | #include <linux/eventfd.h> |
1418 | #include <linux/blkdev.h> |
1419 | #include <linux/compat.h> |
1420 | -#include <linux/anon_inodes.h> |
1421 | #include <linux/migrate.h> |
1422 | #include <linux/ramfs.h> |
1423 | #include <linux/percpu-refcount.h> |
1424 | +#include <linux/mount.h> |
1425 | |
1426 | #include <asm/kmap_types.h> |
1427 | #include <asm/uaccess.h> |
1428 | @@ -80,6 +80,8 @@ struct kioctx { |
1429 | struct percpu_ref users; |
1430 | atomic_t dead; |
1431 | |
1432 | + struct percpu_ref reqs; |
1433 | + |
1434 | unsigned long user_id; |
1435 | |
1436 | struct __percpu kioctx_cpu *cpu; |
1437 | @@ -107,7 +109,6 @@ struct kioctx { |
1438 | struct page **ring_pages; |
1439 | long nr_pages; |
1440 | |
1441 | - struct rcu_head rcu_head; |
1442 | struct work_struct free_work; |
1443 | |
1444 | struct { |
1445 | @@ -152,12 +153,67 @@ unsigned long aio_max_nr = 0x10000; /* system wide maximum number of aio request |
1446 | static struct kmem_cache *kiocb_cachep; |
1447 | static struct kmem_cache *kioctx_cachep; |
1448 | |
1449 | +static struct vfsmount *aio_mnt; |
1450 | + |
1451 | +static const struct file_operations aio_ring_fops; |
1452 | +static const struct address_space_operations aio_ctx_aops; |
1453 | + |
1454 | +static struct file *aio_private_file(struct kioctx *ctx, loff_t nr_pages) |
1455 | +{ |
1456 | + struct qstr this = QSTR_INIT("[aio]", 5); |
1457 | + struct file *file; |
1458 | + struct path path; |
1459 | + struct inode *inode = alloc_anon_inode(aio_mnt->mnt_sb); |
1460 | + if (IS_ERR(inode)) |
1461 | + return ERR_CAST(inode); |
1462 | + |
1463 | + inode->i_mapping->a_ops = &aio_ctx_aops; |
1464 | + inode->i_mapping->private_data = ctx; |
1465 | + inode->i_size = PAGE_SIZE * nr_pages; |
1466 | + |
1467 | + path.dentry = d_alloc_pseudo(aio_mnt->mnt_sb, &this); |
1468 | + if (!path.dentry) { |
1469 | + iput(inode); |
1470 | + return ERR_PTR(-ENOMEM); |
1471 | + } |
1472 | + path.mnt = mntget(aio_mnt); |
1473 | + |
1474 | + d_instantiate(path.dentry, inode); |
1475 | + file = alloc_file(&path, FMODE_READ | FMODE_WRITE, &aio_ring_fops); |
1476 | + if (IS_ERR(file)) { |
1477 | + path_put(&path); |
1478 | + return file; |
1479 | + } |
1480 | + |
1481 | + file->f_flags = O_RDWR; |
1482 | + file->private_data = ctx; |
1483 | + return file; |
1484 | +} |
1485 | + |
1486 | +static struct dentry *aio_mount(struct file_system_type *fs_type, |
1487 | + int flags, const char *dev_name, void *data) |
1488 | +{ |
1489 | + static const struct dentry_operations ops = { |
1490 | + .d_dname = simple_dname, |
1491 | + }; |
1492 | + return mount_pseudo(fs_type, "aio:", NULL, &ops, 0xa10a10a1); |
1493 | +} |
1494 | + |
1495 | /* aio_setup |
1496 | * Creates the slab caches used by the aio routines, panic on |
1497 | * failure as this is done early during the boot sequence. |
1498 | */ |
1499 | static int __init aio_setup(void) |
1500 | { |
1501 | + static struct file_system_type aio_fs = { |
1502 | + .name = "aio", |
1503 | + .mount = aio_mount, |
1504 | + .kill_sb = kill_anon_super, |
1505 | + }; |
1506 | + aio_mnt = kern_mount(&aio_fs); |
1507 | + if (IS_ERR(aio_mnt)) |
1508 | + panic("Failed to create aio fs mount."); |
1509 | + |
1510 | kiocb_cachep = KMEM_CACHE(kiocb, SLAB_HWCACHE_ALIGN|SLAB_PANIC); |
1511 | kioctx_cachep = KMEM_CACHE(kioctx,SLAB_HWCACHE_ALIGN|SLAB_PANIC); |
1512 | |
1513 | @@ -195,8 +251,10 @@ static void aio_free_ring(struct kioctx *ctx) |
1514 | |
1515 | put_aio_ring_file(ctx); |
1516 | |
1517 | - if (ctx->ring_pages && ctx->ring_pages != ctx->internal_pages) |
1518 | + if (ctx->ring_pages && ctx->ring_pages != ctx->internal_pages) { |
1519 | kfree(ctx->ring_pages); |
1520 | + ctx->ring_pages = NULL; |
1521 | + } |
1522 | } |
1523 | |
1524 | static int aio_ring_mmap(struct file *file, struct vm_area_struct *vma) |
1525 | @@ -283,16 +341,12 @@ static int aio_setup_ring(struct kioctx *ctx) |
1526 | if (nr_pages < 0) |
1527 | return -EINVAL; |
1528 | |
1529 | - file = anon_inode_getfile_private("[aio]", &aio_ring_fops, ctx, O_RDWR); |
1530 | + file = aio_private_file(ctx, nr_pages); |
1531 | if (IS_ERR(file)) { |
1532 | ctx->aio_ring_file = NULL; |
1533 | return -EAGAIN; |
1534 | } |
1535 | |
1536 | - file->f_inode->i_mapping->a_ops = &aio_ctx_aops; |
1537 | - file->f_inode->i_mapping->private_data = ctx; |
1538 | - file->f_inode->i_size = PAGE_SIZE * (loff_t)nr_pages; |
1539 | - |
1540 | for (i = 0; i < nr_pages; i++) { |
1541 | struct page *page; |
1542 | page = find_or_create_page(file->f_inode->i_mapping, |
1543 | @@ -313,8 +367,10 @@ static int aio_setup_ring(struct kioctx *ctx) |
1544 | if (nr_pages > AIO_RING_PAGES) { |
1545 | ctx->ring_pages = kcalloc(nr_pages, sizeof(struct page *), |
1546 | GFP_KERNEL); |
1547 | - if (!ctx->ring_pages) |
1548 | + if (!ctx->ring_pages) { |
1549 | + put_aio_ring_file(ctx); |
1550 | return -ENOMEM; |
1551 | + } |
1552 | } |
1553 | |
1554 | ctx->mmap_size = nr_pages * PAGE_SIZE; |
1555 | @@ -412,26 +468,34 @@ static int kiocb_cancel(struct kioctx *ctx, struct kiocb *kiocb) |
1556 | return cancel(kiocb); |
1557 | } |
1558 | |
1559 | -static void free_ioctx_rcu(struct rcu_head *head) |
1560 | +static void free_ioctx(struct work_struct *work) |
1561 | { |
1562 | - struct kioctx *ctx = container_of(head, struct kioctx, rcu_head); |
1563 | + struct kioctx *ctx = container_of(work, struct kioctx, free_work); |
1564 | |
1565 | + pr_debug("freeing %p\n", ctx); |
1566 | + |
1567 | + aio_free_ring(ctx); |
1568 | free_percpu(ctx->cpu); |
1569 | kmem_cache_free(kioctx_cachep, ctx); |
1570 | } |
1571 | |
1572 | +static void free_ioctx_reqs(struct percpu_ref *ref) |
1573 | +{ |
1574 | + struct kioctx *ctx = container_of(ref, struct kioctx, reqs); |
1575 | + |
1576 | + INIT_WORK(&ctx->free_work, free_ioctx); |
1577 | + schedule_work(&ctx->free_work); |
1578 | +} |
1579 | + |
1580 | /* |
1581 | * When this function runs, the kioctx has been removed from the "hash table" |
1582 | * and ctx->users has dropped to 0, so we know no more kiocbs can be submitted - |
1583 | * now it's safe to cancel any that need to be. |
1584 | */ |
1585 | -static void free_ioctx(struct work_struct *work) |
1586 | +static void free_ioctx_users(struct percpu_ref *ref) |
1587 | { |
1588 | - struct kioctx *ctx = container_of(work, struct kioctx, free_work); |
1589 | - struct aio_ring *ring; |
1590 | + struct kioctx *ctx = container_of(ref, struct kioctx, users); |
1591 | struct kiocb *req; |
1592 | - unsigned cpu, avail; |
1593 | - DEFINE_WAIT(wait); |
1594 | |
1595 | spin_lock_irq(&ctx->ctx_lock); |
1596 | |
1597 | @@ -445,54 +509,8 @@ static void free_ioctx(struct work_struct *work) |
1598 | |
1599 | spin_unlock_irq(&ctx->ctx_lock); |
1600 | |
1601 | - for_each_possible_cpu(cpu) { |
1602 | - struct kioctx_cpu *kcpu = per_cpu_ptr(ctx->cpu, cpu); |
1603 | - |
1604 | - atomic_add(kcpu->reqs_available, &ctx->reqs_available); |
1605 | - kcpu->reqs_available = 0; |
1606 | - } |
1607 | - |
1608 | - while (1) { |
1609 | - prepare_to_wait(&ctx->wait, &wait, TASK_UNINTERRUPTIBLE); |
1610 | - |
1611 | - ring = kmap_atomic(ctx->ring_pages[0]); |
1612 | - avail = (ring->head <= ring->tail) |
1613 | - ? ring->tail - ring->head |
1614 | - : ctx->nr_events - ring->head + ring->tail; |
1615 | - |
1616 | - atomic_add(avail, &ctx->reqs_available); |
1617 | - ring->head = ring->tail; |
1618 | - kunmap_atomic(ring); |
1619 | - |
1620 | - if (atomic_read(&ctx->reqs_available) >= ctx->nr_events - 1) |
1621 | - break; |
1622 | - |
1623 | - schedule(); |
1624 | - } |
1625 | - finish_wait(&ctx->wait, &wait); |
1626 | - |
1627 | - WARN_ON(atomic_read(&ctx->reqs_available) > ctx->nr_events - 1); |
1628 | - |
1629 | - aio_free_ring(ctx); |
1630 | - |
1631 | - pr_debug("freeing %p\n", ctx); |
1632 | - |
1633 | - /* |
1634 | - * Here the call_rcu() is between the wait_event() for reqs_active to |
1635 | - * hit 0, and freeing the ioctx. |
1636 | - * |
1637 | - * aio_complete() decrements reqs_active, but it has to touch the ioctx |
1638 | - * after to issue a wakeup so we use rcu. |
1639 | - */ |
1640 | - call_rcu(&ctx->rcu_head, free_ioctx_rcu); |
1641 | -} |
1642 | - |
1643 | -static void free_ioctx_ref(struct percpu_ref *ref) |
1644 | -{ |
1645 | - struct kioctx *ctx = container_of(ref, struct kioctx, users); |
1646 | - |
1647 | - INIT_WORK(&ctx->free_work, free_ioctx); |
1648 | - schedule_work(&ctx->free_work); |
1649 | + percpu_ref_kill(&ctx->reqs); |
1650 | + percpu_ref_put(&ctx->reqs); |
1651 | } |
1652 | |
1653 | static int ioctx_add_table(struct kioctx *ctx, struct mm_struct *mm) |
1654 | @@ -551,6 +569,16 @@ static int ioctx_add_table(struct kioctx *ctx, struct mm_struct *mm) |
1655 | } |
1656 | } |
1657 | |
1658 | +static void aio_nr_sub(unsigned nr) |
1659 | +{ |
1660 | + spin_lock(&aio_nr_lock); |
1661 | + if (WARN_ON(aio_nr - nr > aio_nr)) |
1662 | + aio_nr = 0; |
1663 | + else |
1664 | + aio_nr -= nr; |
1665 | + spin_unlock(&aio_nr_lock); |
1666 | +} |
1667 | + |
1668 | /* ioctx_alloc |
1669 | * Allocates and initializes an ioctx. Returns an ERR_PTR if it failed. |
1670 | */ |
1671 | @@ -588,8 +616,11 @@ static struct kioctx *ioctx_alloc(unsigned nr_events) |
1672 | |
1673 | ctx->max_reqs = nr_events; |
1674 | |
1675 | - if (percpu_ref_init(&ctx->users, free_ioctx_ref)) |
1676 | - goto out_freectx; |
1677 | + if (percpu_ref_init(&ctx->users, free_ioctx_users)) |
1678 | + goto err; |
1679 | + |
1680 | + if (percpu_ref_init(&ctx->reqs, free_ioctx_reqs)) |
1681 | + goto err; |
1682 | |
1683 | spin_lock_init(&ctx->ctx_lock); |
1684 | spin_lock_init(&ctx->completion_lock); |
1685 | @@ -600,10 +631,10 @@ static struct kioctx *ioctx_alloc(unsigned nr_events) |
1686 | |
1687 | ctx->cpu = alloc_percpu(struct kioctx_cpu); |
1688 | if (!ctx->cpu) |
1689 | - goto out_freeref; |
1690 | + goto err; |
1691 | |
1692 | if (aio_setup_ring(ctx) < 0) |
1693 | - goto out_freepcpu; |
1694 | + goto err; |
1695 | |
1696 | atomic_set(&ctx->reqs_available, ctx->nr_events - 1); |
1697 | ctx->req_batch = (ctx->nr_events - 1) / (num_possible_cpus() * 4); |
1698 | @@ -615,7 +646,8 @@ static struct kioctx *ioctx_alloc(unsigned nr_events) |
1699 | if (aio_nr + nr_events > (aio_max_nr * 2UL) || |
1700 | aio_nr + nr_events < aio_nr) { |
1701 | spin_unlock(&aio_nr_lock); |
1702 | - goto out_cleanup; |
1703 | + err = -EAGAIN; |
1704 | + goto err_ctx; |
1705 | } |
1706 | aio_nr += ctx->max_reqs; |
1707 | spin_unlock(&aio_nr_lock); |
1708 | @@ -624,23 +656,20 @@ static struct kioctx *ioctx_alloc(unsigned nr_events) |
1709 | |
1710 | err = ioctx_add_table(ctx, mm); |
1711 | if (err) |
1712 | - goto out_cleanup_put; |
1713 | + goto err_cleanup; |
1714 | |
1715 | pr_debug("allocated ioctx %p[%ld]: mm=%p mask=0x%x\n", |
1716 | ctx, ctx->user_id, mm, ctx->nr_events); |
1717 | return ctx; |
1718 | |
1719 | -out_cleanup_put: |
1720 | - percpu_ref_put(&ctx->users); |
1721 | -out_cleanup: |
1722 | - err = -EAGAIN; |
1723 | +err_cleanup: |
1724 | + aio_nr_sub(ctx->max_reqs); |
1725 | +err_ctx: |
1726 | aio_free_ring(ctx); |
1727 | -out_freepcpu: |
1728 | +err: |
1729 | free_percpu(ctx->cpu); |
1730 | -out_freeref: |
1731 | + free_percpu(ctx->reqs.pcpu_count); |
1732 | free_percpu(ctx->users.pcpu_count); |
1733 | -out_freectx: |
1734 | - put_aio_ring_file(ctx); |
1735 | kmem_cache_free(kioctx_cachep, ctx); |
1736 | pr_debug("error allocating ioctx %d\n", err); |
1737 | return ERR_PTR(err); |
1738 | @@ -675,10 +704,7 @@ static void kill_ioctx(struct mm_struct *mm, struct kioctx *ctx) |
1739 | * -EAGAIN with no ioctxs actually in use (as far as userspace |
1740 | * could tell). |
1741 | */ |
1742 | - spin_lock(&aio_nr_lock); |
1743 | - BUG_ON(aio_nr - ctx->max_reqs > aio_nr); |
1744 | - aio_nr -= ctx->max_reqs; |
1745 | - spin_unlock(&aio_nr_lock); |
1746 | + aio_nr_sub(ctx->max_reqs); |
1747 | |
1748 | if (ctx->mmap_size) |
1749 | vm_munmap(ctx->mmap_base, ctx->mmap_size); |
1750 | @@ -810,6 +836,8 @@ static inline struct kiocb *aio_get_req(struct kioctx *ctx) |
1751 | if (unlikely(!req)) |
1752 | goto out_put; |
1753 | |
1754 | + percpu_ref_get(&ctx->reqs); |
1755 | + |
1756 | req->ki_ctx = ctx; |
1757 | return req; |
1758 | out_put: |
1759 | @@ -879,12 +907,6 @@ void aio_complete(struct kiocb *iocb, long res, long res2) |
1760 | return; |
1761 | } |
1762 | |
1763 | - /* |
1764 | - * Take rcu_read_lock() in case the kioctx is being destroyed, as we |
1765 | - * need to issue a wakeup after incrementing reqs_available. |
1766 | - */ |
1767 | - rcu_read_lock(); |
1768 | - |
1769 | if (iocb->ki_list.next) { |
1770 | unsigned long flags; |
1771 | |
1772 | @@ -959,7 +981,7 @@ void aio_complete(struct kiocb *iocb, long res, long res2) |
1773 | if (waitqueue_active(&ctx->wait)) |
1774 | wake_up(&ctx->wait); |
1775 | |
1776 | - rcu_read_unlock(); |
1777 | + percpu_ref_put(&ctx->reqs); |
1778 | } |
1779 | EXPORT_SYMBOL(aio_complete); |
1780 | |
1781 | @@ -1370,6 +1392,7 @@ static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb, |
1782 | return 0; |
1783 | out_put_req: |
1784 | put_reqs_available(ctx, 1); |
1785 | + percpu_ref_put(&ctx->reqs); |
1786 | kiocb_free(req); |
1787 | return ret; |
1788 | } |
1789 | diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c |
1790 | index 85c961849953..22f9698a1214 100644 |
1791 | --- a/fs/anon_inodes.c |
1792 | +++ b/fs/anon_inodes.c |
1793 | @@ -24,7 +24,6 @@ |
1794 | |
1795 | static struct vfsmount *anon_inode_mnt __read_mostly; |
1796 | static struct inode *anon_inode_inode; |
1797 | -static const struct file_operations anon_inode_fops; |
1798 | |
1799 | /* |
1800 | * anon_inodefs_dname() is called from d_path(). |
1801 | @@ -39,51 +38,6 @@ static const struct dentry_operations anon_inodefs_dentry_operations = { |
1802 | .d_dname = anon_inodefs_dname, |
1803 | }; |
1804 | |
1805 | -/* |
1806 | - * nop .set_page_dirty method so that people can use .page_mkwrite on |
1807 | - * anon inodes. |
1808 | - */ |
1809 | -static int anon_set_page_dirty(struct page *page) |
1810 | -{ |
1811 | - return 0; |
1812 | -}; |
1813 | - |
1814 | -static const struct address_space_operations anon_aops = { |
1815 | - .set_page_dirty = anon_set_page_dirty, |
1816 | -}; |
1817 | - |
1818 | -/* |
1819 | - * A single inode exists for all anon_inode files. Contrary to pipes, |
1820 | - * anon_inode inodes have no associated per-instance data, so we need |
1821 | - * only allocate one of them. |
1822 | - */ |
1823 | -static struct inode *anon_inode_mkinode(struct super_block *s) |
1824 | -{ |
1825 | - struct inode *inode = new_inode_pseudo(s); |
1826 | - |
1827 | - if (!inode) |
1828 | - return ERR_PTR(-ENOMEM); |
1829 | - |
1830 | - inode->i_ino = get_next_ino(); |
1831 | - inode->i_fop = &anon_inode_fops; |
1832 | - |
1833 | - inode->i_mapping->a_ops = &anon_aops; |
1834 | - |
1835 | - /* |
1836 | - * Mark the inode dirty from the very beginning, |
1837 | - * that way it will never be moved to the dirty |
1838 | - * list because mark_inode_dirty() will think |
1839 | - * that it already _is_ on the dirty list. |
1840 | - */ |
1841 | - inode->i_state = I_DIRTY; |
1842 | - inode->i_mode = S_IRUSR | S_IWUSR; |
1843 | - inode->i_uid = current_fsuid(); |
1844 | - inode->i_gid = current_fsgid(); |
1845 | - inode->i_flags |= S_PRIVATE; |
1846 | - inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; |
1847 | - return inode; |
1848 | -} |
1849 | - |
1850 | static struct dentry *anon_inodefs_mount(struct file_system_type *fs_type, |
1851 | int flags, const char *dev_name, void *data) |
1852 | { |
1853 | @@ -92,7 +46,7 @@ static struct dentry *anon_inodefs_mount(struct file_system_type *fs_type, |
1854 | &anon_inodefs_dentry_operations, ANON_INODE_FS_MAGIC); |
1855 | if (!IS_ERR(root)) { |
1856 | struct super_block *s = root->d_sb; |
1857 | - anon_inode_inode = anon_inode_mkinode(s); |
1858 | + anon_inode_inode = alloc_anon_inode(s); |
1859 | if (IS_ERR(anon_inode_inode)) { |
1860 | dput(root); |
1861 | deactivate_locked_super(s); |
1862 | @@ -134,7 +88,7 @@ struct file *anon_inode_getfile_private(const char *name, |
1863 | if (fops->owner && !try_module_get(fops->owner)) |
1864 | return ERR_PTR(-ENOENT); |
1865 | |
1866 | - inode = anon_inode_mkinode(anon_inode_mnt->mnt_sb); |
1867 | + inode = alloc_anon_inode(anon_inode_mnt->mnt_sb); |
1868 | if (IS_ERR(inode)) { |
1869 | file = ERR_PTR(-ENOMEM); |
1870 | goto err_module; |
1871 | diff --git a/fs/libfs.c b/fs/libfs.c |
1872 | index 3a3a9b53bf5a..193e0c29fb94 100644 |
1873 | --- a/fs/libfs.c |
1874 | +++ b/fs/libfs.c |
1875 | @@ -993,3 +993,46 @@ EXPORT_SYMBOL_GPL(simple_attr_open); |
1876 | EXPORT_SYMBOL_GPL(simple_attr_release); |
1877 | EXPORT_SYMBOL_GPL(simple_attr_read); |
1878 | EXPORT_SYMBOL_GPL(simple_attr_write); |
1879 | + |
1880 | +/* |
1881 | + * nop .set_page_dirty method so that people can use .page_mkwrite on |
1882 | + * anon inodes. |
1883 | + */ |
1884 | +static int anon_set_page_dirty(struct page *page) |
1885 | +{ |
1886 | + return 0; |
1887 | +}; |
1888 | + |
1889 | +/* |
1890 | + * A single inode exists for all anon_inode files. Contrary to pipes, |
1891 | + * anon_inode inodes have no associated per-instance data, so we need |
1892 | + * only allocate one of them. |
1893 | + */ |
1894 | +struct inode *alloc_anon_inode(struct super_block *s) |
1895 | +{ |
1896 | + static const struct address_space_operations anon_aops = { |
1897 | + .set_page_dirty = anon_set_page_dirty, |
1898 | + }; |
1899 | + struct inode *inode = new_inode_pseudo(s); |
1900 | + |
1901 | + if (!inode) |
1902 | + return ERR_PTR(-ENOMEM); |
1903 | + |
1904 | + inode->i_ino = get_next_ino(); |
1905 | + inode->i_mapping->a_ops = &anon_aops; |
1906 | + |
1907 | + /* |
1908 | + * Mark the inode dirty from the very beginning, |
1909 | + * that way it will never be moved to the dirty |
1910 | + * list because mark_inode_dirty() will think |
1911 | + * that it already _is_ on the dirty list. |
1912 | + */ |
1913 | + inode->i_state = I_DIRTY; |
1914 | + inode->i_mode = S_IRUSR | S_IWUSR; |
1915 | + inode->i_uid = current_fsuid(); |
1916 | + inode->i_gid = current_fsgid(); |
1917 | + inode->i_flags |= S_PRIVATE; |
1918 | + inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; |
1919 | + return inode; |
1920 | +} |
1921 | +EXPORT_SYMBOL(alloc_anon_inode); |
1922 | diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c |
1923 | index 668e8f4ccf5e..2e1e6c33841d 100644 |
1924 | --- a/fs/xfs/xfs_ioctl.c |
1925 | +++ b/fs/xfs/xfs_ioctl.c |
1926 | @@ -1717,6 +1717,12 @@ xfs_file_ioctl( |
1927 | if (mp->m_flags & XFS_MOUNT_RDONLY) |
1928 | return -XFS_ERROR(EROFS); |
1929 | |
1930 | + if (!capable(CAP_SYS_ADMIN)) |
1931 | + return -EPERM; |
1932 | + |
1933 | + if (mp->m_flags & XFS_MOUNT_RDONLY) |
1934 | + return -XFS_ERROR(EROFS); |
1935 | + |
1936 | if (copy_from_user(&eofb, arg, sizeof(eofb))) |
1937 | return -XFS_ERROR(EFAULT); |
1938 | |
1939 | diff --git a/include/linux/fs.h b/include/linux/fs.h |
1940 | index 3f40547ba191..fefa7b00ba42 100644 |
1941 | --- a/include/linux/fs.h |
1942 | +++ b/include/linux/fs.h |
1943 | @@ -2562,6 +2562,7 @@ extern int simple_write_begin(struct file *file, struct address_space *mapping, |
1944 | extern int simple_write_end(struct file *file, struct address_space *mapping, |
1945 | loff_t pos, unsigned len, unsigned copied, |
1946 | struct page *page, void *fsdata); |
1947 | +extern struct inode *alloc_anon_inode(struct super_block *); |
1948 | |
1949 | extern struct dentry *simple_lookup(struct inode *, struct dentry *, unsigned int flags); |
1950 | extern ssize_t generic_read_dir(struct file *, char __user *, size_t, loff_t *); |
1951 | diff --git a/include/linux/net.h b/include/linux/net.h |
1952 | index 4f27575ce1d6..8bd9d926b3cf 100644 |
1953 | --- a/include/linux/net.h |
1954 | +++ b/include/linux/net.h |
1955 | @@ -163,6 +163,14 @@ struct proto_ops { |
1956 | #endif |
1957 | int (*sendmsg) (struct kiocb *iocb, struct socket *sock, |
1958 | struct msghdr *m, size_t total_len); |
1959 | + /* Notes for implementing recvmsg: |
1960 | + * =============================== |
1961 | + * msg->msg_namelen should get updated by the recvmsg handlers |
1962 | + * iff msg_name != NULL. It is by default 0 to prevent |
1963 | + * returning uninitialized memory to user space. The recvfrom |
1964 | + * handlers can assume that msg.msg_name is either NULL or has |
1965 | + * a minimum size of sizeof(struct sockaddr_storage). |
1966 | + */ |
1967 | int (*recvmsg) (struct kiocb *iocb, struct socket *sock, |
1968 | struct msghdr *m, size_t total_len, |
1969 | int flags); |
1970 | diff --git a/include/linux/random.h b/include/linux/random.h |
1971 | index 6312dd9ba449..bf9085e89fb5 100644 |
1972 | --- a/include/linux/random.h |
1973 | +++ b/include/linux/random.h |
1974 | @@ -50,9 +50,9 @@ static inline void prandom_seed_state(struct rnd_state *state, u64 seed) |
1975 | { |
1976 | u32 i = (seed >> 32) ^ (seed << 10) ^ seed; |
1977 | |
1978 | - state->s1 = __seed(i, 1); |
1979 | - state->s2 = __seed(i, 7); |
1980 | - state->s3 = __seed(i, 15); |
1981 | + state->s1 = __seed(i, 2); |
1982 | + state->s2 = __seed(i, 8); |
1983 | + state->s3 = __seed(i, 16); |
1984 | } |
1985 | |
1986 | #ifdef CONFIG_ARCH_RANDOM |
1987 | diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h |
1988 | index c2d89335f637..f66f346dd164 100644 |
1989 | --- a/include/linux/skbuff.h |
1990 | +++ b/include/linux/skbuff.h |
1991 | @@ -333,11 +333,6 @@ typedef unsigned int sk_buff_data_t; |
1992 | typedef unsigned char *sk_buff_data_t; |
1993 | #endif |
1994 | |
1995 | -#if defined(CONFIG_NF_DEFRAG_IPV4) || defined(CONFIG_NF_DEFRAG_IPV4_MODULE) || \ |
1996 | - defined(CONFIG_NF_DEFRAG_IPV6) || defined(CONFIG_NF_DEFRAG_IPV6_MODULE) |
1997 | -#define NET_SKBUFF_NF_DEFRAG_NEEDED 1 |
1998 | -#endif |
1999 | - |
2000 | /** |
2001 | * struct sk_buff - socket buffer |
2002 | * @next: Next buffer in list |
2003 | @@ -370,7 +365,6 @@ typedef unsigned char *sk_buff_data_t; |
2004 | * @protocol: Packet protocol from driver |
2005 | * @destructor: Destruct function |
2006 | * @nfct: Associated connection, if any |
2007 | - * @nfct_reasm: netfilter conntrack re-assembly pointer |
2008 | * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c |
2009 | * @skb_iif: ifindex of device we arrived on |
2010 | * @tc_index: Traffic control index |
2011 | @@ -459,9 +453,6 @@ struct sk_buff { |
2012 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) |
2013 | struct nf_conntrack *nfct; |
2014 | #endif |
2015 | -#ifdef NET_SKBUFF_NF_DEFRAG_NEEDED |
2016 | - struct sk_buff *nfct_reasm; |
2017 | -#endif |
2018 | #ifdef CONFIG_BRIDGE_NETFILTER |
2019 | struct nf_bridge_info *nf_bridge; |
2020 | #endif |
2021 | @@ -2605,18 +2596,6 @@ static inline void nf_conntrack_get(struct nf_conntrack *nfct) |
2022 | atomic_inc(&nfct->use); |
2023 | } |
2024 | #endif |
2025 | -#ifdef NET_SKBUFF_NF_DEFRAG_NEEDED |
2026 | -static inline void nf_conntrack_get_reasm(struct sk_buff *skb) |
2027 | -{ |
2028 | - if (skb) |
2029 | - atomic_inc(&skb->users); |
2030 | -} |
2031 | -static inline void nf_conntrack_put_reasm(struct sk_buff *skb) |
2032 | -{ |
2033 | - if (skb) |
2034 | - kfree_skb(skb); |
2035 | -} |
2036 | -#endif |
2037 | #ifdef CONFIG_BRIDGE_NETFILTER |
2038 | static inline void nf_bridge_put(struct nf_bridge_info *nf_bridge) |
2039 | { |
2040 | @@ -2635,10 +2614,6 @@ static inline void nf_reset(struct sk_buff *skb) |
2041 | nf_conntrack_put(skb->nfct); |
2042 | skb->nfct = NULL; |
2043 | #endif |
2044 | -#ifdef NET_SKBUFF_NF_DEFRAG_NEEDED |
2045 | - nf_conntrack_put_reasm(skb->nfct_reasm); |
2046 | - skb->nfct_reasm = NULL; |
2047 | -#endif |
2048 | #ifdef CONFIG_BRIDGE_NETFILTER |
2049 | nf_bridge_put(skb->nf_bridge); |
2050 | skb->nf_bridge = NULL; |
2051 | @@ -2660,10 +2635,6 @@ static inline void __nf_copy(struct sk_buff *dst, const struct sk_buff *src) |
2052 | nf_conntrack_get(src->nfct); |
2053 | dst->nfctinfo = src->nfctinfo; |
2054 | #endif |
2055 | -#ifdef NET_SKBUFF_NF_DEFRAG_NEEDED |
2056 | - dst->nfct_reasm = src->nfct_reasm; |
2057 | - nf_conntrack_get_reasm(src->nfct_reasm); |
2058 | -#endif |
2059 | #ifdef CONFIG_BRIDGE_NETFILTER |
2060 | dst->nf_bridge = src->nf_bridge; |
2061 | nf_bridge_get(src->nf_bridge); |
2062 | @@ -2675,9 +2646,6 @@ static inline void nf_copy(struct sk_buff *dst, const struct sk_buff *src) |
2063 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) |
2064 | nf_conntrack_put(dst->nfct); |
2065 | #endif |
2066 | -#ifdef NET_SKBUFF_NF_DEFRAG_NEEDED |
2067 | - nf_conntrack_put_reasm(dst->nfct_reasm); |
2068 | -#endif |
2069 | #ifdef CONFIG_BRIDGE_NETFILTER |
2070 | nf_bridge_put(dst->nf_bridge); |
2071 | #endif |
2072 | diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h |
2073 | index 1855f0a22add..c557c6d096de 100644 |
2074 | --- a/include/linux/vm_event_item.h |
2075 | +++ b/include/linux/vm_event_item.h |
2076 | @@ -39,6 +39,7 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, |
2077 | PAGEOUTRUN, ALLOCSTALL, PGROTATED, |
2078 | #ifdef CONFIG_NUMA_BALANCING |
2079 | NUMA_PTE_UPDATES, |
2080 | + NUMA_HUGE_PTE_UPDATES, |
2081 | NUMA_HINT_FAULTS, |
2082 | NUMA_HINT_FAULTS_LOCAL, |
2083 | NUMA_PAGE_MIGRATE, |
2084 | diff --git a/include/net/ip.h b/include/net/ip.h |
2085 | index 5e5268807a1c..301f10c9b563 100644 |
2086 | --- a/include/net/ip.h |
2087 | +++ b/include/net/ip.h |
2088 | @@ -464,7 +464,7 @@ extern int compat_ip_getsockopt(struct sock *sk, int level, |
2089 | int optname, char __user *optval, int __user *optlen); |
2090 | extern int ip_ra_control(struct sock *sk, unsigned char on, void (*destructor)(struct sock *)); |
2091 | |
2092 | -extern int ip_recv_error(struct sock *sk, struct msghdr *msg, int len); |
2093 | +extern int ip_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len); |
2094 | extern void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err, |
2095 | __be16 port, u32 info, u8 *payload); |
2096 | extern void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 dport, |
2097 | diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h |
2098 | index 9c4d37ec45a1..772252ddc115 100644 |
2099 | --- a/include/net/ip_vs.h |
2100 | +++ b/include/net/ip_vs.h |
2101 | @@ -109,7 +109,6 @@ extern int ip_vs_conn_tab_size; |
2102 | struct ip_vs_iphdr { |
2103 | __u32 len; /* IPv4 simply where L4 starts |
2104 | IPv6 where L4 Transport Header starts */ |
2105 | - __u32 thoff_reasm; /* Transport Header Offset in nfct_reasm skb */ |
2106 | __u16 fragoffs; /* IPv6 fragment offset, 0 if first frag (or not frag)*/ |
2107 | __s16 protocol; |
2108 | __s32 flags; |
2109 | @@ -117,34 +116,12 @@ struct ip_vs_iphdr { |
2110 | union nf_inet_addr daddr; |
2111 | }; |
2112 | |
2113 | -/* Dependency to module: nf_defrag_ipv6 */ |
2114 | -#if defined(CONFIG_NF_DEFRAG_IPV6) || defined(CONFIG_NF_DEFRAG_IPV6_MODULE) |
2115 | -static inline struct sk_buff *skb_nfct_reasm(const struct sk_buff *skb) |
2116 | -{ |
2117 | - return skb->nfct_reasm; |
2118 | -} |
2119 | -static inline void *frag_safe_skb_hp(const struct sk_buff *skb, int offset, |
2120 | - int len, void *buffer, |
2121 | - const struct ip_vs_iphdr *ipvsh) |
2122 | -{ |
2123 | - if (unlikely(ipvsh->fragoffs && skb_nfct_reasm(skb))) |
2124 | - return skb_header_pointer(skb_nfct_reasm(skb), |
2125 | - ipvsh->thoff_reasm, len, buffer); |
2126 | - |
2127 | - return skb_header_pointer(skb, offset, len, buffer); |
2128 | -} |
2129 | -#else |
2130 | -static inline struct sk_buff *skb_nfct_reasm(const struct sk_buff *skb) |
2131 | -{ |
2132 | - return NULL; |
2133 | -} |
2134 | static inline void *frag_safe_skb_hp(const struct sk_buff *skb, int offset, |
2135 | int len, void *buffer, |
2136 | const struct ip_vs_iphdr *ipvsh) |
2137 | { |
2138 | return skb_header_pointer(skb, offset, len, buffer); |
2139 | } |
2140 | -#endif |
2141 | |
2142 | static inline void |
2143 | ip_vs_fill_ip4hdr(const void *nh, struct ip_vs_iphdr *iphdr) |
2144 | @@ -171,19 +148,12 @@ ip_vs_fill_iph_skb(int af, const struct sk_buff *skb, struct ip_vs_iphdr *iphdr) |
2145 | (struct ipv6hdr *)skb_network_header(skb); |
2146 | iphdr->saddr.in6 = iph->saddr; |
2147 | iphdr->daddr.in6 = iph->daddr; |
2148 | - /* ipv6_find_hdr() updates len, flags, thoff_reasm */ |
2149 | - iphdr->thoff_reasm = 0; |
2150 | + /* ipv6_find_hdr() updates len, flags */ |
2151 | iphdr->len = 0; |
2152 | iphdr->flags = 0; |
2153 | iphdr->protocol = ipv6_find_hdr(skb, &iphdr->len, -1, |
2154 | &iphdr->fragoffs, |
2155 | &iphdr->flags); |
2156 | - /* get proto from re-assembled packet and it's offset */ |
2157 | - if (skb_nfct_reasm(skb)) |
2158 | - iphdr->protocol = ipv6_find_hdr(skb_nfct_reasm(skb), |
2159 | - &iphdr->thoff_reasm, |
2160 | - -1, NULL, NULL); |
2161 | - |
2162 | } else |
2163 | #endif |
2164 | { |
2165 | diff --git a/include/net/ipv6.h b/include/net/ipv6.h |
2166 | index bbf1c8fb8511..1f96efd30816 100644 |
2167 | --- a/include/net/ipv6.h |
2168 | +++ b/include/net/ipv6.h |
2169 | @@ -802,8 +802,10 @@ extern int compat_ipv6_getsockopt(struct sock *sk, |
2170 | extern int ip6_datagram_connect(struct sock *sk, |
2171 | struct sockaddr *addr, int addr_len); |
2172 | |
2173 | -extern int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len); |
2174 | -extern int ipv6_recv_rxpmtu(struct sock *sk, struct msghdr *msg, int len); |
2175 | +extern int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len, |
2176 | + int *addr_len); |
2177 | +extern int ipv6_recv_rxpmtu(struct sock *sk, struct msghdr *msg, int len, |
2178 | + int *addr_len); |
2179 | extern void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err, __be16 port, |
2180 | u32 info, u8 *payload); |
2181 | extern void ipv6_local_error(struct sock *sk, int err, struct flowi6 *fl6, u32 info); |
2182 | diff --git a/include/net/netfilter/ipv6/nf_defrag_ipv6.h b/include/net/netfilter/ipv6/nf_defrag_ipv6.h |
2183 | index fd79c9a1779d..17920d847b40 100644 |
2184 | --- a/include/net/netfilter/ipv6/nf_defrag_ipv6.h |
2185 | +++ b/include/net/netfilter/ipv6/nf_defrag_ipv6.h |
2186 | @@ -6,10 +6,7 @@ extern void nf_defrag_ipv6_enable(void); |
2187 | extern int nf_ct_frag6_init(void); |
2188 | extern void nf_ct_frag6_cleanup(void); |
2189 | extern struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb, u32 user); |
2190 | -extern void nf_ct_frag6_output(unsigned int hooknum, struct sk_buff *skb, |
2191 | - struct net_device *in, |
2192 | - struct net_device *out, |
2193 | - int (*okfn)(struct sk_buff *)); |
2194 | +extern void nf_ct_frag6_consume_orig(struct sk_buff *skb); |
2195 | |
2196 | struct inet_frags_ctl; |
2197 | |
2198 | diff --git a/include/net/ping.h b/include/net/ping.h |
2199 | index 5db0224b73ac..2b496e9f9ebd 100644 |
2200 | --- a/include/net/ping.h |
2201 | +++ b/include/net/ping.h |
2202 | @@ -31,7 +31,8 @@ |
2203 | |
2204 | /* Compatibility glue so we can support IPv6 when it's compiled as a module */ |
2205 | struct pingv6_ops { |
2206 | - int (*ipv6_recv_error)(struct sock *sk, struct msghdr *msg, int len); |
2207 | + int (*ipv6_recv_error)(struct sock *sk, struct msghdr *msg, int len, |
2208 | + int *addr_len); |
2209 | int (*ip6_datagram_recv_ctl)(struct sock *sk, struct msghdr *msg, |
2210 | struct sk_buff *skb); |
2211 | int (*icmpv6_err_convert)(u8 type, u8 code, int *err); |
2212 | diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h |
2213 | index 9b829134d422..66f925d3c07b 100644 |
2214 | --- a/include/uapi/linux/pkt_sched.h |
2215 | +++ b/include/uapi/linux/pkt_sched.h |
2216 | @@ -759,13 +759,14 @@ enum { |
2217 | |
2218 | TCA_FQ_RATE_ENABLE, /* enable/disable rate limiting */ |
2219 | |
2220 | - TCA_FQ_FLOW_DEFAULT_RATE,/* for sockets with unspecified sk_rate, |
2221 | - * use the following rate |
2222 | - */ |
2223 | + TCA_FQ_FLOW_DEFAULT_RATE,/* obsolete, do not use */ |
2224 | |
2225 | TCA_FQ_FLOW_MAX_RATE, /* per flow max rate */ |
2226 | |
2227 | TCA_FQ_BUCKETS_LOG, /* log2(number of buckets) */ |
2228 | + |
2229 | + TCA_FQ_FLOW_REFILL_DELAY, /* flow credit refill delay in usec */ |
2230 | + |
2231 | __TCA_FQ_MAX |
2232 | }; |
2233 | |
2234 | diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c |
2235 | index bb2215174f05..af8d1d4f3d55 100644 |
2236 | --- a/kernel/time/ntp.c |
2237 | +++ b/kernel/time/ntp.c |
2238 | @@ -475,6 +475,7 @@ static void sync_cmos_clock(struct work_struct *work) |
2239 | * called as close as possible to 500 ms before the new second starts. |
2240 | * This code is run on a timer. If the clock is set, that timer |
2241 | * may not expire at the correct time. Thus, we adjust... |
2242 | + * We want the clock to be within a couple of ticks from the target. |
2243 | */ |
2244 | if (!ntp_synced()) { |
2245 | /* |
2246 | @@ -485,7 +486,7 @@ static void sync_cmos_clock(struct work_struct *work) |
2247 | } |
2248 | |
2249 | getnstimeofday(&now); |
2250 | - if (abs(now.tv_nsec - (NSEC_PER_SEC / 2)) <= tick_nsec / 2) { |
2251 | + if (abs(now.tv_nsec - (NSEC_PER_SEC / 2)) <= tick_nsec * 5) { |
2252 | struct timespec adjust = now; |
2253 | |
2254 | fail = -ENODEV; |
2255 | diff --git a/lib/random32.c b/lib/random32.c |
2256 | index 52280d5526be..01e8890d1089 100644 |
2257 | --- a/lib/random32.c |
2258 | +++ b/lib/random32.c |
2259 | @@ -141,7 +141,7 @@ void prandom_seed(u32 entropy) |
2260 | */ |
2261 | for_each_possible_cpu (i) { |
2262 | struct rnd_state *state = &per_cpu(net_rand_state, i); |
2263 | - state->s1 = __seed(state->s1 ^ entropy, 1); |
2264 | + state->s1 = __seed(state->s1 ^ entropy, 2); |
2265 | } |
2266 | } |
2267 | EXPORT_SYMBOL(prandom_seed); |
2268 | @@ -158,9 +158,9 @@ static int __init prandom_init(void) |
2269 | struct rnd_state *state = &per_cpu(net_rand_state,i); |
2270 | |
2271 | #define LCG(x) ((x) * 69069) /* super-duper LCG */ |
2272 | - state->s1 = __seed(LCG(i + jiffies), 1); |
2273 | - state->s2 = __seed(LCG(state->s1), 7); |
2274 | - state->s3 = __seed(LCG(state->s2), 15); |
2275 | + state->s1 = __seed(LCG(i + jiffies), 2); |
2276 | + state->s2 = __seed(LCG(state->s1), 8); |
2277 | + state->s3 = __seed(LCG(state->s2), 16); |
2278 | |
2279 | /* "warm it up" */ |
2280 | prandom_u32_state(state); |
2281 | @@ -187,9 +187,9 @@ static int __init prandom_reseed(void) |
2282 | u32 seeds[3]; |
2283 | |
2284 | get_random_bytes(&seeds, sizeof(seeds)); |
2285 | - state->s1 = __seed(seeds[0], 1); |
2286 | - state->s2 = __seed(seeds[1], 7); |
2287 | - state->s3 = __seed(seeds[2], 15); |
2288 | + state->s1 = __seed(seeds[0], 2); |
2289 | + state->s2 = __seed(seeds[1], 8); |
2290 | + state->s3 = __seed(seeds[2], 16); |
2291 | |
2292 | /* mix it in */ |
2293 | prandom_u32_state(state); |
2294 | diff --git a/mm/mprotect.c b/mm/mprotect.c |
2295 | index 412ba2b7326a..6c3f56f19275 100644 |
2296 | --- a/mm/mprotect.c |
2297 | +++ b/mm/mprotect.c |
2298 | @@ -138,6 +138,7 @@ static inline unsigned long change_pmd_range(struct vm_area_struct *vma, |
2299 | pmd_t *pmd; |
2300 | unsigned long next; |
2301 | unsigned long pages = 0; |
2302 | + unsigned long nr_huge_updates = 0; |
2303 | bool all_same_node; |
2304 | |
2305 | pmd = pmd_offset(pud, addr); |
2306 | @@ -148,7 +149,8 @@ static inline unsigned long change_pmd_range(struct vm_area_struct *vma, |
2307 | split_huge_page_pmd(vma, addr, pmd); |
2308 | else if (change_huge_pmd(vma, pmd, addr, newprot, |
2309 | prot_numa)) { |
2310 | - pages++; |
2311 | + pages += HPAGE_PMD_NR; |
2312 | + nr_huge_updates++; |
2313 | continue; |
2314 | } |
2315 | /* fall through */ |
2316 | @@ -168,6 +170,9 @@ static inline unsigned long change_pmd_range(struct vm_area_struct *vma, |
2317 | change_pmd_protnuma(vma->vm_mm, addr, pmd); |
2318 | } while (pmd++, addr = next, addr != end); |
2319 | |
2320 | + if (nr_huge_updates) |
2321 | + count_vm_numa_events(NUMA_HUGE_PTE_UPDATES, nr_huge_updates); |
2322 | + |
2323 | return pages; |
2324 | } |
2325 | |
2326 | diff --git a/mm/vmstat.c b/mm/vmstat.c |
2327 | index 9bb314577911..5a442a723d79 100644 |
2328 | --- a/mm/vmstat.c |
2329 | +++ b/mm/vmstat.c |
2330 | @@ -812,6 +812,7 @@ const char * const vmstat_text[] = { |
2331 | |
2332 | #ifdef CONFIG_NUMA_BALANCING |
2333 | "numa_pte_updates", |
2334 | + "numa_huge_pte_updates", |
2335 | "numa_hint_faults", |
2336 | "numa_hint_faults_local", |
2337 | "numa_pages_migrated", |
2338 | diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c |
2339 | index 7fee50d637f9..7d424ac6e760 100644 |
2340 | --- a/net/appletalk/ddp.c |
2341 | +++ b/net/appletalk/ddp.c |
2342 | @@ -1735,7 +1735,6 @@ static int atalk_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr |
2343 | size_t size, int flags) |
2344 | { |
2345 | struct sock *sk = sock->sk; |
2346 | - struct sockaddr_at *sat = (struct sockaddr_at *)msg->msg_name; |
2347 | struct ddpehdr *ddp; |
2348 | int copied = 0; |
2349 | int offset = 0; |
2350 | @@ -1764,14 +1763,13 @@ static int atalk_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr |
2351 | } |
2352 | err = skb_copy_datagram_iovec(skb, offset, msg->msg_iov, copied); |
2353 | |
2354 | - if (!err) { |
2355 | - if (sat) { |
2356 | - sat->sat_family = AF_APPLETALK; |
2357 | - sat->sat_port = ddp->deh_sport; |
2358 | - sat->sat_addr.s_node = ddp->deh_snode; |
2359 | - sat->sat_addr.s_net = ddp->deh_snet; |
2360 | - } |
2361 | - msg->msg_namelen = sizeof(*sat); |
2362 | + if (!err && msg->msg_name) { |
2363 | + struct sockaddr_at *sat = msg->msg_name; |
2364 | + sat->sat_family = AF_APPLETALK; |
2365 | + sat->sat_port = ddp->deh_sport; |
2366 | + sat->sat_addr.s_node = ddp->deh_snode; |
2367 | + sat->sat_addr.s_net = ddp->deh_snet; |
2368 | + msg->msg_namelen = sizeof(*sat); |
2369 | } |
2370 | |
2371 | skb_free_datagram(sk, skb); /* Free the datagram. */ |
2372 | diff --git a/net/atm/common.c b/net/atm/common.c |
2373 | index 737bef59ce89..7b491006eaf4 100644 |
2374 | --- a/net/atm/common.c |
2375 | +++ b/net/atm/common.c |
2376 | @@ -531,8 +531,6 @@ int vcc_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, |
2377 | struct sk_buff *skb; |
2378 | int copied, error = -EINVAL; |
2379 | |
2380 | - msg->msg_namelen = 0; |
2381 | - |
2382 | if (sock->state != SS_CONNECTED) |
2383 | return -ENOTCONN; |
2384 | |
2385 | diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c |
2386 | index 4b4d2b779ec1..78c474f8f615 100644 |
2387 | --- a/net/ax25/af_ax25.c |
2388 | +++ b/net/ax25/af_ax25.c |
2389 | @@ -1636,11 +1636,11 @@ static int ax25_recvmsg(struct kiocb *iocb, struct socket *sock, |
2390 | |
2391 | skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied); |
2392 | |
2393 | - if (msg->msg_namelen != 0) { |
2394 | - struct sockaddr_ax25 *sax = (struct sockaddr_ax25 *)msg->msg_name; |
2395 | + if (msg->msg_name) { |
2396 | ax25_digi digi; |
2397 | ax25_address src; |
2398 | const unsigned char *mac = skb_mac_header(skb); |
2399 | + struct sockaddr_ax25 *sax = msg->msg_name; |
2400 | |
2401 | memset(sax, 0, sizeof(struct full_sockaddr_ax25)); |
2402 | ax25_addr_parse(mac + 1, skb->data - mac - 1, &src, NULL, |
2403 | diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c |
2404 | index 9096137c889c..6629cdc134dc 100644 |
2405 | --- a/net/bluetooth/af_bluetooth.c |
2406 | +++ b/net/bluetooth/af_bluetooth.c |
2407 | @@ -221,8 +221,6 @@ int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock, |
2408 | if (flags & (MSG_OOB)) |
2409 | return -EOPNOTSUPP; |
2410 | |
2411 | - msg->msg_namelen = 0; |
2412 | - |
2413 | skb = skb_recv_datagram(sk, flags, noblock, &err); |
2414 | if (!skb) { |
2415 | if (sk->sk_shutdown & RCV_SHUTDOWN) |
2416 | @@ -287,8 +285,6 @@ int bt_sock_stream_recvmsg(struct kiocb *iocb, struct socket *sock, |
2417 | if (flags & MSG_OOB) |
2418 | return -EOPNOTSUPP; |
2419 | |
2420 | - msg->msg_namelen = 0; |
2421 | - |
2422 | BT_DBG("sk %p size %zu", sk, size); |
2423 | |
2424 | lock_sock(sk); |
2425 | diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c |
2426 | index 9bd7d959e384..fa4bf6631425 100644 |
2427 | --- a/net/bluetooth/hci_sock.c |
2428 | +++ b/net/bluetooth/hci_sock.c |
2429 | @@ -752,8 +752,6 @@ static int hci_sock_recvmsg(struct kiocb *iocb, struct socket *sock, |
2430 | if (!skb) |
2431 | return err; |
2432 | |
2433 | - msg->msg_namelen = 0; |
2434 | - |
2435 | copied = skb->len; |
2436 | if (len < copied) { |
2437 | msg->msg_flags |= MSG_TRUNC; |
2438 | diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c |
2439 | index 30b3721dc6d7..c1c6028e389a 100644 |
2440 | --- a/net/bluetooth/rfcomm/sock.c |
2441 | +++ b/net/bluetooth/rfcomm/sock.c |
2442 | @@ -608,7 +608,6 @@ static int rfcomm_sock_recvmsg(struct kiocb *iocb, struct socket *sock, |
2443 | |
2444 | if (test_and_clear_bit(RFCOMM_DEFER_SETUP, &d->flags)) { |
2445 | rfcomm_dlc_accept(d); |
2446 | - msg->msg_namelen = 0; |
2447 | return 0; |
2448 | } |
2449 | |
2450 | diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c |
2451 | index 96bd388d93a4..d021e441b6e6 100644 |
2452 | --- a/net/bluetooth/sco.c |
2453 | +++ b/net/bluetooth/sco.c |
2454 | @@ -715,7 +715,6 @@ static int sco_sock_recvmsg(struct kiocb *iocb, struct socket *sock, |
2455 | test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) { |
2456 | sco_conn_defer_accept(pi->conn->hcon, pi->setting); |
2457 | sk->sk_state = BT_CONFIG; |
2458 | - msg->msg_namelen = 0; |
2459 | |
2460 | release_sock(sk); |
2461 | return 0; |
2462 | diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c |
2463 | index c41d5fbb91d0..547504ccba69 100644 |
2464 | --- a/net/bridge/br_if.c |
2465 | +++ b/net/bridge/br_if.c |
2466 | @@ -172,6 +172,8 @@ void br_dev_delete(struct net_device *dev, struct list_head *head) |
2467 | del_nbp(p); |
2468 | } |
2469 | |
2470 | + br_fdb_delete_by_port(br, NULL, 1); |
2471 | + |
2472 | del_timer_sync(&br->gc_timer); |
2473 | |
2474 | br_sysfs_delbr(br->dev); |
2475 | diff --git a/net/caif/caif_socket.c b/net/caif/caif_socket.c |
2476 | index 05a41c7ec304..d6be3edb7a43 100644 |
2477 | --- a/net/caif/caif_socket.c |
2478 | +++ b/net/caif/caif_socket.c |
2479 | @@ -286,8 +286,6 @@ static int caif_seqpkt_recvmsg(struct kiocb *iocb, struct socket *sock, |
2480 | if (m->msg_flags&MSG_OOB) |
2481 | goto read_error; |
2482 | |
2483 | - m->msg_namelen = 0; |
2484 | - |
2485 | skb = skb_recv_datagram(sk, flags, 0 , &ret); |
2486 | if (!skb) |
2487 | goto read_error; |
2488 | @@ -361,8 +359,6 @@ static int caif_stream_recvmsg(struct kiocb *iocb, struct socket *sock, |
2489 | if (flags&MSG_OOB) |
2490 | goto out; |
2491 | |
2492 | - msg->msg_namelen = 0; |
2493 | - |
2494 | /* |
2495 | * Lock the socket to prevent queue disordering |
2496 | * while sleeps in memcpy_tomsg |
2497 | diff --git a/net/compat.c b/net/compat.c |
2498 | index 89032580bd1d..dd32e34c1e2c 100644 |
2499 | --- a/net/compat.c |
2500 | +++ b/net/compat.c |
2501 | @@ -72,7 +72,7 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg) |
2502 | __get_user(kmsg->msg_flags, &umsg->msg_flags)) |
2503 | return -EFAULT; |
2504 | if (kmsg->msg_namelen > sizeof(struct sockaddr_storage)) |
2505 | - return -EINVAL; |
2506 | + kmsg->msg_namelen = sizeof(struct sockaddr_storage); |
2507 | kmsg->msg_name = compat_ptr(tmp1); |
2508 | kmsg->msg_iov = compat_ptr(tmp2); |
2509 | kmsg->msg_control = compat_ptr(tmp3); |
2510 | @@ -93,7 +93,8 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov, |
2511 | if (err < 0) |
2512 | return err; |
2513 | } |
2514 | - kern_msg->msg_name = kern_address; |
2515 | + if (kern_msg->msg_name) |
2516 | + kern_msg->msg_name = kern_address; |
2517 | } else |
2518 | kern_msg->msg_name = NULL; |
2519 | |
2520 | diff --git a/net/core/dev.c b/net/core/dev.c |
2521 | index 3430b1ed12e5..3d1387461279 100644 |
2522 | --- a/net/core/dev.c |
2523 | +++ b/net/core/dev.c |
2524 | @@ -1691,13 +1691,9 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb) |
2525 | kfree_skb(skb); |
2526 | return NET_RX_DROP; |
2527 | } |
2528 | - skb->protocol = eth_type_trans(skb, dev); |
2529 | |
2530 | - /* eth_type_trans() can set pkt_type. |
2531 | - * call skb_scrub_packet() after it to clear pkt_type _after_ calling |
2532 | - * eth_type_trans(). |
2533 | - */ |
2534 | skb_scrub_packet(skb, true); |
2535 | + skb->protocol = eth_type_trans(skb, dev); |
2536 | |
2537 | return netif_rx(skb); |
2538 | } |
2539 | @@ -4819,7 +4815,7 @@ static void dev_change_rx_flags(struct net_device *dev, int flags) |
2540 | { |
2541 | const struct net_device_ops *ops = dev->netdev_ops; |
2542 | |
2543 | - if ((dev->flags & IFF_UP) && ops->ndo_change_rx_flags) |
2544 | + if (ops->ndo_change_rx_flags) |
2545 | ops->ndo_change_rx_flags(dev, flags); |
2546 | } |
2547 | |
2548 | diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c |
2549 | index 2e654138433c..f409e0bd35c0 100644 |
2550 | --- a/net/core/fib_rules.c |
2551 | +++ b/net/core/fib_rules.c |
2552 | @@ -460,7 +460,8 @@ static int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh) |
2553 | if (frh->action && (frh->action != rule->action)) |
2554 | continue; |
2555 | |
2556 | - if (frh->table && (frh_get_table(frh, tb) != rule->table)) |
2557 | + if (frh_get_table(frh, tb) && |
2558 | + (frh_get_table(frh, tb) != rule->table)) |
2559 | continue; |
2560 | |
2561 | if (tb[FRA_PRIORITY] && |
2562 | diff --git a/net/core/iovec.c b/net/core/iovec.c |
2563 | index b77eeecc0011..7d84ea1fbb20 100644 |
2564 | --- a/net/core/iovec.c |
2565 | +++ b/net/core/iovec.c |
2566 | @@ -48,7 +48,8 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a |
2567 | if (err < 0) |
2568 | return err; |
2569 | } |
2570 | - m->msg_name = address; |
2571 | + if (m->msg_name) |
2572 | + m->msg_name = address; |
2573 | } else { |
2574 | m->msg_name = NULL; |
2575 | } |
2576 | diff --git a/net/core/pktgen.c b/net/core/pktgen.c |
2577 | index 261357a66300..a797fff7f222 100644 |
2578 | --- a/net/core/pktgen.c |
2579 | +++ b/net/core/pktgen.c |
2580 | @@ -2527,6 +2527,8 @@ static int process_ipsec(struct pktgen_dev *pkt_dev, |
2581 | if (x) { |
2582 | int ret; |
2583 | __u8 *eth; |
2584 | + struct iphdr *iph; |
2585 | + |
2586 | nhead = x->props.header_len - skb_headroom(skb); |
2587 | if (nhead > 0) { |
2588 | ret = pskb_expand_head(skb, nhead, 0, GFP_ATOMIC); |
2589 | @@ -2548,6 +2550,11 @@ static int process_ipsec(struct pktgen_dev *pkt_dev, |
2590 | eth = (__u8 *) skb_push(skb, ETH_HLEN); |
2591 | memcpy(eth, pkt_dev->hh, 12); |
2592 | *(u16 *) ð[12] = protocol; |
2593 | + |
2594 | + /* Update IPv4 header len as well as checksum value */ |
2595 | + iph = ip_hdr(skb); |
2596 | + iph->tot_len = htons(skb->len - ETH_HLEN); |
2597 | + ip_send_check(iph); |
2598 | } |
2599 | } |
2600 | return 1; |
2601 | diff --git a/net/core/skbuff.c b/net/core/skbuff.c |
2602 | index d81cff119f73..c28c7fed0d0b 100644 |
2603 | --- a/net/core/skbuff.c |
2604 | +++ b/net/core/skbuff.c |
2605 | @@ -580,9 +580,6 @@ static void skb_release_head_state(struct sk_buff *skb) |
2606 | #if IS_ENABLED(CONFIG_NF_CONNTRACK) |
2607 | nf_conntrack_put(skb->nfct); |
2608 | #endif |
2609 | -#ifdef NET_SKBUFF_NF_DEFRAG_NEEDED |
2610 | - nf_conntrack_put_reasm(skb->nfct_reasm); |
2611 | -#endif |
2612 | #ifdef CONFIG_BRIDGE_NETFILTER |
2613 | nf_bridge_put(skb->nf_bridge); |
2614 | #endif |
2615 | @@ -2758,6 +2755,7 @@ struct sk_buff *skb_segment(struct sk_buff *skb, netdev_features_t features) |
2616 | struct sk_buff *segs = NULL; |
2617 | struct sk_buff *tail = NULL; |
2618 | struct sk_buff *fskb = skb_shinfo(skb)->frag_list; |
2619 | + skb_frag_t *skb_frag = skb_shinfo(skb)->frags; |
2620 | unsigned int mss = skb_shinfo(skb)->gso_size; |
2621 | unsigned int doffset = skb->data - skb_mac_header(skb); |
2622 | unsigned int offset = doffset; |
2623 | @@ -2797,16 +2795,38 @@ struct sk_buff *skb_segment(struct sk_buff *skb, netdev_features_t features) |
2624 | if (hsize > len || !sg) |
2625 | hsize = len; |
2626 | |
2627 | - if (!hsize && i >= nfrags) { |
2628 | - BUG_ON(fskb->len != len); |
2629 | + if (!hsize && i >= nfrags && skb_headlen(fskb) && |
2630 | + (skb_headlen(fskb) == len || sg)) { |
2631 | + BUG_ON(skb_headlen(fskb) > len); |
2632 | + |
2633 | + i = 0; |
2634 | + nfrags = skb_shinfo(fskb)->nr_frags; |
2635 | + skb_frag = skb_shinfo(fskb)->frags; |
2636 | + pos += skb_headlen(fskb); |
2637 | + |
2638 | + while (pos < offset + len) { |
2639 | + BUG_ON(i >= nfrags); |
2640 | + |
2641 | + size = skb_frag_size(skb_frag); |
2642 | + if (pos + size > offset + len) |
2643 | + break; |
2644 | + |
2645 | + i++; |
2646 | + pos += size; |
2647 | + skb_frag++; |
2648 | + } |
2649 | |
2650 | - pos += len; |
2651 | nskb = skb_clone(fskb, GFP_ATOMIC); |
2652 | fskb = fskb->next; |
2653 | |
2654 | if (unlikely(!nskb)) |
2655 | goto err; |
2656 | |
2657 | + if (unlikely(pskb_trim(nskb, len))) { |
2658 | + kfree_skb(nskb); |
2659 | + goto err; |
2660 | + } |
2661 | + |
2662 | hsize = skb_end_offset(nskb); |
2663 | if (skb_cow_head(nskb, doffset + headroom)) { |
2664 | kfree_skb(nskb); |
2665 | @@ -2850,7 +2870,7 @@ struct sk_buff *skb_segment(struct sk_buff *skb, netdev_features_t features) |
2666 | nskb->data - tnl_hlen, |
2667 | doffset + tnl_hlen); |
2668 | |
2669 | - if (fskb != skb_shinfo(skb)->frag_list) |
2670 | + if (nskb->len == len + doffset) |
2671 | goto perform_csum_check; |
2672 | |
2673 | if (!sg) { |
2674 | @@ -2868,8 +2888,28 @@ struct sk_buff *skb_segment(struct sk_buff *skb, netdev_features_t features) |
2675 | |
2676 | skb_shinfo(nskb)->tx_flags = skb_shinfo(skb)->tx_flags & SKBTX_SHARED_FRAG; |
2677 | |
2678 | - while (pos < offset + len && i < nfrags) { |
2679 | - *frag = skb_shinfo(skb)->frags[i]; |
2680 | + while (pos < offset + len) { |
2681 | + if (i >= nfrags) { |
2682 | + BUG_ON(skb_headlen(fskb)); |
2683 | + |
2684 | + i = 0; |
2685 | + nfrags = skb_shinfo(fskb)->nr_frags; |
2686 | + skb_frag = skb_shinfo(fskb)->frags; |
2687 | + |
2688 | + BUG_ON(!nfrags); |
2689 | + |
2690 | + fskb = fskb->next; |
2691 | + } |
2692 | + |
2693 | + if (unlikely(skb_shinfo(nskb)->nr_frags >= |
2694 | + MAX_SKB_FRAGS)) { |
2695 | + net_warn_ratelimited( |
2696 | + "skb_segment: too many frags: %u %u\n", |
2697 | + pos, mss); |
2698 | + goto err; |
2699 | + } |
2700 | + |
2701 | + *frag = *skb_frag; |
2702 | __skb_frag_ref(frag); |
2703 | size = skb_frag_size(frag); |
2704 | |
2705 | @@ -2882,6 +2922,7 @@ struct sk_buff *skb_segment(struct sk_buff *skb, netdev_features_t features) |
2706 | |
2707 | if (pos + size <= offset + len) { |
2708 | i++; |
2709 | + skb_frag++; |
2710 | pos += size; |
2711 | } else { |
2712 | skb_frag_size_sub(frag, pos + size - (offset + len)); |
2713 | @@ -2891,25 +2932,6 @@ struct sk_buff *skb_segment(struct sk_buff *skb, netdev_features_t features) |
2714 | frag++; |
2715 | } |
2716 | |
2717 | - if (pos < offset + len) { |
2718 | - struct sk_buff *fskb2 = fskb; |
2719 | - |
2720 | - BUG_ON(pos + fskb->len != offset + len); |
2721 | - |
2722 | - pos += fskb->len; |
2723 | - fskb = fskb->next; |
2724 | - |
2725 | - if (fskb2->next) { |
2726 | - fskb2 = skb_clone(fskb2, GFP_ATOMIC); |
2727 | - if (!fskb2) |
2728 | - goto err; |
2729 | - } else |
2730 | - skb_get(fskb2); |
2731 | - |
2732 | - SKB_FRAG_ASSERT(nskb); |
2733 | - skb_shinfo(nskb)->frag_list = fskb2; |
2734 | - } |
2735 | - |
2736 | skip_fraglist: |
2737 | nskb->data_len = len - hsize; |
2738 | nskb->len += nskb->data_len; |
2739 | diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c |
2740 | index ff41b4d60d30..008f33703a33 100644 |
2741 | --- a/net/ieee802154/6lowpan.c |
2742 | +++ b/net/ieee802154/6lowpan.c |
2743 | @@ -957,7 +957,7 @@ lowpan_process_data(struct sk_buff *skb) |
2744 | * Traffic class carried in-line |
2745 | * ECN + DSCP (1 byte), Flow Label is elided |
2746 | */ |
2747 | - case 1: /* 10b */ |
2748 | + case 2: /* 10b */ |
2749 | if (lowpan_fetch_skb_u8(skb, &tmp)) |
2750 | goto drop; |
2751 | |
2752 | @@ -968,7 +968,7 @@ lowpan_process_data(struct sk_buff *skb) |
2753 | * Flow Label carried in-line |
2754 | * ECN + 2-bit Pad + Flow Label (3 bytes), DSCP is elided |
2755 | */ |
2756 | - case 2: /* 01b */ |
2757 | + case 1: /* 01b */ |
2758 | if (lowpan_fetch_skb_u8(skb, &tmp)) |
2759 | goto drop; |
2760 | |
2761 | diff --git a/net/ieee802154/dgram.c b/net/ieee802154/dgram.c |
2762 | index 581a59504bd5..1865fdf5a5a5 100644 |
2763 | --- a/net/ieee802154/dgram.c |
2764 | +++ b/net/ieee802154/dgram.c |
2765 | @@ -315,9 +315,8 @@ static int dgram_recvmsg(struct kiocb *iocb, struct sock *sk, |
2766 | if (saddr) { |
2767 | saddr->family = AF_IEEE802154; |
2768 | saddr->addr = mac_cb(skb)->sa; |
2769 | - } |
2770 | - if (addr_len) |
2771 | *addr_len = sizeof(*saddr); |
2772 | + } |
2773 | |
2774 | if (flags & MSG_TRUNC) |
2775 | copied = skb->len; |
2776 | diff --git a/net/ipv4/datagram.c b/net/ipv4/datagram.c |
2777 | index b28e863fe0a7..19e36376d2a0 100644 |
2778 | --- a/net/ipv4/datagram.c |
2779 | +++ b/net/ipv4/datagram.c |
2780 | @@ -57,7 +57,7 @@ int ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) |
2781 | if (IS_ERR(rt)) { |
2782 | err = PTR_ERR(rt); |
2783 | if (err == -ENETUNREACH) |
2784 | - IP_INC_STATS_BH(sock_net(sk), IPSTATS_MIB_OUTNOROUTES); |
2785 | + IP_INC_STATS(sock_net(sk), IPSTATS_MIB_OUTNOROUTES); |
2786 | goto out; |
2787 | } |
2788 | |
2789 | diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c |
2790 | index d9c4f113d709..23e6ab0a2dc0 100644 |
2791 | --- a/net/ipv4/ip_sockglue.c |
2792 | +++ b/net/ipv4/ip_sockglue.c |
2793 | @@ -368,7 +368,7 @@ void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 port, u32 inf |
2794 | /* |
2795 | * Handle MSG_ERRQUEUE |
2796 | */ |
2797 | -int ip_recv_error(struct sock *sk, struct msghdr *msg, int len) |
2798 | +int ip_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len) |
2799 | { |
2800 | struct sock_exterr_skb *serr; |
2801 | struct sk_buff *skb, *skb2; |
2802 | @@ -405,6 +405,7 @@ int ip_recv_error(struct sock *sk, struct msghdr *msg, int len) |
2803 | serr->addr_offset); |
2804 | sin->sin_port = serr->port; |
2805 | memset(&sin->sin_zero, 0, sizeof(sin->sin_zero)); |
2806 | + *addr_len = sizeof(*sin); |
2807 | } |
2808 | |
2809 | memcpy(&errhdr.ee, &serr->ee, sizeof(struct sock_extended_err)); |
2810 | diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c |
2811 | index 63a6d6d6b875..254f11c24aa5 100644 |
2812 | --- a/net/ipv4/ip_tunnel.c |
2813 | +++ b/net/ipv4/ip_tunnel.c |
2814 | @@ -454,6 +454,8 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb, |
2815 | tstats->rx_bytes += skb->len; |
2816 | u64_stats_update_end(&tstats->syncp); |
2817 | |
2818 | + skb_scrub_packet(skb, !net_eq(tunnel->net, dev_net(tunnel->dev))); |
2819 | + |
2820 | if (tunnel->dev->type == ARPHRD_ETHER) { |
2821 | skb->protocol = eth_type_trans(skb, tunnel->dev); |
2822 | skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN); |
2823 | @@ -461,8 +463,6 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb, |
2824 | skb->dev = tunnel->dev; |
2825 | } |
2826 | |
2827 | - skb_scrub_packet(skb, !net_eq(tunnel->net, dev_net(tunnel->dev))); |
2828 | - |
2829 | gro_cells_receive(&tunnel->gro_cells, skb); |
2830 | return 0; |
2831 | |
2832 | diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c |
2833 | index 6e87f853d033..26847e189c04 100644 |
2834 | --- a/net/ipv4/ip_vti.c |
2835 | +++ b/net/ipv4/ip_vti.c |
2836 | @@ -190,6 +190,7 @@ static netdev_tx_t vti_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) |
2837 | if (!rt->dst.xfrm || |
2838 | rt->dst.xfrm->props.mode != XFRM_MODE_TUNNEL) { |
2839 | dev->stats.tx_carrier_errors++; |
2840 | + ip_rt_put(rt); |
2841 | goto tx_error_icmp; |
2842 | } |
2843 | tdev = rt->dst.dev; |
2844 | diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c |
2845 | index d7d9882d4cae..c482f7c7dd32 100644 |
2846 | --- a/net/ipv4/ping.c |
2847 | +++ b/net/ipv4/ping.c |
2848 | @@ -769,7 +769,7 @@ int ping_v4_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, |
2849 | err = PTR_ERR(rt); |
2850 | rt = NULL; |
2851 | if (err == -ENETUNREACH) |
2852 | - IP_INC_STATS_BH(net, IPSTATS_MIB_OUTNOROUTES); |
2853 | + IP_INC_STATS(net, IPSTATS_MIB_OUTNOROUTES); |
2854 | goto out; |
2855 | } |
2856 | |
2857 | @@ -827,8 +827,6 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, |
2858 | { |
2859 | struct inet_sock *isk = inet_sk(sk); |
2860 | int family = sk->sk_family; |
2861 | - struct sockaddr_in *sin; |
2862 | - struct sockaddr_in6 *sin6; |
2863 | struct sk_buff *skb; |
2864 | int copied, err; |
2865 | |
2866 | @@ -838,19 +836,13 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, |
2867 | if (flags & MSG_OOB) |
2868 | goto out; |
2869 | |
2870 | - if (addr_len) { |
2871 | - if (family == AF_INET) |
2872 | - *addr_len = sizeof(*sin); |
2873 | - else if (family == AF_INET6 && addr_len) |
2874 | - *addr_len = sizeof(*sin6); |
2875 | - } |
2876 | - |
2877 | if (flags & MSG_ERRQUEUE) { |
2878 | if (family == AF_INET) { |
2879 | - return ip_recv_error(sk, msg, len); |
2880 | + return ip_recv_error(sk, msg, len, addr_len); |
2881 | #if IS_ENABLED(CONFIG_IPV6) |
2882 | } else if (family == AF_INET6) { |
2883 | - return pingv6_ops.ipv6_recv_error(sk, msg, len); |
2884 | + return pingv6_ops.ipv6_recv_error(sk, msg, len, |
2885 | + addr_len); |
2886 | #endif |
2887 | } |
2888 | } |
2889 | @@ -874,11 +866,15 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, |
2890 | |
2891 | /* Copy the address and add cmsg data. */ |
2892 | if (family == AF_INET) { |
2893 | - sin = (struct sockaddr_in *) msg->msg_name; |
2894 | - sin->sin_family = AF_INET; |
2895 | - sin->sin_port = 0 /* skb->h.uh->source */; |
2896 | - sin->sin_addr.s_addr = ip_hdr(skb)->saddr; |
2897 | - memset(sin->sin_zero, 0, sizeof(sin->sin_zero)); |
2898 | + struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name; |
2899 | + |
2900 | + if (sin) { |
2901 | + sin->sin_family = AF_INET; |
2902 | + sin->sin_port = 0 /* skb->h.uh->source */; |
2903 | + sin->sin_addr.s_addr = ip_hdr(skb)->saddr; |
2904 | + memset(sin->sin_zero, 0, sizeof(sin->sin_zero)); |
2905 | + *addr_len = sizeof(*sin); |
2906 | + } |
2907 | |
2908 | if (isk->cmsg_flags) |
2909 | ip_cmsg_recv(msg, skb); |
2910 | @@ -887,17 +883,21 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, |
2911 | } else if (family == AF_INET6) { |
2912 | struct ipv6_pinfo *np = inet6_sk(sk); |
2913 | struct ipv6hdr *ip6 = ipv6_hdr(skb); |
2914 | - sin6 = (struct sockaddr_in6 *) msg->msg_name; |
2915 | - sin6->sin6_family = AF_INET6; |
2916 | - sin6->sin6_port = 0; |
2917 | - sin6->sin6_addr = ip6->saddr; |
2918 | - |
2919 | - sin6->sin6_flowinfo = 0; |
2920 | - if (np->sndflow) |
2921 | - sin6->sin6_flowinfo = ip6_flowinfo(ip6); |
2922 | - |
2923 | - sin6->sin6_scope_id = ipv6_iface_scope_id(&sin6->sin6_addr, |
2924 | - IP6CB(skb)->iif); |
2925 | + struct sockaddr_in6 *sin6 = |
2926 | + (struct sockaddr_in6 *)msg->msg_name; |
2927 | + |
2928 | + if (sin6) { |
2929 | + sin6->sin6_family = AF_INET6; |
2930 | + sin6->sin6_port = 0; |
2931 | + sin6->sin6_addr = ip6->saddr; |
2932 | + sin6->sin6_flowinfo = 0; |
2933 | + if (np->sndflow) |
2934 | + sin6->sin6_flowinfo = ip6_flowinfo(ip6); |
2935 | + sin6->sin6_scope_id = |
2936 | + ipv6_iface_scope_id(&sin6->sin6_addr, |
2937 | + IP6CB(skb)->iif); |
2938 | + *addr_len = sizeof(*sin6); |
2939 | + } |
2940 | |
2941 | if (inet6_sk(sk)->rxopt.all) |
2942 | pingv6_ops.ip6_datagram_recv_ctl(sk, msg, skb); |
2943 | diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c |
2944 | index 193db03540ad..7d3db7838e62 100644 |
2945 | --- a/net/ipv4/raw.c |
2946 | +++ b/net/ipv4/raw.c |
2947 | @@ -694,11 +694,8 @@ static int raw_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, |
2948 | if (flags & MSG_OOB) |
2949 | goto out; |
2950 | |
2951 | - if (addr_len) |
2952 | - *addr_len = sizeof(*sin); |
2953 | - |
2954 | if (flags & MSG_ERRQUEUE) { |
2955 | - err = ip_recv_error(sk, msg, len); |
2956 | + err = ip_recv_error(sk, msg, len, addr_len); |
2957 | goto out; |
2958 | } |
2959 | |
2960 | @@ -724,6 +721,7 @@ static int raw_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, |
2961 | sin->sin_addr.s_addr = ip_hdr(skb)->saddr; |
2962 | sin->sin_port = 0; |
2963 | memset(&sin->sin_zero, 0, sizeof(sin->sin_zero)); |
2964 | + *addr_len = sizeof(*sin); |
2965 | } |
2966 | if (inet->cmsg_flags) |
2967 | ip_cmsg_recv(msg, skb); |
2968 | diff --git a/net/ipv4/route.c b/net/ipv4/route.c |
2969 | index 6011615e810d..62290b5124c8 100644 |
2970 | --- a/net/ipv4/route.c |
2971 | +++ b/net/ipv4/route.c |
2972 | @@ -1772,8 +1772,12 @@ local_input: |
2973 | rth->dst.error= -err; |
2974 | rth->rt_flags &= ~RTCF_LOCAL; |
2975 | } |
2976 | - if (do_cache) |
2977 | - rt_cache_route(&FIB_RES_NH(res), rth); |
2978 | + if (do_cache) { |
2979 | + if (unlikely(!rt_cache_route(&FIB_RES_NH(res), rth))) { |
2980 | + rth->dst.flags |= DST_NOCACHE; |
2981 | + rt_add_uncached_list(rth); |
2982 | + } |
2983 | + } |
2984 | skb_dst_set(skb, &rth->dst); |
2985 | err = 0; |
2986 | goto out; |
2987 | diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c |
2988 | index 6e5617b9f9db..be5246e1d5b6 100644 |
2989 | --- a/net/ipv4/tcp.c |
2990 | +++ b/net/ipv4/tcp.c |
2991 | @@ -806,12 +806,6 @@ static unsigned int tcp_xmit_size_goal(struct sock *sk, u32 mss_now, |
2992 | xmit_size_goal = min_t(u32, gso_size, |
2993 | sk->sk_gso_max_size - 1 - hlen); |
2994 | |
2995 | - /* TSQ : try to have at least two segments in flight |
2996 | - * (one in NIC TX ring, another in Qdisc) |
2997 | - */ |
2998 | - xmit_size_goal = min_t(u32, xmit_size_goal, |
2999 | - sysctl_tcp_limit_output_bytes >> 1); |
3000 | - |
3001 | xmit_size_goal = tcp_bound_to_half_wnd(tp, xmit_size_goal); |
3002 | |
3003 | /* We try hard to avoid divides here */ |
3004 | diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c |
3005 | index b14266bb91eb..5031f68b545d 100644 |
3006 | --- a/net/ipv4/tcp_ipv4.c |
3007 | +++ b/net/ipv4/tcp_ipv4.c |
3008 | @@ -177,7 +177,7 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) |
3009 | if (IS_ERR(rt)) { |
3010 | err = PTR_ERR(rt); |
3011 | if (err == -ENETUNREACH) |
3012 | - IP_INC_STATS_BH(sock_net(sk), IPSTATS_MIB_OUTNOROUTES); |
3013 | + IP_INC_STATS(sock_net(sk), IPSTATS_MIB_OUTNOROUTES); |
3014 | return err; |
3015 | } |
3016 | |
3017 | diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c |
3018 | index 52f3c6b971d2..310711433358 100644 |
3019 | --- a/net/ipv4/tcp_metrics.c |
3020 | +++ b/net/ipv4/tcp_metrics.c |
3021 | @@ -659,10 +659,13 @@ void tcp_fastopen_cache_get(struct sock *sk, u16 *mss, |
3022 | void tcp_fastopen_cache_set(struct sock *sk, u16 mss, |
3023 | struct tcp_fastopen_cookie *cookie, bool syn_lost) |
3024 | { |
3025 | + struct dst_entry *dst = __sk_dst_get(sk); |
3026 | struct tcp_metrics_block *tm; |
3027 | |
3028 | + if (!dst) |
3029 | + return; |
3030 | rcu_read_lock(); |
3031 | - tm = tcp_get_metrics(sk, __sk_dst_get(sk), true); |
3032 | + tm = tcp_get_metrics(sk, dst, true); |
3033 | if (tm) { |
3034 | struct tcp_fastopen_metrics *tfom = &tm->tcpm_fastopen; |
3035 | |
3036 | diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c |
3037 | index 533c58a5cfb7..910ab81bc0dd 100644 |
3038 | --- a/net/ipv4/tcp_offload.c |
3039 | +++ b/net/ipv4/tcp_offload.c |
3040 | @@ -272,33 +272,32 @@ static struct sk_buff **tcp4_gro_receive(struct sk_buff **head, struct sk_buff * |
3041 | { |
3042 | const struct iphdr *iph = skb_gro_network_header(skb); |
3043 | __wsum wsum; |
3044 | - __sum16 sum; |
3045 | + |
3046 | + /* Don't bother verifying checksum if we're going to flush anyway. */ |
3047 | + if (NAPI_GRO_CB(skb)->flush) |
3048 | + goto skip_csum; |
3049 | + |
3050 | + wsum = skb->csum; |
3051 | |
3052 | switch (skb->ip_summed) { |
3053 | + case CHECKSUM_NONE: |
3054 | + wsum = skb_checksum(skb, skb_gro_offset(skb), skb_gro_len(skb), |
3055 | + 0); |
3056 | + |
3057 | + /* fall through */ |
3058 | + |
3059 | case CHECKSUM_COMPLETE: |
3060 | if (!tcp_v4_check(skb_gro_len(skb), iph->saddr, iph->daddr, |
3061 | - skb->csum)) { |
3062 | + wsum)) { |
3063 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
3064 | break; |
3065 | } |
3066 | -flush: |
3067 | + |
3068 | NAPI_GRO_CB(skb)->flush = 1; |
3069 | return NULL; |
3070 | - |
3071 | - case CHECKSUM_NONE: |
3072 | - wsum = csum_tcpudp_nofold(iph->saddr, iph->daddr, |
3073 | - skb_gro_len(skb), IPPROTO_TCP, 0); |
3074 | - sum = csum_fold(skb_checksum(skb, |
3075 | - skb_gro_offset(skb), |
3076 | - skb_gro_len(skb), |
3077 | - wsum)); |
3078 | - if (sum) |
3079 | - goto flush; |
3080 | - |
3081 | - skb->ip_summed = CHECKSUM_UNNECESSARY; |
3082 | - break; |
3083 | } |
3084 | |
3085 | +skip_csum: |
3086 | return tcp_gro_receive(head, skb); |
3087 | } |
3088 | |
3089 | diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c |
3090 | index d46f2143305c..e912634b2f05 100644 |
3091 | --- a/net/ipv4/tcp_output.c |
3092 | +++ b/net/ipv4/tcp_output.c |
3093 | @@ -1875,8 +1875,12 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle, |
3094 | * - better RTT estimation and ACK scheduling |
3095 | * - faster recovery |
3096 | * - high rates |
3097 | + * Alas, some drivers / subsystems require a fair amount |
3098 | + * of queued bytes to ensure line rate. |
3099 | + * One example is wifi aggregation (802.11 AMPDU) |
3100 | */ |
3101 | - limit = max(skb->truesize, sk->sk_pacing_rate >> 10); |
3102 | + limit = max_t(unsigned int, sysctl_tcp_limit_output_bytes, |
3103 | + sk->sk_pacing_rate >> 10); |
3104 | |
3105 | if (atomic_read(&sk->sk_wmem_alloc) > limit) { |
3106 | set_bit(TSQ_THROTTLED, &tp->tsq_flags); |
3107 | @@ -3108,7 +3112,6 @@ void tcp_send_window_probe(struct sock *sk) |
3108 | { |
3109 | if (sk->sk_state == TCP_ESTABLISHED) { |
3110 | tcp_sk(sk)->snd_wl1 = tcp_sk(sk)->rcv_nxt - 1; |
3111 | - tcp_sk(sk)->snd_nxt = tcp_sk(sk)->write_seq; |
3112 | tcp_xmit_probe_skb(sk, 0); |
3113 | } |
3114 | } |
3115 | diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c |
3116 | index 0ca44df51ee9..5e2c2f1a075d 100644 |
3117 | --- a/net/ipv4/udp.c |
3118 | +++ b/net/ipv4/udp.c |
3119 | @@ -973,7 +973,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, |
3120 | err = PTR_ERR(rt); |
3121 | rt = NULL; |
3122 | if (err == -ENETUNREACH) |
3123 | - IP_INC_STATS_BH(net, IPSTATS_MIB_OUTNOROUTES); |
3124 | + IP_INC_STATS(net, IPSTATS_MIB_OUTNOROUTES); |
3125 | goto out; |
3126 | } |
3127 | |
3128 | @@ -1072,6 +1072,9 @@ int udp_sendpage(struct sock *sk, struct page *page, int offset, |
3129 | struct udp_sock *up = udp_sk(sk); |
3130 | int ret; |
3131 | |
3132 | + if (flags & MSG_SENDPAGE_NOTLAST) |
3133 | + flags |= MSG_MORE; |
3134 | + |
3135 | if (!up->pending) { |
3136 | struct msghdr msg = { .msg_flags = flags|MSG_MORE }; |
3137 | |
3138 | @@ -1209,14 +1212,8 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, |
3139 | int is_udplite = IS_UDPLITE(sk); |
3140 | bool slow; |
3141 | |
3142 | - /* |
3143 | - * Check any passed addresses |
3144 | - */ |
3145 | - if (addr_len) |
3146 | - *addr_len = sizeof(*sin); |
3147 | - |
3148 | if (flags & MSG_ERRQUEUE) |
3149 | - return ip_recv_error(sk, msg, len); |
3150 | + return ip_recv_error(sk, msg, len, addr_len); |
3151 | |
3152 | try_again: |
3153 | skb = __skb_recv_datagram(sk, flags | (noblock ? MSG_DONTWAIT : 0), |
3154 | @@ -1276,6 +1273,7 @@ try_again: |
3155 | sin->sin_port = udp_hdr(skb)->source; |
3156 | sin->sin_addr.s_addr = ip_hdr(skb)->saddr; |
3157 | memset(sin->sin_zero, 0, sizeof(sin->sin_zero)); |
3158 | + *addr_len = sizeof(*sin); |
3159 | } |
3160 | if (inet->cmsg_flags) |
3161 | ip_cmsg_recv(msg, skb); |
3162 | diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c |
3163 | index ccde54248c8c..adf998322bd2 100644 |
3164 | --- a/net/ipv4/xfrm4_policy.c |
3165 | +++ b/net/ipv4/xfrm4_policy.c |
3166 | @@ -104,10 +104,14 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse) |
3167 | const struct iphdr *iph = ip_hdr(skb); |
3168 | u8 *xprth = skb_network_header(skb) + iph->ihl * 4; |
3169 | struct flowi4 *fl4 = &fl->u.ip4; |
3170 | + int oif = 0; |
3171 | + |
3172 | + if (skb_dst(skb)) |
3173 | + oif = skb_dst(skb)->dev->ifindex; |
3174 | |
3175 | memset(fl4, 0, sizeof(struct flowi4)); |
3176 | fl4->flowi4_mark = skb->mark; |
3177 | - fl4->flowi4_oif = skb_dst(skb)->dev->ifindex; |
3178 | + fl4->flowi4_oif = reverse ? skb->skb_iif : oif; |
3179 | |
3180 | if (!ip_is_fragment(iph)) { |
3181 | switch (iph->protocol) { |
3182 | diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c |
3183 | index 7c96100b021e..8132b4457b20 100644 |
3184 | --- a/net/ipv6/af_inet6.c |
3185 | +++ b/net/ipv6/af_inet6.c |
3186 | @@ -965,10 +965,10 @@ out: |
3187 | |
3188 | #ifdef CONFIG_SYSCTL |
3189 | sysctl_fail: |
3190 | - ipv6_packet_cleanup(); |
3191 | + pingv6_exit(); |
3192 | #endif |
3193 | pingv6_fail: |
3194 | - pingv6_exit(); |
3195 | + ipv6_packet_cleanup(); |
3196 | ipv6_packet_fail: |
3197 | tcpv6_exit(); |
3198 | tcpv6_fail: |
3199 | diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c |
3200 | index 48b6bd2a9a14..c66c6df6e881 100644 |
3201 | --- a/net/ipv6/datagram.c |
3202 | +++ b/net/ipv6/datagram.c |
3203 | @@ -318,7 +318,7 @@ void ipv6_local_rxpmtu(struct sock *sk, struct flowi6 *fl6, u32 mtu) |
3204 | /* |
3205 | * Handle MSG_ERRQUEUE |
3206 | */ |
3207 | -int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len) |
3208 | +int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len) |
3209 | { |
3210 | struct ipv6_pinfo *np = inet6_sk(sk); |
3211 | struct sock_exterr_skb *serr; |
3212 | @@ -369,6 +369,7 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len) |
3213 | &sin->sin6_addr); |
3214 | sin->sin6_scope_id = 0; |
3215 | } |
3216 | + *addr_len = sizeof(*sin); |
3217 | } |
3218 | |
3219 | memcpy(&errhdr.ee, &serr->ee, sizeof(struct sock_extended_err)); |
3220 | @@ -377,6 +378,7 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len) |
3221 | if (serr->ee.ee_origin != SO_EE_ORIGIN_LOCAL) { |
3222 | sin->sin6_family = AF_INET6; |
3223 | sin->sin6_flowinfo = 0; |
3224 | + sin->sin6_port = 0; |
3225 | if (skb->protocol == htons(ETH_P_IPV6)) { |
3226 | sin->sin6_addr = ipv6_hdr(skb)->saddr; |
3227 | if (np->rxopt.all) |
3228 | @@ -423,7 +425,8 @@ EXPORT_SYMBOL_GPL(ipv6_recv_error); |
3229 | /* |
3230 | * Handle IPV6_RECVPATHMTU |
3231 | */ |
3232 | -int ipv6_recv_rxpmtu(struct sock *sk, struct msghdr *msg, int len) |
3233 | +int ipv6_recv_rxpmtu(struct sock *sk, struct msghdr *msg, int len, |
3234 | + int *addr_len) |
3235 | { |
3236 | struct ipv6_pinfo *np = inet6_sk(sk); |
3237 | struct sk_buff *skb; |
3238 | @@ -457,6 +460,7 @@ int ipv6_recv_rxpmtu(struct sock *sk, struct msghdr *msg, int len) |
3239 | sin->sin6_port = 0; |
3240 | sin->sin6_scope_id = mtu_info.ip6m_addr.sin6_scope_id; |
3241 | sin->sin6_addr = mtu_info.ip6m_addr.sin6_addr; |
3242 | + *addr_len = sizeof(*sin); |
3243 | } |
3244 | |
3245 | put_cmsg(msg, SOL_IPV6, IPV6_PATHMTU, sizeof(mtu_info), &mtu_info); |
3246 | diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c |
3247 | index 46e88433ec7d..f0ccdb787100 100644 |
3248 | --- a/net/ipv6/ip6_flowlabel.c |
3249 | +++ b/net/ipv6/ip6_flowlabel.c |
3250 | @@ -453,8 +453,10 @@ static int mem_check(struct sock *sk) |
3251 | if (room > FL_MAX_SIZE - FL_MAX_PER_SOCK) |
3252 | return 0; |
3253 | |
3254 | + rcu_read_lock_bh(); |
3255 | for_each_sk_fl_rcu(np, sfl) |
3256 | count++; |
3257 | + rcu_read_unlock_bh(); |
3258 | |
3259 | if (room <= 0 || |
3260 | ((count >= FL_MAX_PER_SOCK || |
3261 | diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c |
3262 | index 91fb4e8212f5..b6fa35e7425c 100644 |
3263 | --- a/net/ipv6/ip6_output.c |
3264 | +++ b/net/ipv6/ip6_output.c |
3265 | @@ -116,8 +116,8 @@ static int ip6_finish_output2(struct sk_buff *skb) |
3266 | } |
3267 | rcu_read_unlock_bh(); |
3268 | |
3269 | - IP6_INC_STATS_BH(dev_net(dst->dev), |
3270 | - ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES); |
3271 | + IP6_INC_STATS(dev_net(dst->dev), |
3272 | + ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES); |
3273 | kfree_skb(skb); |
3274 | return -EINVAL; |
3275 | } |
3276 | @@ -125,7 +125,8 @@ static int ip6_finish_output2(struct sk_buff *skb) |
3277 | static int ip6_finish_output(struct sk_buff *skb) |
3278 | { |
3279 | if ((skb->len > ip6_skb_dst_mtu(skb) && !skb_is_gso(skb)) || |
3280 | - dst_allfrag(skb_dst(skb))) |
3281 | + dst_allfrag(skb_dst(skb)) || |
3282 | + (IP6CB(skb)->frag_max_size && skb->len > IP6CB(skb)->frag_max_size)) |
3283 | return ip6_fragment(skb, ip6_finish_output2); |
3284 | else |
3285 | return ip6_finish_output2(skb); |
3286 | diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c |
3287 | index 583b77e2f69b..c1e11b5d6ccc 100644 |
3288 | --- a/net/ipv6/ip6_tunnel.c |
3289 | +++ b/net/ipv6/ip6_tunnel.c |
3290 | @@ -1635,6 +1635,15 @@ static int ip6_tnl_changelink(struct net_device *dev, struct nlattr *tb[], |
3291 | return ip6_tnl_update(t, &p); |
3292 | } |
3293 | |
3294 | +static void ip6_tnl_dellink(struct net_device *dev, struct list_head *head) |
3295 | +{ |
3296 | + struct net *net = dev_net(dev); |
3297 | + struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id); |
3298 | + |
3299 | + if (dev != ip6n->fb_tnl_dev) |
3300 | + unregister_netdevice_queue(dev, head); |
3301 | +} |
3302 | + |
3303 | static size_t ip6_tnl_get_size(const struct net_device *dev) |
3304 | { |
3305 | return |
3306 | @@ -1699,6 +1708,7 @@ static struct rtnl_link_ops ip6_link_ops __read_mostly = { |
3307 | .validate = ip6_tnl_validate, |
3308 | .newlink = ip6_tnl_newlink, |
3309 | .changelink = ip6_tnl_changelink, |
3310 | + .dellink = ip6_tnl_dellink, |
3311 | .get_size = ip6_tnl_get_size, |
3312 | .fill_info = ip6_tnl_fill_info, |
3313 | }; |
3314 | @@ -1715,9 +1725,9 @@ static struct xfrm6_tunnel ip6ip6_handler __read_mostly = { |
3315 | .priority = 1, |
3316 | }; |
3317 | |
3318 | -static void __net_exit ip6_tnl_destroy_tunnels(struct ip6_tnl_net *ip6n) |
3319 | +static void __net_exit ip6_tnl_destroy_tunnels(struct net *net) |
3320 | { |
3321 | - struct net *net = dev_net(ip6n->fb_tnl_dev); |
3322 | + struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id); |
3323 | struct net_device *dev, *aux; |
3324 | int h; |
3325 | struct ip6_tnl *t; |
3326 | @@ -1785,10 +1795,8 @@ err_alloc_dev: |
3327 | |
3328 | static void __net_exit ip6_tnl_exit_net(struct net *net) |
3329 | { |
3330 | - struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id); |
3331 | - |
3332 | rtnl_lock(); |
3333 | - ip6_tnl_destroy_tunnels(ip6n); |
3334 | + ip6_tnl_destroy_tunnels(net); |
3335 | rtnl_unlock(); |
3336 | } |
3337 | |
3338 | diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c |
3339 | index d6e4dd8b58df..83ab37cc8e6a 100644 |
3340 | --- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c |
3341 | +++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c |
3342 | @@ -169,63 +169,13 @@ out: |
3343 | return nf_conntrack_confirm(skb); |
3344 | } |
3345 | |
3346 | -static unsigned int __ipv6_conntrack_in(struct net *net, |
3347 | - unsigned int hooknum, |
3348 | - struct sk_buff *skb, |
3349 | - const struct net_device *in, |
3350 | - const struct net_device *out, |
3351 | - int (*okfn)(struct sk_buff *)) |
3352 | -{ |
3353 | - struct sk_buff *reasm = skb->nfct_reasm; |
3354 | - const struct nf_conn_help *help; |
3355 | - struct nf_conn *ct; |
3356 | - enum ip_conntrack_info ctinfo; |
3357 | - |
3358 | - /* This packet is fragmented and has reassembled packet. */ |
3359 | - if (reasm) { |
3360 | - /* Reassembled packet isn't parsed yet ? */ |
3361 | - if (!reasm->nfct) { |
3362 | - unsigned int ret; |
3363 | - |
3364 | - ret = nf_conntrack_in(net, PF_INET6, hooknum, reasm); |
3365 | - if (ret != NF_ACCEPT) |
3366 | - return ret; |
3367 | - } |
3368 | - |
3369 | - /* Conntrack helpers need the entire reassembled packet in the |
3370 | - * POST_ROUTING hook. In case of unconfirmed connections NAT |
3371 | - * might reassign a helper, so the entire packet is also |
3372 | - * required. |
3373 | - */ |
3374 | - ct = nf_ct_get(reasm, &ctinfo); |
3375 | - if (ct != NULL && !nf_ct_is_untracked(ct)) { |
3376 | - help = nfct_help(ct); |
3377 | - if ((help && help->helper) || !nf_ct_is_confirmed(ct)) { |
3378 | - nf_conntrack_get_reasm(reasm); |
3379 | - NF_HOOK_THRESH(NFPROTO_IPV6, hooknum, reasm, |
3380 | - (struct net_device *)in, |
3381 | - (struct net_device *)out, |
3382 | - okfn, NF_IP6_PRI_CONNTRACK + 1); |
3383 | - return NF_DROP_ERR(-ECANCELED); |
3384 | - } |
3385 | - } |
3386 | - |
3387 | - nf_conntrack_get(reasm->nfct); |
3388 | - skb->nfct = reasm->nfct; |
3389 | - skb->nfctinfo = reasm->nfctinfo; |
3390 | - return NF_ACCEPT; |
3391 | - } |
3392 | - |
3393 | - return nf_conntrack_in(net, PF_INET6, hooknum, skb); |
3394 | -} |
3395 | - |
3396 | static unsigned int ipv6_conntrack_in(unsigned int hooknum, |
3397 | struct sk_buff *skb, |
3398 | const struct net_device *in, |
3399 | const struct net_device *out, |
3400 | int (*okfn)(struct sk_buff *)) |
3401 | { |
3402 | - return __ipv6_conntrack_in(dev_net(in), hooknum, skb, in, out, okfn); |
3403 | + return nf_conntrack_in(dev_net(in), PF_INET6, hooknum, skb); |
3404 | } |
3405 | |
3406 | static unsigned int ipv6_conntrack_local(unsigned int hooknum, |
3407 | @@ -239,7 +189,7 @@ static unsigned int ipv6_conntrack_local(unsigned int hooknum, |
3408 | net_notice_ratelimited("ipv6_conntrack_local: packet too short\n"); |
3409 | return NF_ACCEPT; |
3410 | } |
3411 | - return __ipv6_conntrack_in(dev_net(out), hooknum, skb, in, out, okfn); |
3412 | + return nf_conntrack_in(dev_net(out), PF_INET6, hooknum, skb); |
3413 | } |
3414 | |
3415 | static struct nf_hook_ops ipv6_conntrack_ops[] __read_mostly = { |
3416 | diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c |
3417 | index dffdc1a389c5..253566a8d55b 100644 |
3418 | --- a/net/ipv6/netfilter/nf_conntrack_reasm.c |
3419 | +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c |
3420 | @@ -621,31 +621,16 @@ ret_orig: |
3421 | return skb; |
3422 | } |
3423 | |
3424 | -void nf_ct_frag6_output(unsigned int hooknum, struct sk_buff *skb, |
3425 | - struct net_device *in, struct net_device *out, |
3426 | - int (*okfn)(struct sk_buff *)) |
3427 | +void nf_ct_frag6_consume_orig(struct sk_buff *skb) |
3428 | { |
3429 | struct sk_buff *s, *s2; |
3430 | - unsigned int ret = 0; |
3431 | |
3432 | for (s = NFCT_FRAG6_CB(skb)->orig; s;) { |
3433 | - nf_conntrack_put_reasm(s->nfct_reasm); |
3434 | - nf_conntrack_get_reasm(skb); |
3435 | - s->nfct_reasm = skb; |
3436 | - |
3437 | s2 = s->next; |
3438 | s->next = NULL; |
3439 | - |
3440 | - if (ret != -ECANCELED) |
3441 | - ret = NF_HOOK_THRESH(NFPROTO_IPV6, hooknum, s, |
3442 | - in, out, okfn, |
3443 | - NF_IP6_PRI_CONNTRACK_DEFRAG + 1); |
3444 | - else |
3445 | - kfree_skb(s); |
3446 | - |
3447 | + consume_skb(s); |
3448 | s = s2; |
3449 | } |
3450 | - nf_conntrack_put_reasm(skb); |
3451 | } |
3452 | |
3453 | static int nf_ct_net_init(struct net *net) |
3454 | diff --git a/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c b/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c |
3455 | index aacd121fe8c5..581dd9ede0de 100644 |
3456 | --- a/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c |
3457 | +++ b/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c |
3458 | @@ -75,8 +75,11 @@ static unsigned int ipv6_defrag(unsigned int hooknum, |
3459 | if (reasm == skb) |
3460 | return NF_ACCEPT; |
3461 | |
3462 | - nf_ct_frag6_output(hooknum, reasm, (struct net_device *)in, |
3463 | - (struct net_device *)out, okfn); |
3464 | + nf_ct_frag6_consume_orig(reasm); |
3465 | + |
3466 | + NF_HOOK_THRESH(NFPROTO_IPV6, hooknum, reasm, |
3467 | + (struct net_device *) in, (struct net_device *) out, |
3468 | + okfn, NF_IP6_PRI_CONNTRACK_DEFRAG + 1); |
3469 | |
3470 | return NF_STOLEN; |
3471 | } |
3472 | diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c |
3473 | index 18f19df4189f..7856e962a3e6 100644 |
3474 | --- a/net/ipv6/ping.c |
3475 | +++ b/net/ipv6/ping.c |
3476 | @@ -57,7 +57,8 @@ static struct inet_protosw pingv6_protosw = { |
3477 | |
3478 | |
3479 | /* Compatibility glue so we can support IPv6 when it's compiled as a module */ |
3480 | -static int dummy_ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len) |
3481 | +static int dummy_ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len, |
3482 | + int *addr_len) |
3483 | { |
3484 | return -EAFNOSUPPORT; |
3485 | } |
3486 | diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c |
3487 | index a4ed2416399e..430067cb9210 100644 |
3488 | --- a/net/ipv6/raw.c |
3489 | +++ b/net/ipv6/raw.c |
3490 | @@ -466,14 +466,11 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk, |
3491 | if (flags & MSG_OOB) |
3492 | return -EOPNOTSUPP; |
3493 | |
3494 | - if (addr_len) |
3495 | - *addr_len=sizeof(*sin6); |
3496 | - |
3497 | if (flags & MSG_ERRQUEUE) |
3498 | - return ipv6_recv_error(sk, msg, len); |
3499 | + return ipv6_recv_error(sk, msg, len, addr_len); |
3500 | |
3501 | if (np->rxpmtu && np->rxopt.bits.rxpmtu) |
3502 | - return ipv6_recv_rxpmtu(sk, msg, len); |
3503 | + return ipv6_recv_rxpmtu(sk, msg, len, addr_len); |
3504 | |
3505 | skb = skb_recv_datagram(sk, flags, noblock, &err); |
3506 | if (!skb) |
3507 | @@ -507,6 +504,7 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk, |
3508 | sin6->sin6_flowinfo = 0; |
3509 | sin6->sin6_scope_id = ipv6_iface_scope_id(&sin6->sin6_addr, |
3510 | IP6CB(skb)->iif); |
3511 | + *addr_len = sizeof(*sin6); |
3512 | } |
3513 | |
3514 | sock_recv_ts_and_drops(msg, sk, skb); |
3515 | diff --git a/net/ipv6/route.c b/net/ipv6/route.c |
3516 | index 04e17b3309fb..77308af056bc 100644 |
3517 | --- a/net/ipv6/route.c |
3518 | +++ b/net/ipv6/route.c |
3519 | @@ -731,8 +731,11 @@ int rt6_route_rcv(struct net_device *dev, u8 *opt, int len, |
3520 | prefix = &prefix_buf; |
3521 | } |
3522 | |
3523 | - rt = rt6_get_route_info(net, prefix, rinfo->prefix_len, gwaddr, |
3524 | - dev->ifindex); |
3525 | + if (rinfo->prefix_len == 0) |
3526 | + rt = rt6_get_dflt_router(gwaddr, dev); |
3527 | + else |
3528 | + rt = rt6_get_route_info(net, prefix, rinfo->prefix_len, |
3529 | + gwaddr, dev->ifindex); |
3530 | |
3531 | if (rt && !lifetime) { |
3532 | ip6_del_rt(rt); |
3533 | diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c |
3534 | index 19269453a8ea..b43388452bf8 100644 |
3535 | --- a/net/ipv6/sit.c |
3536 | +++ b/net/ipv6/sit.c |
3537 | @@ -1594,6 +1594,15 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = { |
3538 | #endif |
3539 | }; |
3540 | |
3541 | +static void ipip6_dellink(struct net_device *dev, struct list_head *head) |
3542 | +{ |
3543 | + struct net *net = dev_net(dev); |
3544 | + struct sit_net *sitn = net_generic(net, sit_net_id); |
3545 | + |
3546 | + if (dev != sitn->fb_tunnel_dev) |
3547 | + unregister_netdevice_queue(dev, head); |
3548 | +} |
3549 | + |
3550 | static struct rtnl_link_ops sit_link_ops __read_mostly = { |
3551 | .kind = "sit", |
3552 | .maxtype = IFLA_IPTUN_MAX, |
3553 | @@ -1605,6 +1614,7 @@ static struct rtnl_link_ops sit_link_ops __read_mostly = { |
3554 | .changelink = ipip6_changelink, |
3555 | .get_size = ipip6_get_size, |
3556 | .fill_info = ipip6_fill_info, |
3557 | + .dellink = ipip6_dellink, |
3558 | }; |
3559 | |
3560 | static struct xfrm_tunnel sit_handler __read_mostly = { |
3561 | @@ -1619,9 +1629,10 @@ static struct xfrm_tunnel ipip_handler __read_mostly = { |
3562 | .priority = 2, |
3563 | }; |
3564 | |
3565 | -static void __net_exit sit_destroy_tunnels(struct sit_net *sitn, struct list_head *head) |
3566 | +static void __net_exit sit_destroy_tunnels(struct net *net, |
3567 | + struct list_head *head) |
3568 | { |
3569 | - struct net *net = dev_net(sitn->fb_tunnel_dev); |
3570 | + struct sit_net *sitn = net_generic(net, sit_net_id); |
3571 | struct net_device *dev, *aux; |
3572 | int prio; |
3573 | |
3574 | @@ -1696,11 +1707,10 @@ err_alloc_dev: |
3575 | |
3576 | static void __net_exit sit_exit_net(struct net *net) |
3577 | { |
3578 | - struct sit_net *sitn = net_generic(net, sit_net_id); |
3579 | LIST_HEAD(list); |
3580 | |
3581 | rtnl_lock(); |
3582 | - sit_destroy_tunnels(sitn, &list); |
3583 | + sit_destroy_tunnels(net, &list); |
3584 | unregister_netdevice_many(&list); |
3585 | rtnl_unlock(); |
3586 | } |
3587 | diff --git a/net/ipv6/tcpv6_offload.c b/net/ipv6/tcpv6_offload.c |
3588 | index 2ec6bf6a0aa0..a7a2384b30f5 100644 |
3589 | --- a/net/ipv6/tcpv6_offload.c |
3590 | +++ b/net/ipv6/tcpv6_offload.c |
3591 | @@ -37,34 +37,32 @@ static struct sk_buff **tcp6_gro_receive(struct sk_buff **head, |
3592 | { |
3593 | const struct ipv6hdr *iph = skb_gro_network_header(skb); |
3594 | __wsum wsum; |
3595 | - __sum16 sum; |
3596 | + |
3597 | + /* Don't bother verifying checksum if we're going to flush anyway. */ |
3598 | + if (NAPI_GRO_CB(skb)->flush) |
3599 | + goto skip_csum; |
3600 | + |
3601 | + wsum = skb->csum; |
3602 | |
3603 | switch (skb->ip_summed) { |
3604 | + case CHECKSUM_NONE: |
3605 | + wsum = skb_checksum(skb, skb_gro_offset(skb), skb_gro_len(skb), |
3606 | + wsum); |
3607 | + |
3608 | + /* fall through */ |
3609 | + |
3610 | case CHECKSUM_COMPLETE: |
3611 | if (!tcp_v6_check(skb_gro_len(skb), &iph->saddr, &iph->daddr, |
3612 | - skb->csum)) { |
3613 | + wsum)) { |
3614 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
3615 | break; |
3616 | } |
3617 | -flush: |
3618 | + |
3619 | NAPI_GRO_CB(skb)->flush = 1; |
3620 | return NULL; |
3621 | - |
3622 | - case CHECKSUM_NONE: |
3623 | - wsum = ~csum_unfold(csum_ipv6_magic(&iph->saddr, &iph->daddr, |
3624 | - skb_gro_len(skb), |
3625 | - IPPROTO_TCP, 0)); |
3626 | - sum = csum_fold(skb_checksum(skb, |
3627 | - skb_gro_offset(skb), |
3628 | - skb_gro_len(skb), |
3629 | - wsum)); |
3630 | - if (sum) |
3631 | - goto flush; |
3632 | - |
3633 | - skb->ip_summed = CHECKSUM_UNNECESSARY; |
3634 | - break; |
3635 | } |
3636 | |
3637 | +skip_csum: |
3638 | return tcp_gro_receive(head, skb); |
3639 | } |
3640 | |
3641 | diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c |
3642 | index 18786098fd41..3d2758d4494e 100644 |
3643 | --- a/net/ipv6/udp.c |
3644 | +++ b/net/ipv6/udp.c |
3645 | @@ -374,14 +374,11 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, |
3646 | int is_udp4; |
3647 | bool slow; |
3648 | |
3649 | - if (addr_len) |
3650 | - *addr_len = sizeof(struct sockaddr_in6); |
3651 | - |
3652 | if (flags & MSG_ERRQUEUE) |
3653 | - return ipv6_recv_error(sk, msg, len); |
3654 | + return ipv6_recv_error(sk, msg, len, addr_len); |
3655 | |
3656 | if (np->rxpmtu && np->rxopt.bits.rxpmtu) |
3657 | - return ipv6_recv_rxpmtu(sk, msg, len); |
3658 | + return ipv6_recv_rxpmtu(sk, msg, len, addr_len); |
3659 | |
3660 | try_again: |
3661 | skb = __skb_recv_datagram(sk, flags | (noblock ? MSG_DONTWAIT : 0), |
3662 | @@ -462,7 +459,7 @@ try_again: |
3663 | ipv6_iface_scope_id(&sin6->sin6_addr, |
3664 | IP6CB(skb)->iif); |
3665 | } |
3666 | - |
3667 | + *addr_len = sizeof(*sin6); |
3668 | } |
3669 | if (is_udp4) { |
3670 | if (inet->cmsg_flags) |
3671 | diff --git a/net/ipv6/udp_offload.c b/net/ipv6/udp_offload.c |
3672 | index 60559511bd9c..34c6fff3ae84 100644 |
3673 | --- a/net/ipv6/udp_offload.c |
3674 | +++ b/net/ipv6/udp_offload.c |
3675 | @@ -88,7 +88,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb, |
3676 | |
3677 | /* Check if there is enough headroom to insert fragment header. */ |
3678 | tnl_hlen = skb_tnl_header_len(skb); |
3679 | - if (skb_headroom(skb) < (tnl_hlen + frag_hdr_sz)) { |
3680 | + if (skb->mac_header < (tnl_hlen + frag_hdr_sz)) { |
3681 | if (gso_pskb_expand_head(skb, tnl_hlen + frag_hdr_sz)) |
3682 | goto out; |
3683 | } |
3684 | diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c |
3685 | index 08ed2772b7aa..550b195bb2fc 100644 |
3686 | --- a/net/ipv6/xfrm6_policy.c |
3687 | +++ b/net/ipv6/xfrm6_policy.c |
3688 | @@ -135,10 +135,14 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse) |
3689 | struct ipv6_opt_hdr *exthdr; |
3690 | const unsigned char *nh = skb_network_header(skb); |
3691 | u8 nexthdr = nh[IP6CB(skb)->nhoff]; |
3692 | + int oif = 0; |
3693 | + |
3694 | + if (skb_dst(skb)) |
3695 | + oif = skb_dst(skb)->dev->ifindex; |
3696 | |
3697 | memset(fl6, 0, sizeof(struct flowi6)); |
3698 | fl6->flowi6_mark = skb->mark; |
3699 | - fl6->flowi6_oif = skb_dst(skb)->dev->ifindex; |
3700 | + fl6->flowi6_oif = reverse ? skb->skb_iif : oif; |
3701 | |
3702 | fl6->daddr = reverse ? hdr->saddr : hdr->daddr; |
3703 | fl6->saddr = reverse ? hdr->daddr : hdr->saddr; |
3704 | diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c |
3705 | index 7a1e0fc1bd4d..e096025b477f 100644 |
3706 | --- a/net/ipx/af_ipx.c |
3707 | +++ b/net/ipx/af_ipx.c |
3708 | @@ -1823,8 +1823,6 @@ static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock, |
3709 | if (skb->tstamp.tv64) |
3710 | sk->sk_stamp = skb->tstamp; |
3711 | |
3712 | - msg->msg_namelen = sizeof(*sipx); |
3713 | - |
3714 | if (sipx) { |
3715 | sipx->sipx_family = AF_IPX; |
3716 | sipx->sipx_port = ipx->ipx_source.sock; |
3717 | @@ -1832,6 +1830,7 @@ static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock, |
3718 | sipx->sipx_network = IPX_SKB_CB(skb)->ipx_source_net; |
3719 | sipx->sipx_type = ipx->ipx_type; |
3720 | sipx->sipx_zero = 0; |
3721 | + msg->msg_namelen = sizeof(*sipx); |
3722 | } |
3723 | rc = copied; |
3724 | |
3725 | diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c |
3726 | index 0578d4fa00a9..a5e62ef57155 100644 |
3727 | --- a/net/irda/af_irda.c |
3728 | +++ b/net/irda/af_irda.c |
3729 | @@ -1385,8 +1385,6 @@ static int irda_recvmsg_dgram(struct kiocb *iocb, struct socket *sock, |
3730 | |
3731 | IRDA_DEBUG(4, "%s()\n", __func__); |
3732 | |
3733 | - msg->msg_namelen = 0; |
3734 | - |
3735 | skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, |
3736 | flags & MSG_DONTWAIT, &err); |
3737 | if (!skb) |
3738 | @@ -1451,8 +1449,6 @@ static int irda_recvmsg_stream(struct kiocb *iocb, struct socket *sock, |
3739 | target = sock_rcvlowat(sk, flags & MSG_WAITALL, size); |
3740 | timeo = sock_rcvtimeo(sk, noblock); |
3741 | |
3742 | - msg->msg_namelen = 0; |
3743 | - |
3744 | do { |
3745 | int chunk; |
3746 | struct sk_buff *skb = skb_dequeue(&sk->sk_receive_queue); |
3747 | diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c |
3748 | index 168aff5e60de..c4b7218058b6 100644 |
3749 | --- a/net/iucv/af_iucv.c |
3750 | +++ b/net/iucv/af_iucv.c |
3751 | @@ -1324,8 +1324,6 @@ static int iucv_sock_recvmsg(struct kiocb *iocb, struct socket *sock, |
3752 | int err = 0; |
3753 | u32 offset; |
3754 | |
3755 | - msg->msg_namelen = 0; |
3756 | - |
3757 | if ((sk->sk_state == IUCV_DISCONN) && |
3758 | skb_queue_empty(&iucv->backlog_skb_q) && |
3759 | skb_queue_empty(&sk->sk_receive_queue) && |
3760 | diff --git a/net/key/af_key.c b/net/key/af_key.c |
3761 | index 911ef03bf8fb..545f047868ad 100644 |
3762 | --- a/net/key/af_key.c |
3763 | +++ b/net/key/af_key.c |
3764 | @@ -3616,7 +3616,6 @@ static int pfkey_recvmsg(struct kiocb *kiocb, |
3765 | if (flags & ~(MSG_PEEK|MSG_DONTWAIT|MSG_TRUNC|MSG_CMSG_COMPAT)) |
3766 | goto out; |
3767 | |
3768 | - msg->msg_namelen = 0; |
3769 | skb = skb_recv_datagram(sk, flags, flags & MSG_DONTWAIT, &err); |
3770 | if (skb == NULL) |
3771 | goto out; |
3772 | diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c |
3773 | index 571db8dd2292..da1a1cee1a08 100644 |
3774 | --- a/net/l2tp/l2tp_ip.c |
3775 | +++ b/net/l2tp/l2tp_ip.c |
3776 | @@ -518,9 +518,6 @@ static int l2tp_ip_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *m |
3777 | if (flags & MSG_OOB) |
3778 | goto out; |
3779 | |
3780 | - if (addr_len) |
3781 | - *addr_len = sizeof(*sin); |
3782 | - |
3783 | skb = skb_recv_datagram(sk, flags, noblock, &err); |
3784 | if (!skb) |
3785 | goto out; |
3786 | @@ -543,6 +540,7 @@ static int l2tp_ip_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *m |
3787 | sin->sin_addr.s_addr = ip_hdr(skb)->saddr; |
3788 | sin->sin_port = 0; |
3789 | memset(&sin->sin_zero, 0, sizeof(sin->sin_zero)); |
3790 | + *addr_len = sizeof(*sin); |
3791 | } |
3792 | if (inet->cmsg_flags) |
3793 | ip_cmsg_recv(msg, skb); |
3794 | diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c |
3795 | index b8a6039314e8..e6e8408c9e36 100644 |
3796 | --- a/net/l2tp/l2tp_ip6.c |
3797 | +++ b/net/l2tp/l2tp_ip6.c |
3798 | @@ -665,7 +665,7 @@ static int l2tp_ip6_recvmsg(struct kiocb *iocb, struct sock *sk, |
3799 | *addr_len = sizeof(*lsa); |
3800 | |
3801 | if (flags & MSG_ERRQUEUE) |
3802 | - return ipv6_recv_error(sk, msg, len); |
3803 | + return ipv6_recv_error(sk, msg, len, addr_len); |
3804 | |
3805 | skb = skb_recv_datagram(sk, flags, noblock, &err); |
3806 | if (!skb) |
3807 | diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c |
3808 | index 8c46b271064a..44441c0c5037 100644 |
3809 | --- a/net/l2tp/l2tp_ppp.c |
3810 | +++ b/net/l2tp/l2tp_ppp.c |
3811 | @@ -197,8 +197,6 @@ static int pppol2tp_recvmsg(struct kiocb *iocb, struct socket *sock, |
3812 | if (sk->sk_state & PPPOX_BOUND) |
3813 | goto end; |
3814 | |
3815 | - msg->msg_namelen = 0; |
3816 | - |
3817 | err = 0; |
3818 | skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, |
3819 | flags & MSG_DONTWAIT, &err); |
3820 | diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c |
3821 | index 6cba486353e8..7b01b9f5846c 100644 |
3822 | --- a/net/llc/af_llc.c |
3823 | +++ b/net/llc/af_llc.c |
3824 | @@ -720,8 +720,6 @@ static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock, |
3825 | int target; /* Read at least this many bytes */ |
3826 | long timeo; |
3827 | |
3828 | - msg->msg_namelen = 0; |
3829 | - |
3830 | lock_sock(sk); |
3831 | copied = -ENOTCONN; |
3832 | if (unlikely(sk->sk_type == SOCK_STREAM && sk->sk_state == TCP_LISTEN)) |
3833 | diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c |
3834 | index 74fd00c27210..3581736446d5 100644 |
3835 | --- a/net/netfilter/ipvs/ip_vs_core.c |
3836 | +++ b/net/netfilter/ipvs/ip_vs_core.c |
3837 | @@ -1139,12 +1139,6 @@ ip_vs_out(unsigned int hooknum, struct sk_buff *skb, int af) |
3838 | ip_vs_fill_iph_skb(af, skb, &iph); |
3839 | #ifdef CONFIG_IP_VS_IPV6 |
3840 | if (af == AF_INET6) { |
3841 | - if (!iph.fragoffs && skb_nfct_reasm(skb)) { |
3842 | - struct sk_buff *reasm = skb_nfct_reasm(skb); |
3843 | - /* Save fw mark for coming frags */ |
3844 | - reasm->ipvs_property = 1; |
3845 | - reasm->mark = skb->mark; |
3846 | - } |
3847 | if (unlikely(iph.protocol == IPPROTO_ICMPV6)) { |
3848 | int related; |
3849 | int verdict = ip_vs_out_icmp_v6(skb, &related, |
3850 | @@ -1614,12 +1608,6 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af) |
3851 | |
3852 | #ifdef CONFIG_IP_VS_IPV6 |
3853 | if (af == AF_INET6) { |
3854 | - if (!iph.fragoffs && skb_nfct_reasm(skb)) { |
3855 | - struct sk_buff *reasm = skb_nfct_reasm(skb); |
3856 | - /* Save fw mark for coming frags. */ |
3857 | - reasm->ipvs_property = 1; |
3858 | - reasm->mark = skb->mark; |
3859 | - } |
3860 | if (unlikely(iph.protocol == IPPROTO_ICMPV6)) { |
3861 | int related; |
3862 | int verdict = ip_vs_in_icmp_v6(skb, &related, hooknum, |
3863 | @@ -1671,9 +1659,8 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af) |
3864 | /* sorry, all this trouble for a no-hit :) */ |
3865 | IP_VS_DBG_PKT(12, af, pp, skb, 0, |
3866 | "ip_vs_in: packet continues traversal as normal"); |
3867 | - if (iph.fragoffs && !skb_nfct_reasm(skb)) { |
3868 | + if (iph.fragoffs) { |
3869 | /* Fragment that couldn't be mapped to a conn entry |
3870 | - * and don't have any pointer to a reasm skb |
3871 | * is missing module nf_defrag_ipv6 |
3872 | */ |
3873 | IP_VS_DBG_RL("Unhandled frag, load nf_defrag_ipv6\n"); |
3874 | @@ -1756,38 +1743,6 @@ ip_vs_local_request4(unsigned int hooknum, struct sk_buff *skb, |
3875 | #ifdef CONFIG_IP_VS_IPV6 |
3876 | |
3877 | /* |
3878 | - * AF_INET6 fragment handling |
3879 | - * Copy info from first fragment, to the rest of them. |
3880 | - */ |
3881 | -static unsigned int |
3882 | -ip_vs_preroute_frag6(unsigned int hooknum, struct sk_buff *skb, |
3883 | - const struct net_device *in, |
3884 | - const struct net_device *out, |
3885 | - int (*okfn)(struct sk_buff *)) |
3886 | -{ |
3887 | - struct sk_buff *reasm = skb_nfct_reasm(skb); |
3888 | - struct net *net; |
3889 | - |
3890 | - /* Skip if not a "replay" from nf_ct_frag6_output or first fragment. |
3891 | - * ipvs_property is set when checking first fragment |
3892 | - * in ip_vs_in() and ip_vs_out(). |
3893 | - */ |
3894 | - if (reasm) |
3895 | - IP_VS_DBG(2, "Fragment recv prop:%d\n", reasm->ipvs_property); |
3896 | - if (!reasm || !reasm->ipvs_property) |
3897 | - return NF_ACCEPT; |
3898 | - |
3899 | - net = skb_net(skb); |
3900 | - if (!net_ipvs(net)->enable) |
3901 | - return NF_ACCEPT; |
3902 | - |
3903 | - /* Copy stored fw mark, saved in ip_vs_{in,out} */ |
3904 | - skb->mark = reasm->mark; |
3905 | - |
3906 | - return NF_ACCEPT; |
3907 | -} |
3908 | - |
3909 | -/* |
3910 | * AF_INET6 handler in NF_INET_LOCAL_IN chain |
3911 | * Schedule and forward packets from remote clients |
3912 | */ |
3913 | @@ -1924,14 +1879,6 @@ static struct nf_hook_ops ip_vs_ops[] __read_mostly = { |
3914 | .priority = 100, |
3915 | }, |
3916 | #ifdef CONFIG_IP_VS_IPV6 |
3917 | - /* After mangle & nat fetch 2:nd fragment and following */ |
3918 | - { |
3919 | - .hook = ip_vs_preroute_frag6, |
3920 | - .owner = THIS_MODULE, |
3921 | - .pf = NFPROTO_IPV6, |
3922 | - .hooknum = NF_INET_PRE_ROUTING, |
3923 | - .priority = NF_IP6_PRI_NAT_DST + 1, |
3924 | - }, |
3925 | /* After packet filtering, change source only for VS/NAT */ |
3926 | { |
3927 | .hook = ip_vs_reply6, |
3928 | diff --git a/net/netfilter/ipvs/ip_vs_pe_sip.c b/net/netfilter/ipvs/ip_vs_pe_sip.c |
3929 | index 9ef22bdce9f1..bed5f7042529 100644 |
3930 | --- a/net/netfilter/ipvs/ip_vs_pe_sip.c |
3931 | +++ b/net/netfilter/ipvs/ip_vs_pe_sip.c |
3932 | @@ -65,7 +65,6 @@ static int get_callid(const char *dptr, unsigned int dataoff, |
3933 | static int |
3934 | ip_vs_sip_fill_param(struct ip_vs_conn_param *p, struct sk_buff *skb) |
3935 | { |
3936 | - struct sk_buff *reasm = skb_nfct_reasm(skb); |
3937 | struct ip_vs_iphdr iph; |
3938 | unsigned int dataoff, datalen, matchoff, matchlen; |
3939 | const char *dptr; |
3940 | @@ -79,15 +78,10 @@ ip_vs_sip_fill_param(struct ip_vs_conn_param *p, struct sk_buff *skb) |
3941 | /* todo: IPv6 fragments: |
3942 | * I think this only should be done for the first fragment. /HS |
3943 | */ |
3944 | - if (reasm) { |
3945 | - skb = reasm; |
3946 | - dataoff = iph.thoff_reasm + sizeof(struct udphdr); |
3947 | - } else |
3948 | - dataoff = iph.len + sizeof(struct udphdr); |
3949 | + dataoff = iph.len + sizeof(struct udphdr); |
3950 | |
3951 | if (dataoff >= skb->len) |
3952 | return -EINVAL; |
3953 | - /* todo: Check if this will mess-up the reasm skb !!! /HS */ |
3954 | retc = skb_linearize(skb); |
3955 | if (retc < 0) |
3956 | return retc; |
3957 | diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c |
3958 | index 8df7f64c6db3..613563555515 100644 |
3959 | --- a/net/netlink/af_netlink.c |
3960 | +++ b/net/netlink/af_netlink.c |
3961 | @@ -2335,8 +2335,6 @@ static int netlink_recvmsg(struct kiocb *kiocb, struct socket *sock, |
3962 | } |
3963 | #endif |
3964 | |
3965 | - msg->msg_namelen = 0; |
3966 | - |
3967 | copied = data_skb->len; |
3968 | if (len < copied) { |
3969 | msg->msg_flags |= MSG_TRUNC; |
3970 | diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c |
3971 | index 698814bfa7ad..53c19a35fc6d 100644 |
3972 | --- a/net/netrom/af_netrom.c |
3973 | +++ b/net/netrom/af_netrom.c |
3974 | @@ -1179,10 +1179,9 @@ static int nr_recvmsg(struct kiocb *iocb, struct socket *sock, |
3975 | sax->sax25_family = AF_NETROM; |
3976 | skb_copy_from_linear_data_offset(skb, 7, sax->sax25_call.ax25_call, |
3977 | AX25_ADDR_LEN); |
3978 | + msg->msg_namelen = sizeof(*sax); |
3979 | } |
3980 | |
3981 | - msg->msg_namelen = sizeof(*sax); |
3982 | - |
3983 | skb_free_datagram(sk, skb); |
3984 | |
3985 | release_sock(sk); |
3986 | diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c |
3987 | index d308402b67d8..824c6056bf82 100644 |
3988 | --- a/net/nfc/llcp_sock.c |
3989 | +++ b/net/nfc/llcp_sock.c |
3990 | @@ -807,8 +807,6 @@ static int llcp_sock_recvmsg(struct kiocb *iocb, struct socket *sock, |
3991 | |
3992 | pr_debug("%p %zu\n", sk, len); |
3993 | |
3994 | - msg->msg_namelen = 0; |
3995 | - |
3996 | lock_sock(sk); |
3997 | |
3998 | if (sk->sk_state == LLCP_CLOSED && |
3999 | diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c |
4000 | index 313bf1bc848a..5d11f4ac3ecb 100644 |
4001 | --- a/net/nfc/rawsock.c |
4002 | +++ b/net/nfc/rawsock.c |
4003 | @@ -241,8 +241,6 @@ static int rawsock_recvmsg(struct kiocb *iocb, struct socket *sock, |
4004 | if (!skb) |
4005 | return rc; |
4006 | |
4007 | - msg->msg_namelen = 0; |
4008 | - |
4009 | copied = skb->len; |
4010 | if (len < copied) { |
4011 | msg->msg_flags |= MSG_TRUNC; |
4012 | diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c |
4013 | index 2e8286b47c28..ba2548bd85bf 100644 |
4014 | --- a/net/packet/af_packet.c |
4015 | +++ b/net/packet/af_packet.c |
4016 | @@ -244,11 +244,15 @@ static void __fanout_link(struct sock *sk, struct packet_sock *po); |
4017 | static void register_prot_hook(struct sock *sk) |
4018 | { |
4019 | struct packet_sock *po = pkt_sk(sk); |
4020 | + |
4021 | if (!po->running) { |
4022 | - if (po->fanout) |
4023 | + if (po->fanout) { |
4024 | __fanout_link(sk, po); |
4025 | - else |
4026 | + } else { |
4027 | dev_add_pack(&po->prot_hook); |
4028 | + rcu_assign_pointer(po->cached_dev, po->prot_hook.dev); |
4029 | + } |
4030 | + |
4031 | sock_hold(sk); |
4032 | po->running = 1; |
4033 | } |
4034 | @@ -266,10 +270,13 @@ static void __unregister_prot_hook(struct sock *sk, bool sync) |
4035 | struct packet_sock *po = pkt_sk(sk); |
4036 | |
4037 | po->running = 0; |
4038 | - if (po->fanout) |
4039 | + if (po->fanout) { |
4040 | __fanout_unlink(sk, po); |
4041 | - else |
4042 | + } else { |
4043 | __dev_remove_pack(&po->prot_hook); |
4044 | + RCU_INIT_POINTER(po->cached_dev, NULL); |
4045 | + } |
4046 | + |
4047 | __sock_put(sk); |
4048 | |
4049 | if (sync) { |
4050 | @@ -432,9 +439,9 @@ static void prb_shutdown_retire_blk_timer(struct packet_sock *po, |
4051 | |
4052 | pkc = tx_ring ? &po->tx_ring.prb_bdqc : &po->rx_ring.prb_bdqc; |
4053 | |
4054 | - spin_lock(&rb_queue->lock); |
4055 | + spin_lock_bh(&rb_queue->lock); |
4056 | pkc->delete_blk_timer = 1; |
4057 | - spin_unlock(&rb_queue->lock); |
4058 | + spin_unlock_bh(&rb_queue->lock); |
4059 | |
4060 | prb_del_retire_blk_timer(pkc); |
4061 | } |
4062 | @@ -2052,12 +2059,24 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb, |
4063 | return tp_len; |
4064 | } |
4065 | |
4066 | +static struct net_device *packet_cached_dev_get(struct packet_sock *po) |
4067 | +{ |
4068 | + struct net_device *dev; |
4069 | + |
4070 | + rcu_read_lock(); |
4071 | + dev = rcu_dereference(po->cached_dev); |
4072 | + if (dev) |
4073 | + dev_hold(dev); |
4074 | + rcu_read_unlock(); |
4075 | + |
4076 | + return dev; |
4077 | +} |
4078 | + |
4079 | static int tpacket_snd(struct packet_sock *po, struct msghdr *msg) |
4080 | { |
4081 | struct sk_buff *skb; |
4082 | struct net_device *dev; |
4083 | __be16 proto; |
4084 | - bool need_rls_dev = false; |
4085 | int err, reserve = 0; |
4086 | void *ph; |
4087 | struct sockaddr_ll *saddr = (struct sockaddr_ll *)msg->msg_name; |
4088 | @@ -2070,7 +2089,7 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg) |
4089 | mutex_lock(&po->pg_vec_lock); |
4090 | |
4091 | if (saddr == NULL) { |
4092 | - dev = po->prot_hook.dev; |
4093 | + dev = packet_cached_dev_get(po); |
4094 | proto = po->num; |
4095 | addr = NULL; |
4096 | } else { |
4097 | @@ -2084,19 +2103,17 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg) |
4098 | proto = saddr->sll_protocol; |
4099 | addr = saddr->sll_addr; |
4100 | dev = dev_get_by_index(sock_net(&po->sk), saddr->sll_ifindex); |
4101 | - need_rls_dev = true; |
4102 | } |
4103 | |
4104 | err = -ENXIO; |
4105 | if (unlikely(dev == NULL)) |
4106 | goto out; |
4107 | - |
4108 | - reserve = dev->hard_header_len; |
4109 | - |
4110 | err = -ENETDOWN; |
4111 | if (unlikely(!(dev->flags & IFF_UP))) |
4112 | goto out_put; |
4113 | |
4114 | + reserve = dev->hard_header_len; |
4115 | + |
4116 | size_max = po->tx_ring.frame_size |
4117 | - (po->tp_hdrlen - sizeof(struct sockaddr_ll)); |
4118 | |
4119 | @@ -2173,8 +2190,7 @@ out_status: |
4120 | __packet_set_status(po, ph, status); |
4121 | kfree_skb(skb); |
4122 | out_put: |
4123 | - if (need_rls_dev) |
4124 | - dev_put(dev); |
4125 | + dev_put(dev); |
4126 | out: |
4127 | mutex_unlock(&po->pg_vec_lock); |
4128 | return err; |
4129 | @@ -2212,7 +2228,6 @@ static int packet_snd(struct socket *sock, |
4130 | struct sk_buff *skb; |
4131 | struct net_device *dev; |
4132 | __be16 proto; |
4133 | - bool need_rls_dev = false; |
4134 | unsigned char *addr; |
4135 | int err, reserve = 0; |
4136 | struct virtio_net_hdr vnet_hdr = { 0 }; |
4137 | @@ -2228,7 +2243,7 @@ static int packet_snd(struct socket *sock, |
4138 | */ |
4139 | |
4140 | if (saddr == NULL) { |
4141 | - dev = po->prot_hook.dev; |
4142 | + dev = packet_cached_dev_get(po); |
4143 | proto = po->num; |
4144 | addr = NULL; |
4145 | } else { |
4146 | @@ -2240,19 +2255,17 @@ static int packet_snd(struct socket *sock, |
4147 | proto = saddr->sll_protocol; |
4148 | addr = saddr->sll_addr; |
4149 | dev = dev_get_by_index(sock_net(sk), saddr->sll_ifindex); |
4150 | - need_rls_dev = true; |
4151 | } |
4152 | |
4153 | err = -ENXIO; |
4154 | - if (dev == NULL) |
4155 | + if (unlikely(dev == NULL)) |
4156 | goto out_unlock; |
4157 | - if (sock->type == SOCK_RAW) |
4158 | - reserve = dev->hard_header_len; |
4159 | - |
4160 | err = -ENETDOWN; |
4161 | - if (!(dev->flags & IFF_UP)) |
4162 | + if (unlikely(!(dev->flags & IFF_UP))) |
4163 | goto out_unlock; |
4164 | |
4165 | + if (sock->type == SOCK_RAW) |
4166 | + reserve = dev->hard_header_len; |
4167 | if (po->has_vnet_hdr) { |
4168 | vnet_hdr_len = sizeof(vnet_hdr); |
4169 | |
4170 | @@ -2386,15 +2399,14 @@ static int packet_snd(struct socket *sock, |
4171 | if (err > 0 && (err = net_xmit_errno(err)) != 0) |
4172 | goto out_unlock; |
4173 | |
4174 | - if (need_rls_dev) |
4175 | - dev_put(dev); |
4176 | + dev_put(dev); |
4177 | |
4178 | return len; |
4179 | |
4180 | out_free: |
4181 | kfree_skb(skb); |
4182 | out_unlock: |
4183 | - if (dev && need_rls_dev) |
4184 | + if (dev) |
4185 | dev_put(dev); |
4186 | out: |
4187 | return err; |
4188 | @@ -2614,6 +2626,7 @@ static int packet_create(struct net *net, struct socket *sock, int protocol, |
4189 | po = pkt_sk(sk); |
4190 | sk->sk_family = PF_PACKET; |
4191 | po->num = proto; |
4192 | + RCU_INIT_POINTER(po->cached_dev, NULL); |
4193 | |
4194 | sk->sk_destruct = packet_sock_destruct; |
4195 | sk_refcnt_debug_inc(sk); |
4196 | @@ -2660,7 +2673,6 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock, |
4197 | struct sock *sk = sock->sk; |
4198 | struct sk_buff *skb; |
4199 | int copied, err; |
4200 | - struct sockaddr_ll *sll; |
4201 | int vnet_hdr_len = 0; |
4202 | |
4203 | err = -EINVAL; |
4204 | @@ -2744,22 +2756,10 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock, |
4205 | goto out_free; |
4206 | } |
4207 | |
4208 | - /* |
4209 | - * If the address length field is there to be filled in, we fill |
4210 | - * it in now. |
4211 | + /* You lose any data beyond the buffer you gave. If it worries |
4212 | + * a user program they can ask the device for its MTU |
4213 | + * anyway. |
4214 | */ |
4215 | - |
4216 | - sll = &PACKET_SKB_CB(skb)->sa.ll; |
4217 | - if (sock->type == SOCK_PACKET) |
4218 | - msg->msg_namelen = sizeof(struct sockaddr_pkt); |
4219 | - else |
4220 | - msg->msg_namelen = sll->sll_halen + offsetof(struct sockaddr_ll, sll_addr); |
4221 | - |
4222 | - /* |
4223 | - * You lose any data beyond the buffer you gave. If it worries a |
4224 | - * user program they can ask the device for its MTU anyway. |
4225 | - */ |
4226 | - |
4227 | copied = skb->len; |
4228 | if (copied > len) { |
4229 | copied = len; |
4230 | @@ -2772,9 +2772,20 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock, |
4231 | |
4232 | sock_recv_ts_and_drops(msg, sk, skb); |
4233 | |
4234 | - if (msg->msg_name) |
4235 | + if (msg->msg_name) { |
4236 | + /* If the address length field is there to be filled |
4237 | + * in, we fill it in now. |
4238 | + */ |
4239 | + if (sock->type == SOCK_PACKET) { |
4240 | + msg->msg_namelen = sizeof(struct sockaddr_pkt); |
4241 | + } else { |
4242 | + struct sockaddr_ll *sll = &PACKET_SKB_CB(skb)->sa.ll; |
4243 | + msg->msg_namelen = sll->sll_halen + |
4244 | + offsetof(struct sockaddr_ll, sll_addr); |
4245 | + } |
4246 | memcpy(msg->msg_name, &PACKET_SKB_CB(skb)->sa, |
4247 | msg->msg_namelen); |
4248 | + } |
4249 | |
4250 | if (pkt_sk(sk)->auxdata) { |
4251 | struct tpacket_auxdata aux; |
4252 | diff --git a/net/packet/internal.h b/net/packet/internal.h |
4253 | index c4e4b4561207..1035fa2d909c 100644 |
4254 | --- a/net/packet/internal.h |
4255 | +++ b/net/packet/internal.h |
4256 | @@ -113,6 +113,7 @@ struct packet_sock { |
4257 | unsigned int tp_loss:1; |
4258 | unsigned int tp_tx_has_off:1; |
4259 | unsigned int tp_tstamp; |
4260 | + struct net_device __rcu *cached_dev; |
4261 | struct packet_type prot_hook ____cacheline_aligned_in_smp; |
4262 | }; |
4263 | |
4264 | diff --git a/net/phonet/datagram.c b/net/phonet/datagram.c |
4265 | index 12c30f3e643e..38946b26e471 100644 |
4266 | --- a/net/phonet/datagram.c |
4267 | +++ b/net/phonet/datagram.c |
4268 | @@ -139,9 +139,6 @@ static int pn_recvmsg(struct kiocb *iocb, struct sock *sk, |
4269 | MSG_CMSG_COMPAT)) |
4270 | goto out_nofree; |
4271 | |
4272 | - if (addr_len) |
4273 | - *addr_len = sizeof(sa); |
4274 | - |
4275 | skb = skb_recv_datagram(sk, flags, noblock, &rval); |
4276 | if (skb == NULL) |
4277 | goto out_nofree; |
4278 | @@ -162,8 +159,10 @@ static int pn_recvmsg(struct kiocb *iocb, struct sock *sk, |
4279 | |
4280 | rval = (flags & MSG_TRUNC) ? skb->len : copylen; |
4281 | |
4282 | - if (msg->msg_name != NULL) |
4283 | - memcpy(msg->msg_name, &sa, sizeof(struct sockaddr_pn)); |
4284 | + if (msg->msg_name != NULL) { |
4285 | + memcpy(msg->msg_name, &sa, sizeof(sa)); |
4286 | + *addr_len = sizeof(sa); |
4287 | + } |
4288 | |
4289 | out: |
4290 | skb_free_datagram(sk, skb); |
4291 | diff --git a/net/rds/recv.c b/net/rds/recv.c |
4292 | index 9f0f17cf6bf9..de339b24ca14 100644 |
4293 | --- a/net/rds/recv.c |
4294 | +++ b/net/rds/recv.c |
4295 | @@ -410,8 +410,6 @@ int rds_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, |
4296 | |
4297 | rdsdebug("size %zu flags 0x%x timeo %ld\n", size, msg_flags, timeo); |
4298 | |
4299 | - msg->msg_namelen = 0; |
4300 | - |
4301 | if (msg_flags & MSG_OOB) |
4302 | goto out; |
4303 | |
4304 | diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c |
4305 | index e98fcfbe6007..33af77246bfe 100644 |
4306 | --- a/net/rose/af_rose.c |
4307 | +++ b/net/rose/af_rose.c |
4308 | @@ -1216,7 +1216,6 @@ static int rose_recvmsg(struct kiocb *iocb, struct socket *sock, |
4309 | { |
4310 | struct sock *sk = sock->sk; |
4311 | struct rose_sock *rose = rose_sk(sk); |
4312 | - struct sockaddr_rose *srose = (struct sockaddr_rose *)msg->msg_name; |
4313 | size_t copied; |
4314 | unsigned char *asmptr; |
4315 | struct sk_buff *skb; |
4316 | @@ -1252,8 +1251,11 @@ static int rose_recvmsg(struct kiocb *iocb, struct socket *sock, |
4317 | |
4318 | skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied); |
4319 | |
4320 | - if (srose != NULL) { |
4321 | - memset(srose, 0, msg->msg_namelen); |
4322 | + if (msg->msg_name) { |
4323 | + struct sockaddr_rose *srose; |
4324 | + |
4325 | + memset(msg->msg_name, 0, sizeof(struct full_sockaddr_rose)); |
4326 | + srose = msg->msg_name; |
4327 | srose->srose_family = AF_ROSE; |
4328 | srose->srose_addr = rose->dest_addr; |
4329 | srose->srose_call = rose->dest_call; |
4330 | diff --git a/net/rxrpc/ar-recvmsg.c b/net/rxrpc/ar-recvmsg.c |
4331 | index 4b48687c3890..898492a8d61b 100644 |
4332 | --- a/net/rxrpc/ar-recvmsg.c |
4333 | +++ b/net/rxrpc/ar-recvmsg.c |
4334 | @@ -143,10 +143,13 @@ int rxrpc_recvmsg(struct kiocb *iocb, struct socket *sock, |
4335 | |
4336 | /* copy the peer address and timestamp */ |
4337 | if (!continue_call) { |
4338 | - if (msg->msg_name && msg->msg_namelen > 0) |
4339 | + if (msg->msg_name) { |
4340 | + size_t len = |
4341 | + sizeof(call->conn->trans->peer->srx); |
4342 | memcpy(msg->msg_name, |
4343 | - &call->conn->trans->peer->srx, |
4344 | - sizeof(call->conn->trans->peer->srx)); |
4345 | + &call->conn->trans->peer->srx, len); |
4346 | + msg->msg_namelen = len; |
4347 | + } |
4348 | sock_recv_ts_and_drops(msg, &rx->sk, skb); |
4349 | } |
4350 | |
4351 | diff --git a/net/sched/sch_fq.c b/net/sched/sch_fq.c |
4352 | index a9dfdda9ed1d..2e55f8189502 100644 |
4353 | --- a/net/sched/sch_fq.c |
4354 | +++ b/net/sched/sch_fq.c |
4355 | @@ -88,7 +88,7 @@ struct fq_sched_data { |
4356 | struct fq_flow internal; /* for non classified or high prio packets */ |
4357 | u32 quantum; |
4358 | u32 initial_quantum; |
4359 | - u32 flow_default_rate;/* rate per flow : bytes per second */ |
4360 | + u32 flow_refill_delay; |
4361 | u32 flow_max_rate; /* optional max rate per flow */ |
4362 | u32 flow_plimit; /* max packets per flow */ |
4363 | struct rb_root *fq_root; |
4364 | @@ -115,6 +115,7 @@ static struct fq_flow detached, throttled; |
4365 | static void fq_flow_set_detached(struct fq_flow *f) |
4366 | { |
4367 | f->next = &detached; |
4368 | + f->age = jiffies; |
4369 | } |
4370 | |
4371 | static bool fq_flow_is_detached(const struct fq_flow *f) |
4372 | @@ -209,21 +210,15 @@ static void fq_gc(struct fq_sched_data *q, |
4373 | } |
4374 | } |
4375 | |
4376 | -static const u8 prio2band[TC_PRIO_MAX + 1] = { |
4377 | - 1, 2, 2, 2, 1, 2, 0, 0 , 1, 1, 1, 1, 1, 1, 1, 1 |
4378 | -}; |
4379 | - |
4380 | static struct fq_flow *fq_classify(struct sk_buff *skb, struct fq_sched_data *q) |
4381 | { |
4382 | struct rb_node **p, *parent; |
4383 | struct sock *sk = skb->sk; |
4384 | struct rb_root *root; |
4385 | struct fq_flow *f; |
4386 | - int band; |
4387 | |
4388 | /* warning: no starvation prevention... */ |
4389 | - band = prio2band[skb->priority & TC_PRIO_MAX]; |
4390 | - if (unlikely(band == 0)) |
4391 | + if (unlikely((skb->priority & TC_PRIO_MAX) == TC_PRIO_CONTROL)) |
4392 | return &q->internal; |
4393 | |
4394 | if (unlikely(!sk)) { |
4395 | @@ -372,17 +367,20 @@ static int fq_enqueue(struct sk_buff *skb, struct Qdisc *sch) |
4396 | } |
4397 | |
4398 | f->qlen++; |
4399 | - flow_queue_add(f, skb); |
4400 | if (skb_is_retransmit(skb)) |
4401 | q->stat_tcp_retrans++; |
4402 | sch->qstats.backlog += qdisc_pkt_len(skb); |
4403 | if (fq_flow_is_detached(f)) { |
4404 | fq_flow_add_tail(&q->new_flows, f); |
4405 | - if (q->quantum > f->credit) |
4406 | - f->credit = q->quantum; |
4407 | + if (time_after(jiffies, f->age + q->flow_refill_delay)) |
4408 | + f->credit = max_t(u32, f->credit, q->quantum); |
4409 | q->inactive_flows--; |
4410 | qdisc_unthrottled(sch); |
4411 | } |
4412 | + |
4413 | + /* Note: this overwrites f->age */ |
4414 | + flow_queue_add(f, skb); |
4415 | + |
4416 | if (unlikely(f == &q->internal)) { |
4417 | q->stat_internal_packets++; |
4418 | qdisc_unthrottled(sch); |
4419 | @@ -460,7 +458,6 @@ begin: |
4420 | fq_flow_add_tail(&q->old_flows, f); |
4421 | } else { |
4422 | fq_flow_set_detached(f); |
4423 | - f->age = jiffies; |
4424 | q->inactive_flows++; |
4425 | } |
4426 | goto begin; |
4427 | @@ -614,6 +611,7 @@ static const struct nla_policy fq_policy[TCA_FQ_MAX + 1] = { |
4428 | [TCA_FQ_FLOW_DEFAULT_RATE] = { .type = NLA_U32 }, |
4429 | [TCA_FQ_FLOW_MAX_RATE] = { .type = NLA_U32 }, |
4430 | [TCA_FQ_BUCKETS_LOG] = { .type = NLA_U32 }, |
4431 | + [TCA_FQ_FLOW_REFILL_DELAY] = { .type = NLA_U32 }, |
4432 | }; |
4433 | |
4434 | static int fq_change(struct Qdisc *sch, struct nlattr *opt) |
4435 | @@ -655,7 +653,8 @@ static int fq_change(struct Qdisc *sch, struct nlattr *opt) |
4436 | q->initial_quantum = nla_get_u32(tb[TCA_FQ_INITIAL_QUANTUM]); |
4437 | |
4438 | if (tb[TCA_FQ_FLOW_DEFAULT_RATE]) |
4439 | - q->flow_default_rate = nla_get_u32(tb[TCA_FQ_FLOW_DEFAULT_RATE]); |
4440 | + pr_warn_ratelimited("sch_fq: defrate %u ignored.\n", |
4441 | + nla_get_u32(tb[TCA_FQ_FLOW_DEFAULT_RATE])); |
4442 | |
4443 | if (tb[TCA_FQ_FLOW_MAX_RATE]) |
4444 | q->flow_max_rate = nla_get_u32(tb[TCA_FQ_FLOW_MAX_RATE]); |
4445 | @@ -669,6 +668,12 @@ static int fq_change(struct Qdisc *sch, struct nlattr *opt) |
4446 | err = -EINVAL; |
4447 | } |
4448 | |
4449 | + if (tb[TCA_FQ_FLOW_REFILL_DELAY]) { |
4450 | + u32 usecs_delay = nla_get_u32(tb[TCA_FQ_FLOW_REFILL_DELAY]) ; |
4451 | + |
4452 | + q->flow_refill_delay = usecs_to_jiffies(usecs_delay); |
4453 | + } |
4454 | + |
4455 | if (!err) |
4456 | err = fq_resize(q, fq_log); |
4457 | |
4458 | @@ -704,7 +709,7 @@ static int fq_init(struct Qdisc *sch, struct nlattr *opt) |
4459 | q->flow_plimit = 100; |
4460 | q->quantum = 2 * psched_mtu(qdisc_dev(sch)); |
4461 | q->initial_quantum = 10 * psched_mtu(qdisc_dev(sch)); |
4462 | - q->flow_default_rate = 0; |
4463 | + q->flow_refill_delay = msecs_to_jiffies(40); |
4464 | q->flow_max_rate = ~0U; |
4465 | q->rate_enable = 1; |
4466 | q->new_flows.first = NULL; |
4467 | @@ -731,15 +736,16 @@ static int fq_dump(struct Qdisc *sch, struct sk_buff *skb) |
4468 | if (opts == NULL) |
4469 | goto nla_put_failure; |
4470 | |
4471 | - /* TCA_FQ_FLOW_DEFAULT_RATE is not used anymore, |
4472 | - * do not bother giving its value |
4473 | - */ |
4474 | + /* TCA_FQ_FLOW_DEFAULT_RATE is not used anymore */ |
4475 | + |
4476 | if (nla_put_u32(skb, TCA_FQ_PLIMIT, sch->limit) || |
4477 | nla_put_u32(skb, TCA_FQ_FLOW_PLIMIT, q->flow_plimit) || |
4478 | nla_put_u32(skb, TCA_FQ_QUANTUM, q->quantum) || |
4479 | nla_put_u32(skb, TCA_FQ_INITIAL_QUANTUM, q->initial_quantum) || |
4480 | nla_put_u32(skb, TCA_FQ_RATE_ENABLE, q->rate_enable) || |
4481 | nla_put_u32(skb, TCA_FQ_FLOW_MAX_RATE, q->flow_max_rate) || |
4482 | + nla_put_u32(skb, TCA_FQ_FLOW_REFILL_DELAY, |
4483 | + jiffies_to_usecs(q->flow_refill_delay)) || |
4484 | nla_put_u32(skb, TCA_FQ_BUCKETS_LOG, q->fq_trees_log)) |
4485 | goto nla_put_failure; |
4486 | |
4487 | diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c |
4488 | index 1aaf1b6e51a2..6ddda282f9c7 100644 |
4489 | --- a/net/sched/sch_tbf.c |
4490 | +++ b/net/sched/sch_tbf.c |
4491 | @@ -21,6 +21,7 @@ |
4492 | #include <net/netlink.h> |
4493 | #include <net/sch_generic.h> |
4494 | #include <net/pkt_sched.h> |
4495 | +#include <net/tcp.h> |
4496 | |
4497 | |
4498 | /* Simple Token Bucket Filter. |
4499 | @@ -117,6 +118,22 @@ struct tbf_sched_data { |
4500 | }; |
4501 | |
4502 | |
4503 | +/* |
4504 | + * Return length of individual segments of a gso packet, |
4505 | + * including all headers (MAC, IP, TCP/UDP) |
4506 | + */ |
4507 | +static unsigned int skb_gso_seglen(const struct sk_buff *skb) |
4508 | +{ |
4509 | + unsigned int hdr_len = skb_transport_header(skb) - skb_mac_header(skb); |
4510 | + const struct skb_shared_info *shinfo = skb_shinfo(skb); |
4511 | + |
4512 | + if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))) |
4513 | + hdr_len += tcp_hdrlen(skb); |
4514 | + else |
4515 | + hdr_len += sizeof(struct udphdr); |
4516 | + return hdr_len + shinfo->gso_size; |
4517 | +} |
4518 | + |
4519 | /* GSO packet is too big, segment it so that tbf can transmit |
4520 | * each segment in time |
4521 | */ |
4522 | @@ -136,12 +153,8 @@ static int tbf_segment(struct sk_buff *skb, struct Qdisc *sch) |
4523 | while (segs) { |
4524 | nskb = segs->next; |
4525 | segs->next = NULL; |
4526 | - if (likely(segs->len <= q->max_size)) { |
4527 | - qdisc_skb_cb(segs)->pkt_len = segs->len; |
4528 | - ret = qdisc_enqueue(segs, q->qdisc); |
4529 | - } else { |
4530 | - ret = qdisc_reshape_fail(skb, sch); |
4531 | - } |
4532 | + qdisc_skb_cb(segs)->pkt_len = segs->len; |
4533 | + ret = qdisc_enqueue(segs, q->qdisc); |
4534 | if (ret != NET_XMIT_SUCCESS) { |
4535 | if (net_xmit_drop_count(ret)) |
4536 | sch->qstats.drops++; |
4537 | @@ -163,7 +176,7 @@ static int tbf_enqueue(struct sk_buff *skb, struct Qdisc *sch) |
4538 | int ret; |
4539 | |
4540 | if (qdisc_pkt_len(skb) > q->max_size) { |
4541 | - if (skb_is_gso(skb)) |
4542 | + if (skb_is_gso(skb) && skb_gso_seglen(skb) <= q->max_size) |
4543 | return tbf_segment(skb, sch); |
4544 | return qdisc_reshape_fail(skb, sch); |
4545 | } |
4546 | @@ -316,6 +329,11 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt) |
4547 | if (max_size < 0) |
4548 | goto done; |
4549 | |
4550 | + if (max_size < psched_mtu(qdisc_dev(sch))) |
4551 | + pr_warn_ratelimited("sch_tbf: burst %u is lower than device %s mtu (%u) !\n", |
4552 | + max_size, qdisc_dev(sch)->name, |
4553 | + psched_mtu(qdisc_dev(sch))); |
4554 | + |
4555 | if (q->qdisc != &noop_qdisc) { |
4556 | err = fifo_set_limit(q->qdisc, qopt->limit); |
4557 | if (err) |
4558 | diff --git a/net/socket.c b/net/socket.c |
4559 | index c226aceee65b..e83c416708af 100644 |
4560 | --- a/net/socket.c |
4561 | +++ b/net/socket.c |
4562 | @@ -221,12 +221,13 @@ static int move_addr_to_user(struct sockaddr_storage *kaddr, int klen, |
4563 | int err; |
4564 | int len; |
4565 | |
4566 | + BUG_ON(klen > sizeof(struct sockaddr_storage)); |
4567 | err = get_user(len, ulen); |
4568 | if (err) |
4569 | return err; |
4570 | if (len > klen) |
4571 | len = klen; |
4572 | - if (len < 0 || len > sizeof(struct sockaddr_storage)) |
4573 | + if (len < 0) |
4574 | return -EINVAL; |
4575 | if (len) { |
4576 | if (audit_sockaddr(klen, kaddr)) |
4577 | @@ -1840,8 +1841,10 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size, |
4578 | msg.msg_iov = &iov; |
4579 | iov.iov_len = size; |
4580 | iov.iov_base = ubuf; |
4581 | - msg.msg_name = (struct sockaddr *)&address; |
4582 | - msg.msg_namelen = sizeof(address); |
4583 | + /* Save some cycles and don't copy the address if not needed */ |
4584 | + msg.msg_name = addr ? (struct sockaddr *)&address : NULL; |
4585 | + /* We assume all kernel code knows the size of sockaddr_storage */ |
4586 | + msg.msg_namelen = 0; |
4587 | if (sock->file->f_flags & O_NONBLOCK) |
4588 | flags |= MSG_DONTWAIT; |
4589 | err = sock_recvmsg(sock, &msg, size, flags); |
4590 | @@ -1970,7 +1973,7 @@ static int copy_msghdr_from_user(struct msghdr *kmsg, |
4591 | if (copy_from_user(kmsg, umsg, sizeof(struct msghdr))) |
4592 | return -EFAULT; |
4593 | if (kmsg->msg_namelen > sizeof(struct sockaddr_storage)) |
4594 | - return -EINVAL; |
4595 | + kmsg->msg_namelen = sizeof(struct sockaddr_storage); |
4596 | return 0; |
4597 | } |
4598 | |
4599 | @@ -2221,16 +2224,14 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg, |
4600 | goto out; |
4601 | } |
4602 | |
4603 | - /* |
4604 | - * Save the user-mode address (verify_iovec will change the |
4605 | - * kernel msghdr to use the kernel address space) |
4606 | + /* Save the user-mode address (verify_iovec will change the |
4607 | + * kernel msghdr to use the kernel address space) |
4608 | */ |
4609 | - |
4610 | uaddr = (__force void __user *)msg_sys->msg_name; |
4611 | uaddr_len = COMPAT_NAMELEN(msg); |
4612 | - if (MSG_CMSG_COMPAT & flags) { |
4613 | + if (MSG_CMSG_COMPAT & flags) |
4614 | err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE); |
4615 | - } else |
4616 | + else |
4617 | err = verify_iovec(msg_sys, iov, &addr, VERIFY_WRITE); |
4618 | if (err < 0) |
4619 | goto out_freeiov; |
4620 | @@ -2239,6 +2240,9 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg, |
4621 | cmsg_ptr = (unsigned long)msg_sys->msg_control; |
4622 | msg_sys->msg_flags = flags & (MSG_CMSG_CLOEXEC|MSG_CMSG_COMPAT); |
4623 | |
4624 | + /* We assume all kernel code knows the size of sockaddr_storage */ |
4625 | + msg_sys->msg_namelen = 0; |
4626 | + |
4627 | if (sock->file->f_flags & O_NONBLOCK) |
4628 | flags |= MSG_DONTWAIT; |
4629 | err = (nosec ? sock_recvmsg_nosec : sock_recvmsg)(sock, msg_sys, |
4630 | diff --git a/net/tipc/socket.c b/net/tipc/socket.c |
4631 | index 6cc7ddd2fb7c..dffdbeac18ca 100644 |
4632 | --- a/net/tipc/socket.c |
4633 | +++ b/net/tipc/socket.c |
4634 | @@ -984,9 +984,6 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock, |
4635 | goto exit; |
4636 | } |
4637 | |
4638 | - /* will be updated in set_orig_addr() if needed */ |
4639 | - m->msg_namelen = 0; |
4640 | - |
4641 | timeout = sock_rcvtimeo(sk, flags & MSG_DONTWAIT); |
4642 | restart: |
4643 | |
4644 | @@ -1095,9 +1092,6 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock, |
4645 | goto exit; |
4646 | } |
4647 | |
4648 | - /* will be updated in set_orig_addr() if needed */ |
4649 | - m->msg_namelen = 0; |
4650 | - |
4651 | target = sock_rcvlowat(sk, flags & MSG_WAITALL, buf_len); |
4652 | timeout = sock_rcvtimeo(sk, flags & MSG_DONTWAIT); |
4653 | |
4654 | diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c |
4655 | index c1f403bed683..01625ccc3ae6 100644 |
4656 | --- a/net/unix/af_unix.c |
4657 | +++ b/net/unix/af_unix.c |
4658 | @@ -1754,7 +1754,6 @@ static void unix_copy_addr(struct msghdr *msg, struct sock *sk) |
4659 | { |
4660 | struct unix_sock *u = unix_sk(sk); |
4661 | |
4662 | - msg->msg_namelen = 0; |
4663 | if (u->addr) { |
4664 | msg->msg_namelen = u->addr->len; |
4665 | memcpy(msg->msg_name, u->addr->name, u->addr->len); |
4666 | @@ -1778,8 +1777,6 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock, |
4667 | if (flags&MSG_OOB) |
4668 | goto out; |
4669 | |
4670 | - msg->msg_namelen = 0; |
4671 | - |
4672 | err = mutex_lock_interruptible(&u->readlock); |
4673 | if (err) { |
4674 | err = sock_intr_errno(sock_rcvtimeo(sk, noblock)); |
4675 | @@ -1924,8 +1921,6 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, |
4676 | target = sock_rcvlowat(sk, flags&MSG_WAITALL, size); |
4677 | timeo = sock_rcvtimeo(sk, flags&MSG_DONTWAIT); |
4678 | |
4679 | - msg->msg_namelen = 0; |
4680 | - |
4681 | /* Lock the socket to prevent queue disordering |
4682 | * while sleeps in memcpy_tomsg |
4683 | */ |
4684 | diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c |
4685 | index 545c08b8a1d4..5adfd94c5b85 100644 |
4686 | --- a/net/vmw_vsock/af_vsock.c |
4687 | +++ b/net/vmw_vsock/af_vsock.c |
4688 | @@ -1662,8 +1662,6 @@ vsock_stream_recvmsg(struct kiocb *kiocb, |
4689 | vsk = vsock_sk(sk); |
4690 | err = 0; |
4691 | |
4692 | - msg->msg_namelen = 0; |
4693 | - |
4694 | lock_sock(sk); |
4695 | |
4696 | if (sk->sk_state != SS_CONNECTED) { |
4697 | diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c |
4698 | index 9d6986634e0b..687360da62d9 100644 |
4699 | --- a/net/vmw_vsock/vmci_transport.c |
4700 | +++ b/net/vmw_vsock/vmci_transport.c |
4701 | @@ -1746,8 +1746,6 @@ static int vmci_transport_dgram_dequeue(struct kiocb *kiocb, |
4702 | if (flags & MSG_OOB || flags & MSG_ERRQUEUE) |
4703 | return -EOPNOTSUPP; |
4704 | |
4705 | - msg->msg_namelen = 0; |
4706 | - |
4707 | /* Retrieve the head sk_buff from the socket's receive queue. */ |
4708 | err = 0; |
4709 | skb = skb_recv_datagram(&vsk->sk, flags, noblock, &err); |
4710 | diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c |
4711 | index 45a3ab5612c1..7622789d3750 100644 |
4712 | --- a/net/x25/af_x25.c |
4713 | +++ b/net/x25/af_x25.c |
4714 | @@ -1340,10 +1340,9 @@ static int x25_recvmsg(struct kiocb *iocb, struct socket *sock, |
4715 | if (sx25) { |
4716 | sx25->sx25_family = AF_X25; |
4717 | sx25->sx25_addr = x25->dest_addr; |
4718 | + msg->msg_namelen = sizeof(*sx25); |
4719 | } |
4720 | |
4721 | - msg->msg_namelen = sizeof(struct sockaddr_x25); |
4722 | - |
4723 | x25_check_rbuf(sk); |
4724 | rc = copied; |
4725 | out_free_dgram: |