From owner-freebsd-net@FreeBSD.ORG Thu Jun 9 06:44:55 2005 Return-Path: X-Original-To: net@freebsd.org Delivered-To: freebsd-net@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EE54516A41C; Thu, 9 Jun 2005 06:44:55 +0000 (GMT) (envelope-from brdavis@odin.ac.hmc.edu) Received: from odin.ac.hmc.edu (Odin.AC.HMC.Edu [134.173.32.75]) by mx1.FreeBSD.org (Postfix) with ESMTP id A9F3F43D49; Thu, 9 Jun 2005 06:44:53 +0000 (GMT) (envelope-from brdavis@odin.ac.hmc.edu) Received: from odin.ac.hmc.edu (localhost.localdomain [127.0.0.1]) by odin.ac.hmc.edu (8.13.0/8.13.0) with ESMTP id j596iqxi006097; Wed, 8 Jun 2005 23:44:52 -0700 Received: (from brdavis@localhost) by odin.ac.hmc.edu (8.13.0/8.13.0/Submit) id j596iqFF006096; Wed, 8 Jun 2005 23:44:52 -0700 Date: Wed, 8 Jun 2005 23:44:52 -0700 From: Brooks Davis To: current@freebsd.org Message-ID: <20050609064452.GC1595@odin.ac.hmc.edu> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="uh9ZiVrAOUUm9fzH" Content-Disposition: inline User-Agent: Mutt/1.4.1i X-Virus-Scanned: by amavisd-new X-Spam-Status: No, hits=0.0 required=8.0 tests=none autolearn=no version=2.63 X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on odin.ac.hmc.edu Cc: net@freebsd.org Subject: HEADSUP: internal network interface changes X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Jun 2005 06:44:56 -0000 --uh9ZiVrAOUUm9fzH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I plan to commit a major rework of network interface related storage Friday morning PDT. This is a massive change touching every network driver in the system. This change was discussed at the BSDCan dev summit and derives from discussions at EuroBSDCon on dealing with dynamic network devices. You can view the diff at: http://people.freebsd.org/~brooks/patches/ifnet.diff I'm not posting the diff to the list as it is nearly 700K. Below, you will find the diff to ifnet(9) for a more technical view of the API change. In short, the change removes the embedded struct ifnet and layer 2 common structures (struct arpcom, struct ifatm, struct sppp, etc) from driver softcs and replaces them with a struct ifnet pointer which is allocated with a new function, if_alloc which takes an interface type. For certain types, if_alloc also fills in the new struct ifnet member, if_l2com with an initialized layer 2 common structure. The benefits of this change are: - The size of struct ifnet and the layer 2 common structures is no longer part of the network interface ABI. This means we add features to the generic interface code so long as they do not require action on the part of the driver without breaking the ABI. - Since storage is no longer tied to the softc, we will able to reference count struct ifnet more easily which is a prerequisite for fixing the panics on removing an interface which is configured with dummynet. - This patch eliminates many ugly casts and the historically weakly documented requirement that softc's be castable to ifnet's and arpcom's. Things to note about this change: - External drivers including those in ports will panic if loaded until they are converted to the new API. Things to note about this patch: - There are nearly 100 drivers in the tree and I only use a small set of them so there are likely to be some small bugs in this patch. The changes were mostly mechanical, but varying naming conventions, plus the occasional driver written entirely from scratch introduce the possibility of errors. Use care when updating, particularly with remote systems. - In most cases, this patch does not address the issue of keeping source compatible with previous releases or other systems. I will supply patches to do so in any case where there is a need, but I intend to wait until after committing to do so. I hope the set of drivers requiring these changes will be small. -- Brooks P.S. the posted patch contains a bug in the udav driver. It will be fixed before commit. --- freebsd/share/man/man9/ifnet.9 Sun Jun 5 13:33:05 2005 +++ ifnet/share/man/man9/ifnet.9 Sun Jun 5 20:20:03 2005 @@ -46,9 +46,17 @@ .In net/if_types.h .\" .Ss "Interface Manipulation Functions" +.Ft "struct ifnet *" +.Fn if_alloc "u_char type" .Ft void .Fn if_attach "struct ifnet *ifp" .Ft void +.Fn if_detach "struct ifnet *ifp" +.Ft void +.Fn if_free "struct ifnet *ifp" +.Ft void +.Fn if_free_type "struct ifnet *ifp" "u_char type" +.Ft void .Fn if_down "struct ifnet *ifp" .Ft int .Fn ifioctl "struct socket *so" "u_long cmd" "caddr_t data" "struct thread= *td" @@ -219,6 +227,11 @@ .Pq Vt "void *" A pointer to the driver's private state block. (Initialized by driver.) +.It Va if_l2com +.Pq Vt "void *" +A pointer to the common data for the interface's layer 2 protocol. +(Initialized by +.Fn if_alloc .) .It Va if_link .Pq Fn TAILQ_ENTRY ifnet .Xr queue 3 @@ -270,6 +283,8 @@ to refer to a particular interface by index (see .Xr link_addr 3 ) . +(Initialized by +.Fn if_alloc .) .It Va if_timer .Pq Vt short Number of seconds until the watchdog timer @@ -988,6 +1003,14 @@ .El .Ss Interface Manipulation Functions .Bl -ohang -offset indent +.It Fn if_alloc +Allocate and initalize an +.Fa ifp . +Initalization includes the allocation of an interface index and may +include the allocation of a +.Fa type +specific structure in +.Va if_l2com . .It Fn if_attach Link the specified interface .Fa ifp @@ -999,6 +1022,29 @@ (A pointer to this address structure is saved in the global array .Va ifnet_addrs . ) +The +.Fa ifp +must have been allocted by +.Fn if_alloc . +.It Fn if_detach +Shutdown and unlink the specified +.Fa ifp +from the interface list. +.It Fn if_free +Free the given +.Fa ifp +back to the system. +The interface must have been previously detached if it was ever attached. +.It Fn if_free_type +Identical to +.Fn if_free +except that the given +.Fa type + is used to free=20 + .Va if_l2com + instead of the type in + .Va if_type . + This is intended for use with drivers that change their interface type. .It Fn if_down Mark the interface .Fa ifp --=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 --uh9ZiVrAOUUm9fzH Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQFCp+VjXY6L6fI4GtQRAiZ+AJ9EqZCRd5aoXmm9vFO2DeLcL1qDnACfZDyv RKUK1aWZnYOq+PvkmDsz0FM= =FHKv -----END PGP SIGNATURE----- --uh9ZiVrAOUUm9fzH--