]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
add mtu and macaddr to ip=
authorHarald Hoyer <harald@redhat.com>
Wed, 4 Apr 2012 12:47:29 +0000 (14:47 +0200)
committerHarald Hoyer <harald@redhat.com>
Thu, 5 Apr 2012 11:25:41 +0000 (13:25 +0200)
dracut.cmdline.7.asc
modules.d/40network/ifup.sh
modules.d/40network/net-lib.sh
modules.d/40network/parse-ip-opts.sh
modules.d/45ifcfg/write-ifcfg.sh
modules.d/99base/dracut-lib.sh

index 59b3fb68f8dd73aca95601e039a60ee7ceb6c571..a1e06ddfdddd915a235660afcbffdbfac5e6227b 100644 (file)
@@ -260,16 +260,19 @@ Network
 
     ibft::: iBFT autoconfiguration
 
-**ip=**_<interface>_:_{dhcp|on|any|dhcp6|auto6}_::
+**ip=**_<interface>_:_{dhcp|on|any|dhcp6|auto6}_[:[_<mtu>_][:_<macaddr>_]]::
     This parameter can be specified multiple times.
 +
 dhcp|on|any|dhcp6::: get ip from dhcp server on a specific interface
 auto6::: do IPv6 autoconfiguration
+<macaddr>::: optionally set <macaddr> on the <interface>
 
-**ip=**_<client-IP>_:_<server-IP>_:_<gateway-IP>_:_<netmask>_:_<client_hostname>_:_<interface>_:_{none|off}_::
+**ip=**_<client-IP>_:_<server-IP>_:_<gateway-IP>_:_<netmask>_:_<client_hostname>_:_<interface>_:_{none|off|dhcp|on|any|dhcp6|auto6|ibft}_[:[_<mtu>_][:_<macaddr>_]]::
     explicit network configuration. If you want do define a IPv6 address, put it
     in brackets (e.g. [2001:DB8::1]). This parameter can be specified multiple
     times.
++
+<macaddr>::: optionally set <macaddr> on the <interface>
 
 **ifname=**_<interface>_:_<MAC>_::
     Assign network device name <interface> (ie eth0) to the NIC with MAC <MAC>.
index ffae15c1de0435dd041c6b67aec188b9a88b4faa..2111b41296a55306a997fb8e46d88086d192a4c0 100755 (executable)
@@ -10,9 +10,7 @@
 PATH=/usr/sbin:/usr/bin:/sbin:/bin
 
 type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
-export PS4="ifup.$1.$$ + "
-exec >>/run/initramfs/loginit.pipe 2>>/run/initramfs/loginit.pipe
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh
 
 # Huh? No $1?
 [ -z "$1" ] && exit 1
@@ -107,6 +105,8 @@ do_static() {
     {
         echo ip link set $netif up
         echo wait_for_if_up $netif
+        [ -n "$macaddr" ] && echo ip link set address $macaddr
+        [ -n "$mtu" ] && echo ip link set mtu $mtu
         # do not flush addr for ipv6
         strstr $ip '*:*:*' || \
             echo ip addr flush dev $netif
@@ -219,12 +219,12 @@ for p in $(getargs ip=); do
     ip_to_var $p
     # skip ibft
     [ "$autoconf" = "ibft" ] && continue
-       
+
     # If this option isn't directed at our interface, skip it
     [ -n "$dev" ] && [ "$dev" != "$netif" ] && continue
 
     # Store config for later use
-    for i in ip srv gw mask hostname; do
+    for i in ip srv gw mask hostname macaddr; do
         eval '[ "$'$i'" ] && echo '$i'="$'$i'"'
     done > /tmp/net.$netif.override
 
index 4055ccf6f803f8fe911a810fcf2ef1a283c0436c..467c79f1e124aa19e3fa66552a8ef4d455941a50 100644 (file)
@@ -225,3 +225,30 @@ parse_iscsi_root()
     fi
 }
 
+ip_to_var() {
+    local v=${1}:
+    local i
+    set --
+    while [ -n "$v" ]; do
+        if [ "${v#\[*:*:*\]:}" != "$v" ]; then
+            # handle IPv6 address
+            i="${v%%\]:*}"
+            i="${i##\[}"
+            set -- "$@" "$i"
+            v=${v#\[$i\]:}
+        else
+            set -- "$@" "${v%%:*}"
+            v=${v#*:}
+        fi
+    done
+
+    unset ip srv gw mask hostname dev autoconf macaddr mtu
+    case $# in
+        0)  autoconf="error" ;;
+        1)  autoconf=$1 ;;
+        2)  dev=$1; autoconf=$2 ;;
+        3)  dev=$1; autoconf=$2; mtu=$3 ;;
+        4)  dev=$1; autoconf=$2; mtu=$3; macaddr=$4 ;;
+        *)  ip=$1; srv=$2; gw=$3; mask=$4; hostname=$5; dev=$6; autoconf=$7; mtu=$8; macaddr=$9 ;;
+    esac
+}
index 785132991977b5a46c0594d0edada187c7246c49..97702a2750b1fb730406f1fdbb928215ea432254 100755 (executable)
@@ -5,9 +5,9 @@
 # Format:
 #       ip=[dhcp|on|any]
 #
-#       ip=<interface>:[dhcp|on|any]
+#       ip=<interface>:[dhcp|on|any][:[<mtu>][:<macaddr>]]
 #
-#       ip=<client-IP-number>:<server-IP-number>:<gateway-IP-number>:<netmask>:<client-hostname>:<interface>:[dhcp|on|any|none|off]
+#       ip=<client-IP-number>:<server-IP-number>:<gateway-IP-number>:<netmask>:<client-hostname>:<interface>:{dhcp|on|any|none|off}[:[<mtu>][:<macaddr>]]
 #
 # When supplying more than only ip= line, <interface> is mandatory and
 # bootdev= must contain the name of the primary interface to use for
index fe986df43be93364d1b74b752e4d8668f3a3fc72..c072a138ce92550184833996bd440a291bda4355 100755 (executable)
@@ -38,6 +38,8 @@ for netif in $IFACES ; do
         echo "ONBOOT=yes"
         echo "NETBOOT=yes"
         echo "UUID=$uuid"
+        [ -n "$macaddr" ] && echo "MACADDR=$macaddr"
+        [ -n "$mtu" ] && echo "MTU=$mtu"
         if [ -f /tmp/net.$netif.lease ]; then
             strstr "$ip" '*:*:*' &&
             echo "DHCPV6C=yes"
@@ -60,6 +62,7 @@ for netif in $IFACES ; do
             echo "HWADDR=$(cat /sys/class/net/$netif/address)"
             echo "TYPE=Ethernet"
             echo "NAME=\"Boot Disk\""
+            [ -n "$mtu" ] && echo "MTU=$mtu"
         } >> /tmp/ifcfg/ifcfg-$netif
     fi
 
index ad29451b5c90af13d42415b59709a0ee43341280..14ae62578fdda3f3d7ab949a0a267dc2aee0a46b 100755 (executable)
@@ -436,32 +436,6 @@ nfsroot_to_var() {
     fi
 }
 
-ip_to_var() {
-    local v=${1}:
-    local i
-    set --
-    while [ -n "$v" ]; do
-        if [ "${v#\[*:*:*\]:}" != "$v" ]; then
-            # handle IPv6 address
-            i="${v%%\]:*}"
-            i="${i##\[}"
-            set -- "$@" "$i"
-            v=${v#\[$i\]:}
-        else
-            set -- "$@" "${v%%:*}"
-            v=${v#*:}
-        fi
-    done
-
-    unset ip srv gw mask hostname dev autoconf
-    case $# in
-        0)  autoconf="error" ;;
-        1)  autoconf=$1 ;;
-        2)  dev=$1; autoconf=$2 ;;
-        *)  ip=$1; srv=$2; gw=$3; mask=$4; hostname=$5; dev=$6; autoconf=$7 ;;
-    esac
-}
-
 # Create udev rule match for a device with its device name, or the udev property
 # ID_FS_UUID or ID_FS_LABEL
 #