View previous topic :: View next topic |
Author |
Message |
NiceGuy Guru


Joined: 12 Jun 2006 Posts: 451 Location: Canada
|
Posted: Fri Jun 27, 2008 6:27 pm Post subject: Prevent udev naming on a pci device |
|
|
Hello,
This may or may not be an advanced question. Simply put I have a pci device in my gentoo system that is always getting enumerated (labelled) to eth2 by udev on each boot. However the device is not a valid nic/ethernet card.
To keep things simple (and this post as short as possible) I would simply like a way to have udev ignore naming a device attached to a particular pci address. For example, the device attached to the pci address 0000:02:08.0 (actual device address here) should not be assigned a label AT ALL!!
Of course the enumeration is probably occurring at the kernel level, but still hoping udev could provide a clever resolution .. actually any resolution to be honest ... udev, kernel or otherwise.
Thanks _________________ success is the ability to go from one failure to the next without any loss of enthusiasm |
|
Back to top |
|
 |
eyoung100 Veteran


Joined: 23 Jan 2004 Posts: 1428
|
|
Back to top |
|
 |
cyrillic Watchman


Joined: 19 Feb 2003 Posts: 7313 Location: Groton, Massachusetts USA
|
Posted: Sat Jun 28, 2008 1:08 am Post subject: Re: Prevent udev naming on a pci device |
|
|
NiceGuy wrote: | Simply put I have a pci device in my gentoo system that is always getting enumerated (labelled) to eth2 by udev on each boot. However the device is not a valid nic/ethernet card. |
If you want eth2 to not exist, then don't load the driver for it.
It should be easy enough to tell what driver it is using by looking at dmesg, or by looking in /etc/udev/rules.d/70-persistent-net.rules
The mere existence of an eth2 device should not cause any problems unless you are also running a startup script for it.
Code: | # rm /etc/init.d/net.eth2 |
|
|
Back to top |
|
 |
salahx Guru

Joined: 12 Mar 2005 Posts: 559
|
Posted: Sat Jun 28, 2008 1:38 am Post subject: |
|
|
One solution is to just blacklist the driver ( in /etc/modprobe.d/backlist ). However, this won't work if the driver is built into the kernel or you have instances of the driver you do want to work.
The second solution is unbind the driver from the device:
echo 0000:02:08.0 > /sys/bus/pci/drivers/drivername/unbind
The syntax for re-binding is similar. You might be able to control binding with udev (its called "userspace driver binding support" but I don't know if the Linux kernel and/or udev was ever added with that support. |
|
Back to top |
|
 |
eyoung100 Veteran


Joined: 23 Jan 2004 Posts: 1428
|
Posted: Mon Jun 30, 2008 8:10 pm Post subject: Re: Prevent udev naming on a pci device |
|
|
cyrillic wrote: | NiceGuy wrote: | Simply put I have a pci device in my gentoo system that is always getting enumerated (labelled) to eth2 by udev on each boot. However the device is not a valid nic/ethernet card. |
If you want eth2 to not exist, then don't load the driver for it.
It should be easy enough to tell what driver it is using by looking at dmesg, or by looking in /etc/udev/rules.d/70-persistent-net.rules
The mere existence of an eth2 device should not cause any problems unless you are also running a startup script for it.
Code: | # rm /etc/init.d/net.eth2 |
|
This is where I was headed, except that I was oing to advis not to compile this into the kernel. _________________ The Birth and Growth of Science is the Death and Atrophy of Art -- Unknown
Registerd Linux User #363735
Adopt a Post | Strip Comments| Emerge Wrapper |
|
Back to top |
|
 |
NiceGuy Guru


Joined: 12 Jun 2006 Posts: 451 Location: Canada
|
Posted: Wed Jul 02, 2008 3:27 pm Post subject: |
|
|
Quote: | What is the device? |
Its rather complicated to write (but easy to understand). The unique system I'm using has three ethernet ports located on its motherboard, but actually only two of the ports are usable at any one time. One of the ports (port 1) is jumper (pin) controlled on the motherboard. For clarity, refer to the diagram below.
Diagram:
Code: | |------------Port 1-----------| |------Port 2 -----|
[PORT 1a] [PORT 1b] [Port 2] |
To further explain, only one port in Port 1 (either a or b) can be used at any one time as it is the port that is jumper controlled. So in my particular case, Port 1a and Port2 are the two ports that are usable. Port1b is essentially useless with the pin configuration I employ.
Additionally the removing/adjusting of nic modules/drivers will not work, because as you may have already guessed, the driver for Port 1 is the same for both the Port1a (used) and Port1b (unusable). Completely removing the module would make all of Port1 (both a and b) inoperable which is not desired.
Lastly, each device Port 1a, Port1b and Port2 all have there own PCI bus address and I was hoping a remedy could be worked out using this information, again to ignore the labeling associated with the device located at PCI address "0000:02:08.0"
I apologize for the long post, as I am still looking for a solution
Thanks again for your time _________________ success is the ability to go from one failure to the next without any loss of enthusiasm |
|
Back to top |
|
 |
PaulBredbury Watchman


Joined: 14 Jul 2005 Posts: 7310
|
Posted: Wed Jul 02, 2008 5:50 pm Post subject: |
|
|
There's OPTIONS="ignore_device" to use in e.g. /etc/udev/rules.d/10-local.rules (notice that's a TEN, i.e. early in the rule ordering), but you'll need a way of identifying 1b. |
|
Back to top |
|
 |
kimmie Guru


Joined: 08 Sep 2004 Posts: 531 Location: Australia
|
Posted: Wed Jul 02, 2008 6:16 pm Post subject: |
|
|
A rule like this should work... maybe in /etc/udev/rules.d/51-local.rules:
Code: | KERNEL=="0000:02:08.0", SUBSYSTEM=="pci", OPTIONS="ignore_device, last_rule" |
Although that seems a crude. The output of "udevinfo -a -p /sys/class/net/eth2" might give you some extra things to match on, or an alternative if that rule doesn't work.
You don't need to reboot to test this. If your system isn't otherwise using eth2, adding the rule and running "udevtrigger" should cause the device to disappear; ie. it will no longer show up in output of "ifconfig -a".
EDIT: Scratch that last... I thought I'd just tested that... but no, you need to reboot to get the device to disappear. |
|
Back to top |
|
 |
NiceGuy Guru


Joined: 12 Jun 2006 Posts: 451 Location: Canada
|
Posted: Wed Jul 02, 2008 8:30 pm Post subject: |
|
|
Update:
I have attempted to write some udev rule base on the "OPTIONS=ignore_device, last_rule" suggested (below):
First:
Code: | cat /etc/udev/rules.d/51-local.rules
KERNEL=="0000:02:08.0", SUBSYSTEM=="pci", OPTIONS="ignore_device, last_rule" |
Second:
Code: | cat /etc/udev/rules.d/51-local.rules
KERNEL=="eth*", BUS=="pci", ID=="0000:02:08.0", OPTIONS="ignore_device, last_rule" |
Then I reboot the system and in short, neither work.
-----------------------------------------------------------------
However, using the following:
Code: | echo "0000:02:08.0" > /sys/bus/pci/drivers/<drivername>/unbind |
Seems promising. I've tried it and it appears to work. However I am required to perform the command after each reboot as it does not appear to be persistent.
Does anybody know, or can suggest how to make the modification permanently. If I can issue the command early enough in the boot process .. I would still like to apply some udev rules to map the remaining interfaces to my desired setting with a udev rules file.
Thanks _________________ success is the ability to go from one failure to the next without any loss of enthusiasm |
|
Back to top |
|
 |
|