summaryrefslogtreecommitdiff
path: root/extras
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2007-08-02 21:19:41 +0200
committerKay Sievers <kay.sievers@vrfy.org>2007-08-02 21:19:41 +0200
commitdcfa2acce30c0574bcec761b72cad4141da78e1b (patch)
treefc2b397c834159c9f79feeaae931111cde6aa651 /extras
parentb5485961d7001a4137411e1e16e2e13644c19653 (diff)
rules_generator: skip random MAC addresses
Diffstat (limited to 'extras')
-rw-r--r--extras/rule_generator/75-persistent-net-generator.rules27
-rw-r--r--extras/rule_generator/rule_generator.functions2
-rw-r--r--extras/rule_generator/write_net_rules4
3 files changed, 22 insertions, 11 deletions
diff --git a/extras/rule_generator/75-persistent-net-generator.rules b/extras/rule_generator/75-persistent-net-generator.rules
index 90d7f82d63..cfb13f182b 100644
--- a/extras/rule_generator/75-persistent-net-generator.rules
+++ b/extras/rule_generator/75-persistent-net-generator.rules
@@ -1,22 +1,33 @@
+# do not edit this file, it will be overwritten on update
+
# these rules generate rules for persistent network device naming
-ACTION=="add", SUBSYSTEM=="net", KERNEL=="eth*|ath*|wlan*|ra*|sta*|ctc*|lcs*|hsi*" \
- NAME!="?*", DRIVERS=="?*", GOTO="persistent_net_generator_do"
+ACTION!="add", GOTO="persistent_net_generator_end"
+SUBSYSTEM!="net", GOTO="persistent_net_generator_end"
+
+# device name whitelist
+KERNEL!="eth*|ath*|wlan*|ra*|sta*|ctc*|lcs*|hsi*", GOTO="persistent_net_generator_end"
+
+# ignore the interface if a name has already been set
+NAME=="?*", GOTO="persistent_net_generator_end"
-GOTO="persistent_net_generator_end"
-LABEL="persistent_net_generator_do"
+# ignore Xen virtual interfaces
+SUBSYSTEMS=="xen", GOTO="persistent_net_generator_end"
-# build device description string to add a comment the generated rule
+# build device description string to add a comment to the generated rule
SUBSYSTEMS=="pci", ENV{COMMENT}="PCI device $attr{vendor}:$attr{device} ($driver)"
SUBSYSTEMS=="usb", ENV{COMMENT}="USB device 0x$attr{idVendor}:0x$attr{idProduct} ($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"
SUBSYSTEMS=="ieee1394", ENV{COMMENT}="Firewire device $attr{host_id})"
-SUBSYSTEMS=="xen", ENV{COMMENT}="Xen virtual device"
ENV{COMMENT}=="", ENV{COMMENT}="$env{SUBSYSTEM} device ($driver)"
-ENV{NETDEV}=="?*", IMPORT{program}="write_net_rules --driver $env{NETDRV} --id $env{NETDEV}"
-ENV{NETDEV}!="?*", IMPORT{program}="write_net_rules $attr{address}"
+DRIVERS!="?*", ENV{NETDEV}=="?*", IMPORT{program}="write_net_rules --driver $env{NETDRV} --id $env{NETDEV}"
+
+# skip "locally administered" MAC addresses
+ATTR{address}=="?[2367abef]:*", GOTO="persistent_net_generator_end"
+
+DRIVERS!="?*", ENV{NETDEV}!="?*", IMPORT{program}="write_net_rules $attr{address}"
ENV{INTERFACE_NEW}=="?*", NAME="$env{INTERFACE_NEW}"
LABEL="persistent_net_generator_end"
diff --git a/extras/rule_generator/rule_generator.functions b/extras/rule_generator/rule_generator.functions
index 712ed269e0..495bb7b047 100644
--- a/extras/rule_generator/rule_generator.functions
+++ b/extras/rule_generator/rule_generator.functions
@@ -93,5 +93,5 @@ find_all_rules() {
local match="$3"
local search='.*[[:space:],]'"$key"'"\('"$linkre"'\)"[[:space:]]*\(,.*\|\\\|\)$'
- echo $(sed -n -e "${match}s/${search}/\1/p" $RO_RULES_FILE $RULES_FILE)
+ echo $(sed -n -e "${match}s/${search}/\1/p" $RO_RULES_FILE $RULES_FILE 2>/dev/null)
}
diff --git a/extras/rule_generator/write_net_rules b/extras/rule_generator/write_net_rules
index b873b5bf8c..62acb8820c 100644
--- a/extras/rule_generator/write_net_rules
+++ b/extras/rule_generator/write_net_rules
@@ -115,12 +115,12 @@ fi
# the DRIVERS key is needed to not match bridges and VLAN sub-interfaces
if [ "$MAC_ADDR" ] ; then
- match="DRIVERS==\"?*\", ATTRS{address}==\"$MAC_ADDR\""
+ match="DRIVERS==\"?*\", ATTR{address}==\"$MAC_ADDR\""
else
match="DRIVERS==\"$DRIVER\", KERNELS==\"$ID\""
fi
if [ $basename = "ath" -o $basename = "wlan" ]; then
- match="$match, ATTRS{type}==\"1\"" # do not match the wifi* interfaces
+ match="$match, ATTR{type}==\"1\"" # do not match the wifi* interfaces
fi
write_rule "$match" "$INTERFACE" "$COMMENT"