Skip to contentSkip to conversation

Add ifname= argument for persistent netdev names

PATCH In review Hans de Goede 2 participants 4 messages Sep 14, 2009 – Sep 16, 2009 3 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 Add ifname= argument for persistent netdev names

ifname=<interface>:<MAC>
Assign network device name <interface> (ie eth0) to the NIC with MAC <MAC>. Note that if you use this option you *must* specify an ifname= argument for all interfaces used in ip= or fcoe= arguments

---
 dracut.8                               |    6 +++++
 modules.d/40network/ifname-genrules.sh |   21 ++++++++++++++++++
 modules.d/40network/install            |    2 +
 modules.d/40network/net-genrules.sh    |    2 +-
 modules.d/40network/parse-ifname.sh    |   37 ++++++++++++++++++++++++++++++++
 modules.d/95fcoe/fcoe-genrules.sh      |    2 +-
 modules.d/95fcoe/parse-fcoe.sh         |    2 +-
 7 files changed, 69 insertions(+), 3 deletions(-)
 create mode 100755 modules.d/40network/ifname-genrules.sh
 create mode 100755 modules.d/40network/parse-ifname.sh
dracut.8 +6 -0
index b0547d9..e9bd0d8 100644
@@ -247,6 +247,12 @@ get ip from dhcp server on a specific interface
 .B ip=<client-IP-number>:[<server-id>]:<gateway-IP-number>:<netmask>:<client-hostname>:<interface>:{none|off}
 explicit network configuration
 
+.TP
+.B ifname=<interface>:<MAC>
+Assign network device name <interface> (ie eth0) to the NIC with MAC <MAC>.
+Note that if you use this option you \fBmust\fR specify an ifname= argument
+for all interfaces used in ip= or fcoe= arguments
+
 .SH Misc
 .TP
 .B rdblacklist=<drivername>
modules.d/40network/ifname-genrules.sh new file +21 -0
new file mode 100755
index 0000000..547f230
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+# if there are no ifname parameters, just use NAME=KERNEL
+if ! getarg ifname= >/dev/null ; then
+    echo 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="?*", ATTR{type}=="1", NAME="%k"' \
+        > /etc/udev/rules.d/50-ifname.rules
+    return
+fi
+
+{
+    for p in $(getargs ifname=); do
+        parse_ifname_opts $p
+	printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="%s", ATTR{type}=="1", NAME="%s"\n' "$ifname_mac" "$ifname_if"
+    done
+
+    # Rename non named interfaces out of the way for named ones.
+    for p in $(getargs ifname=); do
+        parse_ifname_opts $p
+	printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="?*", ATTR{type}=="1", NAME!="?*", KERNEL=="%s", NAME="%%k-renamed"\n' "$ifname_if"
+    done
+} > /etc/udev/rules.d/50-ifname.rules
modules.d/40network/install +2 -0
index 34aed93..ded70da 100755
@@ -4,10 +4,12 @@ inst "$moddir/ifup" "/sbin/ifup"
 inst "$moddir/netroot" "/sbin/netroot"
 inst "$moddir/dhclient-script" "/sbin/dhclient-script"
 inst "$moddir/dhclient.conf" "/etc/dhclient.conf" 
+inst_hook pre-udev 50 "$moddir/ifname-genrules.sh"
 inst_hook pre-udev 60 "$moddir/net-genrules.sh"
 inst_hook cmdline 91 "$moddir/dhcp-root.sh"
 inst_hook cmdline 99 "$moddir/parse-ip-opts.sh"
 inst_hook cmdline 98 "$moddir/parse-bridge.sh"
+inst_hook cmdline 99 "$moddir/parse-ifname.sh"
 inst_hook pre-pivot 10 "$moddir/kill-dhclient.sh"
 
 # TODO ifcfg config style is redhat specific, this should probably
modules.d/40network/net-genrules.sh +1 -1
index 04e0528..ba369cc 100755
@@ -29,7 +29,7 @@ fix_bootif() {
     # If we have to handle multiple interfaces, handle only them.
     elif [ -n "$IFACES" ] ; then
 	for iface in $IFACES ; do
-	    printf 'ACTION=="add", SUBSYSTEM=="net", KERNEL=="%s", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$iface"
+	    printf 'ACTION=="add", SUBSYSTEM=="net", NAME=="%s", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$iface"
 	done
 
     # Default: We don't know the interface to use, handle all
modules.d/40network/parse-ifname.sh new file +37 -0
new file mode 100755
index 0000000..aba8475
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# Format:
+#	ifname=<interface>:<mac>
+#
+# Note letters in the macaddress must be lowercase!
+#
+# Examples:
+# ifname=eth0:4a:3f:4c:04:f8:d7
+#
+# Note when using ifname= to get persistent interface names, you must specify
+# an ifname= argument for each interface used in an ip= or fcoe= argument
+
+# check if there are any ifname parameters
+if ! getarg ifname= >/dev/null ; then
+    return
+fi
+
+parse_ifname_opts() {
+    local IFS=:
+    set $1
+
+    case $# in
+        7)
+            ifname_if=$1
+            ifname_mac=$2:$3:$4:$5:$6:$7
+            ;;
+        *)
+            die "Invalid arguments for ifname="
+            ;;
+    esac
+}
+
+# Check ifname= lines
+for p in $(getargs ifname=); do
+    parse_ifname_opts $p
+done
modules.d/95fcoe/fcoe-genrules.sh +1 -1
index b5d6f07..e9d0157 100755
@@ -9,6 +9,6 @@
     if [ -n "$fcoe_mac" ] ; then
 	printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="/sbin/fcoe-up $env{INTERFACE} %s"\n' "$fcoe_mac" "$fcoe_dcb"
     else
