Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Jun 2001 16:48:12 -0700
From:      Brooks Davis <brooks@one-eyed-alien.net>
To:        Brian Somers <brian@Awfulhak.org>
Cc:        Poul-Henning Kamp <phk@critter.freebsd.dk>, hackers@FreeBSD.ORG
Subject:   Re: cloning network interfaces
Message-ID:  <20010607164812.A32379@Odin.AC.HMC.Edu>
In-Reply-To: <200106071119.f57BJr766008@hak.lan.Awfulhak.org>; from brian@Awfulhak.org on Thu, Jun 07, 2001 at 12:19:53PM %2B0100
References:  <phk@critter.freebsd.dk> <200106071119.f57BJr766008@hak.lan.Awfulhak.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--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_<name> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010607164812.A32379>