9080028c8a656ed06dc70a60decbe8a044faa66f
[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: [PATCH] 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 net/batman-adv/routing.c | 15 ++++++++++-----
18 1 file changed, 10 insertions(+), 5 deletions(-)
19
20 diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
21 index 8d927931017e53d285d9c64b4b850bb1d0388e11..6a12612463127f501ad6a0df20632f14586075bd 100644
22 --- a/net/batman-adv/routing.c
23 +++ b/net/batman-adv/routing.c
24 @@ -744,6 +744,7 @@ free_skb:
25 /**
26 * batadv_reroute_unicast_packet - update the unicast header for re-routing
27 * @bat_priv: the bat priv with all the soft interface information
28 + * @skb: unicast packet to process
29 * @unicast_packet: the unicast header to be updated
30 * @dst_addr: the payload destination
31 * @vid: VLAN identifier
32 @@ -755,7 +756,7 @@ free_skb:
33 * Return: true if the packet header has been updated, false otherwise
34 */
35 static bool
36 -batadv_reroute_unicast_packet(struct batadv_priv *bat_priv,
37 +batadv_reroute_unicast_packet(struct batadv_priv *bat_priv, struct sk_buff *skb,
38 struct batadv_unicast_packet *unicast_packet,
39 u8 *dst_addr, unsigned short vid)
40 {
41 @@ -784,8 +785,10 @@ batadv_reroute_unicast_packet(struct batadv_priv *bat_priv,
42 }
43
44 /* update the packet header */
45 + skb_postpull_rcsum(skb, unicast_packet, sizeof(*unicast_packet));
46 ether_addr_copy(unicast_packet->dest, orig_addr);
47 unicast_packet->ttvn = orig_ttvn;
48 + skb_postpush_rcsum(skb, unicast_packet, sizeof(*unicast_packet));
49
50 ret = true;
51 out:
52 @@ -826,7 +829,7 @@ static bool batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
53 * the packet to
54 */
55 if (batadv_tt_local_client_is_roaming(bat_priv, ethhdr->h_dest, vid)) {
56 - if (batadv_reroute_unicast_packet(bat_priv, unicast_packet,
57 + if (batadv_reroute_unicast_packet(bat_priv, skb, unicast_packet,
58 ethhdr->h_dest, vid))
59 batadv_dbg_ratelimited(BATADV_DBG_TT,
60 bat_priv,
61 @@ -872,7 +875,7 @@ static bool batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
62 * destination can possibly be updated and forwarded towards the new
63 * target host
64 */
65 - if (batadv_reroute_unicast_packet(bat_priv, unicast_packet,
66 + if (batadv_reroute_unicast_packet(bat_priv, skb, unicast_packet,
67 ethhdr->h_dest, vid)) {
68 batadv_dbg_ratelimited(BATADV_DBG_TT, bat_priv,
69 "Rerouting unicast packet to %pM (dst=%pM): TTVN mismatch old_ttvn=%u new_ttvn=%u\n",
70 @@ -895,12 +898,14 @@ static bool batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
71 if (!primary_if)
72 return false;
73
74 + /* update the packet header */
75 + skb_postpull_rcsum(skb, unicast_packet, sizeof(*unicast_packet));
76 ether_addr_copy(unicast_packet->dest, primary_if->net_dev->dev_addr);
77 + unicast_packet->ttvn = curr_ttvn;
78 + skb_postpush_rcsum(skb, unicast_packet, sizeof(*unicast_packet));
79
80 batadv_hardif_put(primary_if);
81
82 - unicast_packet->ttvn = curr_ttvn;
83 -
84 return true;
85 }
86