From 6bc37a9952f5757bdb3a29c638e8ba1a6b66e7ca Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Thu, 11 Oct 2012 13:31:43 +0200
Subject: [PATCH] Convert MAC addresses to lowercase with "tr"

https://bugzilla.redhat.com/show_bug.cgi?id=835646
---
 dracut-rhel6.xml                    | 1 -
 dracut.8                            | 2 --
 modules.d/40network/install         | 2 +-
 modules.d/40network/net-genrules.sh | 2 +-
 modules.d/40network/parse-ifname.sh | 4 ++--
 modules.d/95fcoe/install            | 2 +-
 modules.d/95fcoe/parse-fcoe.sh      | 4 +---
 7 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/dracut-rhel6.xml b/dracut-rhel6.xml
index 85b03b4..68f01fb 100644
--- a/dracut-rhel6.xml
+++ b/dracut-rhel6.xml
@@ -1447,7 +1447,6 @@ KEYTABLE=de-latin1-nodeadkeys</programlisting></para>
                 <term><envar>ifname=</envar><replaceable>&lt;interface&gt;</replaceable>:<replaceable>&lt;MAC&gt;</replaceable></term>
                 <listitem>
                   <para>Assign network device name &lt;interface&gt; (ie eth0) to the NIC with MAC &lt;MAC&gt;.
-    Note letters in the MAC-address must be lowercase!
     <remark>Note: If you use this option you <emphasis remap="B">must</emphasis> specify an ifname= argument for all interfaces used in ip= or fcoe= arguments.</remark>
     This parameter can be specified multiple times.</para>
                 </listitem>
diff --git a/dracut.8 b/dracut.8
index 9fcc55b..1e0f036 100644
--- a/dracut.8
+++ b/dracut.8
@@ -303,7 +303,6 @@ This parameter can be specified multiple times.
 .TP
 .BR 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
 This parameter can be specified multiple times.
@@ -406,7 +405,6 @@ This parameter can be specified multiple times.
 .TP
 .BR fcoe=<edd|interface|MAC>:<dcb|nodcb>
 Try to connect to a FCoE SAN through the NIC specified by <interface> or <MAC> or EDD settings.
-Note letters in the MAC-address must be lowercase!
 This parameter can be specified multiple times.
 
 .SS NBD
diff --git a/modules.d/40network/install b/modules.d/40network/install
index abfa7a5..a816260 100755
--- a/modules.d/40network/install
+++ b/modules.d/40network/install
@@ -1,5 +1,5 @@
 #!/bin/bash
-dracut_install ip dhclient brctl arping
+dracut_install ip dhclient brctl arping tr
 inst "$moddir/ifup" "/sbin/ifup"
 inst "$moddir/netroot" "/sbin/netroot"
 inst "$moddir/dhclient-script" "/sbin/dhclient-script"
diff --git a/modules.d/40network/net-genrules.sh b/modules.d/40network/net-genrules.sh
index b435e7c..71d3bd0 100755
--- a/modules.d/40network/net-genrules.sh
+++ b/modules.d/40network/net-genrules.sh
@@ -10,7 +10,7 @@ fix_bootif() {
     macaddr=${macaddr%:}
     # strip hardware type field from pxelinux
     [ -n "${macaddr%??:??:??:??:??:??}" ] && macaddr=${macaddr#??:}
-    echo $macaddr
+    echo $macaddr | tr '[:upper:]' '[:lower:]'
 }
 
 # Don't continue if we don't need network
diff --git a/modules.d/40network/parse-ifname.sh b/modules.d/40network/parse-ifname.sh
index aba8475..9632680 100755
--- a/modules.d/40network/parse-ifname.sh
+++ b/modules.d/40network/parse-ifname.sh
@@ -3,7 +3,6 @@
 # Format:
 #	ifname=<interface>:<mac>
 #
-# Note letters in the macaddress must be lowercase!
 #
 # Examples:
 # ifname=eth0:4a:3f:4c:04:f8:d7
@@ -23,7 +22,8 @@ parse_ifname_opts() {
     case $# in
         7)
             ifname_if=$1
-            ifname_mac=$2:$3:$4:$5:$6:$7
+            # udev requires MAC addresses to be lower case
+            ifname_mac=$(echo $2:$3:$4:$5:$6:$7 | tr '[:upper:]' '[:lower:]')
             ;;
         *)
             die "Invalid arguments for ifname="
diff --git a/modules.d/95fcoe/install b/modules.d/95fcoe/install
index a2312cc..141943a 100755
--- a/modules.d/95fcoe/install
+++ b/modules.d/95fcoe/install
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-dracut_install ip 
+dracut_install ip tr
 inst dcbtool 
 inst fipvlan
 inst lldpad
diff --git a/modules.d/95fcoe/parse-fcoe.sh b/modules.d/95fcoe/parse-fcoe.sh
index 4ac0f58..fa16440 100755
--- a/modules.d/95fcoe/parse-fcoe.sh
+++ b/modules.d/95fcoe/parse-fcoe.sh
@@ -7,8 +7,6 @@
 # Note currently only nodcb is supported, the dcb option is reserved for
 # future use.
 #
-# Note letters in the macaddress must be lowercase!
-#
 # Examples:
 # fcoe=eth0:nodcb
 # fcoe=4a:3f:4c:04:f8:d7:nodcb
@@ -36,7 +34,7 @@ parse_fcoe_opts() {
             return 0
             ;;
         7)
-            fcoe_mac=$1:$2:$3:$4:$5:$6
+            fcoe_mac=$(echo $1:$2:$3:$4:$5:$6 | tr '[:upper:]' '[:lower:]')
             fcoe_dcb=$7
             return 0
             ;;
-- 
1.8.3.1

