Skip to content

Commit 4d64321

Browse files
committed
Merge tag 'batadv-net-pullrequest-20250509' of git://git.open-mesh.org/linux-merge
Simon Wunderlich says: ==================== Here is a batman-adv bugfix: - fix duplicate MAC address check, by Matthias Schiffer * tag 'batadv-net-pullrequest-20250509' of git://git.open-mesh.org/linux-merge: batman-adv: fix duplicate MAC address check ==================== Link: https://patch.msgid.link/20250509090240.107796-1-sw@simonwunderlich.de Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents e4f349b + 8772cc4 commit 4d64321

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

net/batman-adv/hard-interface.c

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -506,28 +506,32 @@ batadv_hardif_is_iface_up(const struct batadv_hard_iface *hard_iface)
506506
return false;
507507
}
508508

509-
static void batadv_check_known_mac_addr(const struct net_device *net_dev)
509+
static void batadv_check_known_mac_addr(const struct batadv_hard_iface *hard_iface)
510510
{
511-
const struct batadv_hard_iface *hard_iface;
511+
const struct net_device *mesh_iface = hard_iface->mesh_iface;
512+
const struct batadv_hard_iface *tmp_hard_iface;
512513

513-
rcu_read_lock();
514-
list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
515-
if (hard_iface->if_status != BATADV_IF_ACTIVE &&
516-
hard_iface->if_status != BATADV_IF_TO_BE_ACTIVATED)
514+
if (!mesh_iface)
515+
return;
516+
517+
list_for_each_entry(tmp_hard_iface, &batadv_hardif_list, list) {
518+
if (tmp_hard_iface == hard_iface)
519+
continue;
520+
521+
if (tmp_hard_iface->mesh_iface != mesh_iface)
517522
continue;
518523

519-
if (hard_iface->net_dev == net_dev)
524+
if (tmp_hard_iface->if_status == BATADV_IF_NOT_IN_USE)
520525
continue;
521526

522-
if (!batadv_compare_eth(hard_iface->net_dev->dev_addr,
523-
net_dev->dev_addr))
527+
if (!batadv_compare_eth(tmp_hard_iface->net_dev->dev_addr,
528+
hard_iface->net_dev->dev_addr))
524529
continue;
525530

526531
pr_warn("The newly added mac address (%pM) already exists on: %s\n",
527-
net_dev->dev_addr, hard_iface->net_dev->name);
532+
hard_iface->net_dev->dev_addr, tmp_hard_iface->net_dev->name);
528533
pr_warn("It is strongly recommended to keep mac addresses unique to avoid problems!\n");
529534
}
530-
rcu_read_unlock();
531535
}
532536

533537
/**
@@ -763,6 +767,8 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
763767
hard_iface->net_dev->name, hardif_mtu,
764768
required_mtu);
765769

770+
batadv_check_known_mac_addr(hard_iface);
771+
766772
if (batadv_hardif_is_iface_up(hard_iface))
767773
batadv_hardif_activate_interface(hard_iface);
768774
else
@@ -901,7 +907,6 @@ batadv_hardif_add_interface(struct net_device *net_dev)
901907

902908
batadv_v_hardif_init(hard_iface);
903909

904-
batadv_check_known_mac_addr(hard_iface->net_dev);
905910
kref_get(&hard_iface->refcount);
906911
list_add_tail_rcu(&hard_iface->list, &batadv_hardif_list);
907912
batadv_hardif_generation++;
@@ -988,7 +993,7 @@ static int batadv_hard_if_event(struct notifier_block *this,
988993
if (hard_iface->if_status == BATADV_IF_NOT_IN_USE)
989994
goto hardif_put;
990995

991-
batadv_check_known_mac_addr(hard_iface->net_dev);
996+
batadv_check_known_mac_addr(hard_iface);
992997

993998
bat_priv = netdev_priv(hard_iface->mesh_iface);
994999
bat_priv->algo_ops->iface.update_mac(hard_iface);

0 commit comments

Comments
 (0)