Re: [PATCH] tun driver use private linked list.
From: Stephen Hemminger <hidden>
Date: 2003-08-12 17:02:59
On Tue, 12 Aug 2003 09:48:50 -0700 Max Krasnyansky [off-list ref] wrote:
At 01:18 AM 8/9/2003, David S. Miller wrote:quoted
On Fri, 8 Aug 2003 11:34:04 -0700 Stephen Hemminger [off-list ref] wrote:quoted
Less grotty version, applies over earlier patch. - keep a private list. - fix debug format strings. - drop the name entry in the private data structure since it already has a pointer to netdev that has name.Applied, thanks for following up on this Stephen.Folks, Sorry for jumping in late. I didn't implement cleanup logic in module_exit() because TUN module is not supposed to be unloaded if it has network devices, _even if those devices are down_. TUN registers net device only when user application asks for it. fd = open("/dev/net/tun") -> ioctl(fd, CREATE_TUN_DEV) -> read(fd)/write(fd); Net device must not be destroyed while fd is open. So instead of cleaning up in tun_module_exit() we should fix misc driver to do refcounting for misc devices so that we could bump ref count for tun driver when application creates net device.
Not necessary to change anything. If user process has /dev/net/tun open, then the owner field in the fops causes the module reference count to correctly increment. Verified this and it works. The issue is that it is possible to create TUN devices with TUN_PERSIST set and they have to be cleaned up upon. module_exit. The patch works as expected.