diff options
author | Sven Eckelmann <sven@narfation.org> | 2016-07-17 15:04:00 -0400 |
---|---|---|
committer | Simon Wunderlich <sw@simonwunderlich.de> | 2016-10-30 06:11:36 -0400 |
commit | bd687fe41991611a6904b7cbc1d596f687584ebb (patch) | |
tree | 515668dc83bd3a60a3b2a7acd4f5a28ea76e8111 /net/batman-adv/network-coding.c | |
parent | 3111beed0d595d26551afb607c9812fe49da2ead (diff) |
batman-adv: use consume_skb for non-dropped packets
kfree_skb assumes that an skb is dropped after an failure and notes that.
consume_skb should be used in non-failure situations. Such information is
important for dropmonitor netlink which tells how many packets were dropped
and where this drop happened.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Diffstat (limited to 'net/batman-adv/network-coding.c')
-rw-r--r-- | net/batman-adv/network-coding.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c index c213ddec86ad..3af66d33d4bf 100644 --- a/net/batman-adv/network-coding.c +++ b/net/batman-adv/network-coding.c | |||
@@ -260,10 +260,16 @@ static void batadv_nc_path_put(struct batadv_nc_path *nc_path) | |||
260 | /** | 260 | /** |
261 | * batadv_nc_packet_free - frees nc packet | 261 | * batadv_nc_packet_free - frees nc packet |
262 | * @nc_packet: the nc packet to free | 262 | * @nc_packet: the nc packet to free |
263 | * @dropped: whether the packet is freed because is is dropped | ||
263 | */ | 264 | */ |
264 | static void batadv_nc_packet_free(struct batadv_nc_packet *nc_packet) | 265 | static void batadv_nc_packet_free(struct batadv_nc_packet *nc_packet, |
266 | bool dropped) | ||
265 | { | 267 | { |
266 | kfree_skb(nc_packet->skb); | 268 | if (dropped) |
269 | kfree_skb(nc_packet->skb); | ||
270 | else | ||
271 | consume_skb(nc_packet->skb); | ||
272 | |||
267 | batadv_nc_path_put(nc_packet->nc_path); | 273 | batadv_nc_path_put(nc_packet->nc_path); |
268 | kfree(nc_packet); | 274 | kfree(nc_packet); |
269 | } | 275 | } |
@@ -576,7 +582,7 @@ static void batadv_nc_send_packet(struct batadv_nc_packet *nc_packet) | |||
576 | { | 582 | { |
577 | batadv_send_unicast_skb(nc_packet->skb, nc_packet->neigh_node); | 583 | batadv_send_unicast_skb(nc_packet->skb, nc_packet->neigh_node); |
578 | nc_packet->skb = NULL; | 584 | nc_packet->skb = NULL; |
579 | batadv_nc_packet_free(nc_packet); | 585 | batadv_nc_packet_free(nc_packet, false); |
580 | } | 586 | } |
581 | 587 | ||
582 | /** | 588 | /** |
@@ -610,7 +616,7 @@ static bool batadv_nc_sniffed_purge(struct batadv_priv *bat_priv, | |||
610 | 616 | ||
611 | /* purge nc packet */ | 617 | /* purge nc packet */ |
612 | list_del(&nc_packet->list); | 618 | list_del(&nc_packet->list); |
613 | batadv_nc_packet_free(nc_packet); | 619 | batadv_nc_packet_free(nc_packet, true); |
614 | 620 | ||
615 | res = true; | 621 | res = true; |
616 | 622 | ||
@@ -1208,11 +1214,11 @@ static bool batadv_nc_code_packets(struct batadv_priv *bat_priv, | |||
1208 | } | 1214 | } |
1209 | 1215 | ||
1210 | /* skb_src is now coded into skb_dest, so free it */ | 1216 | /* skb_src is now coded into skb_dest, so free it */ |
1211 | kfree_skb(skb_src); | 1217 | consume_skb(skb_src); |
1212 | 1218 | ||
1213 | /* avoid duplicate free of skb from nc_packet */ | 1219 | /* avoid duplicate free of skb from nc_packet */ |
1214 | nc_packet->skb = NULL; | 1220 | nc_packet->skb = NULL; |
1215 | batadv_nc_packet_free(nc_packet); | 1221 | batadv_nc_packet_free(nc_packet, false); |
1216 | 1222 | ||
1217 | /* Send the coded packet and return true */ | 1223 | /* Send the coded packet and return true */ |
1218 | batadv_send_unicast_skb(skb_dest, first_dest); | 1224 | batadv_send_unicast_skb(skb_dest, first_dest); |
@@ -1399,7 +1405,7 @@ static void batadv_nc_skb_store_before_coding(struct batadv_priv *bat_priv, | |||
1399 | /* batadv_nc_skb_store_for_decoding() clones the skb, so we must free | 1405 | /* batadv_nc_skb_store_for_decoding() clones the skb, so we must free |
1400 | * our ref | 1406 | * our ref |
1401 | */ | 1407 | */ |
1402 | kfree_skb(skb); | 1408 | consume_skb(skb); |
1403 | } | 1409 | } |
1404 | 1410 | ||
1405 | /** | 1411 | /** |
@@ -1723,7 +1729,7 @@ batadv_nc_skb_decode_packet(struct batadv_priv *bat_priv, struct sk_buff *skb, | |||
1723 | ether_addr_copy(unicast_packet->dest, orig_dest); | 1729 | ether_addr_copy(unicast_packet->dest, orig_dest); |
1724 | unicast_packet->ttvn = ttvn; | 1730 | unicast_packet->ttvn = ttvn; |
1725 | 1731 | ||
1726 | batadv_nc_packet_free(nc_packet); | 1732 | batadv_nc_packet_free(nc_packet, false); |
1727 | return unicast_packet; | 1733 | return unicast_packet; |
1728 | } | 1734 | } |
1729 | 1735 | ||
@@ -1860,7 +1866,7 @@ static int batadv_nc_recv_coded_packet(struct sk_buff *skb, | |||
1860 | return batadv_recv_unicast_packet(skb, recv_if); | 1866 | return batadv_recv_unicast_packet(skb, recv_if); |
1861 | 1867 | ||
1862 | free_nc_packet: | 1868 | free_nc_packet: |
1863 | batadv_nc_packet_free(nc_packet); | 1869 | batadv_nc_packet_free(nc_packet, true); |
1864 | return NET_RX_DROP; | 1870 | return NET_RX_DROP; |
1865 | } | 1871 | } |
1866 | 1872 | ||