# Prevent udev naming on a pci device

## NiceGuy

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

----------

## eyoung100

What is the device   :Question: 

----------

## cyrillic

 *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.

```
# rm /etc/init.d/net.eth2 
```

----------

## salahx

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.

----------

## eyoung100

 *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
> ...

 

This is where I was headed, except that I was oing to advis not to compile this into the kernel.

----------

## NiceGuy

 *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:

```
|------------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

----------

## PaulBredbury

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.

----------

## kimmie

A rule like this should work... maybe in /etc/udev/rules.d/51-local.rules:

```
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.

----------

## NiceGuy

Update:

I have attempted to write some udev rule base on the "OPTIONS=ignore_device, last_rule" suggested (below):

First:

```
cat /etc/udev/rules.d/51-local.rules

KERNEL=="0000:02:08.0", SUBSYSTEM=="pci", OPTIONS="ignore_device, last_rule"
```

Second:

```
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:

```
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

----------

