Patchwork bridge: Have tx_bytes count headers like rx_bytes.

login
register
mail settings
Submitter Ashish Sharma
Date Oct. 7, 2011, 8:47 p.m.
Message ID <1318020461-14494-1-git-send-email-ashishsharma@google.com>
Download mbox | patch
Permalink /patch/118370/
State Changes Requested
Delegated to: David Miller
Headers show

Comments

Ashish Sharma - Oct. 7, 2011, 8:47 p.m.
Since rx_bytes accounting does not include Ethernet Headers in
br_input.c, excluding ETH_HLEN on the transmit path for consistent
measurement of packet length on both the Tx and Rx chains.

Signed-off-by: Ashish Sharma <ashishsharma@google.com>
Signed-off-by: JP Abgrall <jpa@google.com>
---
:100644 100644 32b8f9f... a9dd166... M	net/bridge/br_device.c
 net/bridge/br_device.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
Ben Hutchings - Oct. 8, 2011, 12:14 a.m.
On Fri, 2011-10-07 at 13:47 -0700, Ashish Sharma wrote:
> Since rx_bytes accounting does not include Ethernet Headers in
> br_input.c, excluding ETH_HLEN on the transmit path for consistent
> measurement of packet length on both the Tx and Rx chains.
[...]

I think the TX path is correct in this regard, and the RX path should be
changed to include header length.

Ben.

Patch

diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index 32b8f9f..a9dd166 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -38,16 +38,17 @@  netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
 	}
 #endif
 
-	u64_stats_update_begin(&brstats->syncp);
-	brstats->tx_packets++;
-	brstats->tx_bytes += skb->len;
-	u64_stats_update_end(&brstats->syncp);
-
 	BR_INPUT_SKB_CB(skb)->brdev = dev;
 
 	skb_reset_mac_header(skb);
 	skb_pull(skb, ETH_HLEN);
 
+	u64_stats_update_begin(&brstats->syncp);
+	brstats->tx_packets++;
+	/* Exclude ETH_HLEN from byte stats for consistency with Rx chain */
+	brstats->tx_bytes += skb->len;
+	u64_stats_update_end(&brstats->syncp);
+
 	rcu_read_lock();
 	if (is_broadcast_ether_addr(dest))
 		br_flood_deliver(br, skb);