In bridge mode, broadcast and multicast packets sent by one macvlan are delivered to the other bridge ports by macvlan_broadcast(), called from macvlan_queue_xmit(). The skb still contains its Ethernet header there, so adding ETH_HLEN again in the rx_bytes accounting overcounts by 14 bytes per packet on every receiving macvlan. Packets flooded from the receive handler have had the Ethernet header pulled by eth_type_trans(), so they still need ETH_HLEN. Use the existing mode argument to skip the extra ETH_HLEN for the local bridge-mode path. Noticed in macvlan during review of the ipvlan fix, and confirmed on a 6.6 distribution kernel: five IPv4 UDP packets with 32-byte payloads increased rx_bytes by 440 instead of 370. Tested before and after the change with custom IPv4 and IPv6 UDP tests in UML. The corrected counters match the received Ethernet frame lengths. Local unicast and external RX counts are unchanged in these tests. Fixes: 618e1b7482f7 ("macvlan: implement bridge, VEPA and private mode") Signed-off-by: Xia Yan --- drivers/net/macvlan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 4f8416bb5..96ec9bafa 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -290,7 +290,8 @@ static void macvlan_broadcast(struct sk_buff *skb, err = macvlan_broadcast_one(nskb, vlan, eth, mode == MACVLAN_MODE_BRIDGE) ?: netif_rx(nskb); - macvlan_count_rx(vlan, skb->len + ETH_HLEN, + macvlan_count_rx(vlan, skb->len + + (mode == MACVLAN_MODE_BRIDGE ? 0 : ETH_HLEN), err == NET_RX_SUCCESS, true); } }