]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.1/batman-adv-adjust-name-for-batadv_dat_send_data.patch
fixes for 5.1
[thirdparty/kernel/stable-queue.git] / queue-5.1 / batman-adv-adjust-name-for-batadv_dat_send_data.patch
1 From 7a55c344c95c6518b8fa150aab22b4f52b801578 Mon Sep 17 00:00:00 2001
2 From: Sven Eckelmann <sven@narfation.org>
3 Date: Sun, 17 Mar 2019 10:50:50 +0100
4 Subject: batman-adv: Adjust name for batadv_dat_send_data
5
6 [ Upstream commit c2d8b9a6c17a3848136b3eb31f26d3c5880acd89 ]
7
8 The send functions in batman-adv are expected to consume the skb when
9 either the data is queued up for the underlying driver or when some
10 precondition failed. batadv_dat_send_data didn't do this and instead
11 created a copy of the skb, modified it and queued the copy up for
12 transmission. The caller has to take care that the skb is handled correctly
13 (for example free'd) when batadv_dat_send_data returns.
14
15 This unclear behavior already lead to memory leaks in the recent past.
16 Renaming the function to batadv_dat_forward_data should make it easier to
17 identify that the data is forwarded but the skb is not actually
18 send+consumed.
19
20 Signed-off-by: Sven Eckelmann <sven@narfation.org>
21 Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
22 Signed-off-by: Sasha Levin <sashal@kernel.org>
23 ---
24 net/batman-adv/distributed-arp-table.c | 24 ++++++++++++++----------
25 1 file changed, 14 insertions(+), 10 deletions(-)
26
27 diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
28 index 8d290da0d596..9ba7b9bb198a 100644
29 --- a/net/batman-adv/distributed-arp-table.c
30 +++ b/net/batman-adv/distributed-arp-table.c
31 @@ -667,7 +667,7 @@ batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst,
32 }
33
34 /**
35 - * batadv_dat_send_data() - send a payload to the selected candidates
36 + * batadv_dat_forward_data() - copy and send payload to the selected candidates
37 * @bat_priv: the bat priv with all the soft interface information
38 * @skb: payload to send
39 * @ip: the DHT key
40 @@ -680,9 +680,9 @@ batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst,
41 * Return: true if the packet is sent to at least one candidate, false
42 * otherwise.
43 */
44 -static bool batadv_dat_send_data(struct batadv_priv *bat_priv,
45 - struct sk_buff *skb, __be32 ip,
46 - unsigned short vid, int packet_subtype)
47 +static bool batadv_dat_forward_data(struct batadv_priv *bat_priv,
48 + struct sk_buff *skb, __be32 ip,
49 + unsigned short vid, int packet_subtype)
50 {
51 int i;
52 bool ret = false;
53 @@ -1277,8 +1277,8 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
54 ret = true;
55 } else {
56 /* Send the request to the DHT */
57 - ret = batadv_dat_send_data(bat_priv, skb, ip_dst, vid,
58 - BATADV_P_DAT_DHT_GET);
59 + ret = batadv_dat_forward_data(bat_priv, skb, ip_dst, vid,
60 + BATADV_P_DAT_DHT_GET);
61 }
62 out:
63 if (dat_entry)
64 @@ -1392,8 +1392,10 @@ void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,
65 /* Send the ARP reply to the candidates for both the IP addresses that
66 * the node obtained from the ARP reply
67 */
68 - batadv_dat_send_data(bat_priv, skb, ip_src, vid, BATADV_P_DAT_DHT_PUT);
69 - batadv_dat_send_data(bat_priv, skb, ip_dst, vid, BATADV_P_DAT_DHT_PUT);
70 + batadv_dat_forward_data(bat_priv, skb, ip_src, vid,
71 + BATADV_P_DAT_DHT_PUT);
72 + batadv_dat_forward_data(bat_priv, skb, ip_dst, vid,
73 + BATADV_P_DAT_DHT_PUT);
74 }
75
76 /**
77 @@ -1710,8 +1712,10 @@ static void batadv_dat_put_dhcp(struct batadv_priv *bat_priv, u8 *chaddr,
78 batadv_dat_entry_add(bat_priv, yiaddr, chaddr, vid);
79 batadv_dat_entry_add(bat_priv, ip_dst, hw_dst, vid);
80
81 - batadv_dat_send_data(bat_priv, skb, yiaddr, vid, BATADV_P_DAT_DHT_PUT);
82 - batadv_dat_send_data(bat_priv, skb, ip_dst, vid, BATADV_P_DAT_DHT_PUT);
83 + batadv_dat_forward_data(bat_priv, skb, yiaddr, vid,
84 + BATADV_P_DAT_DHT_PUT);
85 + batadv_dat_forward_data(bat_priv, skb, ip_dst, vid,
86 + BATADV_P_DAT_DHT_PUT);
87
88 consume_skb(skb);
89
90 --
91 2.20.1
92