aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2006-11-10 17:10:15 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2006-12-03 00:22:11 -0500
commit339bf98ffc6a8d8eb16fc532ac57ffbced2f8a68 (patch)
tree499ad948863d2753ca10283dcf006ad28954538e /include
parenta94f723d595ee085f81b1788d18e031af7eeba91 (diff)
[NETLINK]: Do precise netlink message allocations where possible
Account for the netlink message header size directly in nlmsg_new() instead of relying on the caller calculate it correctly. Replaces error handling of message construction functions when constructing notifications with bug traps since a failure implies a bug in calculating the size of the skb. Signed-off-by: Thomas Graf <tgraf@suug.ch> Acked-by: Paul Moore <paul.moore@hp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/linux/netlink.h1
-rw-r--r--include/net/fib_rules.h1
-rw-r--r--include/net/netlink.h9
3 files changed, 7 insertions, 4 deletions
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index 66411622e06e..e61e1e138421 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -174,6 +174,7 @@ int netlink_sendskb(struct sock *sk, struct sk_buff *skb, int protocol);
174 */ 174 */
175#define NLMSG_GOODORDER 0 175#define NLMSG_GOODORDER 0
176#define NLMSG_GOODSIZE (SKB_MAX_ORDER(0, NLMSG_GOODORDER)) 176#define NLMSG_GOODSIZE (SKB_MAX_ORDER(0, NLMSG_GOODORDER))
177#define NLMSG_DEFAULT_SIZE (NLMSG_GOODSIZE - NLMSG_HDRLEN)
177 178
178 179
179struct netlink_callback 180struct netlink_callback
diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h
index e4ba781d289f..bc3c26494c3d 100644
--- a/include/net/fib_rules.h
+++ b/include/net/fib_rules.h
@@ -52,6 +52,7 @@ struct fib_rules_ops
52 struct nlmsghdr *, 52 struct nlmsghdr *,
53 struct fib_rule_hdr *); 53 struct fib_rule_hdr *);
54 u32 (*default_pref)(void); 54 u32 (*default_pref)(void);
55 size_t (*nlmsg_payload)(struct fib_rule *);
55 56
56 int nlgroup; 57 int nlgroup;
57 struct nla_policy *policy; 58 struct nla_policy *policy;
diff --git a/include/net/netlink.h b/include/net/netlink.h
index ce5cba19c393..30021339157c 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -500,14 +500,15 @@ static inline struct nlmsghdr *nlmsg_put_answer(struct sk_buff *skb,
500 500
501/** 501/**
502 * nlmsg_new - Allocate a new netlink message 502 * nlmsg_new - Allocate a new netlink message
503 * @size: maximum size of message 503 * @payload: size of the message payload
504 * @flags: the type of memory to allocate. 504 * @flags: the type of memory to allocate.
505 * 505 *
506 * Use NLMSG_GOODSIZE if size isn't know and you need a good default size. 506 * Use NLMSG_DEFAULT_SIZE if the size of the payload isn't known
507 * and a good default is needed.
507 */ 508 */
508static inline struct sk_buff *nlmsg_new(int size, gfp_t flags) 509static inline struct sk_buff *nlmsg_new(size_t payload, gfp_t flags)
509{ 510{
510 return alloc_skb(size, flags); 511 return alloc_skb(nlmsg_total_size(payload), flags);
511} 512}
512 513
513/** 514/**