From: Pravin B Shelar Date: Tue, 8 Nov 2011 19:16:24 +0000 (-0800) Subject: datapath: Fix vport tx_packets count. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58d01ad97d120506f70809b2302044ff34eb3c7c;p=openvswitch datapath: Fix vport tx_packets count. Signed-off-by: Pravin B Shelar Acked-by: Jesse Gross --- diff --git a/datapath/vport.c b/datapath/vport.c index 6fe6042a..a6b686c8 100644 --- a/datapath/vport.c +++ b/datapath/vport.c @@ -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; }