batman-adv: 2013.3.0 updated stability fixes
[feed/routing.git] / batman-adv / patches / 0002-batman-adv-Unmap-fragment-page-once-iterator-is-done.patch
1 From 0d941e82ab5f92faf33bee6abdde519056f3ac2d Mon Sep 17 00:00:00 2001
2 From: Simon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>
3 Date: Wed, 26 Jun 2013 11:37:51 +0200
4 Subject: [PATCH 2/4] batman-adv: Unmap fragment page once iterator is done
5
6 Callers of skb_seq_read() are currently forced to call skb_abort_seq_read()
7 even when consuming all the data because the last call to skb_seq_read (the
8 one that returns 0 to indicate the end) fails to unmap the last fragment page.
9
10 With this patch callers will be allowed to traverse the SKB data by calling
11 skb_prepare_seq_read() once and repeatedly calling skb_seq_read() as originally
12 intended (and documented in the original commit 677e90eda), that is, only call
13 skb_abort_seq_read() if the sequential read is actually aborted.
14
15 Signed-off-by: Wedson Almeida Filho <wedsonaf@gmail.com>
16 Signed-off-by: David S. Miller <davem@davemloft.net>
17 Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
18 Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
19 ---
20 compat.h | 8 ++++++++
21 main.c | 1 -
22 2 files changed, 8 insertions(+), 1 deletion(-)
23
24 diff --git a/compat.h b/compat.h
25 index 17ef089..346a824 100644
26 --- a/compat.h
27 +++ b/compat.h
28 @@ -306,6 +306,14 @@ static int __batadv_interface_set_mac_addr(x, y)
29
30 #define netdev_notifier_info_to_dev(ptr) ptr
31
32 +/* older kernels still need to call skb_abort_seq_read() */
33 +#define skb_seq_read(consumed, data, st) \
34 + ({ \
35 + int len = skb_seq_read(consumed, data, st); \
36 + if (len == 0) \
37 + skb_abort_seq_read(st); \
38 + len; \
39 + })
40 #endif /* < KERNEL_VERSION(3, 11, 0) */
41
42 #endif /* _NET_BATMAN_ADV_COMPAT_H_ */
43 diff --git a/main.c b/main.c
44 index 51aafd6..08125f3 100644
45 --- a/main.c
46 +++ b/main.c
47 @@ -473,7 +473,6 @@ __be32 batadv_skb_crc32(struct sk_buff *skb, u8 *payload_ptr)
48 crc = crc32c(crc, data, len);
49 consumed += len;
50 }
51 - skb_abort_seq_read(&st);
52
53 return htonl(crc);
54 }
55 --
56 1.8.4.rc3
57