File 0169-network_set_mtu_macaddr_for_dhcp.patch of Package dracut.12460
From b27ca9cfcb5df2066e87f673cb5c060bcf4016fa Mon Sep 17 00:00:00 2001
From: Pawel Wieczorkiewicz <pwieczorkiewicz@suse.de>
Date: Tue, 23 Aug 2016 12:29:03 +0200
Subject: Set MTU and LLADDR for DHCP if specified
References: boo#959803
Signed-off-by: Pawel Wieczorkiewicz <pwieczorkiewicz@suse.de>
---
modules.d/40network/ifup.sh | 52 ++++++++++++++++++++++++++++-----------------
1 file changed, 32 insertions(+), 20 deletions(-)
diff --git a/modules.d/40network/ifup.sh b/modules.d/40network/ifup.sh
index 0aaea72..3b92854 100755
--- a/modules.d/40network/ifup.sh
+++ b/modules.d/40network/ifup.sh
@@ -90,7 +90,7 @@ else
fi
dhcp_apply() {
- unset IPADDR INTERFACE BROADCAST NETWORK PREFIXLEN ROUTES GATEWAYS HOSTNAME DNSDOMAIN DNSSEARCH DNSSERVERS
+ unset IPADDR INTERFACE BROADCAST NETWORK PREFIXLEN ROUTES GATEWAYS MTU HOSTNAME DNSDOMAIN DNSSEARCH DNSSERVERS
if [ -f /tmp/leaseinfo.${netif}.dhcp.ipv${1:1:1} ]; then
. /tmp/leaseinfo.${netif}.dhcp.ipv${1:1:1}
else
@@ -128,6 +128,9 @@ dhcp_apply() {
done
fi
+ # Set MTU
+ [ -n "${MTU}" ] && ip $1 link set mtu "$MTU" dev "$INTERFACE"
+
# Setup hostname
[ -n "${HOSTNAME}" ] && hostname "$HOSTNAME"
@@ -167,6 +170,25 @@ dhcp_apply() {
return 0
}
+read_ifcfg() {
+ unset PREFIXLEN LLADDR MTU REMOTE_IPADDR GATEWAY BOOTPROTO
+
+ if [ -e /etc/sysconfig/network/ifcfg-${netif} ] ; then
+ # Pull in existing configuration
+ . /etc/sysconfig/network/ifcfg-${netif}
+
+ # The first configuration can be anything
+ [ -n "$PREFIXLEN" ] && prefix=${PREFIXLEN}
+ [ -n "$LLADDR" ] && macaddr=${LLADDR}
+ [ -n "$MTU" ] && mtu=${MTU}
+ [ -n "$REMOTE_IPADDR" ] && server=${REMOTE_IPADDR}
+ [ -n "$GATEWAY" ] && gw=${GATEWAY}
+ [ -n "$BOOTPROTO" ] && autoconf=${BOOTPROTO}
+ return 0
+ fi
+ return 1
+}
+
# Run dhclient
do_dhcp() {
# dhclient-script will mark the netif up and generate the online
@@ -197,14 +219,14 @@ do_dhcp() {
dhclient="wickedd-dhcp4 --test"
fi
- if ! iface_has_link $netif; then
- warn "No carrier detected"
- warn "Trying to set $netif up..."
- ip $1 link set dev "$netif" up
- if ! iface_has_link $netif; then
- warn "Failed..."
- return 1
- fi
+ if ! linkup $netif; then
+ warn "Could not bring interface $netif up!"
+ return 1
+ fi
+
+ if read_ifcfg ; then
+ [ -n "$macaddr" ] && ip $1 link set address $macaddr dev $netif
+ [ -n "$mtu" ] && ip $1 link set mtu $mtu dev $netif
fi
$dhclient --test-format leaseinfo --test-output /tmp/leaseinfo.${netif}.dhcp.ipv${1:1:1} --test-request - $netif << EOF
@@ -245,17 +267,7 @@ do_ipv6auto() {
# Handle ip configuration via ifcfg files
do_ifcfg() {
- if [ "$autoconf" = "static" ] &&
- [ -e /etc/sysconfig/network/ifcfg-${netif} ] ; then
- # Pull in existing static configuration
- . /etc/sysconfig/network/ifcfg-${netif}
-
- # The first configuration can be anything
- [ -n "$PREFIXLEN" ] && prefix=${PREFIXLEN}
- [ -n "$MTU" ] && mtu=${MTU}
- [ -n "$REMOTE_IPADDR" ] && server=${REMOTE_IPADDR}
- [ -n "$GATEWAY" ] && gw=${GATEWAY}
- [ -n "$BOOTPROTO" ] && autoconf=${BOOTPROTO}
+ if [ "$autoconf" = "static" ] && read_ifcfg; then
case "$autoconf" in
dhcp6)
load_ipv6
--
2.6.6