batman-adv: add patches from 2016.5-maint 2017-02-21
[feed/routing.git] / batman-adv / patches / 0004-batman-adv-Fix-transmission-of-final-16th-fragment.patch
1 From: Linus Lüssing <linus.luessing@c0d3.blue>
2 Date: Mon, 13 Feb 2017 20:44:31 +0100
3 Subject: [PATCH] batman-adv: Fix transmission of final, 16th fragment
4
5 Trying to split and transmit a unicast packet in 16 parts will fail for
6 the final fragment: After having sent the 15th one with a frag_packet.no
7 index of 14, we will increase the the index to 15 - and return with an
8 error code immediately, even though one more fragment is due for
9 transmission and allowed.
10
11 Fixing this issue by moving the check before incrementing the index.
12
13 While at it, adding an unlikely(), because the check is actually more of
14 an assertion.
15
16 Fixes: db56e4ecf5c2 ("batman-adv: Fragment and send skbs larger than mtu")
17 Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
18 Signed-off-by: Sven Eckelmann <sven@narfation.org>
19
20 Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/464eff3b1768ff190466a453a57ac140ea5cb756
21 ---
22 net/batman-adv/fragmentation.c | 12 ++++++------
23 1 file changed, 6 insertions(+), 6 deletions(-)
24
25 diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
26 index 31e97e9a..11149e5b 100644
27 --- a/net/batman-adv/fragmentation.c
28 +++ b/net/batman-adv/fragmentation.c
29 @@ -501,6 +501,12 @@ int batadv_frag_send_packet(struct sk_buff *skb,
30
31 /* Eat and send fragments from the tail of skb */
32 while (skb->len > max_fragment_size) {
33 + /* The initial check in this function should cover this case */
34 + if (unlikely(frag_header.no == BATADV_FRAG_MAX_FRAGMENTS - 1)) {
35 + ret = -EINVAL;
36 + goto put_primary_if;
37 + }
38 +
39 skb_fragment = batadv_frag_create(skb, &frag_header, mtu);
40 if (!skb_fragment) {
41 ret = -ENOMEM;
42 @@ -517,12 +523,6 @@ int batadv_frag_send_packet(struct sk_buff *skb,
43 }
44
45 frag_header.no++;
46 -
47 - /* The initial check in this function should cover this case */
48 - if (frag_header.no == BATADV_FRAG_MAX_FRAGMENTS - 1) {
49 - ret = -EINVAL;
50 - goto put_primary_if;
51 - }
52 }
53
54 /* Make room for the fragment header. */