bridge: Have tx_bytes count headers like rx_bytes.
authorAshish Sharma <ashishsharma@google.com>
Sat, 8 Oct 2011 00:54:16 +0000 (17:54 -0700)
committerJohn Stultz <john.stultz@linaro.org>
Tue, 16 Feb 2016 21:51:46 +0000 (13:51 -0800)
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.

The clean way would be for Rx to include the eth header, but the
skb len has already been adjusted by the time the br code sees the skb.
This is only a temporary workaround until we can completely ignore or
cleanly fix the skb->len handling.

Change-Id: I910de95a4686b2119da7f1f326e2154ef31f9972
Signed-off-by: Ashish Sharma <ashishsharma@google.com>
net/bridge/br_device.c

index 5e88d3e17546618a728bb429fc61e20d5f8d79dc..689b8412c58e9dd489a3657888e0c6726a35c4d7 100644 (file)
@@ -46,16 +46,17 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
                return NETDEV_TX_OK;
        }
 
-       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);
+
        if (!br_allowed_ingress(br, br_vlan_group_rcu(br), skb, &vid))
                goto out;