[RHEL7,COMMIT] venet: fix counter of dropped packets in venet_xmit

Submitted by Konstantin Khorenko on Oct. 19, 2017, 9:09 a.m.

Details

Message ID 201710190909.v9J99Q0K008287@finist_ce7.work
State New
Series "fixed counter of dropped packets in venet_xmit"
Headers show

Commit Message

Konstantin Khorenko Oct. 19, 2017, 9:09 a.m.
The commit is pushed to "branch-rh7-3.10.0-693.1.1.vz7.37.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.1.1.vz7.37.16
------>
commit a7f875124bc2d81b93e56394552edbdafb2501b2
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Thu Oct 19 12:09:26 2017 +0300

    venet: fix counter of dropped packets in venet_xmit
    
    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>
---
 drivers/net/venetdev.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/net/venetdev.c b/drivers/net/venetdev.c
index 0adc1fd..1c4ae90 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;
 }