From owner-freebsd-arch Wed May 30 2:15:25 2001 Delivered-To: freebsd-arch@freebsd.org Received: from Awfulhak.org (awfulhak.demon.co.uk [194.222.196.252]) by hub.freebsd.org (Postfix) with ESMTP id A04AD37B422 for ; Wed, 30 May 2001 02:15:20 -0700 (PDT) (envelope-from brian@Awfulhak.org) Received: from hak.lan.Awfulhak.org (root@hak.lan.Awfulhak.org [172.16.0.12]) by Awfulhak.org (8.11.3/8.11.3) with ESMTP id f4U9F9Y75201; Wed, 30 May 2001 10:15:10 +0100 (BST) (envelope-from brian@lan.Awfulhak.org) Received: from hak.lan.Awfulhak.org (brian@localhost [127.0.0.1]) by hak.lan.Awfulhak.org (8.11.3/8.11.3) with ESMTP id f4U9F9H32416; Wed, 30 May 2001 10:15:09 +0100 (BST) (envelope-from brian@hak.lan.Awfulhak.org) Message-Id: <200105300915.f4U9F9H32416@hak.lan.Awfulhak.org> X-Mailer: exmh version 2.3.1 01/18/2001 with nmh-1.0.4 To: Poul-Henning Kamp Cc: Brian Somers , freebsd-arch@FreeBSD.ORG, brian@Awfulhak.org Subject: Re: How to handle cloning in a pseudo device. In-Reply-To: Message from Poul-Henning Kamp of "Wed, 30 May 2001 10:48:47 +0200." <39755.991212527@critter> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Wed, 30 May 2001 10:15:09 +0100 From: Brian Somers Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > What you should do when people try to acccess /dev/tun is to > create a hitherto unopened unit on the tunnel and mark the > dev_t "CHEAP_CLONE". > > If people just do an ls -l /dev/tun they get a random line > and that dev_t will be GC'ed pretty quickly. The problem I had was this: $ sudo kldload if_tun $ touch /dev/tun $ sudo kldunload if_tun $ ls -l /dev/tun* The machine froze at that point - I assumed because if_tun hadn't destroy_dev()d tun0 (I haven't got the code any more so I can't give any more info right now). I'm not clear about when devfs_reclaim() gets called (resulting in an auto-destroy_dev)) ? Is that done by the syncer or something ? I've mucked about with setting a 5 second timeout after calling make_dev() from the clone routine, but it doesn't exactly give me a warm feeling of doing things right :-/ > If they open /dev/tun they get a device and the tunopen allocates > a softc and the dev_t stays. When you close, remove the softc > and the dev_t should be reclaimed again. > > -- > Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 > phk@FreeBSD.ORG | TCP/IP since RFC 956 > FreeBSD committer | BSD since 4.3-tahoe > Never attribute to malice what can adequately be explained by incompetence. -- Brian Don't _EVER_ lose your sense of humour ! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message