-	printf 'ACTION=="add", SUBSYSTEM=="net", KERNEL=="%s", RUN+="/sbin/fcoe-up $env{INTERFACE} %s"\n' "$fcoe_interface" "$fcoe_dcb"
+	printf 'ACTION=="add", SUBSYSTEM=="net", NAME=="%s", RUN+="/sbin/fcoe-up $env{INTERFACE} %s"\n' "$fcoe_interface" "$fcoe_dcb"
     fi
 } > /etc/udev/rules.d/60-fcoe.rules
modules.d/95fcoe/parse-fcoe.sh +1 -1
index 81ec760..b35680f 100755
@@ -11,7 +11,7 @@
 #
 # Examples:
 # fcoe=eth0:nodcb
-# fcoe=4A:3F:4C:04:F8:D7:nodcb
+# fcoe=4a:3f:4c:04:f8:d7:nodcb
 
 [ -z "$fcoe" ] && fcoe=$(getarg fcoe=)
 
Signature · 6 lines
1.6.4.2

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1252921374-2798-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#2 lore raw

PATCH 2/3 Document netroot=fcoe:....

---
 dracut.8 |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
dracut.8 +6 -0
index e9bd0d8..322f879 100644
@@ -224,6 +224,12 @@ e.g.
 .B root=??? iscsi_firmware
 will read the iscsi parameter from the BIOS firmware
 
+.SH FCoE
+.TP
+.B netroot=fcoe:<interface|MAC>:<dcb|nodcb>
+Try to connect to a FCoE SAN through the NIC specified by <interface> or <MAC>,
+for the second argument, currently only nodcb is supported.
+
 .SH NBD
 .TP
 .B root=nbd:<server>:<port>[:<fstype>][:<mountopts>]
Signature · 6 lines
1.6.4.2

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1252921374-2798-2-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#4 lore raw

PATCH 3/3 Document that MAC addresses must be lowercase

---
 dracut.8 |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
dracut.8 +3 -1
index 322f879..32d2e5b 100644
@@ -228,7 +228,8 @@ will read the iscsi parameter from the BIOS firmware
 .TP
 .B netroot=fcoe:<interface|MAC>:<dcb|nodcb>
 Try to connect to a FCoE SAN through the NIC specified by <interface> or <MAC>,
-for the second argument, currently only nodcb is supported.
+for the second argument, currently only nodcb is supported. Note letters in
+the MAC-address must be lowercase!
 
 .SH NBD
 .TP
@@ -256,6 +257,7 @@ explicit network configuration
 .TP
 .B ifname=<interface>:<MAC>
 Assign network device name <interface> (ie eth0) to the NIC with MAC <MAC>.
+Note letters in the MAC-address must be lowercase!
 Note that if you use this option you \fBmust\fR specify an ifname= argument
 for all interfaces used in ip= or fcoe= arguments
 
Signature · 6 lines
1.6.4.2

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1252921374-2798-3-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#6 lore raw

Re: [PATCH 3/3] Document that MAC addresses must be lowercase

Quoted 19 lines · Hans de Goede
---
  dracut.8 |    4 +++-
  1 files changed, 3 insertions(+), 1 deletions(-)
dracut.8 +2 -1
index 322f879..32d2e5b 100644
@@ -228,7 +228,8 @@ will read the iscsi parameter from the BIOS firmware
  .TP
  .B netroot=fcoe:<interface|MAC>:<dcb|nodcb>
  Try to connect to a FCoE SAN through the NIC specified by<interface>  or<MAC>,
-for the second argument, currently only nodcb is supported.
+for the second argument, currently only nodcb is supported. Note letters in
+the MAC-address must be lowercase!
 
  .SH NBD
  .TP

dracut.8 explicit network configuration · line 263

Quoted 7 lines
dracut.8 +1 -0
@@ -256,6 +257,7 @@ explicit network configuration
  .TP
  .B ifname=<interface>:<MAC>
  Assign network device name<interface>  (ie eth0) to the NIC with MAC<MAC>.
+Note letters in the MAC-address must be lowercase!
  Note that if you use this option you \fBmust\fR specify an ifname= argument
  for all interfaces used in ip= or fcoe= arguments
 

applied and pushed
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html