The rtl8152 driver does not disable multicasting when userspace asks
it to. For example:
$ ifconfig eth0 -multicast -allmulti
$ tcpdump -p -i eth0 # will still capture multicast frames
Fix by clearing the device multicast filter table when multicast and
allmulti are both unset.
Tested as follows:
- Set multicast on eth0 network interface
- verify that multicast packets are coming in:
$ tcpdump -p -i eth0
- Clear multicast and allmulti on eth0 network interface
- verify that no more multicast packets are coming in:
$ tcpdump -p -i eth0
Signed-off-by: Sven van Ashbrook <[email protected]>
---
drivers/net/usb/r8152.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 688905ea0a6d..5e85b8bf9e87 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -2727,22 +2727,26 @@ static void _rtl8152_set_rx_mode(struct net_device *netdev)
ocp_data |= RCR_AM | RCR_AAP;
mc_filter[1] = 0xffffffff;
mc_filter[0] = 0xffffffff;
- } else if ((netdev_mc_count(netdev) > multicast_filter_limit) ||
- (netdev->flags & IFF_ALLMULTI)) {
+ } else if ((netdev->flags & IFF_MULTICAST &&
+ netdev_mc_count(netdev) > multicast_filter_limit) ||
+ (netdev->flags & IFF_ALLMULTI)) {
/* Too many to filter perfectly -- accept all multicasts. */
ocp_data |= RCR_AM;
mc_filter[1] = 0xffffffff;
mc_filter[0] = 0xffffffff;
} else {
- struct netdev_hw_addr *ha;
-
mc_filter[1] = 0;
mc_filter[0] = 0;
- netdev_for_each_mc_addr(ha, netdev) {
- int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;
- mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
- ocp_data |= RCR_AM;
+ if (netdev->flags & IFF_MULTICAST) {
+ struct netdev_hw_addr *ha;
+
+ netdev_for_each_mc_addr(ha, netdev) {
+ int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;
+
+ mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
+ ocp_data |= RCR_AM;
+ }
}
}
--
2.37.2.672.g94769d06f0-goog
Sven van Ashbrook <[email protected]>
> Sent: Tuesday, August 30, 2022 1:00 PM
[...]
> The rtl8152 driver does not disable multicasting when userspace asks
> it to. For example:
> $ ifconfig eth0 -multicast -allmulti
> $ tcpdump -p -i eth0 # will still capture multicast frames
>
> Fix by clearing the device multicast filter table when multicast and
> allmulti are both unset.
>
> Tested as follows:
> - Set multicast on eth0 network interface
> - verify that multicast packets are coming in:
> $ tcpdump -p -i eth0
> - Clear multicast and allmulti on eth0 network interface
> - verify that no more multicast packets are coming in:
> $ tcpdump -p -i eth0
>
> Signed-off-by: Sven van Ashbrook <[email protected]>
Acked-by: Hayes Wang <[email protected]>
Best Regards,
Hayes
Thank you Hayes and Jakub for taking this upstream.
Hello:
This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <[email protected]>:
On Tue, 30 Aug 2022 04:59:39 +0000 you wrote:
> The rtl8152 driver does not disable multicasting when userspace asks
> it to. For example:
> $ ifconfig eth0 -multicast -allmulti
> $ tcpdump -p -i eth0 # will still capture multicast frames
>
> Fix by clearing the device multicast filter table when multicast and
> allmulti are both unset.
>
> [...]
Here is the summary with links:
- [net-next,v1] r8152: allow userland to disable multicast
https://git.kernel.org/netdev/net-next/c/7305b78ae45f
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html