B.A.T.M.A.N Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Nora Schiffer <neocturne@universe-factory.net>
Subject: Re: [PATCH RFC batadv v3 2/4] batman-adv: remove global hardif list
Date: Thu, 04 Jun 2026 08:57:10 +0200	[thread overview]
Message-ID: <2972055.88bMQJbFj6@ripper> (raw)
In-Reply-To: <20260604-drop-hardif-list-v3-2-e0dfa8c7d602@narfation.org>

[-- Attachment #1: Type: text/plain, Size: 4956 bytes --]

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

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2026-06-04  6:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-04  4:39 [PATCH RFC batadv v3 0/4] batman-adv: drop global hard interface list Sven Eckelmann
2026-06-04  4:39 ` [PATCH RFC batadv v3 1/4] batman-adv: only create hardif while a netdev is part of a mesh Sven Eckelmann
2026-06-04  4:39 ` [PATCH RFC batadv v3 2/4] batman-adv: remove global hardif list Sven Eckelmann
2026-06-04  6:57   ` Sven Eckelmann [this message]
2026-06-04  4:39 ` [PATCH RFC batadv v3 3/4] batman-adv: remove BATADV_IF_NOT_IN_USE hardif state Sven Eckelmann
2026-06-04  4:39 ` [PATCH RFC batadv v3 4/4] batman-adv: move hardif generation counter into batadv_priv Sven Eckelmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2972055.88bMQJbFj6@ripper \
    --to=sven@narfation.org \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=neocturne@universe-factory.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox