diff mbox

net: tunnels - enable module autoloading

Message ID 1399970908-9973-1-git-send-email-teg@jklm.no
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Tom Gundersen May 13, 2014, 8:48 a.m. UTC
Enable the module alias hookup to allow tunnel modules to be autoloaded on demand.

This is in line with how most other netdev kinds work, and will allow userspace
to create tunnels without having CAP_SYS_MODULE.

Signed-off-by: Tom Gundersen <teg@jklm.no>
Tested-by: Susant Sahani <susant@redhat.com>
---
 net/ipv4/ipip.c       | 1 +
 net/ipv6/ip6_tunnel.c | 1 +
 net/ipv6/sit.c        | 1 +
 3 files changed, 3 insertions(+)

Comments

David Miller May 15, 2014, 7:37 p.m. UTC | #1
From: Tom Gundersen <teg@jklm.no>

Date: Tue, 13 May 2014 10:48:28 +0200

> Enable the module alias hookup to allow tunnel modules to be autoloaded on demand.

> 

> This is in line with how most other netdev kinds work, and will allow userspace

> to create tunnels without having CAP_SYS_MODULE.

> 

> Signed-off-by: Tom Gundersen <teg@jklm.no>

> Tested-by: Susant Sahani <susant@redhat.com>


This doesn't even compile:

  CC [M]  net/ipv4/ipip.o
In file included from include/linux/module.h:17:0,
                 from net/ipv4/ipip.c:95:
include/linux/moduleparam.h:21:1: error: expected ‘,’ or ‘;’ before ‘static’
 static const char __UNIQUE_ID(name)[]       \
 ^
include/linux/module.h:86:32: note: in expansion of macro ‘__MODULE_INFO’
 #define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
                                ^
include/linux/module.h:89:30: note: in expansion of macro ‘MODULE_INFO’
 #define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias)
                              ^
include/linux/netdevice.h:3283:2: note: in expansion of macro ‘MODULE_ALIAS’
  MODULE_ALIAS("netdev-" device)
  ^
net/ipv4/ipip.c:490:1: note: in expansion of macro ‘MODULE_ALIAS_NETDEV’
 MODULE_ALIAS_NETDEV("tunl0");
 ^
Stephen Hemminger May 15, 2014, 9:32 p.m. UTC | #2
On Tue, 13 May 2014 10:48:28 +0200
Tom Gundersen <teg@jklm.no> wrote:

> Enable the module alias hookup to allow tunnel modules to be autoloaded on demand.
> 
> This is in line with how most other netdev kinds work, and will allow userspace
> to create tunnels without having CAP_SYS_MODULE.
> 
> Signed-off-by: Tom Gundersen <teg@jklm.no>
> Tested-by: Susant Sahani <susant@redhat.com>
> ---
>  net/ipv4/ipip.c       | 1 +
>  net/ipv6/ip6_tunnel.c | 1 +
>  net/ipv6/sit.c        | 1 +
>  3 files changed, 3 insertions(+)

But tunnel modules are autoloaded now.
If I create a tunnel with ip tunnel based on the existing MODULE_ALIAS_NETDEV().

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tom Gundersen May 15, 2014, 9:42 p.m. UTC | #3
On Thu, May 15, 2014 at 11:32 PM, Stephen Hemminger
<stephen@networkplumber.org> wrote:
> On Tue, 13 May 2014 10:48:28 +0200
> Tom Gundersen <teg@jklm.no> wrote:
>
>> Enable the module alias hookup to allow tunnel modules to be autoloaded on demand.
>>
>> This is in line with how most other netdev kinds work, and will allow userspace
>> to create tunnels without having CAP_SYS_MODULE.
>>
>> Signed-off-by: Tom Gundersen <teg@jklm.no>
>> Tested-by: Susant Sahani <susant@redhat.com>
>> ---
>>  net/ipv4/ipip.c       | 1 +
>>  net/ipv6/ip6_tunnel.c | 1 +
>>  net/ipv6/sit.c        | 1 +
>>  3 files changed, 3 insertions(+)
>
> But tunnel modules are autoloaded now.
> If I create a tunnel with ip tunnel based on the existing MODULE_ALIAS_NETDEV().

Hm, please correct me if I'm wrong, but this only works if you create
a tunnel with one of the hardcoded tunnel names, right? And also, if I
read the code correctly, it only works if you use the ioctl interface
and not the rtnl interface?

What we'd like to do is to use the rtnl interface to create tunnels
with arbitrary names, is there a way this can already be done that I
have missed?

Cheers,

Tom
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index 812b183..d8155cf 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -486,4 +486,5 @@  static void __exit ipip_fini(void)
 module_init(ipip_init);
 module_exit(ipip_fini);
 MODULE_LICENSE("GPL");
+MODULE_ALIAS_RTNL_LINK("ipip")
 MODULE_ALIAS_NETDEV("tunl0");
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index b05b609..fe61545 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -61,6 +61,7 @@ 
 MODULE_AUTHOR("Ville Nuorvala");
 MODULE_DESCRIPTION("IPv6 tunneling device");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS_RTNL_LINK("ip6tnl");
 MODULE_ALIAS_NETDEV("ip6tnl0");
 
 #ifdef IP6_TNL_DEBUG
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index e5a453c..f438004 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -1828,4 +1828,5 @@  xfrm_tunnel_failed:
 module_init(sit_init);
 module_exit(sit_cleanup);
 MODULE_LICENSE("GPL");
+MODULE_ALIAS_RTNL_LINK("sit");
 MODULE_ALIAS_NETDEV("sit0");