dracut/0133-Allow-multiple-configurations-per-network-interface-.patch
Marcus Meissner 0f203926a1 Accepting request 422869 from home:hreinecke:branches:Base:System
- Rename patch:
  * From 0211-fix_multipath_check_hostonly.patch
    to 0303-fix_multipath_check_hostonly.patch
- Rename patch:
  * From 0213-10i18n-keymap-find.patch
    to 0213-Fix-wrong-keymap-inclusion.patch

- 95fcoe: Do not complain about missing /etc/hba.conf (bsc#980539)
  * Add 0215-95fcoe-Do-not-complain-about-missing-etc-hba.conf.patch
- 95fcoe: silence lldpad warnings
  * Add 0216-95fcoe-silence-lldpad-warnings.patch
- 95fcoe: Allow to specify the FCoE mode via the fcoe= parameter
  * Add 0217-95fcoe-Allow-to-specify-the-FCoE-mode-via-the-fcoe-p.patch
- 40network: allow persistent interface names (bsc#995284)
  * Add 0218-40network-allow-persistent-interface-names.patch
- 95fcoe: use interface names instead of MAC addresses
  * Add 0219-95fcoe-use-interface-names-instead-of-MAC-addresses.patch
- 95fcoe: always set AUTO_VLAN for fcoemon (bsc#995019)
  * Add 0220-95fcoe-always-set-AUTO_VLAN-for-fcoemon.patch
- 95fcoe: Add shutdown script (bsc#994860)
  * Add 0221-95fcoe-Add-shutdown-script.patch
- 90dm: Fixup shutdown script (bsc#994860)
  * Add 0222-90dm-Fixup-shutdown-script.patch
- 90dm: fixup dependency cycle between MD and DM shutdown (bsc#994860)
  * Add 0223-90dm-fixup-dependency-cycle-between-MD-and-DM-shutdo.patch
- 90multipath: Start daemon after udev settle (bsc#986734)
  * Add 0304-90multipath-Start-daemon-after-udev-settle.patch
- 90multipath: load dm_multipath module during startup
  * Add 0305-90multipath-load-dm_multipath-module-during-startup.patch
- 90multipath: add shutdown script (bsc#994860)

OBS-URL: https://build.opensuse.org/request/show/422869
OBS-URL: https://build.opensuse.org/package/show/Base:System/dracut?expand=0&rev=263
2016-09-01 11:57:40 +00:00

274 lines
9.4 KiB
Diff

From 114aadff326cb6ac63d2b3926fafe944b1670a62 Mon Sep 17 00:00:00 2001
From: Julian Wolf <juwolf@suse.com>
Date: Thu, 31 Jul 2014 17:11:16 +0200
Subject: Allow multiple configurations per network interface bnc#887906
Signed-off-by: Julian Wolf <juwolf@suse.com>
---
modules.d/40network/ifup.sh | 91 ++++++++++++++++++++++------------
modules.d/40network/net-genrules.sh | 2 +-
modules.d/40network/net-lib.sh | 4 +-
modules.d/40network/parse-ibft.sh | 4 +-
modules.d/40network/parse-ip-opts.sh | 14 ++---
5 files changed, 70 insertions(+), 45 deletions(-)
Index: dracut-044/modules.d/40network/ifup.sh
===================================================================
--- dracut-044.orig/modules.d/40network/ifup.sh
+++ dracut-044/modules.d/40network/ifup.sh
@@ -90,6 +90,7 @@ else
fi
dhcp_apply() {
+ unset IPADDR INTERFACE BROADCAST NETWORK PREFIXLEN ROUTES GATEWAYS HOSTNAME DNSDOMAIN DNSSEARCH DNSSERVERS
if [ -f /tmp/leaseinfo.${netif}.dhcp.ipv${1:1:1} ]; then
. /tmp/leaseinfo.${netif}.dhcp.ipv${1:1:1}
else
@@ -131,24 +132,37 @@ dhcp_apply() {
[ -n "${HOSTNAME}" ] && hostname "$HOSTNAME"
# If nameserver= has not been specified, use what dhcp provides
- if [ ! -s /tmp/net.$netif.resolv.conf ]; then
+ if [ ! -s /tmp/net.$netif.resolv.conf.ipv${1:1:1} ]; then
if [ -n "${DNSDOMAIN}" ]; then
echo domain "${DNSDOMAIN}"
- fi >> /tmp/net.$netif.resolv.conf
+ fi >> /tmp/net.$netif.resolv.conf.ipv${1:1:1}
if [ -n "${DNSSEARCH}" ]; then
echo search "${DNSSEARCH}"
- fi >> /tmp/net.$netif.resolv.conf
+ fi >> /tmp/net.$netif.resolv.conf.ipv${1:1:1}
if [ -n "${DNSSERVERS}" ] ; then
for s in ${DNSSERVERS}; do
echo nameserver "$s"
done
- fi >> /tmp/net.$netif.resolv.conf
+ fi >> /tmp/net.$netif.resolv.conf.ipv${1:1:1}
fi
- [ -e /tmp/net.$netif.resolv.conf ] && \
- cp -f /tmp/net.$netif.resolv.conf /etc/resolv.conf
-
+ # copy resolv.conf if it doesn't exist yet, modify otherwise
+ if [ -e /tmp/net.$netif.resolv.conf.ipv${1:1:1} ] && [ ! -e /etc/resolv.conf ]; then
+ cp -f /tmp/net.$netif.resolv.conf.ipv${1:1:1} /etc/resolv.conf
+ else
+ if [ -n "$(sed -n '/^search .*$/p' /etc/resolv.conf)" ]; then
+ sed -i "s/\(^search .*\)$/\1 ${DNSSEARCH}/" /etc/resolv.conf
+ else
+ echo search ${DNSSEARCH} >> /etc/resolv.conf
+ fi
+ if [ -n "${DNSSERVERS}" ] ; then
+ for s in ${DNSSERVERS}; do
+ echo nameserver "$s"
+ done
+ fi >> /etc/resolv.conf
+ fi
+
info "DHCP is finished successfully"
return 0
}
@@ -175,9 +189,6 @@ do_dhcp() {
dhclient="wickedd-dhcp6"
fi
- # Address changed
- ip $1 addr flush dev "$netif"
-
if ! iface_has_link $netif; then
warn "No carrier detected"
warn "Trying to set $netif up..."
@@ -191,7 +202,6 @@ do_dhcp() {
$dhclient --test $netif > /tmp/leaseinfo.${netif}.dhcp.ipv${1:1:1}
dhcp_apply $1 || return $?
- echo $netif > /tmp/net.${netif}.did-setup
echo $netif > /tmp/setup_net_${netif}.ok
return 0
}
@@ -222,6 +232,31 @@ do_ipv6auto() {
# Handle static ip configuration
do_static() {
+ if [ "$autoconf" = "static" ] &&
+ [ -e /etc/sysconfig/network/ifcfg-${netif} ] ; then
+ # Pull in existing static configuration
+ . /etc/sysconfig/network/ifcfg-${netif}
+
+ # 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="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
+ done
+ else
+ do_static_setup
+ fi
+
+ return 0
+}
+
+do_static_setup() {
strglobin $ip '*:*:*' && load_ipv6
if ! linkup $netif; then
@@ -258,7 +293,6 @@ if strglobin $ip '*:*:*'; then
fi
# Assume /24 prefix for IPv4
[ -z "$prefix" ] && prefix=24
- ip addr flush dev $netif
ip addr add $ip/$prefix ${srv:+peer $srv} brd + dev $netif
fi
@@ -277,8 +311,6 @@ if strglobin $ip '*:*:*'; then
done
[ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
-
- return 0
}
# loopback is always handled the same way
@@ -426,6 +458,14 @@ for p in $(getargs ip=); do
ip_to_var $p
# skip ibft
[ "$autoconf" = "ibft" ] && continue
+
+ # skip if same configuration appears twice
+ while read line
+ do
+ [ "$line" = "$p" ] && continue 2
+ done < /tmp/net.${netif}.conf
+
+ echo $p >> /tmp/net.${netif}.conf
case "$dev" in
??:??:??:??:??:??) # MAC address
@@ -443,29 +483,12 @@ for p in $(getargs ip=); do
[ "$use_bridge" != 'true' ] && \
[ "$use_vlan" != 'true' ] && continue
- if [ "$autoconf" = "static" ] &&
- [ -e /etc/sysconfig/network/ifcfg-${netif} ] ; then
- # Pull in existing static configuration
- . /etc/sysconfig/network/ifcfg-${netif}
- ip=${IPADDR}
- prefix=${PREFIXLEN}
- mtu=${MTU}
- server=${REMOTE_IPADDR}
- gw=${GATEWAY}
- autoconf=${BOOTPROTO}
- fi
-
# setup nameserver
for s in "$dns1" "$dns2" $(getargs nameserver); do
[ -n "$s" ] || continue
echo nameserver $s >> /tmp/net.$netif.resolv.conf
done
- # Store config for later use
- for i in ip srv gw mask prefix hostname macaddr dns1 dns2; do
- eval '[ "$'$i'" ] && echo '$i'="$'$i'"'
- done > /tmp/net.$netif.override
-
for autoopt in $(str_replace "$autoconf" "," " "); do
case $autoopt in
dhcp4|dhcp|on|any)
@@ -493,8 +516,6 @@ for p in $(getargs ip=); do
/sbin/netroot $netif
fi
fi
-
- exit 0
done
# netif isn't the top stack? Then we should exit here.
@@ -523,4 +544,9 @@ if [ ! -e /tmp/net.${netif}.up ]; then
fi
fi
+if [ -e /tmp/net.${netif}.up ]; then
+ > /tmp/net.$netif.did-setup
+ [ -e /sys/class/net/$netif/address ] && \
+ > /tmp/net.$(cat /sys/class/net/$netif/address).did-setup
+fi
exit 0
Index: dracut-044/modules.d/40network/net-genrules.sh
===================================================================
--- dracut-044.orig/modules.d/40network/net-genrules.sh
+++ dracut-044/modules.d/40network/net-genrules.sh
@@ -96,7 +96,7 @@ command -v fix_bootif >/dev/null || . /l
# if you change the name of "91-default-net.rules", also change modules.d/80cms/cmssetup.sh
if [ "$NEEDNET" = "1" ]; then
echo "$cond, $runcmd" > /etc/udev/rules.d/91-default-net.rules
- echo "[ -f /tmp/net.*.did-setup ]" >$hookdir/initqueue/finished/wait-network.sh
+ echo "ls -1 /tmp/net.*.did-setup >/dev/null 2>&1" >$hookdir/initqueue/finished/wait-network.sh
fi
fi
Index: dracut-044/modules.d/40network/net-lib.sh
===================================================================
--- dracut-044.orig/modules.d/40network/net-lib.sh
+++ dracut-044/modules.d/40network/net-lib.sh
@@ -130,6 +130,7 @@ ifdown() {
ip addr flush dev $netif
echo "#empty" > /etc/resolv.conf
rm -f -- /tmp/net.$netif.did-setup
+ rm -f -- /tmp/net.$netif.conf
[ -e /sys/class/net/$netif/address ] && \
rm -f -- /tmp/net.$(cat /sys/class/net/$netif/address).did-setup
# TODO: send "offline" uevent?
@@ -202,9 +203,6 @@ setup_net() {
fi
unset layer2
- > /tmp/net.$netif.did-setup
- [ -e /sys/class/net/$netif/address ] && \
- > /tmp/net.$(cat /sys/class/net/$netif/address).did-setup
}
save_netinfo() {
Index: dracut-044/modules.d/40network/parse-ip-opts.sh
===================================================================
--- dracut-044.orig/modules.d/40network/parse-ip-opts.sh
+++ dracut-044/modules.d/40network/parse-ip-opts.sh
@@ -83,25 +83,23 @@ for p in $(getargs ip=); do
die "Sorry, automatic calculation of netmask is not yet supported"
;;
auto6);;
- dhcp|dhcp6|on|any) \
- [ -n "$NEEDBOOTDEV" ] && [ -z "$dev" ] && \
- die "Sorry, 'ip=$p' does not make sense for multiple interface configurations"
- [ -n "$ip" ] && \
- die "For argument 'ip=$p'\nSorry, setting client-ip does not make sense for '$autoopt'"
- ;;
+ dhcp|dhcp6|on|any);;
*) die "For argument 'ip=$p'\nSorry, unknown value '$autoopt'";;
esac
done
+ dup=0
if [ -n "$dev" ] ; then
# We don't like duplicate device configs
if [ -n "$IFACES" ] ; then
for i in $IFACES ; do
- [ "$dev" = "$i" ] && die "For argument 'ip=$p'\nDuplication configurations for '$dev'"
+ [ "$dev" = "$i" ] && dup=1 && break
done
fi
# IFACES list for later use
- IFACES="$IFACES $dev"
+ if [ $dup -eq 0 ]; then
+ IFACES="$IFACES $dev"
+ fi
fi
# Do we need to check for specific options?