Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 76328 - please add a 'ifrename' net module
Summary: please add a 'ifrename' net module
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Roy Marples (RETIRED)
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks:
 
Reported: 2005-01-01 11:36 UTC by Stefan Briesenick (RETIRED)
Modified: 2005-07-19 14:00 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Briesenick (RETIRED) gentoo-dev 2005-01-01 11:36:30 UTC
following code:

[ -x /usr/sbin/ifrename -a -r /etc/iftab ] && /usr/sbin/ifrename

should be placed into one of the baselayout scripts.
I don't know which would be the best.

candidates are:

/etc/init.d/bootmisc
/etc/init.d/net.lo

if you have more than one network adapter, then you need 'ifrename' to ensure, that you have the right interface names assigned.

ifrename is located in net-wireless/wireless-tools, but is THE solution for all your interface naming problems. Not just for wireless cards! ;-)

btw: it would be nice for network hotplugging, to have some kind of wildcard net.* scripts.

for example:

I've set 'usbnet*' in /etc/iftab, so all USB network adapters gets names like usbnet0, usbnet1, etc.

Now I have to symlink all possible numbers from net.lo to net.usbnet0, etc.

it would be nice, if just 'net.usbnet' would also work. First you should look, if "net.<fullname>" exist. If not, then strip the numbers from the right and look if "net.<name>" exists. This way you could have wildcard setups for some kind of network adapters.


Reproducible: Always
Steps to Reproduce:
Comment 1 Stefan Briesenick (RETIRED) gentoo-dev 2005-01-01 11:39:37 UTC
oh well, 'ifrename' should be run as early as possible.
At least before the module-autoload stuff.
Comment 2 SpanKY gentoo-dev 2005-01-01 13:02:34 UTC
sounds like you should make a ifrename net module
Comment 3 Stefan Briesenick (RETIRED) gentoo-dev 2005-01-01 13:37:32 UTC
I looked at the source code of 'ifrename' and it seems, that I was wrong with when it should be executed.

It just renames the existing interfaces. So in /etc/hotplug/net.agent, it is a good place for all hotplug devices. And it's already there.

But for renaming static devices (i.e. PCI cards), it would be also good to execute 'ifrename' once. So the right time would be after module-loading, but before net.*

I don't think, we need an own init-script for this. This would be overkill. If we find a good existing place, then this is the way to go. Otherwise I can make such a script. It has to go to wireless-tools then. But I really prefer some existing script.
Comment 4 Stefan Briesenick (RETIRED) gentoo-dev 2005-01-17 18:07:31 UTC
are there any docs about the net-modules architecture?

the examples in /lib/rcscripts/net.modules.d are not really good if you want to write your own plugin and want to do it RIGHT in every aspect.
Comment 5 Yuri Vasilevski (RETIRED) gentoo-dev 2005-06-03 15:09:01 UTC
I used ifrename in my Gentoo by adding the following to my /etc/conf.d/net:

preup() {
        if [ -x /usr/sbin/ifrename -a -r /etc/iftab ] ; then 
                /usr/sbin/ifrename -n ${IFACE}
        fi
}

and then just edited /etc/iftab with the names and parameters I wanted like:

intel*  mac 00:11:11:43:11:CF
3com*   mac 00:0A:5E:56:99:DC

I think it's a good way to use it, but it will be much better if this code is
available as a module.
(I'll try to write it if there is interest.)
Comment 6 Roy Marples (RETIRED) gentoo-dev 2005-06-17 05:19:01 UTC
ifrename must happen before net scripts are called, otherwise dependancies on
specific net scripts may fail.

hotplug calls ifrename if it's available. If the interface module is in the
kernel, then an init script should be called before net scripts.

Assigning to mobile herd as ifrename is part of wireless-tools.
Comment 7 Henrik Brix Andersen 2005-06-17 05:32:57 UTC
The recommended way of renaming network interfaces is by using udev. See
http://www.reactivated.net/writing_udev_rules.html#example-iface
Comment 8 Stefan Briesenick (RETIRED) gentoo-dev 2005-06-17 08:18:15 UTC
cool. accepted. ;-) 
 
But: this also affects hotplug-network-cards. So it would be cool to install a 
sample rule-file. As an extra file (i.e. /etc/udev/rules.d/30-net), so one can 
find it easily and setup it as needed. Sample entries should be comment out of 
course.  
 
I think, this is a much cleaner and more consistent method than ifrename 
(via /etc/iftab). 
 
Comment 9 Yuri Vasilevski (RETIRED) gentoo-dev 2005-06-17 08:44:17 UTC
(In reply to comment #8)
> cool. accepted. ;-) 
>  
> But: this also affects hotplug-network-cards. So it would be cool to install a 
> sample rule-file. As an extra file (i.e. /etc/udev/rules.d/30-net), so one can 
> find it easily and setup it as needed. Sample entries should be comment out of 
> course.  
>  
> I think, this is a much cleaner and more consistent method than ifrename 
> (via /etc/iftab). 

I agree that this is a very nice and logical way to rename interfaces, but I
think it's not good for gentoo to force the use of udev. After all gentoo is
quite about flexibility and not letting an alternate method will exclude
Gentoo/!Linux (*BDS, Darwin, Hurd, ...) and may harm embedded Gentoo Linux.

(In reply to comment #6)
> ifrename must happen before net scripts are called, otherwise dependancies on
> specific net scripts may fail.

So if there is a way to force that this will be the first script to run before
any other script. Something like:

ifrename_depend() {
        before macchanger interface wireless
}

Then this will make a good fallback for non Linux 2.6 + udev systems.
(The network script will certainly need to be extended for use on non linux
systems, but it'll me there to be extended)

Yuri.
Comment 10 Henrik Brix Andersen 2005-06-25 02:52:10 UTC
The best, and most generic, way to do this is by using udev.

Closing as WONTFIX.
Comment 11 Roy Marples (RETIRED) gentoo-dev 2005-07-04 06:26:16 UTC
Writing udev rules can be overly complicated for many users
Comment 12 Roy Marples (RETIRED) gentoo-dev 2005-07-04 06:27:44 UTC
baselayout-1.12.0-alpha3 will ship with a "rename" module that allows device
renaming

rename_001122334455="foo1" # rename based on MAC address
renaem_eth0="foo2" #rename based on current name
Comment 13 Roy Marples (RETIRED) gentoo-dev 2005-07-19 14:00:27 UTC
Fixed in baselayout-1.12.0_pre1-r1