Date: Fri, 26 Jul 2002 21:10:50 -0700 From: Brooks Davis <brooks@one-eyed-alien.net> To: net@freebsd.org Subject: switching to if_xname from if_name and if_unit Message-ID: <20020726211050.A30598@Odin.AC.HMC.Edu>
next in thread | raw e-mail | index | archive | help
--Qxx1br4bt0+wmkIi
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
[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".
- 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 =3D (ifp->if_softc !=3D 0);
=20
ifp->if_softc =3D sc;
- ifp->if_unit =3D sc->unit;
- ifp->if_name =3D "ep";
+ sprintf(ifp->if_xname, "ep%d", sc->unit);
ifp->if_mtu =3D ETHERMTU;
ifp->if_flags =3D IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_output =3D ether_output;
@@ -917,7 +916,7 @@ ep_if_watchdog(ifp)
/*
printf("ep: watchdog\n");
=20
- log(LOG_ERR, "ep%d: watchdog\n", ifp->if_unit);
+ log(LOG_ERR, "%s: watchdog\n", ifp->if_xname);
ifp->if_oerrors++;
*/
=20
--=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
--Qxx1br4bt0+wmkIi
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE9Qh1IXY6L6fI4GtQRAquDAJ9jKQf6WETQotJOtNc+nNeA6Lc4NgCfa16L
WgNyRmierxeARLWN+JMPkpQ=
=QQr1
-----END PGP SIGNATURE-----
--Qxx1br4bt0+wmkIi--
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020726211050.A30598>
