ndppd: importing ndppd package in openwrt-routing feed
[feed/routing.git] / batman-adv / patches / 0001-batman-adv-use-the-proper-header-len-when-checking-t.patch
1 From 9b96ecbae7295269aaa0320667f646870de65661 Mon Sep 17 00:00:00 2001
2 From: Antonio Quartulli <antonio@open-mesh.com>
3 Date: Wed, 3 Apr 2013 10:14:20 +0200
4 Subject: [PATCH 01/10] batman-adv: use the proper header len when checking
5 the TTVN
6
7 Unicast packet might be of type either UNICAST or
8 UNICAST4ADDR.
9 In the two cases the header size is different, but the
10 mechanism checking the TTVN field was assuming it to be
11 always of the same type (UNICAST), so failing to access the
12 inner Ethernet header in case of UNICAST4ADDR.
13
14 Fix this by passing the real header length as argument.
15
16 Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
17 Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
18 ---
19 routing.c | 11 +++++------
20 1 file changed, 5 insertions(+), 6 deletions(-)
21
22 diff --git a/routing.c b/routing.c
23 index 2f1f889..b27a4d7 100644
24 --- a/routing.c
25 +++ b/routing.c
26 @@ -939,7 +939,7 @@ out:
27 }
28
29 static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
30 - struct sk_buff *skb) {
31 + struct sk_buff *skb, int hdr_len) {
32 uint8_t curr_ttvn, old_ttvn;
33 struct batadv_orig_node *orig_node;
34 struct ethhdr *ethhdr;
35 @@ -948,7 +948,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
36 int is_old_ttvn;
37
38 /* check if there is enough data before accessing it */
39 - if (pskb_may_pull(skb, sizeof(*unicast_packet) + ETH_HLEN) < 0)
40 + if (pskb_may_pull(skb, hdr_len + ETH_HLEN) < 0)
41 return 0;
42
43 /* create a copy of the skb (in case of for re-routing) to modify it. */
44 @@ -956,7 +956,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
45 return 0;
46
47 unicast_packet = (struct batadv_unicast_packet *)skb->data;
48 - ethhdr = (struct ethhdr *)(skb->data + sizeof(*unicast_packet));
49 + ethhdr = (struct ethhdr *)(skb->data + hdr_len);
50
51 /* check if the destination client was served by this node and it is now
52 * roaming. In this case, it means that the node has got a ROAM_ADV
53 @@ -1072,8 +1072,7 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
54
55 if (check < 0)
56 return NET_RX_DROP;
57 -
58 - if (!batadv_check_unicast_ttvn(bat_priv, skb))
59 + if (!batadv_check_unicast_ttvn(bat_priv, skb, hdr_size))
60 return NET_RX_DROP;
61
62 /* packet for me */
63 @@ -1117,7 +1116,7 @@ int batadv_recv_ucast_frag_packet(struct sk_buff *skb,
64 if (batadv_check_unicast_packet(bat_priv, skb, hdr_size) < 0)
65 return NET_RX_DROP;
66
67 - if (!batadv_check_unicast_ttvn(bat_priv, skb))
68 + if (!batadv_check_unicast_ttvn(bat_priv, skb, hdr_size))
69 return NET_RX_DROP;
70
71 unicast_packet = (struct batadv_unicast_frag_packet *)skb->data;
72 --
73 1.7.10.4
74