macvlan: Don't propagate promisc change to lower dev in passthru
Subsystems (2)
PATCH 1/1 macvlan: Don't propagate promisc change to lower dev in passthru
Macvlan device in passthru mode sets its lower device promiscuous mode according to its MACVLAN_FLAG_NOPROMISC flag instead of synchronizing it to its own promiscuity setting. However, macvlan_change_rx_flags() function doesn't check the mode before propagating such changes to the lower device which can cause net_device->promiscuity counter overflow as illustrated by reproduction example [0] and resulting dmesg log [1]. Fix the issue by first verifying the mode in macvlan_change_rx_flags() function before propagating promiscuous mode change to the lower device.
[0]:
ip link add macvlan1 link enp8s0f0 type macvlan mode passthru ip link set macvlan1 promisc on
ip l set dev macvlan1 up
ip link set macvlan1 promisc off
ip l set dev macvlan1 down
ip l set dev macvlan1 up
[1]:
[ 5156.281724] macvlan1: entered promiscuous mode [ 5156.285467] mlx5_core 0000:08:00.0 enp8s0f0: entered promiscuous mode [ 5156.287639] macvlan1: left promiscuous mode [ 5156.288339] mlx5_core 0000:08:00.0 enp8s0f0: left promiscuous mode [ 5156.290907] mlx5_core 0000:08:00.0 enp8s0f0: entered promiscuous mode [ 5156.317197] mlx5_core 0000:08:00.0 enp8s0f0: promiscuity touches roof, set promiscuity failed. promiscuity feature of device might be broken.
--- drivers/net/macvlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/macvlan.c +1 -1
@@ -780,7 +780,7 @@ static void macvlan_change_rx_flags(struct net_device *dev, int change)if (dev->flags &IFF_UP ) {if (change &IFF_ALLMULTI )dev_set_allmulti (lowerdev, dev->flags &IFF_ALLMULTI ?1 :-1 ); -if (change &IFF_PROMISC ) +if (!macvlan_passthru (vlan->port) && change &IFF_PROMISC )dev_set_promiscuity (lowerdev, dev->flags &IFF_PROMISC ?1 :-1 );
Signature · 1 line
2.39.2
Quoted 25 lines · Tue, Nov 14, 2023 at 06:59:15PM CET, [email protected] wrote:
Macvlan device in passthru mode sets its lower device promiscuous mode according to its
MACVLAN_FLAG_NOPROMISCflag instead of synchronizing it to its own promiscuity setting. However,macvlan_change_rx_flags()function doesn't check the mode before propagating such changes to the lower device which can causenet_device->promiscuitycounter overflow as illustrated by reproduction example [0] and resulting dmesg log [1]. Fix the issue by first verifying the mode inmacvlan_change_rx_flags()function before propagating promiscuous mode change to the lower device.[0]:
ip link add macvlan1 link enp8s0f0 type macvlan mode passthru ip link set macvlan1 promisc on
ip l set dev macvlan1 up
ip link set macvlan1 promisc off
ip l set dev macvlan1 down
ip l set dev macvlan1 up[1]:
[ 5156.281724] macvlan1: entered promiscuous mode [ 5156.285467] mlx5_core 0000:08:00.0 enp8s0f0: entered promiscuous mode [ 5156.287639] macvlan1: left promiscuous mode [ 5156.288339] mlx5_core 0000:08:00.0 enp8s0f0: left promiscuous mode [ 5156.290907] mlx5_core 0000:08:00.0 enp8s0f0: entered promiscuous mode [ 5156.317197] mlx5_core 0000:08:00.0 enp8s0f0: promiscuity touches roof, set promiscuity failed. promiscuity feature of device might be broken.
Quoted 3 lines
Fixes efdbd2b30caa ("macvlan: Propagate promiscuity setting to lower devices.")Reviewed-by Gal Pressman <[email protected]>Signed-off-by Vlad Buslov <[email protected]>
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 10 lines · On Tue, 14 Nov 2023 18:59:15 +0100 you wrote:
Macvlan device in passthru mode sets its lower device promiscuous mode according to its
MACVLAN_FLAG_NOPROMISCflag instead of synchronizing it to its own promiscuity setting. However,macvlan_change_rx_flags()function doesn't check the mode before propagating such changes to the lower device which can causenet_device->promiscuitycounter overflow as illustrated by reproduction example [0] and resulting dmesg log [1]. Fix the issue by first verifying the mode inmacvlan_change_rx_flags()function before propagating promiscuous mode change to the lower device.[...]
Here is the summary with links:
- [net] macvlan: Don't propagate promisc change to lower dev in passthru
https://git.kernel.org/netdev/net/c/7e1caeace041
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html