Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Network Interface Naming
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
Vieri
Guru
Guru


Joined: 18 Dec 2005
Posts: 546

PostPosted: Thu Jan 16, 2014 7:28 pm    Post subject: Network Interface Naming Reply with quote

Hi,

I setup a new Gentoo system with a Dec. 2013 ISO install medium.
The live system showed my ethernet devices with the new naming scheme (enp* in my case).
However, once I installed on hard disk and booted from there (with a recent 3.11.7 kernel) my ethernet devices were listed with the old naming scheme, ie. eth*.

Also, running the following showed that the kernel or device manager could get the new names:

Code:

# udevadm test-builtin net_id /sys/class/net/eth4
calling: test-builtin
=== trie on-disk ===
tool version:          208
file size:         5860871 bytes
header size             80 bytes
strings            1295087 bytes
nodes              4565704 bytes
load module index
ID_NET_NAME_MAC=enx000d88cd1c3d
ID_OUI_FROM_DATABASE=D-Link Corporation
ID_NET_NAME_PATH=enp2s5
unload module index


So my question is: how can I enable the new naming scheme?
By the way, /etc/udev/rules.d/ is empty and I'm not setting the net.ifnames=0 boot option.

Thanks,

Vieri
Back to top
View user's profile Send private message
miket
Guru
Guru


Joined: 28 Apr 2007
Posts: 411
Location: Gainesville, FL, USA

PostPosted: Sat Jan 18, 2014 9:09 am    Post subject: Reply with quote

So far as I know, the new Chaotic Naming Scheme gets applied only to network interfaces whose drivers are not built into the kernel. The kernel discovers and enumerates devices having built-in drivers before early userspace starts: the bootup code (in /usr/src/linux/init/main.c) calls driver_init() before it opens the console and calls run_init_process().

For the life of me, I don't know why you *want* to get the so-called predictable naming scheme. If you do, try building those drivers as loadable modules. I myself will continue to use in-kernel network drivers and stick with sensible names (the race conditions which motivated the new naming scheme arise only during module loading).

If you have multiple network interfaces of a similar class (such as in a router) and you want to stay away from the renaming of ethN to some other ethN, you can set up explicit udev rules to give the interfaces meaningful names like wan0 and lan0.
Back to top
View user's profile Send private message
PaulBredbury
Watchman
Watchman


Joined: 14 Jul 2005
Posts: 7310

PostPosted: Sat Jan 18, 2014 12:14 pm    Post subject: Reply with quote

miket wrote:
meaningful names like wan0

Zero?? That's little better than eth0, eth1, etc. Those numbers aren't meaningful.

wanoffice, wanhome - those are meaningful. Be more imaginative with names ;)

It's easy to set up the names, with udev rules.
Back to top
View user's profile Send private message
miket
Guru
Guru


Joined: 28 Apr 2007
Posts: 411
Location: Gainesville, FL, USA

PostPosted: Sat Jan 18, 2014 2:15 pm    Post subject: Reply with quote

PaulBredbury wrote:
Zero?? That's little better than eth0, eth1, etc. Those numbers aren't meaningful.

wanoffice, wanhome - those are meaningful. Be more imaginative with names ;)

Well, the particular example I had was for a router, which in most cases means a box don't move around. If you have a math and science background, counting from zero is very natural, even if there is only one of something. If your usage case is different (as in a machine which moves around) or your naming preferences are different, by all means, follow the naming convention you need!

The point is not to be stuck into silly names like en0s4 or whatever new udev wants to make by default.
Back to top
View user's profile Send private message
Vieri
Guru
Guru


Joined: 18 Dec 2005
Posts: 546

PostPosted: Sat Jan 18, 2014 2:35 pm    Post subject: Reply with quote

Strange... my installed system boots and does not load any network drivers (I only see local loopback). I need to modprobe <module_name> or include the module names in modules.autoload... so they are compiled as modules and they're not within the kernel. Still, I'm only seeing eth* device names after loading the modules.

As for the reason why I'd like to try the new naming system, it's because I sometimes need to replace an ethernet card within a PC with multiple NICs (router), as fast as possible and without rewriting anything. I once had to replace a faulty card which was labeled 'eth0' (no udev rules whatsoever) and the new card came out with another name (I don't remember the number but it wasn't eth0). I didn't have any udev rules forcing an association of eth0 with the old card's MAC address. This was annoying (especially on a production system) and I was hoping the new naming scheme would solve this issue.
I don't care what the name is just as long as it doesn't change if I change the hardware (well, at least the network card).

