aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/packet/af_packet.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 26fbeb140a6a..a11c731d2ee4 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -167,7 +167,6 @@ static int packet_set_ring(struct sock *sk, struct tpacket_req *req,
167#define PGV_FROM_VMALLOC 1 167#define PGV_FROM_VMALLOC 1
168struct pgv { 168struct pgv {
169 char *buffer; 169 char *buffer;
170 unsigned char flags;
171}; 170};
172 171
173struct packet_ring_buffer { 172struct packet_ring_buffer {
@@ -2342,7 +2341,7 @@ static void free_pg_vec(struct pgv *pg_vec, unsigned int order,
2342 2341
2343 for (i = 0; i < len; i++) { 2342 for (i = 0; i < len; i++) {
2344 if (likely(pg_vec[i].buffer)) { 2343 if (likely(pg_vec[i].buffer)) {
2345 if (pg_vec[i].flags & PGV_FROM_VMALLOC) 2344 if (is_vmalloc_addr(pg_vec[i].buffer))
2346 vfree(pg_vec[i].buffer); 2345 vfree(pg_vec[i].buffer);
2347 else 2346 else
2348 free_pages((unsigned long)pg_vec[i].buffer, 2347 free_pages((unsigned long)pg_vec[i].buffer,
@@ -2353,8 +2352,7 @@ static void free_pg_vec(struct pgv *pg_vec, unsigned int order,
2353 kfree(pg_vec); 2352 kfree(pg_vec);
2354} 2353}
2355 2354
2356static inline char *alloc_one_pg_vec_page(unsigned long order, 2355static inline char *alloc_one_pg_vec_page(unsigned long order)
2357 unsigned char *flags)
2358{ 2356{
2359 char *buffer = NULL; 2357 char *buffer = NULL;
2360 gfp_t gfp_flags = GFP_KERNEL | __GFP_COMP | 2358 gfp_t gfp_flags = GFP_KERNEL | __GFP_COMP |
@@ -2368,7 +2366,6 @@ static inline char *alloc_one_pg_vec_page(unsigned long order,
2368 /* 2366 /*
2369 * __get_free_pages failed, fall back to vmalloc 2367 * __get_free_pages failed, fall back to vmalloc
2370 */ 2368 */
2371 *flags |= PGV_FROM_VMALLOC;
2372 buffer = vzalloc((1 << order) * PAGE_SIZE); 2369 buffer = vzalloc((1 << order) * PAGE_SIZE);
2373 2370
2374 if (buffer) 2371 if (buffer)
@@ -2377,7 +2374,6 @@ static inline char *alloc_one_pg_vec_page(unsigned long order,
2377 /* 2374 /*
2378 * vmalloc failed, lets dig into swap here 2375 * vmalloc failed, lets dig into swap here
2379 */ 2376 */
2380 *flags = 0;
2381 gfp_flags &= ~__GFP_NORETRY; 2377 gfp_flags &= ~__GFP_NORETRY;
2382 buffer = (char *)__get_free_pages(gfp_flags, order); 2378 buffer = (char *)__get_free_pages(gfp_flags, order);
2383 if (buffer) 2379 if (buffer)
@@ -2400,8 +2396,7 @@ static struct pgv *alloc_pg_vec(struct tpacket_req *req, int order)
2400 goto out; 2396 goto out;
2401 2397
2402 for (i = 0; i < block_nr; i++) { 2398 for (i = 0; i < block_nr; i++) {
2403 pg_vec[i].buffer = alloc_one_pg_vec_page(order, 2399 pg_vec[i].buffer = alloc_one_pg_vec_page(order);
2404 &pg_vec[i].flags);
2405 if (unlikely(!pg_vec[i].buffer)) 2400 if (unlikely(!pg_vec[i].buffer))
2406 goto out_free_pgvec; 2401 goto out_free_pgvec;
2407 } 2402 }
@@ -2585,13 +2580,8 @@ static int packet_mmap(struct file *file, struct socket *sock,
2585 void *kaddr = rb->pg_vec[i].buffer; 2580 void *kaddr = rb->pg_vec[i].buffer;
2586 int pg_num; 2581 int pg_num;
2587 2582
2588 for (pg_num = 0; pg_num < rb->pg_vec_pages; 2583 for (pg_num = 0; pg_num < rb->pg_vec_pages; pg_num++) {
2589 pg_num++) { 2584 page = pgv_to_page(kaddr);
2590 if (rb->pg_vec[i].flags & PGV_FROM_VMALLOC)
2591 page = vmalloc_to_page(kaddr);
2592 else
2593 page = virt_to_page(kaddr);
2594
2595 err = vm_insert_page(vma, start, page); 2585 err = vm_insert_page(vma, start, page);
2596 if (unlikely(err)) 2586 if (unlikely(err))
2597 goto out; 2587 goto out;