Commit b7630b79 authored by Sven Eckelmann's avatar Sven Eckelmann Committed by Greg Kroah-Hartman

batman-adv: Adjust name for batadv_dat_send_data

[ Upstream commit c2d8b9a6 ]

The send functions in batman-adv are expected to consume the skb when
either the data is queued up for the underlying driver or when some
precondition failed. batadv_dat_send_data didn't do this and instead
created a copy of the skb, modified it and queued the copy up for
transmission. The caller has to take care that the skb is handled correctly
(for example free'd) when batadv_dat_send_data returns.

This unclear behavior already lead to memory leaks in the recent past.
Renaming the function to batadv_dat_forward_data should make it easier to
identify that the data is forwarded but the skb is not actually
send+consumed.
Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
Signed-off-by: default avatarSimon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 864c051b
...@@ -667,7 +667,7 @@ batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst, ...@@ -667,7 +667,7 @@ batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst,
} }
/** /**
* batadv_dat_send_data() - send a payload to the selected candidates * batadv_dat_forward_data() - copy and send payload to the selected candidates
* @bat_priv: the bat priv with all the soft interface information * @bat_priv: the bat priv with all the soft interface information
* @skb: payload to send * @skb: payload to send
* @ip: the DHT key * @ip: the DHT key
...@@ -680,9 +680,9 @@ batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst, ...@@ -680,9 +680,9 @@ batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst,
* Return: true if the packet is sent to at least one candidate, false * Return: true if the packet is sent to at least one candidate, false
* otherwise. * otherwise.
*/ */
static bool batadv_dat_send_data(struct batadv_priv *bat_priv, static bool batadv_dat_forward_data(struct batadv_priv *bat_priv,
struct sk_buff *skb, __be32 ip, struct sk_buff *skb, __be32 ip,
unsigned short vid, int packet_subtype) unsigned short vid, int packet_subtype)
{ {
int i; int i;
bool ret = false; bool ret = false;
...@@ -1277,8 +1277,8 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv, ...@@ -1277,8 +1277,8 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
ret = true; ret = true;
} else { } else {
/* Send the request to the DHT */ /* Send the request to the DHT */
ret = batadv_dat_send_data(bat_priv, skb, ip_dst, vid, ret = batadv_dat_forward_data(bat_priv, skb, ip_dst, vid,
BATADV_P_DAT_DHT_GET); BATADV_P_DAT_DHT_GET);
} }
out: out:
if (dat_entry) if (dat_entry)
...@@ -1392,8 +1392,10 @@ void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv, ...@@ -1392,8 +1392,10 @@ void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,
/* Send the ARP reply to the candidates for both the IP addresses that /* Send the ARP reply to the candidates for both the IP addresses that
* the node obtained from the ARP reply * the node obtained from the ARP reply
*/ */
batadv_dat_send_data(bat_priv, skb, ip_src, vid, BATADV_P_DAT_DHT_PUT); batadv_dat_forward_data(bat_priv, skb, ip_src, vid,
batadv_dat_send_data(bat_priv, skb, ip_dst, vid, BATADV_P_DAT_DHT_PUT); BATADV_P_DAT_DHT_PUT);
batadv_dat_forward_data(bat_priv, skb, ip_dst, vid,
BATADV_P_DAT_DHT_PUT);
} }
/** /**
...@@ -1710,8 +1712,10 @@ static void batadv_dat_put_dhcp(struct batadv_priv *bat_priv, u8 *chaddr, ...@@ -1710,8 +1712,10 @@ static void batadv_dat_put_dhcp(struct batadv_priv *bat_priv, u8 *chaddr,
batadv_dat_entry_add(bat_priv, yiaddr, chaddr, vid); batadv_dat_entry_add(bat_priv, yiaddr, chaddr, vid);
batadv_dat_entry_add(bat_priv, ip_dst, hw_dst, vid); batadv_dat_entry_add(bat_priv, ip_dst, hw_dst, vid);
batadv_dat_send_data(bat_priv, skb, yiaddr, vid, BATADV_P_DAT_DHT_PUT); batadv_dat_forward_data(bat_priv, skb, yiaddr, vid,
batadv_dat_send_data(bat_priv, skb, ip_dst, vid, BATADV_P_DAT_DHT_PUT); BATADV_P_DAT_DHT_PUT);
batadv_dat_forward_data(bat_priv, skb, ip_dst, vid,
BATADV_P_DAT_DHT_PUT);
consume_skb(skb); consume_skb(skb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment