Skip to contentSkip to conversation

nfqueue message is on a diet

PATCH In review Pablo Neira Ayuso 2 participants 2 messages Feb 13, 2006

Subsystems (2)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 3/4 nfqueue message is on a diet

[NFNETLINK_QUEUE] nfqueue message is on a diet

Fix oversized message, use NLMSG_SPACE just one since it reserves space for the netlink header.

Signature · 2 lines
The dawn of the fourth age of Linux firewalling is coming; a time of
great struggle and heroic deeds -- J.Kadlecsik got inspired by J.Morris

[NFNETLINK_QUEUE] nfqueue message is on a diet

Fix oversized message, use NLMSG_SPACE just one since it reserves space for the netlink header.

net/netfilter/nfnetlink_queue.c +9 -8
Index: net-2.6.git/net/netfilter/nfnetlink_queue.c
===================================================================
@@ -354,16 +354,17 @@ nfqnl_build_packet_message(struct nfqnl_
 	QDEBUG("entered\n");
 
 	/* all macros expand to constant values at compile time */
-	size =    NLMSG_SPACE(sizeof(struct nfqnl_msg_packet_hdr))
-		+ NLMSG_SPACE(sizeof(u_int32_t))	/* ifindex */
-		+ NLMSG_SPACE(sizeof(u_int32_t))	/* ifindex */
+	size =    NLMSG_SPACE(sizeof(struct nfgenmsg))
+		+ NLMSG_ALIGN(sizeof(struct nfqnl_msg_packet_hdr))
+		+ NLMSG_ALIGN(sizeof(u_int32_t))	/* ifindex */
+		+ NLMSG_ALIGN(sizeof(u_int32_t))	/* ifindex */
 #ifdef CONFIG_BRIDGE_NETFILTER
-		+ NLMSG_SPACE(sizeof(u_int32_t))	/* ifindex */
-		+ NLMSG_SPACE(sizeof(u_int32_t))	/* ifindex */
+		+ NLMSG_ALIGN(sizeof(u_int32_t))	/* ifindex */
+		+ NLMSG_ALIGN(sizeof(u_int32_t))	/* ifindex */
 #endif
-		+ NLMSG_SPACE(sizeof(u_int32_t))	/* mark */
-		+ NLMSG_SPACE(sizeof(struct nfqnl_msg_packet_hw))
-		+ NLMSG_SPACE(sizeof(struct nfqnl_msg_packet_timestamp));
+		+ NLMSG_ALIGN(sizeof(u_int32_t))	/* mark */
+		+ NLMSG_ALIGN(sizeof(struct nfqnl_msg_packet_hw))
+		+ NLMSG_ALIGN(sizeof(struct nfqnl_msg_packet_timestamp));
 
 	outdev = entinf->outdev;
 
#1 lore raw
Quoted 4 lines · Pablo Neira Ayuso

[NFNETLINK_QUEUE] nfqueue message is on a diet

Fix oversized message, use NLMSG_SPACE just one since it reserves space for the netlink header.

I think before and after your patch, it is wrong in both cases.

What we rally need is:
- one time NLMSG_SPACE in order to account for the nlmsghdr
- all the other times:
Size of struct nfattr
+ size of data element
+ alignment overhead

So IMHO we should use 1 time NLMSG_SPACE, then NFA_SPACE. Please let me know what you think, update your patch and resubmit.

Also, the same kind of fix is probably needed for nfnetlink_log.

Quoted 1 line

Signed-off-by !

Signature · 5 lines
- Harald Welte <[email protected]>                 http://netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie