]> git.karo-electronics.de Git - linux-beck.git/commitdiff
l2tp: auto load type modules
authorstephen hemminger <stephen@networkplumber.org>
Thu, 24 Sep 2015 04:33:34 +0000 (21:33 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 25 Sep 2015 19:27:22 +0000 (12:27 -0700)
It should not be necessary to do explicit module loading when
configuring L2TP. Modules should be loaded as needed instead
(as is done already with netlink and other tunnel types).

This patch adds a new module alias type and code to load
the sub module on demand.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/l2tp/l2tp_core.h
net/l2tp/l2tp_eth.c
net/l2tp/l2tp_netlink.c
net/l2tp/l2tp_ppp.c

index 68aa9ffd4ae4d972cdd57ea742ddf3b78ba497d6..5871537af387b2566c8ffaa79d107efaf3701fae 100644 (file)
@@ -321,4 +321,7 @@ do {                                                                        \
 #define l2tp_dbg(ptr, type, fmt, ...)                                  \
        l2tp_printk(ptr, type, pr_debug, fmt, ##__VA_ARGS__)
 
+#define MODULE_ALIAS_L2TP_PWTYPE(type) \
+       MODULE_ALIAS("net-l2tp-type-" __stringify(type))
+
 #endif /* _L2TP_CORE_H_ */
index 4b552873b55603a648f37bbd497efbb43bd869a4..e253c26f31ac378b644c925f1e44c1d4ef753e17 100644 (file)
@@ -358,3 +358,4 @@ MODULE_LICENSE("GPL");
 MODULE_AUTHOR("James Chapman <jchapman@katalix.com>");
 MODULE_DESCRIPTION("L2TP ethernet pseudowire driver");
 MODULE_VERSION("1.0");
+MODULE_ALIAS_L2TP_PWTYPE(5);
index 9e13c2ff878970fbbe355990f756684d9e868988..f93c5be612a7cb43611708ebb66c25b4db0d27cf 100644 (file)
@@ -576,6 +576,13 @@ static int l2tp_nl_cmd_session_create(struct sk_buff *skb, struct genl_info *inf
        if (info->attrs[L2TP_ATTR_MRU])
                cfg.mru = nla_get_u16(info->attrs[L2TP_ATTR_MRU]);
 
+#ifdef CONFIG_MODULES
+       if (l2tp_nl_cmd_ops[cfg.pw_type] == NULL) {
+               genl_unlock();
+               request_module("net-l2tp-type-%u", cfg.pw_type);
+               genl_lock();
+       }
+#endif
        if ((l2tp_nl_cmd_ops[cfg.pw_type] == NULL) ||
            (l2tp_nl_cmd_ops[cfg.pw_type]->session_create == NULL)) {
                ret = -EPROTONOSUPPORT;
index f56c9f69e9f288b2d1f9da53257a5f64bf5dd067..1ad18c55064cafac516d2b719d9c1ba5f09c1b03 100644 (file)
@@ -1863,3 +1863,4 @@ MODULE_DESCRIPTION("PPP over L2TP over UDP");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(PPPOL2TP_DRV_VERSION);
 MODULE_ALIAS("pppox-proto-" __stringify(PX_PROTO_OL2TP));
+MODULE_ALIAS_L2TP_PWTYPE(11);