From owner-freebsd-net Sat Jul 27 2:54:14 2002 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 3AA5E37B400 for ; Sat, 27 Jul 2002 02:54:09 -0700 (PDT) Received: from mailtoaster1.pipeline.ch (mailtoaster1.pipeline.ch [62.48.0.70]) by mx1.FreeBSD.org (Postfix) with SMTP id 0A7BB43E31 for ; Sat, 27 Jul 2002 02:54:08 -0700 (PDT) (envelope-from oppermann@pipeline.ch) Received: (qmail 43166 invoked from network); 27 Jul 2002 09:52:39 -0000 Received: from unknown (HELO pipeline.ch) ([62.48.0.53]) (envelope-sender ) by mailtoaster1.pipeline.ch (qmail-ldap-1.03) with SMTP for ; 27 Jul 2002 09:52:39 -0000 Message-ID: <3D426DA0.923B7F81@pipeline.ch> Date: Sat, 27 Jul 2002 11:53:36 +0200 From: Andre Oppermann X-Mailer: Mozilla 4.76 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: Brooks Davis Cc: net@freebsd.org Subject: Re: switching to if_xname from if_name and if_unit References: <20020726211050.A30598@Odin.AC.HMC.Edu> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org Brooks Davis wrote: > > [Bcc to -arch for interested people not on -net] > > NetBSD and OpenBSD have replaced the "char *if_name" and "int if_unit" > members of struct ifnet with "char if_xname[IFNAMESIZ]". I propose that > we follow suit. > > Pros: > - Better source compatibility with NetBSD and OpenBSD. > - The ability to handle free-form device names. This could allow > things like and advanced cloning interface for vlans that let you > configure vlan X on interface nameY with "ifconfig nameY.X create". I like this one ;-) I vote yes for doing this change. -- Andre > - Most uses of if_name and if_unit together really just want the full > name of the device and the same with the majority of if_unit > entries. The remaining if_unit usages are usually the result of > sloppy code with hard wired limits on the number of devices that > should be fixed. > - We can implement the if_name() function without the current gross > hacks. > - Well defined maximum name size simplifies code. > > Cons: > - Lost of source compatibility between 5.x and previous versions. > [We've already lost it with the spls and in most drivers it's > a two line change that you could handle with __FreeBSD_version if > you wanted to.] > - A few devices do have a legitimate use for use for the unit. [They > can use the softc to store it. That's what NetBSD did.] > - Well defined maximum name size limits length of name. [It's 16 > bytes with is more then I'd want to type in to ifconfig.] > - It touches 140-150 files. [Most of the changes are minor in nature > and I'm about halfway through with 2-3hrs of work.] > - Slight bloating of struct ifnet (8 bytes on normal 32-bit > architectures). [None on 64-bit arches.] > - We've resisted for 8 years, we can't stop now. :-) > > What do other people think? > > -- Brooks > > PS. Here the diff for a typical interface (around half have only the > initialization change and most others have more, but similar debugging > output changes): > > RCS file: /usr/cvs/src/sys/dev/ep/if_ep.c,v > retrieving revision 1.109 > diff -u -p -r1.109 if_ep.c > --- ep/if_ep.c 20 Mar 2002 02:07:19 -0000 1.109 > +++ ep/if_ep.c 26 Jul 2002 06:55:58 -0000 > @@ -280,8 +280,7 @@ ep_attach(sc) > attached = (ifp->if_softc != 0); > > ifp->if_softc = sc; > - ifp->if_unit = sc->unit; > - ifp->if_name = "ep"; > + sprintf(ifp->if_xname, "ep%d", sc->unit); > ifp->if_mtu = ETHERMTU; > ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; > ifp->if_output = ether_output; > @@ -917,7 +916,7 @@ ep_if_watchdog(ifp) > /* > printf("ep: watchdog\n"); > > - log(LOG_ERR, "ep%d: watchdog\n", ifp->if_unit); > + log(LOG_ERR, "%s: watchdog\n", ifp->if_xname); > ifp->if_oerrors++; > */ > > > -- > 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 > > ------------------------------------------------------------------------ > Part 1.2Type: application/pgp-signature To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message