net/netlink/: possible cleanups
Subsystems (2)
RFC PATCH 1/1 net/netlink/: possible cleanups
This patch contains the following possible cleanups plus changes related to them:
- make the following needlessly global functions static:
- attr.c: __nla_reserve()
- attr.c: __nla_put()
- #if 0 the following unused global functions:
- attr.c: nla_validate()
- attr.c: nla_find()
- attr.c: nla_memcpy()
- attr.c: nla_memcmp()
- attr.c: nla_strcmp()
- attr.c: nla_reserve()
- genetlink.c: genl_unregister_ops()
- remove the following unused EXPORT_SYMBOL's:
- af_netlink.c: netlink_set_nonroot
- attr.c: nla_parse
- attr.c: nla_strlcpy
- attr.c: nla_put
---
include/net/genetlink.h | 1 - include/net/netlink.h | 23 ++++++++--------------- net/netlink/af_netlink.c | 1 - net/netlink/attr.c | 29 ++++++++++++++--------------- net/netlink/genetlink.c | 3 ++- 5 files changed, 24 insertions(+), 33 deletions(-)
net/netlink/af_netlink.c renamed from net/netlink/af_netlink.c.old +0 -1
@@ -1805,7 +1805,6 @@EXPORT_SYMBOL (netlink_kernel_create);EXPORT_SYMBOL (netlink_register_notifier);EXPORT_SYMBOL (netlink_set_err); -EXPORT_SYMBOL (netlink_set_nonroot);EXPORT_SYMBOL (netlink_unicast);EXPORT_SYMBOL (netlink_unregister_notifier);
include/net/netlink.h renamed from include/net/netlink.h.old +8 -15
@@ -189,24 +189,11 @@extern void netlink_queue_skip (struct nlmsghdr *nlh,struct sk_buff *skb); -extern int nla_validate (struct nlattr *head,int len,int maxtype, -struct nla_policy *policy);extern int nla_parse (struct nlattr *tb[],int maxtype,struct nlattr *head,int len,struct nla_policy *policy); -extern struct nlattr *nla_find (struct nlattr *head,int len,int attrtype);extern size_t nla_strlcpy (char *dst,const struct nlattr *nla,size_t dstsize); -extern int nla_memcpy (void *dest,struct nlattr *src,int count); -extern int nla_memcmp (const struct nlattr *nla,const void *data, -size_t size); -extern int nla_strcmp (const struct nlattr *nla,const char *str); -extern struct nlattr *__nla_reserve (struct sk_buff *skb,int attrtype, -int attrlen); -extern struct nlattr *nla_reserve (struct sk_buff *skb,int attrtype, -int attrlen); -extern void __nla_put (struct sk_buff *skb,int attrtype, -int attrlen,const void *data);extern int nla_put (struct sk_buff *skb,int attrtype,int attrlen,const void *data);
@@ -331,6 +318,8 @@ nlmsg_attrlen(nlh, hdrlen), policy); } +#if 0 +/** * nlmsg_find_attr - find a specific attribute in a netlink message * @nlh: netlink message header
@@ -374,7 +363,6 @@nla_for_each_attr (pos,nlmsg_attrdata (nlh, hdrlen), \nlmsg_attrlen (nlh, hdrlen), rem) -#if 0 /* FIXME: Enable once all users have been converted */ /**
@@ -407,7 +395,8 @@ return nlh; } -#endif + +#endif /* 0 */ /** * nlmsg_put - Add a new netlink message to an skb
@@ -784,6 +773,7 @@return *(u8 *)nla_data (nla); } +#if 0 /** * nla_get_u64 - return payload of u64 attribute * @nla: u64 netlink attribute
@@ -796,6 +786,7 @@ return tmp; } +#endif /* 0 */ /** * nla_get_flag - return payload of flag attribute
@@ -806,6 +797,7 @@return !!nla; } +#if 0 /** * nla_get_msecs - return payload of msecs attribute * @nla: msecs netlink attribute
@@ -818,6 +810,7 @@ return msecs_to_jiffies((unsigned long) msecs); } +#endif /* 0 */ /** * nla_nest_start - Start a new level of nested attributes
net/netlink/attr.c renamed from net/netlink/attr.c.old +14 -15
@@ -52,6 +52,7 @@return 0 ; } +#if 0 /** * nla_validate - Validate a stream of attributes * @head: head of attribute stream
@@ -81,6 +82,7 @@ errout: return err; } +#endif /* 0 */ /** * nla_parse - Parse a stream of attributes into a tb buffer
@@ -127,6 +129,7 @@return err; } +#if 0 /** * nla_find - Find a specific attribute in a stream of attributes * @head: head of attribute stream
@@ -146,6 +149,7 @@ return NULL; } +#endif /* 0 */ /** * nla_strlcpy - Copy string attribute payload into a sized buffer
@@ -177,6 +181,8 @@return srclen; } +#if 0 +/** * nla_memcpy - Copy a netlink attribute into another memory area * @dest: where to copy to memcpy
@@ -230,6 +236,8 @@ return d; } +#endif /* 0 */ +/** * __nla_reserve - reserve room for attribute on the skb * @skb: socket buffer to reserve room on
@@ -242,7 +250,8 @@* The caller is responsible to ensure that the skb provides enough * tailroom for the attribute header and payload. */ -struct nlattr *__nla_reserve (struct sk_buff *skb,int attrtype,int attrlen) +static struct nlattr *__nla_reserve (struct sk_buff *skb,int attrtype, +int attrlen) {struct nlattr *nla;
@@ -255,6 +264,7 @@return nla; } +#if 0 /** * nla_reserve - reserve room for attribute on the skb * @skb: socket buffer to reserve room on
@@ -274,6 +284,7 @@ return __nla_reserve(skb, attrtype, attrlen); } +#endif /* 0 */ /** * __nla_put - Add a netlink attribute to a socket buffer
@@ -285,8 +296,8 @@* The caller is responsible to ensure that the skb provides enough * tailroom for the attribute header and payload. */ -void __nla_put (struct sk_buff *skb,int attrtype,int attrlen, -const void *data) +static void __nla_put (struct sk_buff *skb,int attrtype,int attrlen, +const void *data) {struct nlattr *nla;
@@ -314,15 +325,3 @@return 0 ; } - -EXPORT_SYMBOL (nla_validate); -EXPORT_SYMBOL (nla_parse); -EXPORT_SYMBOL (nla_find); -EXPORT_SYMBOL (nla_strlcpy); -EXPORT_SYMBOL (__nla_reserve); -EXPORT_SYMBOL (nla_reserve); -EXPORT_SYMBOL (__nla_put); -EXPORT_SYMBOL (nla_put); -EXPORT_SYMBOL (nla_memcpy); -EXPORT_SYMBOL (nla_memcmp); -EXPORT_SYMBOL (nla_strcmp);
include/net/genetlink.h renamed from include/net/genetlink.h.old +0 -1
@@ -72,7 +72,6 @@extern int genl_register_family (struct genl_family *family);extern int genl_unregister_family (struct genl_family *family);extern int genl_register_ops (struct genl_family *,struct genl_ops *ops); -extern int genl_unregister_ops (struct genl_family *,struct genl_ops *ops);extern struct sock *genl_sock;
net/netlink/genetlink.c renamed from net/netlink/genetlink.c.old +2 -1
@@ -154,6 +154,7 @@return err; } +#if 0 /** * genl_unregister_ops - unregister generic netlink operations * @family: generic netlink family
@@ -187,6 +188,7 @@ return -ENOENT; } +#endif /* 0 */ /** * genl_register_family - register a generic netlink family
@@ -565,6 +567,5 @@EXPORT_SYMBOL (genl_sock);EXPORT_SYMBOL (genl_register_ops); -EXPORT_SYMBOL (genl_unregister_ops);EXPORT_SYMBOL (genl_register_family);EXPORT_SYMBOL (genl_unregister_family);
David S. Miller
maintainerFrom: Adrian Bunk <[email protected]>
Date: Thu, 13 Apr 2006 18:27:10 +0200
Quoted 19 lines
This patch contains the following possible cleanups plus changes related to them:
- make the following needlessly global functions static:
-attr.c:__nla_reserve()
-attr.c:__nla_put()
- #if 0 the following unused global functions:
-attr.c:nla_validate()
-attr.c:nla_find()
-attr.c:nla_memcpy()
-attr.c:nla_memcmp()
-attr.c:nla_strcmp()
-attr.c:nla_reserve()
-genetlink.c:genl_unregister_ops()
- remove the following unused EXPORT_SYMBOL's:
-af_netlink.c:netlink_set_nonroot
-attr.c:nla_parse
-attr.c:nla_strlcpy
-attr.c:nla_put
Quoted 1 line
Signed-off-by Adrian Bunk <[email protected]>
Bunk-bot, you have to stop.
These interfaces were added so that new users of netlink could write their code more easily.
Unused does not equate to "comment out or delete".
Quoted 22 lines · David S. Miller
From: Adrian Bunk <[email protected]>
Date: Thu, 13 Apr 2006 18:27:10 +0200Quoted 19 lines
This patch contains the following possible cleanups plus changes related to them:
- make the following needlessly global functions static:
-attr.c:__nla_reserve()
-attr.c:__nla_put()
- #if 0 the following unused global functions:
-attr.c:nla_validate()
-attr.c:nla_find()
-attr.c:nla_memcpy()
-attr.c:nla_memcmp()
-attr.c:nla_strcmp()
-attr.c:nla_reserve()
-genetlink.c:genl_unregister_ops()
- remove the following unused EXPORT_SYMBOL's:
-af_netlink.c:netlink_set_nonroot
-attr.c:nla_parse
-attr.c:nla_strlcpy
-attr.c:nla_put
Quoted 8 lines
Quoted 1 line
Signed-off-by Adrian Bunk <[email protected]>Bunk-bot, you have to stop.
These interfaces were added so that new users of netlink could write their code more easily.
Unused does not equate to "comment out or delete".
Can you give a more detailed answer which parts of my patch you disagree with?
Is the export of netlink_set_nonroot that seems to be both present and unused since at least kernel 2.6.0 covered by your statement?
Anything else where a removal might be OK?
I'll then send a stripped-down patch (if any non-empty subset of my patch is OK).
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedQuoted 24 lines · Adrian Bunk
Quoted 23 lines · David S. Miller
From: Adrian Bunk <[email protected]>
Date: Thu, 13 Apr 2006 18:27:10 +0200Quoted 20 lines
This patch contains the following possible cleanups plus changes related to them:
- make the following needlessly global functions static:
-attr.c:__nla_reserve()
-attr.c:__nla_put()
- #if 0 the following unused global functions:
-attr.c:nla_validate()
-attr.c:nla_find()
-attr.c:nla_memcpy()
-attr.c:nla_memcmp()
-attr.c:nla_strcmp()
-attr.c:nla_reserve()
-genetlink.c:genl_unregister_ops()
- remove the following unused EXPORT_SYMBOL's:
-af_netlink.c:netlink_set_nonroot
-attr.c:nla_parse
-attr.c:nla_strlcpy
-attr.c:nla_putSigned-off-by Adrian Bunk <[email protected]>
...
Quoted 1 line
Anything else where a removal might be OK?
__nla_* helpers were created for small performance optimisation if reservation is heavily used.
nla_* helpers were created to be used, but not to be removed or commented. Some of them are used in generic netlink family.
Others and genl_register/unregister_ops() might be used in recenly announced accounting patches.genl_unregister_ops() is supposed to be used in, for example, generic netlink exit path (which can not be called though).
Although it is always statically built systems, it is still very convenient way of netlink usage for others (future modular systems).
Quoted 2 lines
cu
Adrian
Signature · 1 line
Evgeniy Polyakov
Quoted 3 lines · Evgeniy Polyakov
...
Although it is always statically built systems, it is still very convenient way of netlink usage for others (future modular systems).
I do understand Dave's "new API, users are expected soon" point.
OTOH, we also have to always check whether users are expected soon (and recheck whether there are really users after some time) since every single export makes the kernel larger for nearly everyone.
Quoted 1 line
Evgeniy Polyakov
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedQuoted 3 lines · Adrian Bunk
OTOH, we also have to always check whether users are expected soon (and recheck whether there are really users after some time) since every single export makes the kernel larger for nearly everyone.
Of course fixing the amount of memory used by an EXPORT_SYMBOL would be far more productive.
Quoted 7 lines · Alan Cox
Quoted 3 lines · Adrian Bunk
OTOH, we also have to always check whether users are expected soon (and recheck whether there are really users after some time) since every single export makes the kernel larger for nearly everyone.
Of course fixing the amount of memory used by an
EXPORT_SYMBOLwould be far more productive.
Both is productive.
You can decrease the amount of memory used by an EXPORT_SYMBOL, but you can't get it down to 0.
And in some cases the memory used by an EXPORT_SYMBOL mostly consists of an otherwise unused function...
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedQuoted 4 lines · David S. Miller
These interfaces were added so that new users of netlink could write their code more easily.
Unused does not equate to "comment out or delete".
Does a GENETLINK Kconfig option make sense (possibly dependant on EMBEDDED)? I'm unsure whether these interfaces are going to be used in core networking code that can't be disabled anyway.