http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/
Back to top
View user's profile Send private message
miket
Guru
Guru


Joined: 28 Apr 2007
Posts: 411
Location: Gainesville, FL, USA

PostPosted: Sat Jan 18, 2014 4:06 pm    Post subject: Reply with quote

Vieri wrote:
Strange... my installed system boots and does not load any network drivers (I only see local loopback). I need to modprobe <module_name> or include the module names in modules.autoload... so they are compiled as modules and they're not within the kernel. Still, I'm only seeing eth* device names after loading the modules.

Wow. So much for what I said. I guess it turns into a necessary but not sufficient condition. This is strange. You did the things you might normally need to do (such as no /etc/udev/rules.d/80-net-name-slot.rules file).

I understand something got changed lately in terms of symlinks to /etc/init.d/net.lo and network-device init scripts added to the default runlevel, but unfortunately these changes are still not reflected in the Handbook and I'm not clear about them either. Do you still have symlinks to /etc/init.d/net.lo from /etc/init.d/net.eth0 and such? Can you the newfangled interface names in the /sys/class/net/ directory?

So far as I know, you can't magically make network interfaces appear simply by making symlinks to /etc/init.d/net.lo and adding those to the default runlevel, but it might be worth it to test if those ethN devices you're seeing actually work.

Vieri wrote:
As for the reason why I'd like to try the new naming system, it's because I sometimes need to replace an ethernet card within a PC with multiple NICs (router), as fast as possible and without rewriting anything. I once had to replace a faulty card which was labeled 'eth0' (no udev rules whatsoever) and the new card came out with another name (I don't remember the number but it wasn't eth0). I didn't have any udev rules forcing an association of eth0 with the old card's MAC address. This was annoying (especially on a production system) and I was hoping the new naming scheme would solve this issue.
I don't care what the name is just as long as it doesn't change if I change the hardware (well, at least the network card).

http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/

The kind of thing I suggested months ago for being able to keep working when you swap out a NIC is that you you can write udev rules that depend on parameters other than the actual MAC address, such as slot, range of slots, or manufacturer. I *think* you might even be able to so some particular kinds of probing based on udev rules in order to tell where the new NIC faces the LAN or the WAN.

On the other hand, if you can't do anything in udev that is able to make a reliable determination of what kind of network is plugged into the NIC but have to defer that to a NIC-probing script later on, they I guess you might as well use the strange names. Of course, if you're in that situation, you'd do just as well with just a series of eth{0..N} NIC's you'd need to probe.

Your first problem, though, is being able to find them in the first place. I wish I were clear about the new thing I heard about /etc/init./d symlinks and runlevels for network devices--I haven't had to deal with that myself. You could try explicit udev rules even to make names like netN to see if that kind of renaming is broken or working.
Back to top
View user's profile Send private message
litan
n00b
n00b


Joined: 13 Aug 2012
Posts: 51

PostPosted: Sun Jan 19, 2014 12:15 am    Post subject: Re: Network Interface Naming Reply with quote

Hi Vieri,
Vieri wrote:
I setup a new Gentoo system with a Dec. 2013 ISO install medium.
The live system showed my ethernet devices with the new naming scheme (enp* in my case).
However, once I installed on hard disk and booted from there (with a recent 3.11.7 kernel) my ethernet devices were listed with the old naming scheme, ie. eth*.

Same thing happened to me.
I assume you named your init-scripts after the new udev names you saw on the live CD, when linking against net.lo, right?
Please check if udevd is running and if udev and udev-mount are added to the sysinit runlevel.
For some reason they were not on my newly installed system.

Since you say you are running recent 3.11.7, you are using hardened-sources and a hardened profile, right?
I don't use hardened-sources, but I do have a hardened profile and installed from a hardened stage3 tarball.
Maybe this is connected?
Back to top
View user's profile Send private message
Vieri
Guru
Guru


Joined: 18 Dec 2005
Posts: 546

PostPosted: Sun Jan 19, 2014 1:19 pm    Post subject: Reply with quote

Thanks for the comments. Really appreciated.

