[NETLINK]: Use SKB_MAXORDER to calculate NLMSG_GOODSIZE

Linux Kernel Mailing List <[email protected]>
Newsgroups gmane.linux.kernel.commits.2-4
Message-ID <[email protected]>
ChangeSet 1.1539.1.7, 2005/02/06 22:01:47-08:00, [email protected]

	[NETLINK]: Use SKB_MAXORDER to calculate NLMSG_GOODSIZE
	
	NLMSG_GOODSIZE specifies a good default size for the skb tailroom
	used in netlink messages when the size is unknown at the time of
	the allocation.
	
	The current value doesn't make much sense anymore because
	skb_shared_info isn't taken into account which means that
	depending on the architecture NLMSG_GOOSIZE can exceed PAGE_SIZE
	resulting in a waste of almost a complete page.
	
	Using SKB_MAXORDER solves this potential leak at the cost of
	slightly smaller but safer sizes for some architectures.
	
	Signed-off-by: Thomas Graf <[email protected]>
	Signed-off-by: David S. Miller <[email protected]>



 netlink.h |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)


diff -Nru a/include/linux/netlink.h b/include/linux/netlink.h
--- a/include/linux/netlink.h	2005-02-09 09:07:57 -08:00
+++ b/include/linux/netlink.h	2005-02-09 09:07:57 -08:00
@@ -117,10 +117,9 @@
 
 /*
  *	skb should fit one page. This choice is good for headerless malloc.
- *
- *      FIXME: What is the best size for SLAB???? --ANK
  */
-#define NLMSG_GOODSIZE (PAGE_SIZE - ((sizeof(struct sk_buff)+0xF)&~0xF))
+#define NLMSG_GOODORDER 0
+#define NLMSG_GOODSIZE (SKB_MAX_ORDER(0, NLMSG_GOODORDER))
 
 
 struct netlink_callback
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.