All of lore.kernel.org
 help / color / mirror / Atom feed
* libnfnetlink: Strange behaviour in nfnl_fill_hdr
@ 2008-05-13  8:30 Fabian Hugelshofer
  0 siblings, 0 replies; only message in thread
From: Fabian Hugelshofer @ 2008-05-13  8:30 UTC (permalink / raw)
  To: netfilter-devel

Hi,

I am trying to use libnetfilter-log and libnfnetlink on a router with 
armeb architecture running OpenWRT. I cross-compiled the libraries, but 
have problems with the test tool nfulnl_test. When I run it I get:

"unbinding existing nf_log handler for AF_INET (if any)
nfnl_talk: sendmsg(netlink) Message too long 

error nflog_unbind_pf()"

The problem is caused by nfnl_fill_hdr from libnfnetlink. Here is the 
start of the function with two printfs added by me:

void nfnl_fill_hdr(struct nfnl_subsys_handle *ssh,
		    struct nlmsghdr *nlh, unsigned int len,
		    u_int8_t family,
		    u_int16_t res_id,
		    u_int16_t msg_type,
		    u_int16_t msg_flags)
{
	assert(ssh);
	assert(nlh);

	struct nfgenmsg *nfg = (struct nfgenmsg *)
					((void *)nlh + sizeof(*nlh));

	nlh->nlmsg_len = NLMSG_LENGTH(len+sizeof(*nfg));
	printf("nfnfl len %d\n", nlh->nlmsg_len);
	printf("nfnfl len %d\n", nlh->nlmsg_len);

The first printf prints 20 (0x14), whereas the second one prints 1310720 
(0x140000). The length stays on 1310720, which causes the "Message too 
long" error.

There is some magic going on. I supect this being a compiler bug. Else I 
have no explanation for shifting 16bit or half-word swapping for no 
reason. Can someone imagine another reason for this strange behaviour?

Regards,

Fabian


PS: If you think, I should have posted to the user list, just let me know.


Stacktrace:
main (nfulnl_test.c)
nflog_unbind_pf (libnetfilter_loc.c)
__build_send_cfg_msg (libnetfilter_log.c)
nfnl_fill_hdr (libnfnetlink.c)

Software:
libnetfilter_log 0.0.13
libnfnetlink 0.0.30
linux 2.6.24.2
armeb-linux-gcc 4.1.2

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-05-13  8:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-13  8:30 libnfnetlink: Strange behaviour in nfnl_fill_hdr Fabian Hugelshofer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.