1 |
# /etc/udev/rules/75-persistent-net-generator.rules: device naming rules for udev |
# /etc/udev/rules/75-persistent-net-generator.rules: device naming rules for udev |
2 |
# $Header: /root/magellan-cvs/src/udev/udev-persistent-net-generator.rules.magellan,v 1.2 2007-08-17 20:08:47 niro Exp $ |
# $Header: /root/magellan-cvs/src/udev/udev-persistent-net-generator.rules.magellan,v 1.3 2008-03-22 18:12:11 niro Exp $ |
3 |
|
# |
4 |
|
# There are a number of modifiers that are allowed to be used in some |
5 |
|
# of the different fields. They provide the following subsitutions: |
6 |
|
# %n - the "kernel number" of the device. |
7 |
|
# For example, 'sda3' has a "kernel number" of '3' |
8 |
|
# %k - the kernel name for the device. |
9 |
|
# %M - the kernel major number for the device |
10 |
|
# %m - the kernel minor number for the device |
11 |
|
# %b - the bus id for the device |
12 |
|
# %c - the string returned by the PROGRAM. (Note, this doesn't work within |
13 |
|
# the PROGRAM field for the obvious reason.) |
14 |
|
# %s{filename} - the content of a sysfs attribute. |
15 |
|
# %% - the '%' char itself. |
16 |
|
# |
17 |
|
# Try not to modify this file, if you wish to change things, create a new rule |
18 |
|
# file that can be run before this one. |
19 |
|
# |
20 |
|
|
21 |
# these rules generate rules for persistent network device naming |
# these rules generate rules for persistent network device naming |
22 |
|
# |
23 |
|
# variables used to communicate: |
24 |
|
# MATCHADDR MAC address used for the match |
25 |
|
# MATCHID bus_id used for the match |
26 |
|
# MATCHDRV driver name used for the match |
27 |
|
# MATCHIFTYPE interface type match |
28 |
|
# COMMENT comment to add to the generated rule |
29 |
|
# INTERFACE_NAME requested name supplied by external tool |
30 |
|
# INTERFACE_NEW new interface name returned by rule writer |
31 |
|
|
32 |
ACTION!="add", GOTO="persistent_net_generator_end" |
ACTION!="add", GOTO="persistent_net_generator_end" |
33 |
SUBSYSTEM!="net", GOTO="persistent_net_generator_end" |
SUBSYSTEM!="net", GOTO="persistent_net_generator_end" |
34 |
|
|
|
# device name whitelist |
|
|
KERNEL!="eth*|ath*|wlan*|ra*|sta*|ctc*|lcs*|hsi*", GOTO="persistent_net_generator_end" |
|
|
|
|
|
# build device description string to add a comment the generated rule |
|
35 |
# ignore the interface if a name has already been set |
# ignore the interface if a name has already been set |
36 |
NAME=="?*", GOTO="persistent_net_generator_end" |
NAME=="?*", GOTO="persistent_net_generator_end" |
37 |
|
|
38 |
|
# device name whitelist |
39 |
|
KERNEL!="eth*|ath*|wlan*[0-9]|ra*|sta*|ctc*|lcs*|hsi*", GOTO="persistent_net_generator_end" |
40 |
|
|
41 |
# ignore Xen virtual interfaces |
# ignore Xen virtual interfaces |
42 |
SUBSYSTEMS=="xen", GOTO="persistent_net_generator_end" |
SUBSYSTEMS=="xen", GOTO="persistent_net_generator_end" |
43 |
|
|
44 |
|
# read MAC address |
45 |
|
ENV{MATCHADDR}="$attr{address}" |
46 |
|
|
47 |
|
# match interface type |
48 |
|
ENV{MATCHIFTYPE}="$attr{type}" |
49 |
|
|
50 |
|
# do not use "locally administered" MAC address |
51 |
|
ENV{MATCHADDR}=="?[2367abef]:*", ENV{MATCHADDR}="" |
52 |
|
|
53 |
|
# do not use empty address |
54 |
|
ENV{MATCHADDR}=="00:00:00:00:00:00", ENV{MATCHADDR}="" |
55 |
|
|
56 |
|
# build comment line for generated rule: |
57 |
SUBSYSTEMS=="pci", ENV{COMMENT}="PCI device $attr{vendor}:$attr{device} ($driver)" |
SUBSYSTEMS=="pci", ENV{COMMENT}="PCI device $attr{vendor}:$attr{device} ($driver)" |
58 |
SUBSYSTEMS=="usb", ENV{COMMENT}="USB device 0x$attr{idVendor}:0x$attr{idProduct} ($driver)" |
SUBSYSTEMS=="usb", ENV{COMMENT}="USB device 0x$attr{idVendor}:0x$attr{idProduct} ($driver)" |
59 |
SUBSYSTEMS=="pcmcia", ENV{COMMENT}="PCMCIA device $attr{card_id}:$attr{manf_id} ($driver)" |
SUBSYSTEMS=="pcmcia", ENV{COMMENT}="PCMCIA device $attr{card_id}:$attr{manf_id} ($driver)" |
|
SUBSYSTEMS=="ccwgroup", ENV{COMMENT}="S/390 $driver device at $id", ENV{NETDEV}="$id", ENV{NETDRV}="$driver" |
|
60 |
SUBSYSTEMS=="ieee1394", ENV{COMMENT}="Firewire device $attr{host_id})" |
SUBSYSTEMS=="ieee1394", ENV{COMMENT}="Firewire device $attr{host_id})" |
|
ENV{COMMENT}=="", ENV{COMMENT}="$env{SUBSYSTEM} device ($driver)" |
|
61 |
|
|
62 |
DRIVERS!="?*", ENV{NETDEV}=="?*", IMPORT{program}="write_net_rules --driver $env{NETDRV} --id $env{NETDEV}" |
# S/390 uses id matches only, do not use MAC address match |
63 |
|
SUBSYSTEMS=="ccwgroup", ENV{COMMENT}="S/390 $driver device at $id", ENV{MATCHID}="$id", ENV{MATCHDRV}="$driver", ENV{MATCHADDR}="" |
64 |
|
|
65 |
|
# see if we got enough data to create a rule |
66 |
|
ENV{MATCHADDR}=="", ENV{MATCHID}=="", ENV{INTERFACE_NAME}=="", GOTO="persistent_net_generator_end" |
67 |
|
|
68 |
# skip "locally administered" MAC addresses |
# default comment |
69 |
ATTR{address}=="?[2367abef]:*", GOTO="persistent_net_generator_end" |
ENV{COMMENT}=="", ENV{COMMENT}="$env{SUBSYSTEM} device" |
70 |
|
|
71 |
DRIVERS!="?*", ENV{NETDEV}!="?*", IMPORT{program}="write_net_rules $attr{address}" |
# write rule |
72 |
|
DRIVERS=="?*", IMPORT{program}="write_net_rules" |
73 |
|
|
74 |
|
# rename interface if needed |
75 |
ENV{INTERFACE_NEW}=="?*", NAME="$env{INTERFACE_NEW}" |
ENV{INTERFACE_NEW}=="?*", NAME="$env{INTERFACE_NEW}" |
76 |
|
|
77 |
LABEL="persistent_net_generator_end" |
LABEL="persistent_net_generator_end" |
|
|
|