[RH7] fixed counter of dropped packets in venet_xmit

Submitted by Vasily Averin on Oct. 18, 2017, 1:30 p.m.

Details

Message ID 31924961-3890-e037-40e5-cd7d9db4b5d3@virtuozzo.com
State New
Series "fixed counter of dropped packets in venet_xmit"
Headers show

Commit Message

Vasily Averin Oct. 18, 2017, 1:30 p.m.
venet_xmit() calls netif_rx(), does not check its return value
and always increases tx_packets and tx_bytes

However netif_rx() can drop packet.

This patch increases tx_dropped in described case.

https://jira.sw.ru/browse/PSBM-75049
Signed-off-by: Vasily Averin <vvs@virtuozzo.com>

Patch hide | download patch | download mbox

diff --git a/drivers/net/venetdev.c b/drivers/net/venetdev.c
index 7a546cc..4559f5d 100644
--- a/drivers/net/venetdev.c
+++ b/drivers/net/venetdev.c
@@ -512,11 +512,9 @@  static int venet_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	dev_hold(rcv);
 
-	if (!(rcv->flags & IFF_UP)) {
+	if (!(rcv->flags & IFF_UP))
 		/* Target VE does not want to receive packets */
-		dev_put(rcv);
 		goto outf;
-	}
 
 	skb->pkt_type = PACKET_HOST;
 	skb->dev = rcv;
@@ -537,10 +535,9 @@  static int venet_xmit(struct sk_buff *skb, struct net_device *dev)
 		struct sk_buff *skb2;
 
 		skb2 = skb_realloc_headroom(skb, LL_RESERVED_SPACE(dev));
-		if (!skb2) {
-			dev_put(rcv);
+		if (!skb2)
 			goto outf;
-		}
+
 		if (skb->sk)
 			skb_set_owner_w(skb2, skb->sk);
 		kfree_skb(skb);
@@ -553,7 +550,8 @@  static int venet_xmit(struct sk_buff *skb, struct net_device *dev)
 	nf_reset(skb);
 	length = skb->len;
 
-	netif_rx(skb);
+	if (unlikely(netif_rx(skb) != NET_RX_SUCCESS))
+		goto dropped;
 
 	stats->tx_bytes += length;
 	stats->tx_packets++;
@@ -570,6 +568,9 @@  static int venet_xmit(struct sk_buff *skb, struct net_device *dev)
 
 outf:
 	kfree_skb(skb);
+dropped:
+	if (rcv)
+		dev_put(rcv);
 	++stats->tx_dropped;
 	return 0;
 }