Skip to content

Commit 24cc59d

Browse files
blpdavem330
authored andcommitted
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.html Reported-by: Motonori Shindo <mshindo@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com> Reviewed-by: Flavio Leitner <fbl@sysclose.org> Acked-by: Pravin B Shelar <pshelar@nicira.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 843925f commit 24cc59d

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

‎net/openvswitch/flow.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ void ovs_flow_stats_update(struct sw_flow *flow, __be16 tcp_flags,
7070
{
7171
struct flow_stats *stats;
7272
int node = numa_node_id();
73+
int len = skb->len + (vlan_tx_tag_present(skb) ? VLAN_HLEN : 0);
7374

7475
stats = rcu_dereference(flow->stats[node]);
7576

@@ -105,7 +106,7 @@ void ovs_flow_stats_update(struct sw_flow *flow, __be16 tcp_flags,
105106
if (likely(new_stats)) {
106107
new_stats->used = jiffies;
107108
new_stats->packet_count = 1;
108-
new_stats->byte_count = skb->len;
109+
new_stats->byte_count = len;
109110
new_stats->tcp_flags = tcp_flags;
110111
spin_lock_init(&new_stats->lock);
111112

@@ -120,7 +121,7 @@ void ovs_flow_stats_update(struct sw_flow *flow, __be16 tcp_flags,
120121

121122
stats->used = jiffies;
122123
stats->packet_count++;
123-
stats->byte_count += skb->len;
124+
stats->byte_count += len;
124125
stats->tcp_flags |= tcp_flags;
125126
unlock:
126127
spin_unlock(&stats->lock);

‎net/openvswitch/vport.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ void ovs_vport_receive(struct vport *vport, struct sk_buff *skb,
480480
stats = this_cpu_ptr(vport->percpu_stats);
481481
u64_stats_update_begin(&stats->syncp);
482482
stats->rx_packets++;
483-
stats->rx_bytes += skb->len;
483+
stats->rx_bytes += skb->len + (vlan_tx_tag_present(skb) ? VLAN_HLEN : 0);
484484
u64_stats_update_end(&stats->syncp);
485485

486486
OVS_CB(skb)->input_vport = vport;

0 commit comments

Comments
 (0)