Interface auto-cloning bug or feature?

From: Maxim Sobolev <sobomax_at_sippysoft.com>
Date: Thu, 18 Sep 2008 17:56:53 -0700
Hi,

I've noticed that stat/open call on /dev/tun always creates new 
interface, despite the fact that existing spare interfaces may be 
available. I believe that it's a bug, since the whole purpose of 
auto-cloning is to create new instance only when no existing one could 
be allocated. At least that's my reading of the manual page for the tun(4).

<quote>
      If the sysctl(8) variable net.link.tun.devfs_cloning is non-zero, 
the tun
      interface permits opens on the special control device /dev/tun.  When
      this device is opened, tun will return a handle for the lowest 
unused tun
      device (use devname(3) to determine which).
</quote>

-Maxim

[root_at_sp1 /usr/home/sobomax]# ifconfig -a
tun0: flags=8010<POINTOPOINT,MULTICAST> mtu 1500
[root_at_sp1 /usr/home/sobomax]# stat /dev/tun
67174144 96 crw------- 1 uucp dialer 96 0 "May  2 22:21:28 2008" "May  2 
22:21:28 2008" "May  2 22:21:28 2008" "Dec 31 23:59:59 1969" 4096 0 0 
/dev/tun
[root_at_sp1 /usr/home/sobomax]# ifconfig -a
tun0: flags=8010<POINTOPOINT,MULTICAST> mtu 1500
tun1: flags=8010<POINTOPOINT,MULTICAST> mtu 1500
[root_at_sp1 /usr/home/sobomax]# stat /dev/tun
67174144 99 crw------- 1 uucp dialer 99 0 "May  2 22:21:28 2008" "May  2 
22:21:28 2008" "May  2 22:21:28 2008" "Dec 31 23:59:59 1969" 4096 0 0 
/dev/tun
[root_at_sp1 /usr/home/sobomax]# ifconfig -a
tun0: flags=8010<POINTOPOINT,MULTICAST> mtu 1500
tun1: flags=8010<POINTOPOINT,MULTICAST> mtu 1500
tun2: flags=8010<POINTOPOINT,MULTICAST> mtu 1500
[root_at_sp1 /usr/home/sobomax]# stat /dev/tun
67174144 105 crw------- 1 uucp dialer 105 0 "May  2 22:21:28 2008" "May 
  2 22:21:28 2008" "May  2 22:21:28 2008" "Dec 31 23:59:59 1969" 4096 0 
0 /dev/tun
[root_at_sp1 /usr/home/sobomax]# ifconfig -a
tun0: flags=8010<POINTOPOINT,MULTICAST> mtu 1500
tun1: flags=8010<POINTOPOINT,MULTICAST> mtu 1500
tun2: flags=8010<POINTOPOINT,MULTICAST> mtu 1500
tun3: flags=8010<POINTOPOINT,MULTICAST> mtu 1500
Received on Thu Sep 18 2008 - 23:08:46 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:35 UTC