Subject: Re: ppp(4) made clonable
To: Quentin Garnier <cube@cubidou.net>
From: Andrew Brown <atatat@atatdot.net>
List: tech-net
Date: 08/24/2003 21:25:20
>I've been wondering why ppp(4) isn't clonable, which in my mind means
>"dynamically allocatable". Right now a static array of ppp_softcs is
>allocated, whereas some other devices such as gre(4) were made clonable
>some time ago.
>
>Maybe there is a good reason for this situation, maybe not. I'm sure
>someone here will tell me.
no *real* reason, other than no one wishing to undertake all the work
involved. strip, sl, and ppp have left for last because they are the
most complex cases. as i understand it, bridge, vlan, stf, faith,
gif, gre, and pppoe are pseudo-interfaces with no "entry-points" from
userland, besides ioctls aimed directly at them. making the tun
interface clonable required that i work out some locking issues and
deal with an interface being deleted while another process was blocked
on it.
i looked at ppp and sl a little while ago (and strip, though only in
passing, since i can't really test it very easily), and noted that
since they get bound to a serial device, you have to make damn sure
the serial device knows the interface is gone, and you have to be very
careful not to delete it while the serial port is using it. the use
of something like splserial() might apply here. then there's the
pppd. you need to make sure *it* doesn't cause problems and deals
properly with the interface being destroyed out from under it.
>Anyway, the attached patch makes ppp(4) clonable, and pppalloc()
>now allocates a new interface when it needs a new one, making pppd(8)
>usable without having to type 'ifconfig ppp%d create' for each
>interface before launching it.
>
>I have not tested it extensively yet (notably the unit number selection
>may be a bit unefficient), but it worked very well for the tests I made.
>
>There is still an issue with pppd(8) though, because at startup it tests
>for kernel PPP support by making an ioctl on ppp0, which may not exist.
>I don't know how to solve this yet, but for now the patch takes in
>account the value of NPPP to create some interfaces, starting with ppp0.
i hit this sort of thing with tun as well, and the solution was to
allocate them on demand as well as when someone explicitly tried to
create one.
>The code should recycle unit numbers to not make it grow when
>connections are made and then shut down.
>
>I made the patch usable as a kernel option, PPP_CLONABLE.
>
>If anyone could at least tell me why this haven't been done before,
>since it only took a few hours to code.
you did the easy part. now do the hard part. :)
--
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org * "ah! i see you have the internet
twofsonet@graffiti.com (Andrew Brown) that goes *ping*!"
werdna@squooshy.com * "information is power -- share the wealth."