From: Jiri Slaby <jirislaby@gmail.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: Jouni Malinen <j@w1.fi>,
linux-wireless <linux-wireless@vger.kernel.org>,
Thomas Graf <tgraf@suug.ch>
Subject: Re: NL80211_CMD_GET_WIPHY reply doesn't fit into nl message buffer
Date: Mon, 29 Sep 2008 14:01:08 +0200 [thread overview]
Message-ID: <48E0C384.3000903@gmail.com> (raw)
In-Reply-To: <1222689340.7064.26.camel@johannes.berg>
On 09/29/2008 01:55 PM, Johannes Berg wrote:
> On Mon, 2008-09-29 at 13:52 +0200, Jiri Slaby wrote:
>
>> --- a/net/wireless/nl80211.c
>> +++ b/net/wireless/nl80211.c
>> @@ -246,16 +246,26 @@ static int nl80211_get_wiphy(struct sk_buff *skb, struct
>> genl_info *info)
>> {
>> struct sk_buff *msg;
>> struct cfg80211_registered_device *dev;
>> + size_t bufsize = NLMSG_GOODSIZE;
>> + unsigned int tries = 0;
>> + int ret;
>>
>> dev = cfg80211_get_dev_from_info(info);
>> if (IS_ERR(dev))
>> return PTR_ERR(dev);
>>
>> - msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
>> +retry:
>> + msg = nlmsg_new(bufsize, GFP_KERNEL);
>> if (!msg)
>> goto out_err;
>>
>> - if (nl80211_send_wiphy(msg, info->snd_pid, info->snd_seq, 0, dev) < 0)
>> + ret = nl80211_send_wiphy(msg, info->snd_pid, info->snd_seq, 0, dev);
>> + if (ret == -EMSGSIZE && ++tries < 2) {
>> + bufsize *= 2;
>> + nlmsg_free(msg);
>> + goto retry;
>> + }
>> + if (ret < 0)
>> goto out_free;
>>
>> cfg80211_put_dev(dev);
>>
>
> Works for me. Not the greatest way to do this I guess, but hey, it
> works.
Anyway it is wrong. NLMSG_GOODSIZE * x for x > 1 doesn't give skb aligned to a
page boundary. bufsize should start with PAGE_SIZE or 8192 and be multiplied
then and the parameter used for nlmsg_new SKB_WITH_OVERHEAD(bufsize).
But it's ugly as hell, I agree -- and quite a temporary solution until somebody
decides to add channels, another channel info or whatever.
next prev parent reply other threads:[~2008-09-29 12:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-29 9:56 NL80211_CMD_GET_WIPHY reply doesn't fit into nl message buffer Jiri Slaby
2008-09-29 10:01 ` Johannes Berg
2008-09-29 10:20 ` Jouni Malinen
2008-09-29 10:25 ` Johannes Berg
2008-09-29 10:35 ` Johannes Berg
2008-09-29 10:45 ` Johannes Berg
2008-09-29 11:38 ` Jiri Slaby
2008-09-29 11:52 ` Johannes Berg
2008-09-29 11:52 ` Jiri Slaby
2008-09-29 11:55 ` Johannes Berg
2008-09-29 12:01 ` Jiri Slaby [this message]
2008-09-29 12:05 ` Johannes Berg
2008-09-29 16:31 ` Jouni Malinen
2008-09-29 16:45 ` Johannes Berg
2008-09-30 13:48 ` Jouni Malinen
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=48E0C384.3000903@gmail.com \
--to=jirislaby@gmail.com \
--cc=j@w1.fi \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=tgraf@suug.ch \
/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;
as well as URLs for NNTP newsgroup(s).