All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] netfilter_queue: byte order of mark
@ 2007-12-07 23:50 Stephanie Lockwood-Childs
  2007-12-08  3:05 ` Patrick McHardy
  0 siblings, 1 reply; 3+ messages in thread
From: Stephanie Lockwood-Childs @ 2007-12-07 23:50 UTC (permalink / raw)
  To: netfilter-devel

Apologies to those who subscribe to both netfilter and netfilter-devel 
lists and get a dupe -- I meant to send this only to -devel, but managed 
to copy the wrong 'send mail' link from netfilter home page...

--------
Hi,

when trying to set marks with netfilter_queue library, I discovered there is
a discrepency in byte ordering between the library and the nfnetlink_queue
kernel model. The kernel code expects to receive the mark attribute in
network order

net/netfilter/nfnetlink_queue.c
if (nfqa[NFQA_MARK-1])
 	entry->skb->mark = ntohl(*(__be32 *)
 				NFA_DATA(nfqa[NFQA_MARK-1]));

so netfilter_queue library should put the mark into network order when
sending it.

diff -ur libnetfilter_queue.orig/src/libnetfilter_queue.c
libnetfilter_queue/src/libnetfilter_queue.c
--- netfilter/libnetfilter_queue/src/libnetfilter_queue.c	2007-12-05
11:26:24.000000000 -0800
+++ libnetfilter_queue-0.0.15/src/libnetfilter_queue.c	2007-12-05
16:47:44.000000000 -0800
@@ -333,8 +333,9 @@
  	/* add verdict header */
  	nfnl_addattr_l(nmh, sizeof(buf), NFQA_VERDICT_HDR, &vh, sizeof(vh));

+	/* kernel module expects mark to be in network byte order */
  	if (set_mark)
-		nfnl_addattr32(nmh, sizeof(buf), NFQA_MARK, mark);
+		nfnl_addattr32(nmh, sizeof(buf), NFQA_MARK, htonl(mark));

  	iov[0].iov_base = nmh;
  	iov[0].iov_len = NLMSG_TAIL(nmh) - (void *)nmh;

^ permalink raw reply	[flat|nested] 3+ messages in thread
* [PATCH] netfilter_queue: byte order of mark
@ 2007-12-07 23:35 Stephanie Lockwood-Childs
  0 siblings, 0 replies; 3+ messages in thread
From: Stephanie Lockwood-Childs @ 2007-12-07 23:35 UTC (permalink / raw)
  To: netfilter

Hi,

when trying to set marks with netfilter_queue library, I discovered there 
is a discrepency in byte ordering between the library and the 
nfnetlink_queue kernel model. The kernel code expects to receive the mark 
attribute in network order

net/netfilter/nfnetlink_queue.c
if (nfqa[NFQA_MARK-1])
 	entry->skb->mark = ntohl(*(__be32 *)
 				NFA_DATA(nfqa[NFQA_MARK-1]));

so netfilter_queue library should put the mark into network order when
sending it.

diff -ur libnetfilter_queue.orig/src/libnetfilter_queue.c libnetfilter_queue/src/libnetfilter_queue.c
--- netfilter/libnetfilter_queue/src/libnetfilter_queue.c	2007-12-05 11:26:24.000000000 -0800
+++ libnetfilter_queue-0.0.15/src/libnetfilter_queue.c	2007-12-05 16:47:44.000000000 -0800
@@ -333,8 +333,9 @@
  	/* add verdict header */
  	nfnl_addattr_l(nmh, sizeof(buf), NFQA_VERDICT_HDR, &vh, sizeof(vh));

+	/* kernel module expects mark to be in network byte order */
  	if (set_mark)
-		nfnl_addattr32(nmh, sizeof(buf), NFQA_MARK, mark);
+		nfnl_addattr32(nmh, sizeof(buf), NFQA_MARK, htonl(mark));

  	iov[0].iov_base = nmh;
  	iov[0].iov_len = NLMSG_TAIL(nmh) - (void *)nmh;

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-12-08  3:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-07 23:50 [PATCH] netfilter_queue: byte order of mark Stephanie Lockwood-Childs
2007-12-08  3:05 ` Patrick McHardy
  -- strict thread matches above, loose matches on Subject: below --
2007-12-07 23:35 Stephanie Lockwood-Childs

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.