Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=fc910a27839584209726537698b596576940add4
Commit:     fc910a27839584209726537698b596576940add4
Parent:     ca043569390c528de4cd5ec9e07502f2bf4ecd1f
Author:     David S. Miller <[EMAIL PROTECTED]>
AuthorDate: Sun Mar 25 20:27:59 2007 -0700
Committer:  David S. Miller <[EMAIL PROTECTED]>
CommitDate: Wed Apr 25 22:23:45 2007 -0700

    [NETLINK]: Limit NLMSG_GOODSIZE to 8K.
    
    Signed-off-by: David S. Miller <[EMAIL PROTECTED]>
---
 include/linux/netlink.h |   11 +++++++++--
 include/linux/skbuff.h  |    8 +++++---
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index 2a20f48..a9d3ad5 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -171,9 +171,16 @@ int netlink_sendskb(struct sock *sk, struct sk_buff *skb, 
int protocol);
 
 /*
  *     skb should fit one page. This choice is good for headerless malloc.
+ *     But we should limit to 8K so that userspace does not have to
+ *     use enormous buffer sizes on recvmsg() calls just to avoid
+ *     MSG_TRUNC when PAGE_SIZE is very large.
  */
-#define NLMSG_GOODORDER 0
-#define NLMSG_GOODSIZE (SKB_MAX_ORDER(0, NLMSG_GOODORDER))
+#if PAGE_SIZE < 8192UL
+#define NLMSG_GOODSIZE SKB_WITH_OVERHEAD(PAGE_SIZE)
+#else
+#define NLMSG_GOODSIZE SKB_WITH_OVERHEAD(8192UL)
+#endif
+
 #define NLMSG_DEFAULT_SIZE (NLMSG_GOODSIZE - NLMSG_HDRLEN)
 
 
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index f9441b5..30089ad 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -39,9 +39,11 @@
 
 #define SKB_DATA_ALIGN(X)      (((X) + (SMP_CACHE_BYTES - 1)) & \
                                 ~(SMP_CACHE_BYTES - 1))
-#define SKB_MAX_ORDER(X, ORDER)        (((PAGE_SIZE << (ORDER)) - (X) - \
-                                 sizeof(struct skb_shared_info)) & \
-                                 ~(SMP_CACHE_BYTES - 1))
+#define SKB_WITH_OVERHEAD(X)   \
+       (((X) - sizeof(struct skb_shared_info)) & \
+        ~(SMP_CACHE_BYTES - 1))
+#define SKB_MAX_ORDER(X, ORDER) \
+       SKB_WITH_OVERHEAD((PAGE_SIZE << (ORDER)) - (X))
 #define SKB_MAX_HEAD(X)                (SKB_MAX_ORDER((X), 0))
 #define SKB_MAX_ALLOC          (SKB_MAX_ORDER(0, 2))
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to