Commit ae63ad9b authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller

macvlan: Fix mc_filter calculation

On Wed, Mar 29, 2023 at 08:10:26AM +0000, patchwork-bot+netdevbpf@kernel.org wrote:
>
> Here is the summary with links:
>   - [1/2] macvlan: Skip broadcast queue if multicast with single receiver
>     https://git.kernel.org/netdev/net-next/c/d45276e75e90
>   - [2/2] macvlan: Add netlink attribute for broadcast cutoff
>     https://git.kernel.org/netdev/net-next/c/954d1fa1ac93

Sorry, I made an error and posted my patches from an earlier
revision so a follow-up fix was missing:

---8<---
The bc_cutoff patch broke the calculation of mc_filter causing
some multicast packets to not make it through to the targeted
device.

Fix this by checking whether vlan is set instead of cutoff >= 0.

Also move the cutoff < 0 logic into macvlan_recompute_bc_filter
so that it doesn't change the mc_filter at all.

Fixes: d45276e7 ("macvlan: Skip broadcast queue if multicast with single receiver")
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ce7928f7
......@@ -792,23 +792,19 @@ static void macvlan_compute_filter(unsigned long *mc_filter,
struct macvlan_dev *vlan, int cutoff)
{
if (dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) {
if (cutoff >= 0)
bitmap_fill(mc_filter, MACVLAN_MC_FILTER_SZ);
else
bitmap_zero(mc_filter, MACVLAN_MC_FILTER_SZ);
} else {
DECLARE_BITMAP(filter, MACVLAN_MC_FILTER_SZ);
struct netdev_hw_addr *ha;
bitmap_zero(filter, MACVLAN_MC_FILTER_SZ);
netdev_for_each_mc_addr(ha, dev) {
if (cutoff >= 0 && ha->synced <= cutoff)
if (!vlan && ha->synced <= cutoff)
continue;
__set_bit(mc_hash(vlan, ha->addr), filter);
}
if (cutoff >= 0)
__set_bit(mc_hash(vlan, dev->broadcast), filter);
bitmap_copy(mc_filter, filter, MACVLAN_MC_FILTER_SZ);
......@@ -817,6 +813,11 @@ static void macvlan_compute_filter(unsigned long *mc_filter,
static void macvlan_recompute_bc_filter(struct macvlan_dev *vlan)
{
if (vlan->port->bc_cutoff < 0) {
bitmap_zero(vlan->port->bc_filter, MACVLAN_MC_FILTER_SZ);
return;
}
macvlan_compute_filter(vlan->port->bc_filter, vlan->lowerdev, NULL,
vlan->port->bc_cutoff);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment