Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 35736 - New feature: Configuring MII types in /etc/conf.d/net
Summary: New feature: Configuring MII types in /etc/conf.d/net
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Aron Griffis (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-12-13 09:16 UTC by Christian Birchinger (RETIRED)
Modified: 2004-05-06 13:05 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
patch for init.d/net.* (init.d-net-media.patch,1.08 KB, patch)
2003-12-13 09:18 UTC, Christian Birchinger (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Birchinger (RETIRED) gentoo-dev 2003-12-13 09:16:28 UTC
It would be great if it would be possible to force MII types in the network-config
because some big vendor seems to have problem with autoneg. on their switches

I edited conf.d and init.d to allow this. (Files will be attached to this report)

Reproducible: Always
Steps to Reproduce:
1. (none)
2.
3.

Actual Results:  
(none)

Expected Results:  
(none)
Comment 1 Christian Birchinger (RETIRED) gentoo-dev 2003-12-13 09:18:06 UTC
Created attachment 22140 [details, diff]
patch for init.d/net.*

Additional entries in /etc/conf.d/net are needed:

# MII settings for an interface. If none set, the driver and hardware defaults
are being used.
# (auto, 100baseTx-FD, 100baseTx-HD, 10baseT-FD, or 10baseT-HD)
#
# WARNING: Some drivers don't support this feature
#
#media_eth0="100baseTx-FD"
Comment 2 Aron Griffis (RETIRED) gentoo-dev 2004-03-09 15:55:09 UTC
Rather than this approach, how about being able to define functions in /etc/conf.d/net which would be run automatically?  For example:

preup() {
  local iface=${1}
  case $iface in
  eth0)
    ebegin "Forcing 100baseTx-FD on $iface"
    /sbin/mii-tool --force=100baseTx-FD $iface >/dev/null
    eend $? "Failed to force $iface to 100baseTx-FD"
    return $? ;;
  *)
    return 0 ;;
  esac
}

Additionally postup(), predown(), postdown() could be declared.  I think this would handle many edge cases that aren't currently handled by net.eth0.  What do you think?
Comment 3 Grant Goodyear (RETIRED) gentoo-dev 2004-03-09 17:59:31 UTC
Just to add another thought, OpenBSD uses a system similar to ours (although
they have a one-interface-per-file approach).  As the config files are read, 
any line in the file starting with a "!" is executed by the shell.
Using that syntax it's pretty easy to customize interfaces.  Not as full-
featured a solution as Aron's, but perhaps simpler.
Comment 4 Christian Birchinger (RETIRED) gentoo-dev 2004-03-10 02:38:15 UTC
Well i think setting mediatype is a basic. Every large company with overpriced
switches need static mediatype settings. I don't think the user should be needed
to add a script to this. It should be as easy as setting a default gw or an alias.

Ofcourse an optional script is never wrong for really obscure stuff. (I had to hack a "route add -host" because i split a subnet on 2 interfaces and use proxy_arp). This is the right place for a free definable script.
But i think mediatype should be really a basic and be settable with media_ethX.
Comment 5 Aron Griffis (RETIRED) gentoo-dev 2004-03-10 05:57:41 UTC
Grant, regarding comment #3, I'm wondering if I just made the example too complex for your taste.  It could have just been the following if all interfaces were to be affected.

preup() { 
  /sbin/mii-tool --force=100baseTx-FD ${IFACE}
}

I think this is better than OpenBSD's approach because it (1) uses the power of bash, which we have at our disposal and would be silly to ignore, (2) doesn't require caching up the !lines to eventually run as a script/function anyway.

Joker, regarding comment #4, setting mediatype is only a basic for a few users, particularly those users you mention.  It's extra cruft if we add it to net.eth0, which I would like to simplify at this point rather than complexify.  Azarah has stated the same opinion in related bugs.  Additionally mii-tool does not work for all drivers, and further I don't want baselayout to depend on mii-tool.  Finally, it's easy to get an invalid network configuration playing with mii-tool, for example 100baseTx-FD paired with an auto-negotiating switch will leave you wondering where all your packets are going.  For all of these reasons I'm not going to add direct support for this to net.eth0 via media_eth0

Most recent version of net.eth0 with support for the functions mentioned in comment #2 is at http://gentoo.org/~agriffis/net.eth0
Comment 6 Christian Birchinger (RETIRED) gentoo-dev 2004-03-10 06:25:30 UTC
mii-tools is provided by sys-apps/net-tools and that's a base package anyway
since it provides arp, ifconfig etc. There is no dependency for a "special tool".
(too bad it's not really usable directly from ifconfig like on freebsd)

I never said it should be enabled by default. media_XXX is commented out by default ofcourse. The same way as vlan or aliases are commented out.
Comment 7 Gustavo Zacarias (RETIRED) gentoo-dev 2004-03-10 06:36:59 UTC
It could be done as an undocumented feature for experts.
In any case there are many scenarios where media type should be forced, like bad NIC / Switch combos.
Good example is sunhme against some cisco switches.
Comment 8 Colin Morey (RETIRED) gentoo-dev 2004-03-10 06:46:47 UTC
I agree with the ability to force MII settings is pretty much a must have, if it's by setting media_eth0="100baseTx-FD" then that's fine, having a pre-up and post-up may be more powerful, for example updating resolv.conf or routing based on what interfaces are up.
i'd vote for the former as one that's less likely to cause problems, but having (documented)support for preup postup etc functions would be nice as well. I can't see there being any problem with having the ability to do both, why can't the presence of media_ call a default preup/postup function to do the work?
Comment 9 Aron Griffis (RETIRED) gentoo-dev 2004-03-10 06:54:05 UTC
Joker, regarding comment #6, the problem is that I don't like where this is going.  Let me explain...  First, mii-tool has capabilities beyond what your snippet handles, for example --advertise.  Second, I am personally working on 10 Gbit drivers which use some custom tools for configuration.  These would not work with mii-tool and would require preup() anyway, so why include direct support for mii-tool in net.eth0?  (I'm just using my personal work as an example of a situation where mii-tool is not sufficient)

So already this is leading to more bug reports:
  "media_eth0 not sufficient for my needs"
  "need support for additional mii tools"
  etc.

The point is that preup() handles these situations in a way that is simple, not dependent on mii-tool, and should lead to fewer bug reports against net.eth0 instead of more.  I don't see any reason to use media_eth0 instead of preup().  Every system administrator for whom this is an issue should be able to write one line of bash.

Slightly OT, but it occurs to me that this is adherence to the worse-is-better approach of software engineering (see http://www.jwz.org/doc/worse-is-better.html) because it keeps the design and implementation simple.
Comment 10 Aron Griffis (RETIRED) gentoo-dev 2004-03-10 07:03:10 UTC
Btw, Joker, as you mentioned that media_eth0 could be commented out in the default /etc/conf.d/net, I'm thinking we could have a commented out preup() which calls mii-tool as an example.  That would make it easy for people that need this functionality.
Comment 11 Christian Birchinger (RETIRED) gentoo-dev 2004-03-10 08:05:47 UTC
I'm not against a preup(). I just say media_xxx should be provided with the generic config without cusotm scripting. It's important enough for that i think.
Personaly i think stuff like vlan is much less used than static media options.
And vlan even needs additional tools. mii-tool is part of the same package as ifconfig and people who don't add a media_xxxx option in "conf.d/net" don't
break or even notice anything. I don't see it more dangerous as any other manual hack a user can do to break his gentoo.

Ofcourse everything can be done with customized scripts (i even need a customized /etc/init.d/net.eth2 because not everything can be done with the options).

But media is a basic thing which for example can even configured in windows
on the main networkcard config.

And every company i worked for had strict rules to only use configured media
types and never use autoneg.

I know a $20 switch at home can do autosens quiet well. But oviously $2000
equipment fails alot.

The config in "net" will never fit the needs of all users. So some people will
always need scripting. Only basic setups can be configured with normal variables.
I think the only difference we have is that i think media is a basic option
which needs a var and you don't. Just the same way as i think vlan isn't needed
in a basic networkconfig. But i don't think it's bad since it's fully optional.
The same way as media would be fully optional and disabled by default.
Comment 12 Aron Griffis (RETIRED) gentoo-dev 2004-03-10 09:22:25 UTC
Joker, I'll respond point-by-point...

> I'm not against a preup(). I just say media_xxx should be provided
> with the generic config without cusotm scripting. It's important
> enough for that i think.

As mentioned earlier, media_xxx is not flexible enough.  Regarding
custom scripting, we are talking about the difference between:

    media_eth0="100baseTx-FD"

        vs.

    preup() {
        [[ $IFACE == eth0 ]] && /sbin/mii-tool --force=100baseTx-FD eth0         
        return 0
    }

I personally think that billing this as "custom scripting" is a little
heavy of a term ;-)  Regarding "important enough," I agree completely!
I just want to do it in a generic way instead of using media_eth0

> Personaly i think stuff like vlan is much less used than static
> media options.
> And vlan even needs additional tools. 

Yes, IMHO it's too bad that vlan stuff is in net.eth0 already.  It
would be better in postup() but would be difficult to remove now
because that would introduce a regression.  :-(

However the presence of vlan in net.eth0 doesn't mean that more cruft
should be added.

> mii-tool is part of the same package as ifconfig and people who
> don't add a media_xxxx option in "conf.d/net" don't break or even
> notice anything. I don't see it more dangerous as any other manual
> hack a user can do to break his gentoo.

True, but equally so between media_xxxx and preup()

> Ofcourse everything can be done with customized scripts (i even need
> a customized /etc/init.d/net.eth2 because not everything can be done
> with the options).

Routes, right?  That's covered in http://gentoo.org/~agriffis/net.eth0
and bug 19695.  If it isn't covered by that, then it's covered by
preup() ;-)

Customizing net.* should go the way of the dodo bird.  Ideally,
/etc/init.d/* scripts should never need to be customized by the user.

> But media is a basic thing which for example can even configured in
> windows on the main networkcard config.

I see your point, but I'll weakly argue that Windows isn't something
we want to emulate  :-) :-)

> And every company i worked for had strict rules to only use
> configured media types and never use autoneg.

That's too bad when they get to Gigabit speed for which the spec 
mandates auto-negotation to establish master/slave relationship.  (I
have had to deal with some of these foolish companies)

> The config in "net" will never fit the needs of all users. So some
> people will always need scripting. Only basic setups can be
> configured with normal variables.  I think the only difference we
> have is that i think media is a basic option which needs a var and
> you don't. Just the same way as i think vlan isn't needed in a basic
> networkconfig. But i don't think it's bad since it's fully optional.
> The same way as media would be fully optional and disabled by
> default.

As mentioned earlier in this post, I think that vlan should not be in
net.eth0, so it's not a good example.  I understand your reasoning on
this issue but personally I think user's will not find preup()
unwieldy, especially in the future when it covers their needs without
a new spin of net.eth0 for additional tools/options.

My current stance is this: I would like to include preup() in the next 
version of baselayout without an additional media_xxx variable.  I will
include a commented example in /etc/conf.d/net to help guide its
usage.  We'll see how that meets people's needs and work from there.
If media_xxx is deemed exceptionally helpful in the future, then I'll
reconsider.
Comment 13 Lisa Seelye (RETIRED) gentoo-dev 2004-03-10 10:14:13 UTC
I should point out that forcing a media type or autodiscovery type or what-have-you on a NIC whose link partner can't handle that can cause bad things to happen.  A note should be put in to this effect.
Comment 14 Aron Griffis (RETIRED) gentoo-dev 2004-03-10 10:20:37 UTC
Lisa, this was mentioned earlier in this bug, a couple times, thanks
Comment 15 Aron Griffis (RETIRED) gentoo-dev 2004-03-11 09:12:04 UTC
Joker, based on the lack of conversation in gentoo-dev, and on the fact that
I learned yesterday about the deprecation of mii-tool in favor of ethtool,
I've decided that for now we'll stick with the preup() only solution.  Thanks
for your willingness to discuss this and compromise.

One more note... if we decide in the future to allow speed/duplex setting as
a variable in conf.d/net, then we should at least use a name different from
media_xxx.  The setting in question isn't media, which would refer to thinwire,
thickwire, twisted-pair, fiber, etc.  In fact ifconfig has a "media" option
for controlling this.  The setting we've been discussing is rather "speed"
or "mode".  Anyway, just a closing thought.

I'll be working on getting these changes into baselayout ASAP.
Comment 16 Aron Griffis (RETIRED) gentoo-dev 2004-05-06 13:05:42 UTC
preup is in baselayout, forgot to close this bug