@@ -7,6 +7,7 @@
# MATCHID bus_id used for the match
# MATCHDRV driver name used for the match
# MATCHIFTYPE interface type match
+# MATCHINDEX firmware index used for the match
# COMMENT comment to add to the generated rule
# INTERFACE_NAME requested name supplied by external tool
# INTERFACE_NEW new interface name returned by rule writer
@@ -29,6 +30,9 @@ ENV{MATCHADDR}="$attr{address}"
# match interface type
ENV{MATCHIFTYPE}="$attr{type}"
+#read firmware index
+ATTRS{index}=="?*", ENV{MATCHINDEX}="$attr{index}"
+
# ignore KVM virtual interfaces
ENV{MATCHADDR}=="54:52:00:*", GOTO="persistent_net_generator_end"
@@ -11,6 +11,7 @@
# MATCHDEVID dev_id used for the match
# MATCHDRV driver name used for the match
# MATCHIFTYPE interface type match
+# MATCHINDEX firmware index used for the match
# COMMENT comment to add to the generated rule
# INTERFACE_NAME requested name supplied by external tool
# INTERFACE_NEW new interface name returned by rule writer
@@ -72,7 +73,11 @@ write_rule() {
echo ""
[ "$comment" ] && echo "# $comment"
- echo "SUBSYSTEM==\"net\", ACTION==\"add\"$match, NAME=\"$name\""
+ if [ "$MATCHINDEX" -a "$UDEVLOM" ]; then
+ echo "SUBSYSTEM==\"net\", ACTION==\"add\"$match, NAME=\"lom$MATCHINDEX\""
+ else
+ echo "SUBSYSTEM==\"net\", ACTION==\"add\"$match, NAME=\"$name\""
+ fi
} >> $RULES_FILE
}
@@ -108,6 +113,10 @@ if [ "$MATCHIFTYPE" ]; then
match="$match, ATTR{type}==\"$MATCHIFTYPE\""
fi
+if [ "$MATCHINDEX" -a "$UDEVLOM" ]; then
+ match="$match, ATTRS{index}==\"$MATCHINDEX\""
+fi
+
if [ -z "$match" ]; then
echo "missing valid match" >&2
unlock_rules_file
@@ -134,6 +143,10 @@ else
fi
fi
+if [ "$MATCHINDEX" -a "$UDEVLOM" ]; then
+ echo "INTERFACE_NEW=lom$MATCHINDEX"
+fi
+
write_rule "$match" "$INTERFACE" "$COMMENT"
unlock_rules_file