batman-adv: Refresh patches
[feed/routing.git] / batman-adv / patches / 0034-batman-adv-Fix-skbuff-rcsum-on-packet-reroute.patch
1 From: Sven Eckelmann <sven@narfation.org>
2 Date: Sun, 18 Mar 2018 13:12:01 +0100
3 Subject: batman-adv: Fix skbuff rcsum on packet reroute
4
5 batadv_check_unicast_ttvn may redirect a packet to itself or another
6 originator. This involves rewriting the ttvn and the destination address in
7 the batadv unicast header. These field were not yet pulled (with skb rcsum
8 update) and thus any change to them also requires a change in the receive
9 checksum.
10
11 Reported-by: Matthias Schiffer <mschiffer@universe-factory.net>
12 Fixes: cea194d90b11 ("batman-adv: improved client announcement mechanism")
13 Signed-off-by: Sven Eckelmann <sven@narfation.org>
14
15 Origin: backport, https://git.open-mesh.org/batman-adv.git/commit/fb91b0ef84738102807e5dd7ec0b3565415aff56
16
17 diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
18 index 8d927931017e53d285d9c64b4b850bb1d0388e11..6a12612463127f501ad6a0df20632f14586075bd 100644
19 --- a/net/batman-adv/routing.c
20 +++ b/net/batman-adv/routing.c
21 @@ -744,6 +744,7 @@ free_skb:
22 /**
23 * batadv_reroute_unicast_packet - update the unicast header for re-routing
24 * @bat_priv: the bat priv with all the soft interface information
25 + * @skb: unicast packet to process
26 * @unicast_packet: the unicast header to be updated
27 * @dst_addr: the payload destination
28 * @vid: VLAN identifier
29 @@ -755,7 +756,7 @@ free_skb:
30 * Return: true if the packet header has been updated, false otherwise
31 */
32 static bool
33 -batadv_reroute_unicast_packet(struct batadv_priv *bat_priv,
34 +batadv_reroute_unicast_packet(struct batadv_priv *bat_priv, struct sk_buff *skb,
35 struct batadv_unicast_packet *unicast_packet,
36 u8 *dst_addr, unsigned short vid)
37 {
38 @@ -784,8 +785,10 @@ batadv_reroute_unicast_packet(struct batadv_priv *bat_priv,
39 }
40
41 /* update the packet header */
42 + skb_postpull_rcsum(skb, unicast_packet, sizeof(*unicast_packet));
43 ether_addr_copy(unicast_packet->dest, orig_addr);
44 unicast_packet->ttvn = orig_ttvn;
45 + skb_postpush_rcsum(skb, unicast_packet, sizeof(*unicast_packet));
46
47 ret = true;
48 out:
49 @@ -826,7 +829,7 @@ static bool batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
50 * the packet to
51 */
52 if (batadv_tt_local_client_is_roaming(bat_priv, ethhdr->h_dest, vid)) {
53 - if (batadv_reroute_unicast_packet(bat_priv, unicast_packet,
54 + if (batadv_reroute_unicast_packet(bat_priv, skb, unicast_packet,
55 ethhdr->h_dest, vid))
56 batadv_dbg_ratelimited(BATADV_DBG_TT,
57 bat_priv,
58 @@ -872,7 +875,7 @@ static bool batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
59 * destination can possibly be updated and forwarded towards the new
60 * target host
61 */
62 - if (batadv_reroute_unicast_packet(bat_priv, unicast_packet,
63 + if (batadv_reroute_unicast_packet(bat_priv, skb, unicast_packet,
64 ethhdr->h_dest, vid)) {
65 batadv_dbg_ratelimited(BATADV_DBG_TT, bat_priv,
66 "Rerouting unicast packet to %pM (dst=%pM): TTVN mismatch old_ttvn=%u new_ttvn=%u\n",
67 @@ -895,12 +898,14 @@ static bool batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
68 if (!primary_if)
69 return false;
70
71 + /* update the packet header */
72 + skb_postpull_rcsum(skb, unicast_packet, sizeof(*unicast_packet));
73 ether_addr_copy(unicast_packet->dest, primary_if->net_dev->dev_addr);
74 + unicast_packet->ttvn = curr_ttvn;
75 + skb_postpush_rcsum(skb, unicast_packet, sizeof(*unicast_packet));
76
77 batadv_hardif_put(primary_if);
78
79 - unicast_packet->ttvn = curr_ttvn;
80 -
81 return true;
82 }
83