[Gllug] Automatic module loading

Nix nix at esperi.org.uk
Thu Feb 22 23:36:56 UTC 2007


On 22 Feb 2007, tethys at gmail.com spake thusly:
> It's been a while since I last looked at this, and it's all changed
> since then. How can I get the kernel to automatically load a module
> when it needs it? At the moment, I get:
>
> mrburns:~# ip tunnel add foo mode gre local 1.1.1.1 remote 2.2.2.2
> ioctl: No such device
> mrburns:~# modprobe ip_gre
> mrburns:~# ip tunnel add foo mode gre local 1.1.1.1 remote 2.2.2.2

... but that's a bit different. `ip tunnel add' issues a SIOCADDTUNNEL
ioctl() on the `gre0' interface of (usually) a SOCK_DGRAM AF_INET
socket. Inside the kernel, this hits linux/net/core/dev_ioctl(),
which, for ioctl()s between SIOCDEVPRIVATE and SIOCDEVPRIVATE+15,
loads the module with the same name as the interface. SIOCADDTUNNEL
is SIOCDEVPRIVATE+1.

I suspect your only problem is that you need a module alias in
modules.conf, something like this (I hope I've got this the right way
round):

alias gre0 ip_gre

(It seems rather ridiculous that unrenameable system-level interfaces
like this don't automatically load the right module, but I suppose
nothing stops you naming an interface of your own `greek' or something
and screwing up any such code.)


(Warning: I've never tried this because I don't run modular kernels.
But hopefully armed with the info above you can add printk()s or
systemtap points sufficient to track the real problem down.)

-- 
`In the future, company names will be a 32-character hex string.'
  --- Bruce Schneier on the shortage of company names
-------------- next part --------------
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list