niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » *nix » BSD » FreeBSD » mail-lists » Architecture
switching to if_xname from if_name and if_unit
Post new topic   Reply to topic Page 1 of 1 [1 Post] View previous topic :: View next topic
Author Message
Brooks Davis
*nix forums addict


Joined: 14 Jun 2002
Posts: 97

PostPosted: Sat Jul 27, 2002 2:10 am    Post subject: switching to if_xname from if_name and if_unit Reply with quote

[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 = (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
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [1 Post] View previous topic :: View next topic
The time now is Fri Jan 09, 2009 3:49 am | All times are GMT
navigation Forum index » *nix » BSD » FreeBSD » mail-lists » Architecture
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Switching from Plesk to Webmin matt3830 networking 0 Fri Jul 21, 2006 9:09 am
No new posts switching users in cgi s99999999s2003@yahoo.com python 0 Fri Jul 07, 2006 8:07 am
No new posts switching between dynamic and static IP on wifi laptop? idiotprogrammer networking 3 Tue Jun 27, 2006 5:56 pm
No new posts Mandrivia 2006: switching users/desktops does not work andy.leszczynski@gmail.co Mandrake 0 Mon Jun 26, 2006 5:43 pm
No new posts switching between desktop and consoles takes long time H.S. Debian 3 Tue Jun 20, 2006 5:00 am

Mortgages uk | Bad Credit Mortgages | Debt Help | Loans | Loans
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1096s ][ Queries: 16 (0.0312s) ][ GZIP on - Debug on ]