Re: [PATCH RFC batadv v3 2/4] batman-adv: remove global hardif list
Sven Eckelmann <[email protected]> Thu, 04 Jun 2026 08:57:10 +0200
| Newsgroups | org.open-mesh.lists.batman |
|---|---|
| Message-ID | <2972055.88bMQJbFj6@ripper> |
On Thursday, 4 June 2026 06:39:30 CEST Sven Eckelmann wrote:
> err_upper:
> netdev_upper_dev_unlink(hard_iface->net_dev, mesh_iface);
> err_dev:
> - hard_iface->mesh_iface = NULL;
> netdev_put(mesh_iface, &hard_iface->meshif_dev_tracker);
> batadv_hardif_put(hard_iface);
> return ret;
Looks like I should also have removed the
netdev_put(mesh_iface, &hard_iface->meshif_dev_tracker);
because it is done by batadv_hardif_release() - behind batadv_hardif_put().
The `mesh_iface = NULL` was removed btw. because it would break the invariant
that "a hard_iface always belongs to a mesh_iface". Some of the code is
already (incorrectly) assuming this and doesn't check if "mesh_iface" is NULL
(or changed the mesh_iface to which the hardif is associated to).
Just as note for myself: these code checks might be removed after this
patchset was applied:
diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c
index d5ae58cb43ba7b40380feb76e55e896324fe4856..d1310e7b6e7a080485126452f58732dde3ddb173 100644
--- a/net/batman-adv/bat_v_elp.c
+++ b/net/batman-adv/bat_v_elp.c
@@ -90,12 +90,6 @@ static bool batadv_v_elp_get_throughput(struct batadv_hardif_neigh_node *neigh,
u32 throughput;
int ret;
- /* don't query throughput when no longer associated with any
- * batman-adv interface
- */
- if (!mesh_iface)
- return false;
-
/* if the user specified a customised value for this interface, then
* return it directly
*/
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index 0461f11227d06b50802b8d30a4809d615a4b9ca4..d27ad3c168f6c7007ad004f02b3c3d440ef1add8 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -344,7 +344,6 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, const u8 *mac,
struct sk_buff *skb;
struct ethhdr *ethhdr;
struct batadv_hard_iface *primary_if;
- struct net_device *mesh_iface;
u8 *hw_src;
struct batadv_bla_claim_dst local_claim_dest;
__be32 zeroip = 0;
@@ -357,14 +356,10 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, const u8 *mac,
sizeof(local_claim_dest));
local_claim_dest.type = claimtype;
- mesh_iface = READ_ONCE(primary_if->mesh_iface);
- if (!mesh_iface)
- goto out;
-
skb = arp_create(ARPOP_REPLY, ETH_P_ARP,
/* IP DST: 0.0.0.0 */
zeroip,
- mesh_iface,
+ primary_if->mesh_iface,
/* IP SRC: 0.0.0.0 */
zeroip,
/* Ethernet DST: Broadcast */
@@ -442,7 +437,7 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, const u8 *mac,
}
skb_reset_mac_header(skb);
- skb->protocol = eth_type_trans(skb, mesh_iface);
+ skb->protocol = eth_type_trans(skb, primary_if->mesh_iface);
batadv_inc_counter(bat_priv, BATADV_CNT_RX);
batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES,
skb->len + ETH_HLEN);
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index bb13426f90394e674c2ad789367c3dd13e328e0d..5df14a796f623819e668c43304d455b1249a0a05 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -246,7 +246,7 @@ struct net_device *__batadv_get_real_netdev(struct net_device *netdev)
}
hard_iface = batadv_hardif_get_by_netdev(netdev);
- if (!hard_iface || !hard_iface->mesh_iface)
+ if (!hard_iface)
goto out;
net = dev_net(hard_iface->mesh_iface);
@@ -540,9 +540,6 @@ static void batadv_check_known_mac_addr(const struct batadv_hard_iface *hard_ifa
const struct batadv_hard_iface *tmp_hard_iface;
struct list_head *iter;
- if (!mesh_iface)
- return;
-
netdev_for_each_lower_private(mesh_iface, tmp_hard_iface, iter) {
if (tmp_hard_iface == hard_iface)
continue;
@@ -1082,8 +1079,7 @@ static int batadv_hard_if_event(struct notifier_block *this,
batadv_hardif_disable_interface(hard_iface);
break;
case NETDEV_CHANGEMTU:
- if (hard_iface->mesh_iface)
- batadv_update_min_mtu(hard_iface->mesh_iface);
+ batadv_update_min_mtu(hard_iface->mesh_iface);
break;
case NETDEV_CHANGEADDR:
batadv_check_known_mac_addr(hard_iface);
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index badc1df0af1d58e1dfd429453b4d83abcb7da829..04bb030ef299ac24710ea776a7f3c1aaf089598c 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -444,9 +444,6 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
if (unlikely(skb->mac_len != ETH_HLEN || !skb_mac_header(skb)))
goto err_free;
- if (!hard_iface->mesh_iface)
- goto err_free;
-
bat_priv = netdev_priv(hard_iface->mesh_iface);
if (READ_ONCE(bat_priv->mesh_state) != BATADV_MESH_ACTIVE)
(WARNING, this is a rather unclean PoC change)
Plus a revert of commit 3d550f6440fc ("batman-adv: v: stop OGMv2 on disabled
interface"). Most likely also also the code in batadv_iv_ogm_emit. There might
be more I haven't yet checked.
Regards,
Sven
signature.asc
(application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQS81G/PswftH/OW8cVND3cr0xT1ywUCaiEhxgAKCRBND3cr0xT1 y7AkAQDfaQ8Twmp5gcInXMJJJKx4gR+FjMSyGi/LnDgwAOP8kwEAsxIruWv/24X1 l2Li4mZxeCsGMwA4BB31JhU1D0UOAg4= =HeMK -----END PGP SIGNATURE-----