From owner-freebsd-hackers Thu Jun 7 16:48:35 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from odin.ac.hmc.edu (Odin.AC.HMC.Edu [134.173.32.75]) by hub.freebsd.org (Postfix) with ESMTP id 8579337B401 for ; Thu, 7 Jun 2001 16:48:31 -0700 (PDT) (envelope-from brdavis@odin.ac.hmc.edu) Received: (from brdavis@localhost) by odin.ac.hmc.edu (8.11.0/8.11.0) id f57NmCV06179; Thu, 7 Jun 2001 16:48:12 -0700 Date: Thu, 7 Jun 2001 16:48:12 -0700 From: Brooks Davis To: Brian Somers Cc: Poul-Henning Kamp , hackers@FreeBSD.ORG Subject: Re: cloning network interfaces Message-ID: <20010607164812.A32379@Odin.AC.HMC.Edu> References: <200106071119.f57BJr766008@hak.lan.Awfulhak.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="1yeeQ81UyVL57Vl7" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200106071119.f57BJr766008@hak.lan.Awfulhak.org>; from brian@Awfulhak.org on Thu, Jun 07, 2001 at 12:19:53PM +0100 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --1yeeQ81UyVL57Vl7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jun 07, 2001 at 12:19:53PM +0100, Brian Somers wrote: > > The quick and dirty way: > >=20 > > Make a clone handler despite the fact that there is no /dev > > entry needed. You don't actually have to create a dev entry > > in the clone handler, you could just create the gif_interface. > >=20 > > Applications would then: > >=20 > > stat("/dev/gif345") /* Ignore error */ > > system("ifconfig gif345 bla bla bla"); > >=20 > > The slower but less dirty: > >=20 > > Make a sysctl which returns an integer which is the next > > free gif device. > >=20 > > The really slow and very dirty: > >=20 > > Implement cloning in ifconfig. >=20 > Maybe a reasonable alternative would be to have a /dev/if_gif device=20 > with ioctls for creating and destroying interfaces. ifconfig(8)=20 > could be taught to create (and maybe even to delete) them. Ok, I've got the quick and dirty way working for testing (a nine line clone handler works great for that), but I think Brian's suggestion is probably best for a real solution especialy since it's rather easier to check for permissions before allowing creation this way. My current patch lets joe user create 2^15 gif devices by doing "ls /dev/gif###" 2^15 times because I didn't have a proc structure handy. The other advantage is that it should be fairly easy to backport to -stable which is where the project I'm working on this for is currently being developed. I think I'll add a to ifconfig function styled after ifmaybeload() that trys to create interfaces if the user trys to do something with them. I'm still thinking about the right way to handle creation of new, free devices, perhaps a syntax like: ifconfig gif# where ifconfig returns the interface name the way mdconfig does when you don't specify a unit. If we decied that interfaces that want to grow this way will have a /dev/if_ device that accepts the appropriate ioctl(s), that should be fairly easy to implement so it works in all cases without further hacks to ifconfig. -- Brooks --=20 Any statement of the form "X is the one, true Y" is FALSE. PGP fingerprint 655D 519C 26A7 82E7 2529 9BF0 5D8E 8BE9 F238 1AD4 --1yeeQ81UyVL57Vl7 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE7IBK7XY6L6fI4GtQRArgRAKCTEczHrnop8a5ipQCGC3+Q/xeMPgCgrxNu pTNli7jJmp7iaLAUgpIZbmc= =tXUK -----END PGP SIGNATURE----- --1yeeQ81UyVL57Vl7-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message