diff options
-rw-r--r-- | include/linux/netlink.h | 11 | ||||
-rw-r--r-- | 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 2a20f488ac1b..a9d3ad5bc80f 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); | |||
171 | 171 | ||
172 | /* | 172 | /* |
173 | * skb should fit one page. This choice is good for headerless malloc. | 173 | * skb should fit one page. This choice is good for headerless malloc. |
174 | * But we should limit to 8K so that userspace does not have to | ||
175 | * use enormous buffer sizes on recvmsg() calls just to avoid | ||
176 | * MSG_TRUNC when PAGE_SIZE is very large. | ||
174 | */ | 177 | */ |
175 | #define NLMSG_GOODORDER 0 | 178 | #if PAGE_SIZE < 8192UL |
176 | #define NLMSG_GOODSIZE (SKB_MAX_ORDER(0, NLMSG_GOODORDER)) | 179 | #define NLMSG_GOODSIZE SKB_WITH_OVERHEAD(PAGE_SIZE) |
180 | #else | ||
181 | #define NLMSG_GOODSIZE SKB_WITH_OVERHEAD(8192UL) | ||
182 | #endif | ||
183 | |||
177 | #define NLMSG_DEFAULT_SIZE (NLMSG_GOODSIZE - NLMSG_HDRLEN) | 184 | #define NLMSG_DEFAULT_SIZE (NLMSG_GOODSIZE - NLMSG_HDRLEN) |
178 | 185 | ||
179 | 186 | ||
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index f9441b5f8d13..30089adb2e78 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
@@ -39,9 +39,11 @@ | |||
39 | 39 | ||
40 | #define SKB_DATA_ALIGN(X) (((X) + (SMP_CACHE_BYTES - 1)) & \ | 40 | #define SKB_DATA_ALIGN(X) (((X) + (SMP_CACHE_BYTES - 1)) & \ |
41 | ~(SMP_CACHE_BYTES - 1)) | 41 | ~(SMP_CACHE_BYTES - 1)) |
42 | #define SKB_MAX_ORDER(X, ORDER) (((PAGE_SIZE << (ORDER)) - (X) - \ | 42 | #define SKB_WITH_OVERHEAD(X) \ |
43 | sizeof(struct skb_shared_info)) & \ | 43 | (((X) - sizeof(struct skb_shared_info)) & \ |
44 | ~(SMP_CACHE_BYTES - 1)) | 44 | ~(SMP_CACHE_BYTES - 1)) |
45 | #define SKB_MAX_ORDER(X, ORDER) \ | ||
46 | SKB_WITH_OVERHEAD((PAGE_SIZE << (ORDER)) - (X)) | ||
45 | #define SKB_MAX_HEAD(X) (SKB_MAX_ORDER((X), 0)) | 47 | #define SKB_MAX_HEAD(X) (SKB_MAX_ORDER((X), 0)) |
46 | #define SKB_MAX_ALLOC (SKB_MAX_ORDER(0, 2)) | 48 | #define SKB_MAX_ALLOC (SKB_MAX_ORDER(0, 2)) |
47 | 49 | ||