dracut/0145-40network-handle-ip-ifname-static-correctly.patch
Thomas Renninger 3080f777f5 Accepting request 355392 from home:favogt:branches:Base:System
- Refresh and merge:
    0133-Allow-multiple-configurations-per-network-interface-.patch
    0145-40network-handle-ip-ifname-static-correctly.patch
    0162-network-Request-DHCP-lease-instead-of-getting-applyi.patch
- Delete 0134-Remove-bootdev-warning-bnc-881112.patch:
    - ip=ibft got deprecated, so workaround not necessary

OBS-URL: https://build.opensuse.org/request/show/355392
OBS-URL: https://build.opensuse.org/package/show/Base:System/dracut?expand=0&rev=246
2016-01-26 16:28:00 +00:00

106 lines
3.3 KiB
Diff

From 4b0e5841ce7dbeca5186e0d47f8835b00007cd6e Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Thu, 21 Aug 2014 12:46:45 +0200
Subject: 40network: handle 'ip=ifname:static' correctly
'static' configuration means 'apply the settings from the ifcfg file'.
Which might be either static or dhcp.
And for multiple configurations the first configuration can be
either dhcp or static; only the following configurations must
be static.
References: bnc#892801
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
modules.d/40network/ifup.sh | 40 ++++++++++++++++++++++++++++++----------
1 file changed, 30 insertions(+), 10 deletions(-)
Index: dracut-044/modules.d/40network/ifup.sh
===================================================================
--- dracut-044.orig/modules.d/40network/ifup.sh
+++ dracut-044/modules.d/40network/ifup.sh
@@ -182,11 +182,13 @@ do_dhcp() {
info "Preparation for DHCP transaction"
+ [ -d /var/lib/wicked ] || mkdir -p /var/lib/wicked
+
local dhclient=''
- if [ "$1" = "-4" ] ; then
- dhclient="wickedd-dhcp4"
- elif [ "$1" = "-6" ] ; then
+ if [ "$1" = "-6" ] ; then
dhclient="wickedd-dhcp6"
+ else
+ dhclient="wickedd-dhcp4"
fi
if ! iface_has_link $netif; then
@@ -230,33 +232,49 @@ do_ipv6auto() {
return 0
}
-# Handle static ip configuration
-do_static() {
+# 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}
+ case "$autoconf" in
+ dhcp6)
+ load_ipv6
+ do_dhcp -6 ;;
+ dhcp*)
+ do_dhcp -4 ;;
+ *)
+ do_static ;;
+ esac
# loop over all configurations in ifcfg-$netif (IPADDR*) and apply
for conf in ${!IPADDR@}; do
ip=${!conf}
[ -z "$ip" ] && continue
ext=${conf#IPADDR}
- concat="PREFIXLEN$ext" && [ -n "${!concat}" ] && mtu=${!concat}
+ concat="PREFIXLEN$ext" && [ -n "${!concat}" ] && prefix=${!concat}
concat="MTU$ext" && [ -n "${!concat}" ] && mtu=${!concat}
concat="REMOTE_IPADDR$ext" && [ -n "${!concat}" ] && server=${!concat}
concat="GATEWAY$ext" && [ -n "${!concat}" ] && gw=${!concat}
- concat="BOOTPROTO$ext" && [ -n "${!concat}" ] && autoconf=${!concat}
- do_static_setup
+ # Additional configurations must be static
+ do_static
done
else
- do_static_setup
+ do_static
fi
return 0
}
-do_static_setup() {
+# Handle static ip configuration
+do_static() {
strglobin $ip '*:*:*' && load_ipv6
if ! linkup $netif; then
@@ -498,6 +516,8 @@ for p in $(getargs ip=); do
do_dhcp -6 ;;
auto6)
do_ipv6auto ;;
+ static)
+ do_ifcfg ;;
*)
do_static ;;
esac