Thread View: linux.kernel.netdev
5 messages
5 total messages
Started by Xia Yan
Thu, 12 Nov 2026 02:56
[PATCH net-next v2 0/2] ipvlan/macvlan: fix local RX byte accounting
Author: Xia Yan
Date: Thu, 12 Nov 2026 02:56
Date: Thu, 12 Nov 2026 02:56
34 lines
9793 bytes
9793 bytes
Both ipvlan and macvlan count the Ethernet header twice for some traffic between virtual devices sharing one lower device. Patch 1 fixes ipvlan local unicast, broadcast and multicast RX accounting. Patch 2 fixes macvlan bridge-mode local broadcast and multicast RX accounting. The lower-device receive paths retain their existing Ethernet-header adjustment. Tested in UML on net-next 368fbf5d82da with IPv4 and IPv6 UDP traffic: 26 ipvlan cases and 20 macvlan cases. The corrected byte counts match the received Ethernet frame lengths. The external RX cases and macvlan local unicast cases retain their counts. The ipvlan fix was first submitted to net. This v2 targets net-next and adds the macvlan fix as Eric suggested. Cc: stable is dropped. Changes since v1: - Target net-next and drop Cc: stable. - Add the macvlan local broadcast and multicast accounting fix. v1: https://lore.kernel.org/netdev/20261025014251.542973-1-yanxia@cmss.chinamobile.com/ Review: https://lore.kernel.org/netdev/CAL4WiioxAR1ZBjVJNgYfLM0hUwyHapRu+TAUzedpOpe0yheH3w@mail.gmail.com/ Xia Yan (2): ipvlan: fix RX byte accounting for local traffic macvlan: fix RX byte accounting for local broadcast and multicast drivers/net/ipvlan/ipvlan_core.c | 4 ++-- drivers/net/macvlan.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) base-commit: 368fbf5d82da9ebce309449c74fc0b128f7d0219
[PATCH net-next v2 2/2] macvlan: fix RX byte accounting for local broadcast and multicast
Author: Xia Yan
Date: Thu, 12 Nov 2026 02:56
Date: Thu, 12 Nov 2026 02:56
43 lines
10294 bytes
10294 bytes
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 <yanxia@cmss.chinamobile.com>
---
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);
}
}
Re: [PATCH net-next v2 2/2] macvlan: fix RX byte accounting for local broadcast and multicast
Author: Simon Horman
Date: Wed, 18 Nov 2026 17:43
Date: Wed, 18 Nov 2026 17:43
30 lines
9052 bytes
9052 bytes
On Thu, Nov 12, 2026 at 10:56:19AM +0800, Xia Yan wrote:
> 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 <yanxia@cmss.chinamobile.com>
I agree that net-next is an appropriate target for this change.
Reviewed-by: Simon Horman <horms@kernel.org>
Re: [PATCH net-next v2 2/2] macvlan: fix RX byte accounting for local broadcast and multicast
Author: "Arnd Bergmann"
Date: Wed, 18 Nov 2026 17:48
Date: Wed, 18 Nov 2026 17:48
28 lines
14047 bytes
14047 bytes
On Thu, Nov 12, 2026, at 03:56, Xia Yan wrote:
> 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 <yanxia@cmss.chinamobile.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Re: [PATCH net-next v2 0/2] ipvlan/macvlan: fix local RX byte accounting
Author: patchwork-bot+netdevbpf
Date: Thu, 19 Nov 2026 00:10
Date: Thu, 19 Nov 2026 00:10
27 lines
8899 bytes
8899 bytes
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 12 Nov 2026 10:56:17 +0800 you wrote:
> Both ipvlan and macvlan count the Ethernet header twice for some
> traffic between virtual devices sharing one lower device.
>
> Patch 1 fixes ipvlan local unicast, broadcast and multicast RX
> accounting. Patch 2 fixes macvlan bridge-mode local broadcast and
> multicast RX accounting. The lower-device receive paths retain
> their existing Ethernet-header adjustment.
>
> [...]
Here is the summary with links:
- [net-next,v2,1/2] ipvlan: fix RX byte accounting for local traffic
https://git.kernel.org/netdev/net-next/c/d7c994e96af3
- [net-next,v2,2/2] macvlan: fix RX byte accounting for local broadcast and multicast
https://git.kernel.org/netdev/net-next/c/65addda143d4
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads