75-persistent-net-generator.rules.optional 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # do not edit this file, it will be overwritten on update
  2. # these rules generate rules for persistent network device naming
  3. #
  4. # variables used to communicate:
  5. # MATCHADDR MAC address used for the match
  6. # MATCHID bus_id used for the match
  7. # MATCHDRV driver name used for the match
  8. # MATCHIFTYPE interface type match
  9. # COMMENT comment to add to the generated rule
  10. # INTERFACE_NAME requested name supplied by external tool
  11. # INTERFACE_NEW new interface name returned by rule writer
  12. ACTION!="add", GOTO="persistent_net_generator_end"
  13. SUBSYSTEM!="net", GOTO="persistent_net_generator_end"
  14. # ignore the interface if a name has already been set
  15. NAME=="?*", GOTO="persistent_net_generator_end"
  16. # device name whitelist
  17. KERNEL!="eth*|ath*|wlan*[0-9]|msh*|ra*|sta*|ctc*|lcs*|hsi*", GOTO="persistent_net_generator_end"
  18. # ignore Xen virtual interfaces
  19. SUBSYSTEMS=="xen", GOTO="persistent_net_generator_end"
  20. # read MAC address
  21. ENV{MATCHADDR}="$attr{address}"
  22. # match interface type
  23. ENV{MATCHIFTYPE}="$attr{type}"
  24. # do not use "locally administered" MAC address
  25. ENV{MATCHADDR}=="?[2367abef]:*", ENV{MATCHADDR}=""
  26. # do not use empty address
  27. ENV{MATCHADDR}=="00:00:00:00:00:00", ENV{MATCHADDR}=""
  28. # build comment line for generated rule:
  29. SUBSYSTEMS=="pci", ENV{COMMENT}="PCI device $attr{vendor}:$attr{device} ($driver)"
  30. SUBSYSTEMS=="usb", ENV{COMMENT}="USB device 0x$attr{idVendor}:0x$attr{idProduct} ($driver)"
  31. SUBSYSTEMS=="pcmcia", ENV{COMMENT}="PCMCIA device $attr{card_id}:$attr{manf_id} ($driver)"
  32. SUBSYSTEMS=="ieee1394", ENV{COMMENT}="Firewire device $attr{host_id})"
  33. # ibmveth likes to use "locally administered" MAC addresses
  34. DRIVERS=="ibmveth", ENV{MATCHADDR}="$attr{address}", ENV{COMMENT}="ibmveth ($id)"
  35. # S/390 uses id matches only, do not use MAC address match
  36. SUBSYSTEMS=="ccwgroup", ENV{COMMENT}="S/390 $driver device at $id", ENV{MATCHID}="$id", ENV{MATCHDRV}="$driver", ENV{MATCHADDR}=""
  37. # see if we got enough data to create a rule
  38. ENV{MATCHADDR}=="", ENV{MATCHID}=="", ENV{INTERFACE_NAME}=="", GOTO="persistent_net_generator_end"
  39. # default comment
  40. ENV{COMMENT}=="", ENV{COMMENT}="net device ($attr{driver})"
  41. # write rule
  42. DRIVERS=="?*", IMPORT{program}="write_net_rules"
  43. # rename interface if needed
  44. ENV{INTERFACE_NEW}=="?*", NAME="$env{INTERFACE_NEW}"
  45. LABEL="persistent_net_generator_end"