[1/2] nl80211: allocate more memory for channel_switch cmd

Message ID 1391183140-3437-2-git-send-email-bartosz.markowski@tieto.com
State Superseded
Headers show

Commit Message

Bartosz.Markowski@tieto.com Jan. 31, 2014, 3:45 p.m.
From: Michal Kazior <michal.kazior@tieto.com>

Once a certain threshold was reached (depending on
number of IEs and BSSes) channel switch was
failing with -ENOBUFS meaning nlmsg was too small
to fit the whole command.

Pre-allocate a big buffer for channel switch to
avoid this. 64KiB seems reasonable from a
practical point of view as it should handle at
least 8 BSSes.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
 src/drivers/driver_nl80211.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)


diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 81f20b3..77149ba 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -11596,7 +11596,11 @@  static int nl80211_switch_channel(void *priv, struct csa_settings *settings)
 		return -EINVAL;
-	msg = nlmsg_alloc();
+	/* each interface channel switch request can be sizable as it contains
+	 * a beacon and possibly a probe response. this size varies depending
+	 * on the number of IEs. pre-allocate memory for the nlmsg. this could
+	 * be probably caculated/estimated but 64KiB seems like a sane value */
+	msg = nlmsg_alloc_size(64 * 1024);
 	if (!msg)
 		return -ENOMEM;