net/mac80211/mesh.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
Allow kmem_cache_create() to fail gracefully when the mesh RMC slab
cannot be created so multicast forwarding continues even without
duplicate filtering.
Signed-off-by: Sayooj K Karun <sayooj@aerlync.com>
---
net/mac80211/mesh.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index f37068a533f4..20f25226d2f2 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -2,10 +2,13 @@
/*
* Copyright (c) 2008, 2009 open80211s Ltd.
* Copyright (C) 2018 - 2024 Intel Corporation
+ * Copyright (C) 2025 Aerlync Labs Inc.
* Authors: Luis Carlos Cobo <luisca@cozybit.com>
* Javier Cardona <javier@cozybit.com>
+ * Sayooj K Karun <sayooj@aerlync.com>
*/
+#include <linux/printk.h>
#include <linux/slab.h>
#include <linux/unaligned.h>
#include <net/sock.h>
@@ -25,9 +28,14 @@ bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt)
void ieee80211s_init(void)
{
- mesh_allocated = 1;
rm_cache = kmem_cache_create("mesh_rmc", sizeof(struct rmc_entry),
0, 0, NULL);
+ if (!rm_cache) {
+ pr_warn("mac80211: failed to allocate mesh RMC cache; duplicate filtering disabled\n");
+ return;
+ }
+
+ mesh_allocated = 1;
}
void ieee80211s_stop(void)
@@ -35,6 +43,8 @@ void ieee80211s_stop(void)
if (!mesh_allocated)
return;
kmem_cache_destroy(rm_cache);
+ rm_cache = NULL;
+ mesh_allocated = 0;
}
static void ieee80211_mesh_housekeeping_timer(struct timer_list *t)
@@ -231,8 +241,8 @@ int mesh_rmc_check(struct ieee80211_sub_if_data *sdata,
struct rmc_entry *p;
struct hlist_node *n;
- if (!rmc)
- return -1;
+ if (!rmc || !rm_cache)
+ return 0;
/* Don't care about endianness since only match matters */
memcpy(&seqnum, &mesh_hdr->seqnum, sizeof(mesh_hdr->seqnum));
--
2.43.0
You need to fix the subject.
> void ieee80211s_init(void)
> {
> - mesh_allocated = 1;
> rm_cache = kmem_cache_create("mesh_rmc", sizeof(struct rmc_entry),
> 0, 0, NULL);
> + if (!rm_cache) {
> + pr_warn("mac80211: failed to allocate mesh RMC cache; duplicate filtering disabled\n");
A message after an allocation failure is almost always pointless since
it's already a really big scary warning... Maybe there's a way to
supress the original warning in this case (not sure) and then have this
message.
johannes
Allow kmem_cache_create() in ieee80211s_init() to fail gracefully
when the mesh RMC slab cannot be created so multicast forwarding
continues even without duplicate filtering.
Signed-off-by: Sayooj K Karun <sayooj@aerlync.com>
---
Changes in v2:
- Retitled the patch to “mac80211: mesh: handle RMC cache allocation failure”
- Added more clarity to the commit message
- dropped the extra pr_warn() after kmem_cache_create() failure
net/mac80211/mesh.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index f37068a533f4..eae78d9528ac 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -2,8 +2,10 @@
/*
* Copyright (c) 2008, 2009 open80211s Ltd.
* Copyright (C) 2018 - 2024 Intel Corporation
+ * Copyright (C) 2025 Aerlync Labs Inc.
* Authors: Luis Carlos Cobo <luisca@cozybit.com>
* Javier Cardona <javier@cozybit.com>
+ * Sayooj K Karun <sayooj@aerlync.com>
*/
#include <linux/slab.h>
@@ -25,9 +27,12 @@ bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt)
void ieee80211s_init(void)
{
- mesh_allocated = 1;
rm_cache = kmem_cache_create("mesh_rmc", sizeof(struct rmc_entry),
0, 0, NULL);
+ if (!rm_cache)
+ return;
+
+ mesh_allocated = 1;
}
void ieee80211s_stop(void)
@@ -35,6 +40,8 @@ void ieee80211s_stop(void)
if (!mesh_allocated)
return;
kmem_cache_destroy(rm_cache);
+ rm_cache = NULL;
+ mesh_allocated = 0;
}
static void ieee80211_mesh_housekeeping_timer(struct timer_list *t)
@@ -231,8 +238,8 @@ int mesh_rmc_check(struct ieee80211_sub_if_data *sdata,
struct rmc_entry *p;
struct hlist_node *n;
- if (!rmc)
- return -1;
+ if (!rmc || !rm_cache)
+ return 0;
/* Don't care about endianness since only match matters */
memcpy(&seqnum, &mesh_hdr->seqnum, sizeof(mesh_hdr->seqnum));
--
2.43.0
© 2016 - 2025 Red Hat, Inc.