Skip to content

Commit e4a3c4a

Browse files
JiexunWanggregkh
authored andcommitted
batman-adv: reject new tp_meter sessions during teardown
commit 3243543 upstream. Prevent tp_meter from starting new sender or receiver sessions after mesh_state has left BATADV_MESH_ACTIVE. Fixes: 33a3bb4 ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f614993 commit e4a3c4a

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

net/batman-adv/tp_meter.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,13 @@ void batadv_tp_start(struct batadv_priv *bat_priv, const u8 *dst,
947947

948948
/* look for an already existing test towards this node */
949949
spin_lock_bh(&bat_priv->tp_list_lock);
950+
if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) {
951+
spin_unlock_bh(&bat_priv->tp_list_lock);
952+
batadv_tp_batctl_error_notify(BATADV_TP_REASON_DST_UNREACHABLE,
953+
dst, bat_priv, session_cookie);
954+
return;
955+
}
956+
950957
tp_vars = batadv_tp_list_find(bat_priv, dst);
951958
if (tp_vars) {
952959
spin_unlock_bh(&bat_priv->tp_list_lock);
@@ -1329,9 +1336,12 @@ static struct batadv_tp_vars *
13291336
batadv_tp_init_recv(struct batadv_priv *bat_priv,
13301337
const struct batadv_icmp_tp_packet *icmp)
13311338
{
1332-
struct batadv_tp_vars *tp_vars;
1339+
struct batadv_tp_vars *tp_vars = NULL;
13331340

13341341
spin_lock_bh(&bat_priv->tp_list_lock);
1342+
if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE)
1343+
goto out_unlock;
1344+
13351345
tp_vars = batadv_tp_list_find_session(bat_priv, icmp->orig,
13361346
icmp->session);
13371347
if (tp_vars)
@@ -1464,6 +1474,9 @@ void batadv_tp_meter_recv(struct batadv_priv *bat_priv, struct sk_buff *skb)
14641474
{
14651475
struct batadv_icmp_tp_packet *icmp;
14661476

1477+
if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE)
1478+
goto out;
1479+
14671480
icmp = (struct batadv_icmp_tp_packet *)skb->data;
14681481

14691482
switch (icmp->subtype) {
@@ -1478,6 +1491,8 @@ void batadv_tp_meter_recv(struct batadv_priv *bat_priv, struct sk_buff *skb)
14781491
"Received unknown TP Metric packet type %u\n",
14791492
icmp->subtype);
14801493
}
1494+
1495+
out:
14811496
consume_skb(skb);
14821497
}
14831498

0 commit comments

Comments
 (0)