diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2012-01-30 15:22:06 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-01-30 15:22:06 -0500 |
commit | a46621a3a8f24557201a7ef62de151c812f8985c (patch) | |
tree | 9701dd51e082d600ce4b69ee4773805630ab0ada | |
parent | 5de658f878d49e952d7b3f3f26a396132829f513 (diff) |
net: Deinline __nlmsg_put and genlmsg_put. -7k code on i386 defconfig.
text data bss dec hex filename
8455963 532732 1810804 10799499 a4c98b vmlinux.o.before
8448899 532732 1810804 10792435 a4adf3 vmlinux.o
This change also removes commented-out copy of __nlmsg_put
which was last touched in 2005 with "Enable once all users
have been converted" comment on top.
Changes in v2: rediffed against net-next.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/netlink.h | 18 | ||||
-rw-r--r-- | include/net/genetlink.h | 31 | ||||
-rw-r--r-- | include/net/netlink.h | 35 | ||||
-rw-r--r-- | net/netlink/af_netlink.c | 18 | ||||
-rw-r--r-- | net/netlink/genetlink.c | 31 |
5 files changed, 53 insertions, 80 deletions
diff --git a/include/linux/netlink.h b/include/linux/netlink.h index 52e48959cfa1..a390e9d54827 100644 --- a/include/linux/netlink.h +++ b/include/linux/netlink.h | |||
@@ -237,22 +237,8 @@ struct netlink_notify { | |||
237 | int protocol; | 237 | int protocol; |
238 | }; | 238 | }; |
239 | 239 | ||
240 | static __inline__ struct nlmsghdr * | 240 | struct nlmsghdr * |
241 | __nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags) | 241 | __nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags); |
242 | { | ||
243 | struct nlmsghdr *nlh; | ||
244 | int size = NLMSG_LENGTH(len); | ||
245 | |||
246 | nlh = (struct nlmsghdr*)skb_put(skb, NLMSG_ALIGN(size)); | ||
247 | nlh->nlmsg_type = type; | ||
248 | nlh->nlmsg_len = size; | ||
249 | nlh->nlmsg_flags = flags; | ||
250 | nlh->nlmsg_pid = pid; | ||
251 | nlh->nlmsg_seq = seq; | ||
252 | if (!__builtin_constant_p(size) || NLMSG_ALIGN(size) - size != 0) | ||
253 | memset(NLMSG_DATA(nlh) + len, 0, NLMSG_ALIGN(size) - size); | ||
254 | return nlh; | ||
255 | } | ||
256 | 242 | ||
257 | #define NLMSG_NEW(skb, pid, seq, type, len, flags) \ | 243 | #define NLMSG_NEW(skb, pid, seq, type, len, flags) \ |
258 | ({ if (unlikely(skb_tailroom(skb) < (int)NLMSG_SPACE(len))) \ | 244 | ({ if (unlikely(skb_tailroom(skb) < (int)NLMSG_SPACE(len))) \ |
diff --git a/include/net/genetlink.h b/include/net/genetlink.h index 7db32995ccd3..ccb68880abf5 100644 --- a/include/net/genetlink.h +++ b/include/net/genetlink.h | |||
@@ -131,35 +131,8 @@ extern void genl_unregister_mc_group(struct genl_family *family, | |||
131 | extern void genl_notify(struct sk_buff *skb, struct net *net, u32 pid, | 131 | extern void genl_notify(struct sk_buff *skb, struct net *net, u32 pid, |
132 | u32 group, struct nlmsghdr *nlh, gfp_t flags); | 132 | u32 group, struct nlmsghdr *nlh, gfp_t flags); |
133 | 133 | ||
134 | /** | 134 | void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, |
135 | * genlmsg_put - Add generic netlink header to netlink message | 135 | struct genl_family *family, int flags, u8 cmd); |
136 | * @skb: socket buffer holding the message | ||
137 | * @pid: netlink pid the message is addressed to | ||
138 | * @seq: sequence number (usually the one of the sender) | ||
139 | * @family: generic netlink family | ||
140 | * @flags netlink message flags | ||
141 | * @cmd: generic netlink command | ||
142 | * | ||
143 | * Returns pointer to user specific header | ||
144 | */ | ||
145 | static inline void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, | ||
146 | struct genl_family *family, int flags, u8 cmd) | ||
147 | { | ||
148 | struct nlmsghdr *nlh; | ||
149 | struct genlmsghdr *hdr; | ||
150 | |||
151 | nlh = nlmsg_put(skb, pid, seq, family->id, GENL_HDRLEN + | ||
152 | family->hdrsize, flags); | ||
153 | if (nlh == NULL) | ||
154 | return NULL; | ||
155 | |||
156 | hdr = nlmsg_data(nlh); | ||
157 | hdr->cmd = cmd; | ||
158 | hdr->version = family->version; | ||
159 | hdr->reserved = 0; | ||
160 | |||
161 | return (char *) hdr + GENL_HDRLEN; | ||
162 | } | ||
163 | 136 | ||
164 | /** | 137 | /** |
165 | * genlmsg_nlhdr - Obtain netlink header from user specified header | 138 | * genlmsg_nlhdr - Obtain netlink header from user specified header |
diff --git a/include/net/netlink.h b/include/net/netlink.h index cb1f3504687f..f394fe5d7641 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h | |||
@@ -441,41 +441,6 @@ static inline int nlmsg_report(const struct nlmsghdr *nlh) | |||
441 | nla_for_each_attr(pos, nlmsg_attrdata(nlh, hdrlen), \ | 441 | nla_for_each_attr(pos, nlmsg_attrdata(nlh, hdrlen), \ |
442 | nlmsg_attrlen(nlh, hdrlen), rem) | 442 | nlmsg_attrlen(nlh, hdrlen), rem) |
443 | 443 | ||
444 | #if 0 | ||
445 | /* FIXME: Enable once all users have been converted */ | ||
446 | |||
447 | /** | ||
448 | * __nlmsg_put - Add a new netlink message to an skb | ||
449 | * @skb: socket buffer to store message in | ||
450 | * @pid: netlink process id | ||
451 | * @seq: sequence number of message | ||
452 | * @type: message type | ||
453 | * @payload: length of message payload | ||
454 | * @flags: message flags | ||
455 | * | ||
456 | * The caller is responsible to ensure that the skb provides enough | ||
457 | * tailroom for both the netlink header and payload. | ||
458 | */ | ||
459 | static inline struct nlmsghdr *__nlmsg_put(struct sk_buff *skb, u32 pid, | ||
460 | u32 seq, int type, int payload, | ||
461 | int flags) | ||
462 | { | ||
463 | struct nlmsghdr *nlh; | ||
464 | |||
465 | nlh = (struct nlmsghdr *) skb_put(skb, nlmsg_total_size(payload)); | ||
466 | nlh->nlmsg_type = type; | ||
467 | nlh->nlmsg_len = nlmsg_msg_size(payload); | ||
468 | nlh->nlmsg_flags = flags; | ||
469 | nlh->nlmsg_pid = pid; | ||
470 | nlh->nlmsg_seq = seq; | ||
471 | |||
472 | memset((unsigned char *) nlmsg_data(nlh) + payload, 0, | ||
473 | nlmsg_padlen(payload)); | ||
474 | |||
475 | return nlh; | ||
476 | } | ||
477 | #endif | ||
478 | |||
479 | /** | 444 | /** |
480 | * nlmsg_put - Add a new netlink message to an skb | 445 | * nlmsg_put - Add a new netlink message to an skb |
481 | * @skb: socket buffer to store message in | 446 | * @skb: socket buffer to store message in |
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 629b06182f3f..4d751e3d4b4b 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
@@ -1645,6 +1645,24 @@ static void netlink_destroy_callback(struct netlink_callback *cb) | |||
1645 | kfree(cb); | 1645 | kfree(cb); |
1646 | } | 1646 | } |
1647 | 1647 | ||
1648 | struct nlmsghdr * | ||
1649 | __nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags) | ||
1650 | { | ||
1651 | struct nlmsghdr *nlh; | ||
1652 | int size = NLMSG_LENGTH(len); | ||
1653 | |||
1654 | nlh = (struct nlmsghdr*)skb_put(skb, NLMSG_ALIGN(size)); | ||
1655 | nlh->nlmsg_type = type; | ||
1656 | nlh->nlmsg_len = size; | ||
1657 | nlh->nlmsg_flags = flags; | ||
1658 | nlh->nlmsg_pid = pid; | ||
1659 | nlh->nlmsg_seq = seq; | ||
1660 | if (!__builtin_constant_p(size) || NLMSG_ALIGN(size) - size != 0) | ||
1661 | memset(NLMSG_DATA(nlh) + len, 0, NLMSG_ALIGN(size) - size); | ||
1662 | return nlh; | ||
1663 | } | ||
1664 | EXPORT_SYMBOL(__nlmsg_put); | ||
1665 | |||
1648 | /* | 1666 | /* |
1649 | * It looks a bit ugly. | 1667 | * It looks a bit ugly. |
1650 | * It would be better to create kernel thread. | 1668 | * It would be better to create kernel thread. |
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c index c29d2568c9e0..a1154717219e 100644 --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c | |||
@@ -498,6 +498,37 @@ int genl_unregister_family(struct genl_family *family) | |||
498 | } | 498 | } |
499 | EXPORT_SYMBOL(genl_unregister_family); | 499 | EXPORT_SYMBOL(genl_unregister_family); |
500 | 500 | ||
501 | /** | ||
502 | * genlmsg_put - Add generic netlink header to netlink message | ||
503 | * @skb: socket buffer holding the message | ||
504 | * @pid: netlink pid the message is addressed to | ||
505 | * @seq: sequence number (usually the one of the sender) | ||
506 | * @family: generic netlink family | ||
507 | * @flags netlink message flags | ||
508 | * @cmd: generic netlink command | ||
509 | * | ||
510 | * Returns pointer to user specific header | ||
511 | */ | ||
512 | void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, | ||
513 | struct genl_family *family, int flags, u8 cmd) | ||
514 | { | ||
515 | struct nlmsghdr *nlh; | ||
516 | struct genlmsghdr *hdr; | ||
517 | |||
518 | nlh = nlmsg_put(skb, pid, seq, family->id, GENL_HDRLEN + | ||
519 | family->hdrsize, flags); | ||
520 | if (nlh == NULL) | ||
521 | return NULL; | ||
522 | |||
523 | hdr = nlmsg_data(nlh); | ||
524 | hdr->cmd = cmd; | ||
525 | hdr->version = family->version; | ||
526 | hdr->reserved = 0; | ||
527 | |||
528 | return (char *) hdr + GENL_HDRLEN; | ||
529 | } | ||
530 | EXPORT_SYMBOL(genlmsg_put); | ||
531 | |||
501 | static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | 532 | static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) |
502 | { | 533 | { |
503 | struct genl_ops *ops; | 534 | struct genl_ops *ops; |