Bug 17758

Summary: Make sl driver dynamicallly expandable.
Product: Base System Reporter: dwmalone <dwmalone>
Component: kernAssignee: Brian Feldman <green>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 5.0-CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description dwmalone 2000-04-02 21:40:01 UTC
Currently you need to give the numbes of slip units in the kernel
config file. I include a patch which allocates units dynamically
as they are required. The patch is based on the tun driver and the
recent ability to delete interfaces which are no longer required.

One or two points of the patch are slightly tricky, so I'll explain
them here. These points relate to the fact that slip driver has an
ioctl which allows you to select what slip unit number you want.

First, if you specifically select a unit number, that unit is marked
as static and will not be handed out dynamically (ie. when SLIPDISC
is first selected for a tty). This used to be stored in the sl_softc
using the SC_STATIC flag, however as the new code now deallocates
sl_softc structs that are no longer in use it seemed a waste to
store a whole softc struct to just remember that it shouldn't be
handed out dynamically. For this reason I just store an array of
unit numbers which are to be considered static. The array is
explanded as necessary.

Second, the unit selecting code had become really complicated. It
swapped the contents of two softcs, and then swapped the contained
if structs back again. It seems these acrobatics aimed to ensure
that the linked list of interfaces didn't get screwed up. However
interfaces can now be deleted, and I wanted to deallocate the struct
softcs while they were no longer in use, so this code is now somewhat
more straight forward. (I don't understand why the cblocks are
reallocated after selecting a new unit number, it may now be
unnecessary).

The other changes just relate to the fact that the old driver got
the softc from sl_softc[ifp->if_unit] instead of ifp->if_softc.
Other than that I've tried to use the old code as much as possible.

(The only code which is a bit less efficient would be the code which
finds a free unit number. This could be improved by sorting the list
of static unit numbers and the list of existing slip devices, but it
doesn't seem worth the extra complexity).

I've given this patch some testing configuring one/both of my serial
ports as slip interfaces in various ways, and it seems to work fine.

How-To-Repeat: 
Try to use more slip devices than you have configured.
Comment 1 Sheldon Hearn freebsd_committer freebsd_triage 2000-04-03 13:56:48 UTC
Responsible Changed
From-To: freebsd-bugs->green

I'm trying to twist Brian's rubber arm into taking this one. :-) 
Comment 2 Brian Feldman freebsd_committer freebsd_triage 2000-05-17 02:38:00 UTC
State Changed
From-To: open->feedback

I want to commit this, but I cannot test it.  Can you give it a stamp of 
"I know that this consistently and definitely works in daily use"? 
Comment 3 Brian Feldman freebsd_committer freebsd_triage 2002-03-20 00:07:32 UTC
State Changed
From-To: feedback->closed

This was closed so long ago the originator is a committer now :)