datapath: Fix vport tx_packets count.
authorPravin B Shelar <pshelar@nicira.com>
Tue, 8 Nov 2011 19:16:24 +0000 (11:16 -0800)
committerPravin B Shelar <pshelar@nicira.com>
Tue, 8 Nov 2011 19:16:24 +0000 (11:16 -0800)
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
datapath/vport.c

index 6fe6042a7fefbc4dd165fc756d07671d1fb1da92..a6b686c85928c1ea389b447f8a997d1fa2a02310 100644 (file)
@@ -459,16 +459,18 @@ void vport_receive(struct vport *vport, struct sk_buff *skb)
  */
 int vport_send(struct vport *vport, struct sk_buff *skb)
 {
-       struct vport_percpu_stats *stats;
        int sent = vport->ops->send(vport, skb);
 
-       stats = per_cpu_ptr(vport->percpu_stats, smp_processor_id());
+       if (likely(sent)) {
+               struct vport_percpu_stats *stats;
 
-       write_seqcount_begin(&stats->seqlock);
-       stats->tx_packets++;
-       stats->tx_bytes += sent;
-       write_seqcount_end(&stats->seqlock);
+               stats = per_cpu_ptr(vport->percpu_stats, smp_processor_id());
 
+               write_seqcount_begin(&stats->seqlock);
+               stats->tx_packets++;
+               stats->tx_bytes += sent;
+               write_seqcount_end(&stats->seqlock);
+       }
        return sent;
 }