Skip to content

Commit

Permalink
datapath: Consistently include VLAN header in flow and port stats.
Browse files Browse the repository at this point in the history
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

Already committed to upstream Linux netdev tree as
24cc59d1ebaac54d933dc0b30abcd8bd86193eef.

Reported-by: Motonori Shindo <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
Reviewed-by: Flavio Leitner <[email protected]>
Acked-by: Pravin B Shelar <[email protected]>
  • Loading branch information
blp committed Jan 6, 2015
1 parent c598aa6 commit 9e91741
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions datapath/flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,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]);

Expand Down Expand Up @@ -106,7 +107,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);

Expand All @@ -121,7 +122,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);
Expand Down
2 changes: 1 addition & 1 deletion datapath/vport.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,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_skb_init_inner_protocol(skb);
Expand Down

0 comments on commit 9e91741

Please sign in to comment.