batman-adv: Merge bugfixes from 2018.1
[feed/routing.git] / batman-adv / patches / 0032-batman-adv-update-data-pointers-after-skb_cow.patch
1 From: Matthias Schiffer <mschiffer@universe-factory.net>
2 Date: Fri, 16 Mar 2018 11:29:09 +0100
3 Subject: [PATCH] batman-adv: update data pointers after skb_cow()
4
5 batadv_check_unicast_ttvn() calls skb_cow(), so pointers into the SKB data
6 must be (re)set after calling it. The ethhdr variable is dropped
7 altogether.
8
9 Fixes: 78fc6bbe0aca ("batman-adv: add UNICAST_4ADDR packet type")
10 Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
11 Signed-off-by: Sven Eckelmann <sven@narfation.org>
12
13 Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/64d22c76a207ed313b2496f0709b2567719452c4
14 ---
15 net/batman-adv/routing.c | 10 +++++-----
16 1 file changed, 5 insertions(+), 5 deletions(-)
17
18 diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
19 index 213cc01ad00392f7cbd4efd9d4796f76691d2d9e..8d927931017e53d285d9c64b4b850bb1d0388e11 100644
20 --- a/net/batman-adv/routing.c
21 +++ b/net/batman-adv/routing.c
22 @@ -946,14 +946,10 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
23 struct batadv_orig_node *orig_node = NULL, *orig_node_gw = NULL;
24 int check, hdr_size = sizeof(*unicast_packet);
25 enum batadv_subtype subtype;
26 - struct ethhdr *ethhdr;
27 int ret = NET_RX_DROP;
28 bool is4addr, is_gw;
29
30 unicast_packet = (struct batadv_unicast_packet *)skb->data;
31 - unicast_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data;
32 - ethhdr = eth_hdr(skb);
33 -
34 is4addr = unicast_packet->packet_type == BATADV_UNICAST_4ADDR;
35 /* the caller function should have already pulled 2 bytes */
36 if (is4addr)
37 @@ -973,12 +969,14 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
38 if (!batadv_check_unicast_ttvn(bat_priv, skb, hdr_size))
39 goto free_skb;
40
41 + unicast_packet = (struct batadv_unicast_packet *)skb->data;
42 +
43 /* packet for me */
44 if (batadv_is_my_mac(bat_priv, unicast_packet->dest)) {
45 /* If this is a unicast packet from another backgone gw,
46 * drop it.
47 */
48 - orig_addr_gw = ethhdr->h_source;
49 + orig_addr_gw = eth_hdr(skb)->h_source;
50 orig_node_gw = batadv_orig_hash_find(bat_priv, orig_addr_gw);
51 if (orig_node_gw) {
52 is_gw = batadv_bla_is_backbone_gw(skb, orig_node_gw,
53 @@ -993,6 +991,8 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
54 }
55
56 if (is4addr) {
57 + unicast_4addr_packet =
58 + (struct batadv_unicast_4addr_packet *)skb->data;
59 subtype = unicast_4addr_packet->subtype;
60 batadv_dat_inc_counter(bat_priv, subtype);
61