Skip to content

Commit c2d8b9a

Browse files
ecsvsimonwunderlich
authored andcommitted
batman-adv: Adjust name for batadv_dat_send_data
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: Sven Eckelmann <[email protected]> Signed-off-by: Simon Wunderlich <[email protected]>
1 parent cedb0db commit c2d8b9a

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

net/batman-adv/distributed-arp-table.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst,
655655
}
656656

657657
/**
658-
* batadv_dat_send_data() - send a payload to the selected candidates
658+
* batadv_dat_forward_data() - copy and send payload to the selected candidates
659659
* @bat_priv: the bat priv with all the soft interface information
660660
* @skb: payload to send
661661
* @ip: the DHT key
@@ -668,9 +668,9 @@ batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst,
668668
* Return: true if the packet is sent to at least one candidate, false
669669
* otherwise.
670670
*/
671-
static bool batadv_dat_send_data(struct batadv_priv *bat_priv,
672-
struct sk_buff *skb, __be32 ip,
673-
unsigned short vid, int packet_subtype)
671+
static bool batadv_dat_forward_data(struct batadv_priv *bat_priv,
672+
struct sk_buff *skb, __be32 ip,
673+
unsigned short vid, int packet_subtype)
674674
{
675675
int i;
676676
bool ret = false;
@@ -1265,8 +1265,8 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
12651265
ret = true;
12661266
} else {
12671267
/* Send the request to the DHT */
1268-
ret = batadv_dat_send_data(bat_priv, skb, ip_dst, vid,
1269-
BATADV_P_DAT_DHT_GET);
1268+
ret = batadv_dat_forward_data(bat_priv, skb, ip_dst, vid,
1269+
BATADV_P_DAT_DHT_GET);
12701270
}
12711271
out:
12721272
if (dat_entry)
@@ -1380,8 +1380,10 @@ void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,
13801380
/* Send the ARP reply to the candidates for both the IP addresses that
13811381
* the node obtained from the ARP reply
13821382
*/
1383-
batadv_dat_send_data(bat_priv, skb, ip_src, vid, BATADV_P_DAT_DHT_PUT);
1384-
batadv_dat_send_data(bat_priv, skb, ip_dst, vid, BATADV_P_DAT_DHT_PUT);
1383+
batadv_dat_forward_data(bat_priv, skb, ip_src, vid,
1384+
BATADV_P_DAT_DHT_PUT);
1385+
batadv_dat_forward_data(bat_priv, skb, ip_dst, vid,
1386+
BATADV_P_DAT_DHT_PUT);
13851387
}
13861388

13871389
/**
@@ -1696,8 +1698,10 @@ static void batadv_dat_put_dhcp(struct batadv_priv *bat_priv, u8 *chaddr,
16961698
batadv_dat_entry_add(bat_priv, yiaddr, chaddr, vid);
16971699
batadv_dat_entry_add(bat_priv, ip_dst, hw_dst, vid);
16981700

1699-
batadv_dat_send_data(bat_priv, skb, yiaddr, vid, BATADV_P_DAT_DHT_PUT);
1700-
batadv_dat_send_data(bat_priv, skb, ip_dst, vid, BATADV_P_DAT_DHT_PUT);
1701+
batadv_dat_forward_data(bat_priv, skb, yiaddr, vid,
1702+
BATADV_P_DAT_DHT_PUT);
1703+
batadv_dat_forward_data(bat_priv, skb, ip_dst, vid,
1704+
BATADV_P_DAT_DHT_PUT);
17011705

17021706
consume_skb(skb);
17031707

0 commit comments

Comments
 (0)