Skip to content

Commit f1f39f9

Browse files
shemmingerdavem330
authored andcommitted
l2tp: auto load type modules
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f37db85 commit f1f39f9

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

net/l2tp/l2tp_core.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,4 +321,7 @@ do { \
321321
#define l2tp_dbg(ptr, type, fmt, ...) \
322322
l2tp_printk(ptr, type, pr_debug, fmt, ##__VA_ARGS__)
323323

324+
#define MODULE_ALIAS_L2TP_PWTYPE(type) \
325+
MODULE_ALIAS("net-l2tp-type-" __stringify(type))
326+
324327
#endif /* _L2TP_CORE_H_ */

net/l2tp/l2tp_eth.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,3 +358,4 @@ MODULE_LICENSE("GPL");
358358
MODULE_AUTHOR("James Chapman <[email protected]>");
359359
MODULE_DESCRIPTION("L2TP ethernet pseudowire driver");
360360
MODULE_VERSION("1.0");
361+
MODULE_ALIAS_L2TP_PWTYPE(5);

net/l2tp/l2tp_netlink.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,13 @@ static int l2tp_nl_cmd_session_create(struct sk_buff *skb, struct genl_info *inf
576576
if (info->attrs[L2TP_ATTR_MRU])
577577
cfg.mru = nla_get_u16(info->attrs[L2TP_ATTR_MRU]);
578578

579+
#ifdef CONFIG_MODULES
580+
if (l2tp_nl_cmd_ops[cfg.pw_type] == NULL) {
581+
genl_unlock();
582+
request_module("net-l2tp-type-%u", cfg.pw_type);
583+
genl_lock();
584+
}
585+
#endif
579586
if ((l2tp_nl_cmd_ops[cfg.pw_type] == NULL) ||
580587
(l2tp_nl_cmd_ops[cfg.pw_type]->session_create == NULL)) {
581588
ret = -EPROTONOSUPPORT;

net/l2tp/l2tp_ppp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,3 +1863,4 @@ MODULE_DESCRIPTION("PPP over L2TP over UDP");
18631863
MODULE_LICENSE("GPL");
18641864
MODULE_VERSION(PPPOL2TP_DRV_VERSION);
18651865
MODULE_ALIAS("pppox-proto-" __stringify(PX_PROTO_OL2TP));
1866+
MODULE_ALIAS_L2TP_PWTYPE(11);

0 commit comments

Comments
 (0)