miket, /etc/udev/rules.d/ is empty on my installed system.
I did NOT symlink any devices in /etc/init.d/net.* from my live system onto my hard disk.
In fact, I skipped this part because I wanted to boot networkless into my installed system and configure my NICs directly then.
So after installing grub2 from my live medium to my hard disk and booting for the first time, I ended up with just /etc/init.d/net.lo, as expected.

lspci -v showed me the network kernel modules I needed to load and so I loaded them with modprobe and could see the devices with 'ifconfig -a' or 'ip addr show'.

At that point I took the dev names from the 'ip' or 'ifconfig -a' commands and started creating my symlinks such as:
Code:
ln -s net.lo net.eth0

Of course, I then edited /etc/conf.d/net and added a static IP address into 'config_eth0' before runing '/etc/init.d/net.eth0 start'.
The interface came up fine, as well as all the others:

Code:

# ls /sys/class/net/
eth0  eth1  eth2  eth3  eth4  eth5  eth6  lo


I even tried to force the use of eg. 'enp2s5' instead of 'eth4' (see my first post) EVEN IF 'ip' or 'ifconfig' do not know about this new/alternative name.
So I did something like this:
Code:

# /etc/init.d/net.eth4 stop
# sed -i 's/eth4/enp2s5/g' /etc/conf.d/net
# rm -f /etc/init.d/net.eth4
# ln -s /etc/init.d/net.lo /etc/init.d/net.enp2s5
# /etc/init.d/net.enp2s5 start

And obviously I got the following error:
Code:
ERROR: interface enp2s5 does not exist


miket, udev rules based on "slots" could actually be helpful, yes. If the kernel can do that for me without having to write or maintain the rules then that's even better (yes, I'm lazy ;-) but most of all I want to "keep it simple" as much as possible).

litan, I did NOT create the symlinks with the net names I saw on the liveCD. I waited to boot the installed system, check the network names and then create the symlinks. That's when I saw the difference.
Code:
# ps -ae | grep udev

yields nothing.
Code:
# rc-update show | grep udev

yields nothing.
Code:

# ls /etc/init.d/udev*
/etc/init.d/udev  /etc/init.d/udev-mount

Code:
# grep "^rc_hotplug" /etc/rc.conf

yields nothing.
Code:
# ls /etc/udev/rules.d/

yields nothing.

How is udevd launched? Is it via /etc/init.d/udev start? Have I missed this step somewhere?
I believe (but I may be wrong) that the handbook doesn't mention adding udev and udev-mount to the default or boot runlevel. EDIT: should 'udev' show up in 'rc-update show sysinit'?

Finally, yes, I'm using hardened-sources.

Thanks
Back to top
View user's profile Send private message
litan
n00b
n00b


Joined: 13 Aug 2012
Posts: 51

PostPosted: Sun Jan 19, 2014 1:37 pm    Post subject: Reply with quote

Vieri, thank you very much for the additional information.
As I remember, there is really nothing in the handbook about adding udev to runlevels,
and on my previous installations it was not necessary.
Please run
Code:
rc-update add udev sysinit
rc-update add udev-mount sysinit

and reboot your system.
You should now have the new-style interface names and should be able to create
the appropriate links in /etc/init.d/

Hope that helped.
Back to top
View user's profile Send private message
Vieri
Guru
Guru


Joined: 18 Dec 2005
Posts: 546

PostPosted: Sun Jan 19, 2014 7:22 pm    Post subject: Reply with quote

Thanks to both of you (EDIT: the three of you).

It seems that what I had to do was add the 'openrc' flag into make.conf's USE variable.
If I re-emerge udev with the openrc flag enabled then it also pulls in the udev-init-scripts package which in turn automatically installs the udev scripts in the correct runlevel:

http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sys-fs/udev-init-scripts/udev-init-scripts-26.ebuild?view=markup

I didn't know about this and I falsely presumed that since openrc was Gentoo's default init system then it would have auto-enabled this flag.

EDIT: the ebuild I mention actually doesn't auto-install the scripts into the runlevel but warns the user to do so (better than nothing).
Back to top
View user's profile Send private message
litan
n00b
n00b


Joined: 13 Aug 2012
Posts: 51

PostPosted: Sun Jan 19, 2014 8:52 pm    Post subject: Reply with quote

Vieri, thank you for the update.
I did not see the warning, because udev-init-scripts was already installed on my system.
So our problems are partly related, I guess.

edit: Does anyone know why either of this happened?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum