Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Cant rename specific port on dual port network interfaces
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
plindgren90
n00b
n00b


Joined: 05 Jun 2014
Posts: 6

PostPosted: Thu Jun 05, 2014 2:33 pm    Post subject: Cant rename specific port on dual port network interfaces Reply with quote

Hello

I can rename the interfaces, however. I have an application with hardcoded use of interface names. So i need one specific port to be eth0, and the rest to be eth1,2,3. the rest of the ports just have to have a eth* name.

On one of my servers i have 2 PCI cards with network interfaces:
card0.port0
card0.port1
card1.port0
card1.port1

To get eth* names i just put net.ifnames=0 in the bootloader options, it works fine. However, card1.port0 should be eth0. but when the drivers are loaded it loads the drivers for card0 first then card1. so the names end up being

card0.port0 eth0
card0.port1 eth1
card1.port0 eth2
card1.port1 eth3

I can do modprobe -r e1000 modprobe -r tg3 and then load the drivers in the order i want. and then card1.port0 becomes eth0.
like this:

card0.port0 eth2
card0.port1 eth3
card1.port0 eth0
card1.port1 eth1

However, on different servers the port i need to be eth0 is connected diffrently. Redoing the cables is not an option right now.

So i need to be able to rename each port to exactly the eth* i dictate.

If i use udev rules and name the interfaces to eth* they default to the order in which they are placed in the chassi like:
So it seems like when i add one port, the other one gets added with it right after because its on the same card as the port i added in udev. and it defaults to the next availabe eth*

So i if do something in udev like add card0.port0 as eth0 card0.port1 will be named eth1 if i give it a eth* name, regardless if i specify it should be eth2 or eth3.
If there are conflicts in udev, it defaults to slot order again.

card0.port0 eth0
card0.port1 eth1
card1.port0 eth2
card1.port1 eth3

So the option i am exploring is trying to disable hardware disable one port at a time, by doing something like echo 1 > /sys/bus/pci/devices/$pcislotid.port/remove

So i have two questions
Do you know of a way to hardware disable one port on a two nic card?
Or, do you know of a way that will actually rename the cards to the exakt names i want them to be?

Any help much appriciated!
Back to top
View user's profile Send private message
plindgren90
n00b
n00b


Joined: 05 Jun 2014
Posts: 6

PostPosted: Thu Jun 05, 2014 2:47 pm    Post subject: Reply with quote

Of course i solve the issue minutes after posting this question. Heres how i did it:


# Fix net.ifnames=0 to get legacy names (eth0,1,2,3)
# Add net.ifnames=0 to the kernel linux commandline
mount /boot
nano /etc/default/grub
# update grub...
grub2-mkconfig -o /boot/grub/grub.cfg
reboot
# now you have eth* names in default order
# echo pci slot.port id into drivers unbindfile /sys/bus/pci/drivers/$driver/unbind
# This is to hardware disable all ports one by one
echo 0000:00.01.0 >> /sys/bus/pci/drivers/$driver/unbind
echo 0000:00.01.1 >> /sys/bus/pci/drivers/$driver/unbind
echo 0000:00:02.0 >> /sys/bus/pci/drivers/$driver/unbind
echo 0000:00:02.1 >> /sys/bus/pci/drivers/$driver/unbind

# then add the ports one by one in the order you want
# if you want card1.port1 as eth0 do that first, if you want card0.port0 as eth1 add that second etc...
echo 0000:00:02.1 >> /sys/bus/pci/drivers/$driver/bind
echo 0000:00.01.0 >> /sys/bus/pci/drivers/$driver/bind
echo 0000:00.01.1 >> /sys/bus/pci/drivers/$driver/bind
echo 0000:00:02.0 >> /sys/bus/pci/drivers/$driver/bind
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware 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