Commit 24cc59d1 authored by Ben Pfaff's avatar Ben Pfaff Committed by David S. Miller

openvswitch: Consistently include VLAN header in flow and port stats.

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.htmlReported-by: default avatarMotonori Shindo <mshindo@vmware.com>
Signed-off-by: default avatarBen Pfaff <blp@nicira.com>
Reviewed-by: default avatarFlavio Leitner <fbl@sysclose.org>
Acked-by: default avatarPravin B Shelar <pshelar@nicira.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 843925f3
...@@ -70,6 +70,7 @@ void ovs_flow_stats_update(struct sw_flow *flow, __be16 tcp_flags, ...@@ -70,6 +70,7 @@ void ovs_flow_stats_update(struct sw_flow *flow, __be16 tcp_flags,
{ {
struct flow_stats *stats; struct flow_stats *stats;
int node = numa_node_id(); int node = numa_node_id();
int len = skb->len + (vlan_tx_tag_present(skb) ? VLAN_HLEN : 0);
stats = rcu_dereference(flow->stats[node]); stats = rcu_dereference(flow->stats[node]);
...@@ -105,7 +106,7 @@ void ovs_flow_stats_update(struct sw_flow *flow, __be16 tcp_flags, ...@@ -105,7 +106,7 @@ void ovs_flow_stats_update(struct sw_flow *flow, __be16 tcp_flags,
if (likely(new_stats)) { if (likely(new_stats)) {
new_stats->used = jiffies; new_stats->used = jiffies;
new_stats->packet_count = 1; new_stats->packet_count = 1;
new_stats->byte_count = skb->len; new_stats->byte_count = len;
new_stats->tcp_flags = tcp_flags; new_stats->tcp_flags = tcp_flags;
spin_lock_init(&new_stats->lock); spin_lock_init(&new_stats->lock);
...@@ -120,7 +121,7 @@ void ovs_flow_stats_update(struct sw_flow *flow, __be16 tcp_flags, ...@@ -120,7 +121,7 @@ void ovs_flow_stats_update(struct sw_flow *flow, __be16 tcp_flags,
stats->used = jiffies; stats->used = jiffies;
stats->packet_count++; stats->packet_count++;
stats->byte_count += skb->len; stats->byte_count += len;
stats->tcp_flags |= tcp_flags; stats->tcp_flags |= tcp_flags;
unlock: unlock:
spin_unlock(&stats->lock); spin_unlock(&stats->lock);
......
...@@ -480,7 +480,7 @@ void ovs_vport_receive(struct vport *vport, struct sk_buff *skb, ...@@ -480,7 +480,7 @@ void ovs_vport_receive(struct vport *vport, struct sk_buff *skb,
stats = this_cpu_ptr(vport->percpu_stats); stats = this_cpu_ptr(vport->percpu_stats);
u64_stats_update_begin(&stats->syncp); u64_stats_update_begin(&stats->syncp);
stats->rx_packets++; 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); u64_stats_update_end(&stats->syncp);
OVS_CB(skb)->input_vport = vport; OVS_CB(skb)->input_vport = vport;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment