]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
batman-adv: reject new tp_meter sessions during teardown
authorJiexun Wang <wangjiexun2025@gmail.com>
Mon, 27 Apr 2026 06:43:33 +0000 (14:43 +0800)
committerSven Eckelmann <sven@narfation.org>
Sat, 2 May 2026 19:58:37 +0000 (21:58 +0200)
Prevent tp_meter from starting new sender or receiver sessions after
mesh_state has left BATADV_MESH_ACTIVE.

Fixes: 33a3bb4a3345 ("batman-adv: throughput meter implementation")
Cc: stable@kernel.org
Reported-by: Yuan Tan <yuantan098@gmail.com>
Reported-by: Yifan Wu <yifanwucs@gmail.com>
Reported-by: Juefei Pu <tomapufckgml@gmail.com>
Reported-by: Xin Liu <bird@lzu.edu.cn>
Co-developed-by: Luxing Yin <tr0jan@lzu.edu.cn>
Signed-off-by: Luxing Yin <tr0jan@lzu.edu.cn>
Signed-off-by: Jiexun Wang <wangjiexun2025@gmail.com>
Signed-off-by: Ren Wei <n05ec@lzu.edu.cn>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
net/batman-adv/tp_meter.c

index 2e42f6b348c83db127ab5101bcaf0ab997e78641..d9a80e459c2e4a70cc61864b13f332ed7246e013 100644 (file)
@@ -947,6 +947,13 @@ void batadv_tp_start(struct batadv_priv *bat_priv, const u8 *dst,
 
        /* look for an already existing test towards this node */
        spin_lock_bh(&bat_priv->tp_list_lock);
+       if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) {
+               spin_unlock_bh(&bat_priv->tp_list_lock);
+               batadv_tp_batctl_error_notify(BATADV_TP_REASON_DST_UNREACHABLE,
+                                             dst, bat_priv, session_cookie);
+               return;
+       }
+
        tp_vars = batadv_tp_list_find(bat_priv, dst);
        if (tp_vars) {
                spin_unlock_bh(&bat_priv->tp_list_lock);
@@ -1329,9 +1336,12 @@ static struct batadv_tp_vars *
 batadv_tp_init_recv(struct batadv_priv *bat_priv,
                    const struct batadv_icmp_tp_packet *icmp)
 {
-       struct batadv_tp_vars *tp_vars;
+       struct batadv_tp_vars *tp_vars = NULL;
 
        spin_lock_bh(&bat_priv->tp_list_lock);
+       if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE)
+               goto out_unlock;
+
        tp_vars = batadv_tp_list_find_session(bat_priv, icmp->orig,
                                              icmp->session);
        if (tp_vars)
@@ -1464,6 +1474,9 @@ void batadv_tp_meter_recv(struct batadv_priv *bat_priv, struct sk_buff *skb)
 {
        struct batadv_icmp_tp_packet *icmp;
 
+       if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE)
+               goto out;
+
        icmp = (struct batadv_icmp_tp_packet *)skb->data;
 
        switch (icmp->subtype) {
@@ -1478,6 +1491,8 @@ void batadv_tp_meter_recv(struct batadv_priv *bat_priv, struct sk_buff *skb)
                           "Received unknown TP Metric packet type %u\n",
                           icmp->subtype);
        }
+
+out:
        consume_skb(skb);
 }