* nlmsg_failure on a function in some machines
@ 2009-04-15 20:53 Giacomo
0 siblings, 0 replies; only message in thread
From: Giacomo @ 2009-04-15 20:53 UTC (permalink / raw)
To: netfilter-devel
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-04-15 20:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-15 20:53 nlmsg_failure on a function in some machines Giacomo
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).