From patchwork Wed Dec 31 16:45:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 424812 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 6477B1400F1 for ; Thu, 1 Jan 2015 03:55:22 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751104AbaLaQzG (ORCPT ); Wed, 31 Dec 2014 11:55:06 -0500 Received: from na3sys009aog131.obsmtp.com ([74.125.149.247]:39795 "HELO na3sys009aog131.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1750726AbaLaQzE (ORCPT ); Wed, 31 Dec 2014 11:55:04 -0500 X-Greylist: delayed 490 seconds by postgrey-1.27 at vger.kernel.org; Wed, 31 Dec 2014 11:55:04 EST Received: from mail-pa0-f44.google.com ([209.85.220.44]) (using TLSv1) by na3sys009aob131.postini.com ([74.125.148.12]) with SMTP ID DSNKVKQqZ3XET0ompi454zVbdiaMOh+IrRbk@postini.com; Wed, 31 Dec 2014 08:55:04 PST Received: by mail-pa0-f44.google.com with SMTP id et14so21531767pad.31 for ; Wed, 31 Dec 2014 08:55:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=FwB9U7kpDuvtgiI+7c/nach8wSf+CrIkAS1uc3P4554=; b=bSDAXfwMo9aIhgxA4wvxwP4e829Ac6/ArSVvlDtUtxCgW6dNPATO3UTltHSqjz10wv fHQHW+PfMNT5gUh0nel8pH3PM/ZzclOJXQFx1oBUw2Iuw8NYAWD7oKwx7LfHUC3gLRih R0IXt1DRIR3LGxkyKfmPlc/V62eIGR/nDl7lXM8+i45XeuSjPjNKO6Zj+acMU6E3t/Uc v4WIsRHIEtiLxtIaw2KvAv5tYItngRM60pzXgrZB0MsPrMLpVIlfxLmIBC5hMelQq5TE 1blRuufM/ND3AemF8+aHr47nJu6KNl207n7aH0gKO38vQeGXjI35hSXOAwf6MbNgsO+r 6dtQ== X-Received: by 10.70.35.109 with SMTP id g13mr44448086pdj.17.1420044413294; Wed, 31 Dec 2014 08:46:53 -0800 (PST) X-Gm-Message-State: ALoCoQnbF/jaWVLONCUD23QUKGCA3eyNe7CgWTjFNUtBUAaHs0glXaxXLwtI3KPq5Z3FUpKCG8FZdbBXYSP3EoopXjXwVXUQECycBRuftLeXq6dwJAtNV0ibuONby114HSnITyKLvy1mgr+zNFvgoPvHIEbuzNQk1w== X-Received: by 10.70.35.109 with SMTP id g13mr44448041pdj.17.1420044412985; Wed, 31 Dec 2014 08:46:52 -0800 (PST) Received: from sigabrt.benpfaff.org (173-228-112-69.dsl.dynamic.fusionbroadband.com. [173.228.112.69]) by mx.google.com with ESMTPSA id nz4sm41672553pdb.69.2014.12.31.08.46.51 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 31 Dec 2014 08:46:51 -0800 (PST) From: Ben Pfaff To: netdev@vger.kernel.org, dev@openvswitch.org Cc: Ben Pfaff , Pravin Shelar , Motonori Shindo Subject: [PATCH net] openvswitch: Consistently include VLAN header in flow and port stats. Date: Wed, 31 Dec 2014 08:45:46 -0800 Message-Id: <1420044346-27957-1-git-send-email-blp@nicira.com> X-Mailer: git-send-email 2.1.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Until now, when VLAN acceleration was in use, the bytes of the VLAN header were not included in port or flow byte counters. They were however included when VLAN acceleration was not used. This commit corrects the inconsistency, by always including the VLAN header in byte counters. Previous discussion at http://openvswitch.org/pipermail/dev/2014-December/049521.html Reported-by: Motonori Shindo Signed-off-by: Ben Pfaff Reviewed-by: Flavio Leitner Acked-by: Pravin B Shelar --- net/openvswitch/flow.c | 5 +++-- net/openvswitch/vport.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c index 70bef2a..da2fae0 100644 --- a/net/openvswitch/flow.c +++ b/net/openvswitch/flow.c @@ -70,6 +70,7 @@ void ovs_flow_stats_update(struct sw_flow *flow, __be16 tcp_flags, { struct flow_stats *stats; int node = numa_node_id(); + int len = skb->len + (vlan_tx_tag_present(skb) ? VLAN_HLEN : 0); stats = rcu_dereference(flow->stats[node]); @@ -105,7 +106,7 @@ void ovs_flow_stats_update(struct sw_flow *flow, __be16 tcp_flags, if (likely(new_stats)) { new_stats->used = jiffies; new_stats->packet_count = 1; - new_stats->byte_count = skb->len; + new_stats->byte_count = len; new_stats->tcp_flags = tcp_flags; spin_lock_init(&new_stats->lock); @@ -120,7 +121,7 @@ void ovs_flow_stats_update(struct sw_flow *flow, __be16 tcp_flags, stats->used = jiffies; stats->packet_count++; - stats->byte_count += skb->len; + stats->byte_count += len; stats->tcp_flags |= tcp_flags; unlock: spin_unlock(&stats->lock); diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c index 53f3ebb..2034c6d 100644 --- a/net/openvswitch/vport.c +++ b/net/openvswitch/vport.c @@ -480,7 +480,7 @@ void ovs_vport_receive(struct vport *vport, struct sk_buff *skb, stats = this_cpu_ptr(vport->percpu_stats); u64_stats_update_begin(&stats->syncp); stats->rx_packets++; - stats->rx_bytes += skb->len; + stats->rx_bytes += skb->len + (vlan_tx_tag_present(skb) ? VLAN_HLEN : 0); u64_stats_update_end(&stats->syncp); OVS_CB(skb)->input_vport = vport;