From: Giacomo <delleceste@gmail.com>
To: netfilter-devel <netfilter-devel@vger.kernel.org>
Subject: nlmsg_failure on a function in some machines
Date: Wed, 15 Apr 2009 22:53:24 +0200 [thread overview]
Message-ID: <885896af0904151353r2c3fb13du9ce3ac524bf5ae9@mail.gmail.com> (raw)
Good morning to all.
I noticed that the following piece of code, while working on many machines,
goes to NLMSG_PUT nlmsg_failure goto label in some cases.
Is there something wrong with it?
Thanks in advance.
Code follows here:
/* buf is a buffer containing the data to be sent to userspace,
* numbytes is the length of the data contained in buf
*/
struct sk_buff *build_packet(void *buf, int numbytes)
4 {
5 struct sk_buff *skb_to_user;
6 struct nlmsghdr *nlh;
7 void *data;
8 int len = NLMSG_SPACE(numbytes);
9 /* allocate socket buffer space atomically */
10 skb_to_user = alloc_skb(len, GFP_ATOMIC);
11
12 if(skb_to_user == NULL)
13 return NULL;
14
15 nlh = NLMSG_PUT(skb_to_user, 0, 0, 0, len);
16 if(NLMSG_OK(nlh, NLMSG_LENGTH(len)))
17 {
18 nlh->nlmsg_len = NLMSG_LENGTH(len);
19 data = NLMSG_DATA(nlh);
20 memcpy(data, buf, numbytes);
21 }
22 else
23 {
24 printk("IPFIRE: NLMSG_OK failed: NLMSG_LENGTH(%d) is %d,
NLMSG_SPACE(numbytes %d) is %d in build_packet(), "
25 "ipfi_netl_packet_builder.c\n", len, NLMSG_LENGTH(len),
numbytes, NLMSG_SPACE(numbytes));
26 return NULL;
27 }
28 return skb_to_user; /* return just allocated socket buffer */
29
30 nlmsg_failure: /* NLMSG_PUT fails */
31
32 printk("IPFIRE: nlmsg failure in build_packet() - %d bytes -
ipfi_netl_packet_builder.c\n", len);
33 return NULL;
34 }
35
As told before, in some machines NLMSG_PUT goes to nlmsg_failure label.
Thanks in advance for any suggestion.
Best regards
Giacomo
--
Giacomo S.
http://www.giacomos.it
- - - - - - - - - - - - - - - - - - - - - -
* Aprile 2008: iqfire-wall, un progetto
open source che implementa un
filtro di pacchetti di rete per Linux,
e` disponibile per il download qui:
http://sourceforge.net/projects/ipfire-wall
* Informazioni e pagina web ufficiale:
http://www.giacomos.it/iqfire/index.html
- - - - - - - - - - - - - - - - - - - - - -
. '' `.
: :' :
`. ` '
`- Debian GNU/Linux -- The power of freedom
http://www.debian.org
reply other threads:[~2009-04-15 20:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=885896af0904151353r2c3fb13du9ce3ac524bf5ae9@mail.gmail.com \
--to=delleceste@gmail.com \
--cc=netfilter-devel@vger.kernel.org \
/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).