Subject: Attack of the clones: turning sl*, strip*, ppp* into cloners.
To: None <>
From: Bill Sommerfeld <>
List: tech-net
Date: 02/23/2002 13:56:55
Since the interface-cloning mechanism was introduced into -current a
while back, a few interfaces which probably should have been converted

I spend a half-hour clonifying sl* and strip* on an airplane
yesterday, and will do likewise to ppp*.  

Before I commit it I wanted to talk a bit about the user-visible
ramifications of this, and ways we could make the transition as simple
as posible.

The code I currently have requires users of these interfaces to do
"ifconfig ppp0 create" etc., before starting pppd; likewise for sl*
and strip*; there's fundamentally no reason why we couldn't change
slattach/pppd to do the interface create as well.

Meanwhile, some folks have mentioned to me a desire to allow the admin
to specify the interface instance to attach to the tty; this clearly
simplifies things like ipf and ipnat configurations.  This turns out
to be somewhat tricky -- the interface instance is selected in the tty
line-discipline open routine and there's no way with the current line
discipline interface to specify the interface instance.

[I considered, and rejected, allowing the interface <-> tty binding to
be changed after the line discipline is opened as potentially too
disruptive to the existing code.]

Two interfaces need to change/be augmented to enable the interface
instance to be specified when the line discipline is set:

 1) TIOC{G,S}LINED, which is the ioctl used to change the line
discipline from whatever it was into the networking line discipline

 2) the line discipline open routine needs to know the requested unit

I'll deal with each of these in turn.

1) TIOCSLINED takes an up-to-32-character string identifying the line
discipline.  We could change the code which parses this to interpret
an optional trailing decimal integer as a unit number, and pass this
to the line discipline open routine; alternatively, we could introduce
a parallel pair of ioctl requests which take a line discipline and a
ldisc-specific parameter.

2) two options:

 a) we change the signature of (struct linesw)'s l_open routine to take
a third "int" parameter.

	int	(*l_open)(dev_t dev, struct tty *tp, int unit);

If "unit" is non-negative, the unit number is unspecified, and the
ldisc should just pick one; if non-negative, it's the unit number to

 b) we add an "int t_lunit;" field to "struct tty", defaulting to
"-1"; TIOCSLINED fills it in before calling the line discipline's
l_open routine if one was specified.

I think I prefer "b" as it involves fewer code changes.


					- Bill