* [PATCH 1/3] net: add MODULE_ALIAS_NET_PF_PROTO_NAME
2012-05-29 19:30 [PATCH 0/3] net: implement auto-loading of generic netlink modules Neil Horman
@ 2012-05-29 19:30 ` Neil Horman
2012-05-29 19:30 ` [PATCH 2/3] genetlink: Build a generic netlink family module alias Neil Horman
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Neil Horman @ 2012-05-29 19:30 UTC (permalink / raw)
To: netdev; +Cc: Neil Horman, Eric Dumazet, David Miller
The MODULE_ALAIS_NET_PF macro set is missing a variant that allows for the
appending of an arbitrary string to the net-pf-<x>-proto-<y> base. while
MODULE_ALIAS_NET_PF_PROTO_NAME_TYPE allows an appending of a numerical type, we
need to be able to append a generic string to support generic netlink families
that have neither a fix numberical protocol or type number
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: Eric Dumazet <eric.dumazet@gmail.com>
CC: David Miller <davem@davemloft.net>
---
include/linux/net.h | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/include/linux/net.h b/include/linux/net.h
index 2d7510f..e9ac2df 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -313,5 +313,8 @@ extern int kernel_sock_shutdown(struct socket *sock,
MODULE_ALIAS("net-pf-" __stringify(pf) "-proto-" __stringify(proto) \
"-type-" __stringify(type))
+#define MODULE_ALIAS_NET_PF_PROTO_NAME(pf, proto, name) \
+ MODULE_ALIAS("net-pf-" __stringify(pf) "-proto-" __stringify(proto) \
+ name)
#endif /* __KERNEL__ */
#endif /* _LINUX_NET_H */
--
1.7.7.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] genetlink: Build a generic netlink family module alias
2012-05-29 19:30 [PATCH 0/3] net: implement auto-loading of generic netlink modules Neil Horman
2012-05-29 19:30 ` [PATCH 1/3] net: add MODULE_ALIAS_NET_PF_PROTO_NAME Neil Horman
@ 2012-05-29 19:30 ` Neil Horman
2012-05-29 19:30 ` [PATCH 3/3] drop_monitor: Add module alias to enable automatic module loading Neil Horman
2012-05-30 2:34 ` [PATCH 0/3] net: implement auto-loading of generic netlink modules David Miller
3 siblings, 0 replies; 5+ messages in thread
From: Neil Horman @ 2012-05-29 19:30 UTC (permalink / raw)
To: netdev; +Cc: Neil Horman, Eric Dumazet, James Chapman, David Miller
Generic netlink searches for -type- formatted aliases when requesting a module to
fulfill a protocol request (i.e. net-pf-16-proto-16-type-<x>, where x is a type
value). However generic netlink protocols have no well defined type numbers,
they have string names. Modify genl_ctrl_getfamily to request an alias in the
format net-pf-16-proto-16-family-<x> instead, where x is a generic string, and
add a macro that builds on the previously added MODULE_ALIAS_NET_PF_PROTO_NAME
macro to allow modules to specifify those generic strings.
Note, l2tp previously hacked together an net-pf-16-proto-16-type-l2tp alias
using the MODULE_ALIAS macro, with these updates we can convert that to use the
PROTO_NAME macro.
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: Eric Dumazet <eric.dumazet@gmail.com>
CC: James Chapman <jchapman@katalix.com>
CC: David Miller <davem@davemloft.net>
---
include/linux/genetlink.h | 3 +++
net/l2tp/l2tp_netlink.c | 3 +--
net/netlink/genetlink.c | 2 +-
3 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/include/linux/genetlink.h b/include/linux/genetlink.h
index 73c28de..7a11401 100644
--- a/include/linux/genetlink.h
+++ b/include/linux/genetlink.h
@@ -110,6 +110,9 @@ extern int lockdep_genl_is_held(void);
#define genl_dereference(p) \
rcu_dereference_protected(p, lockdep_genl_is_held())
+#define MODULE_ALIAS_GENL_FAMILY(family)\
+ MODULE_ALIAS_NET_PF_PROTO_NAME(PF_NETLINK, NETLINK_GENERIC, "-family-" family)
+
#endif /* __KERNEL__ */
#endif /* __LINUX_GENERIC_NETLINK_H */
diff --git a/net/l2tp/l2tp_netlink.c b/net/l2tp/l2tp_netlink.c
index 8577264..ddc553e 100644
--- a/net/l2tp/l2tp_netlink.c
+++ b/net/l2tp/l2tp_netlink.c
@@ -923,5 +923,4 @@ MODULE_AUTHOR("James Chapman <jchapman@katalix.com>");
MODULE_DESCRIPTION("L2TP netlink");
MODULE_LICENSE("GPL");
MODULE_VERSION("1.0");
-MODULE_ALIAS("net-pf-" __stringify(PF_NETLINK) "-proto-" \
- __stringify(NETLINK_GENERIC) "-type-" "l2tp");
+MODULE_ALIAS_GENL_FAMILY("l2tp");
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 8340ace..2cc7c1e 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -836,7 +836,7 @@ static int ctrl_getfamily(struct sk_buff *skb, struct genl_info *info)
#ifdef CONFIG_MODULES
if (res == NULL) {
genl_unlock();
- request_module("net-pf-%d-proto-%d-type-%s",
+ request_module("net-pf-%d-proto-%d-family-%s",
PF_NETLINK, NETLINK_GENERIC, name);
genl_lock();
res = genl_family_find_byname(name);
--
1.7.7.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] drop_monitor: Add module alias to enable automatic module loading
2012-05-29 19:30 [PATCH 0/3] net: implement auto-loading of generic netlink modules Neil Horman
2012-05-29 19:30 ` [PATCH 1/3] net: add MODULE_ALIAS_NET_PF_PROTO_NAME Neil Horman
2012-05-29 19:30 ` [PATCH 2/3] genetlink: Build a generic netlink family module alias Neil Horman
@ 2012-05-29 19:30 ` Neil Horman
2012-05-30 2:34 ` [PATCH 0/3] net: implement auto-loading of generic netlink modules David Miller
3 siblings, 0 replies; 5+ messages in thread
From: Neil Horman @ 2012-05-29 19:30 UTC (permalink / raw)
To: netdev; +Cc: Neil Horman, Eric Dumazet, David Miller
Now that we have module alias macros for generic netlink families, lets use
those to mark modules with the appropriate family names for loading
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: Eric Dumazet <eric.dumazet@gmail.com>
CC: David Miller <davem@davemloft.net>
---
net/core/drop_monitor.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
index 3252e7e..ea5fb9f 100644
--- a/net/core/drop_monitor.c
+++ b/net/core/drop_monitor.c
@@ -468,3 +468,4 @@ module_exit(exit_net_drop_monitor);
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Neil Horman <nhorman@tuxdriver.com>");
+MODULE_ALIAS_GENL_FAMILY("NET_DM");
--
1.7.7.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3] net: implement auto-loading of generic netlink modules
2012-05-29 19:30 [PATCH 0/3] net: implement auto-loading of generic netlink modules Neil Horman
` (2 preceding siblings ...)
2012-05-29 19:30 ` [PATCH 3/3] drop_monitor: Add module alias to enable automatic module loading Neil Horman
@ 2012-05-30 2:34 ` David Miller
3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2012-05-30 2:34 UTC (permalink / raw)
To: nhorman; +Cc: netdev, eric.dumazet, jchapman
From: Neil Horman <nhorman@tuxdriver.com>
Date: Tue, 29 May 2012 15:30:39 -0400
>
> Eric D. recently noted that the drop_monitor module didn't autoload when the
> dropwatch user space utility started. Looking into this I noted that theres no
> formal macro set to define module aliases that can be used by a request module
> call in the generic netlink family lookup path. Currenlty the
> net-pf-*-proto-*-type-<n> format is used, but the macros which form this expect
> <n> to be a well defined integer, which generic netlink doesn't use for family
> definitions. So this series creates a new macro that create a
> net-pf-*-proto-*-name format where name can be any arbitrary string, allowing us
> to apend family-<x> where x is a generic netlink family name. With these
> macros, we can easily autoload modules that register generic netlink families
>
> Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Looks great, all applied, thanks Neil.
^ permalink raw reply [flat|nested] 5+ messages in thread