tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: if_tun module doesn't autoload if opening /dev/tunN



FWIW, even if you manually create the tun0 interface with ifconfig, it is not accessible via /dev/tun0 - accessing the /dev/tun0 node results in ENXIO (errno == 6, Device not configured).

I suspect that similar issues may well exist with other "cloners" such as if_tap ... (Note that if_gif, if_gre, if_ppp, and if_pppoe do not claim to be accessible via /dev so there shouldn't be any problems...)

I'll try to have a look at these sometime in the next few days, but if anyone else wants to dive in, please don't hesitate! :)



On Wed, 7 Sep 2016, Paul Goyette wrote:

According to the tun(4) man page, you can create an interface "by using the ifconfig(8) create command" and this works just fine. The man page goes on to say "An open() call on /dev/tunN, will also create a network interface..." but this does not work.

I think this is because the code in sys/miscfs/specfs/spec_vnops.c assumes that the module name is the same as the device name, ie it expects that /dev/tunN will be handled by module tun.kmod However, the module is actually named if_tun.kmod so it never gets loaded, and the open() fails.

I can see a couple of ways to "fix" this:

	1. Rename the module (with all appropriate updates to the
	   sets lists in src/distrib/sets/lists), or
	2. Add code to spec_vnops.c to try loading module if_xxx if the
	   autoload of module xxx fails.

Comments?  Preferences?  Any other options I haven't yet seen?


+------------------+--------------------------+------------------------+
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:      |
| (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
+------------------+--------------------------+------------------------+


+------------------+--------------------------+------------------------+
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:      |
| (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
+------------------+--------------------------+------------------------+


Home | Main Index | Thread Index | Old Index