Skip to contentSkip to conversation

ipconfig: Add new kernel parameter to force MAC address

RFC PATCH In review Naohiro Aota 2 participants 2 messages Oct 20, 2011 – Oct 21, 2011

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 ipconfig: Add new kernel parameter to force MAC address

There are some boards (such as Pandaboard) that doesn't have persistent MAC address and so the kernel generate random MAC for it. Usually you can configure the device to use some static MAC address with userland tools. However it's not possible when you are using NFS root since the kernel already set the random MAC address and you cannot change it after system boot up process.

This patch add new kernel parameter "mac". When this parameter is used, the kernel auto configuration routine force the network device to use the specified MAC address.

---

Here is Pandaboard block diagram. http://pandaboard.org/node/223/

As you can see, the ethernet device is connected via USB so that the kernel use smsc95xx to configure this device. Since the device lacks EEPROM, it doesn't have its own MAC and the kernel specify some random MAC for it.

I've also considered a way to force random_ether_addr() to use kernel parameter specified MAC. However there are two problems with it.

1. There are much use of the function among Linux kernel tree so that it should be difficult and hard way to take.

2. If there are more than one ethernet device available, one cannot distinguish which device get the MAC address.

 Documentation/filesystems/nfs/nfsroot.txt |    8 +++
 Documentation/kernel-parameters.txt       |    3 +
 net/ipv4/Kconfig                          |   13 ++++
 net/ipv4/ipconfig.c                       |   91 +++++++++++++++++++++++++++++
 4 files changed, 115 insertions(+), 0 deletions(-)
Documentation/filesystems/nfs/nfsroot.txt +8 -0
index ffdd9d8..fa2bea3 100644
@@ -159,6 +159,14 @@ ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>
                 Default: any
 
 
+mac=<mac-address>
+
+  This parameter tells the kernel to try using the specified MAC
+  address. This is useful when your network device does not have its
+  own MAC address and so the kernel select some random address for the
+  device.
+
+
 nfsrootdebug
 
   This parameter enables debugging messages to appear in the kernel
Documentation/kernel-parameters.txt +3 -0
index d6e6724..4bc7d84 100644
@@ -1333,6 +1333,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 	ltpc=		[NET]
 			Format: <io>,<irq>,<dma>
 
+	mac=		[IP_PNP]
+			See Documentation/filesystems/nfs/nfsroot.txt.
+
 	machvec=	[IA-64] Force the use of a particular machine-vector
 			(machvec) in a generic kernel.
 			Example: machvec=hpzx1_swiotlb
net/ipv4/Kconfig +13 -0
index cbb505b..ac4da23 100644
@@ -163,6 +163,19 @@ config IP_PNP_RARP
 	  operating on your network. Read
 	  <file:Documentation/filesystems/nfs/nfsroot.txt> for details.
 
+config IP_PNP_SPECIFIC_MAC
+       bool "IP: Specific MAC address support"
+       depends on IP_PNP
+       help
+	 If you want your Linux box to mount its whole root file system (the
+	 one containing the directory /) from some other computer over the net
+	 via NFS and you want the IP address of your computer to be discovered
+	 automatically at boot time using some protocols like DHCP, BOOTP or
+	 RARP but your network device does not have static MAC address, you may
+	 want to say Y here. This option add kernel boot parameter mac= to
+	 specify the MAC address to be used for automatic IP address
+	 configuration.
+
 # not yet ready..
 #   bool '    IP: ARP support' CONFIG_IP_PNP_ARP
 config NET_IPIP
net/ipv4/ipconfig.c +92 -0

134 lines not on this page · raw message

Signature · 1 line
1.7.6.1
#1 lore raw
Quoted 3 lines · Naohiro Aota

However it's not possible when you are using NFS root since the kernel already set the random MAC address and you cannot change it after system boot up process.

Is there any particular reason you're not using an initramfs? Kernel autoconfiguration & NFS-root are relicts of old times, with an initramfs you can start a proper portmap/rpcbind daemon and use full regular NFS (v4 even).

... and you can change the MAC before bringing the interface up.

-David