Blame SOURCES/0004-Revert-redhat-remove-files-that-we-no-longer-use.patch

34fff7
From a3fcedf3c4fd338e87ce9728e43b62fd7ede8f7c Mon Sep 17 00:00:00 2001
34fff7
From: Jarod Wilson <jarod@redhat.com>
34fff7
Date: Wed, 20 Jun 2018 16:22:05 -0400
34fff7
Subject: [PATCH rdma-core] Revert "redhat: remove files that we no longer use"
34fff7
34fff7
This reverts commit d6d2396af1b8737b9f003ea45d55dc31d87c5611.
34fff7
34fff7
Upstream doesn't need them, but RHEL7.x does, as people do still bypass
34fff7
NetworkManager and bring up interfaces using SysV-initscripts type things.
34fff7
34fff7
Signed-off-by: Jarod Wilson <jarod@redhat.com>
34fff7
---
34fff7
 redhat/rdma.ifdown-ib | 183 ++++++++++++++++++++++++++++++
34fff7
 redhat/rdma.ifup-ib   | 308 ++++++++++++++++++++++++++++++++++++++++++++++++++
34fff7
 2 files changed, 491 insertions(+)
34fff7
 create mode 100644 redhat/rdma.ifdown-ib
34fff7
 create mode 100644 redhat/rdma.ifup-ib
34fff7
34fff7
diff --git a/redhat/rdma.ifdown-ib b/redhat/rdma.ifdown-ib
34fff7
new file mode 100644
34fff7
index 00000000..1cb284dc
34fff7
--- /dev/null
34fff7
+++ b/redhat/rdma.ifdown-ib
34fff7
@@ -0,0 +1,183 @@
34fff7
+#!/bin/bash
34fff7
+# Network Interface Configuration System
34fff7
+# Copyright (c) 1996-2013 Red Hat, Inc. all rights reserved.
34fff7
+#
34fff7
+# This program is free software; you can redistribute it and/or modify
34fff7
+# it under the terms of the GNU General Public License, version 2,
34fff7
+# as published by the Free Software Foundation.
34fff7
+#
34fff7
+# This program is distributed in the hope that it will be useful,
34fff7
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
34fff7
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
34fff7
+# GNU General Public License for more details.
34fff7
+#
34fff7
+# You should have received a copy of the GNU General Public License
34fff7
+# along with this program; if not, write to the Free Software
34fff7
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
34fff7
+
34fff7
+. /etc/init.d/functions
34fff7
+
34fff7
+cd /etc/sysconfig/network-scripts
34fff7
+. ./network-functions
34fff7
+
34fff7
+[ -f ../network ] && . ../network
34fff7
+
34fff7
+CONFIG=${1}
34fff7
+
34fff7
+source_config
34fff7
+
34fff7
+# Allow the user to override the detection of our physical device by passing
34fff7
+# it in.  No checking is done, if the user gives us a bogus dev, it's
34fff7
+# their problem.
34fff7
+[ -n "${PHYSDEV}" ] && REALDEVICE="$PHYSDEV"
34fff7
+
34fff7
+. /etc/sysconfig/network
34fff7
+
34fff7
+# Check to make sure the device is actually up
34fff7
+check_device_down ${DEVICE} && exit 0
34fff7
+
34fff7
+# If we are a P_Key device, we need to munge a few things
34fff7
+if [ "${PKEY}" = yes ]; then
34fff7
+	[ -z "${PKEY_ID}" ] && {
34fff7
+	        net_log $"InfiniBand IPoIB device: PKEY=yes requires a PKEY_ID"
34fff7
+	        exit 1
34fff7
+	}
34fff7
+	[ -z "${PHYSDEV}" ] && {
34fff7
+	        net_log $"InfiniBand IPoIB device: PKEY=yes requires a PHYSDEV"
34fff7
+	        exit 1
34fff7
+	}
34fff7
+	# Normalize our PKEY_ID to have the high bit set
34fff7
+	NEW_PKEY_ID=`printf "0x%04x" $(( 0x8000 | ${PKEY_ID} ))`
34fff7
+	NEW_PKEY_NAME=`printf "%04x" ${NEW_PKEY_ID}`
34fff7
+	[ "${DEVICE}" != "${PHYSDEV}.${NEW_PKEY_NAME}" ] && {
34fff7
+                net_log $"Configured DEVICE name does not match what new device name would be.  This
34fff7
+is most likely because once the PKEY_ID was normalized, it no longer
34fff7
+resulted in the expected device naming, and so the DEVICE entry in the
34fff7
+config file needs to be updated to match. This can also be caused by
34fff7
+giving PKEY_ID as a hex number but without using the mandatory 0x prefix.
34fff7
+	Configured DEVICE=$DEVICE
34fff7
+        Configured PHYSDEV=$PHYSDEV
34fff7
+        Configured PKEY_ID=$PKEY_ID
34fff7
+        Calculated PKEY_ID=$NEW_PKEY_ID
34fff7
+        Calculated name=${PHYSDEV}.${NEW_PKEY_NAME}"
34fff7
+                exit 1
34fff7
+        }
34fff7
+        [ -d "/sys/class/net/${DEVICE}" ] || exit 0
34fff7
+        # When we get to downing the IP address, we need REALDEVICE to
34fff7
+        # point to our PKEY device
34fff7
+        REALDEVICE="${DEVICE}"
34fff7
+fi
34fff7
+
34fff7
+
34fff7
+if [ "${SLAVE}" != "yes" -o -z "${MASTER}" ]; then
34fff7
+if [ -n "${HWADDR}" -a -z "${MACADDR}" ]; then
34fff7
+    HWADDR=$(echo $HWADDR | tail -c 24)
34fff7
+    FOUNDMACADDR=$(get_hwaddr ${REALDEVICE} | tail -c 24)
34fff7
+    if [ -n "${FOUNDMACADDR}" -a "${FOUNDMACADDR}" != "${HWADDR}" ]; then
34fff7
+        NEWCONFIG=$(get_config_by_hwaddr ${FOUNDMACADDR})
34fff7
+	if [ -n "${NEWCONFIG}" ]; then
34fff7
+	   eval $(LANG=C grep -F "DEVICE=" $NEWCONFIG)
34fff7
+	else
34fff7
+	   net_log $"Device ${DEVICE} has MAC address ${FOUNDMACADDR}, instead of configured address ${HWADDR}. Ignoring."
34fff7
+	   exit 1
34fff7
+	fi
34fff7
+	if [ -n "${NEWCONFIG}" -a "${NEWCONFIG##*/}" != "${CONFIG##*/}" -a "${DEVICE}" = "${REALDEVICE}" ]; then
34fff7
+	   exec /sbin/ifdown ${NEWCONFIG}
34fff7
+	else
34fff7
+	   net_log $"Device ${DEVICE} has MAC address ${FOUNDMACADDR}, instead of configured address ${HWADDR}. Ignoring."
34fff7
+	   exit 1
34fff7
+	fi
34fff7
+    fi
34fff7
+fi
34fff7
+fi
34fff7
+
34fff7
+if is_bonding_device ${DEVICE} ; then
34fff7
+    for device in $(LANG=C grep -l "^[[:space:]]*MASTER=\"\?${DEVICE}\"\?\([[:space:]#]\|$\)" /etc/sysconfig/network-scripts/ifcfg-*) ; do
34fff7
+	is_ignored_file "$device" && continue
34fff7
+	/sbin/ifdown ${device##*/}
34fff7
+    done
34fff7
+    for arg in $BONDING_OPTS ; do
34fff7
+	key=${arg%%=*};
34fff7
+	[[ "${key}" != "arp_ip_target" ]] && continue
34fff7
+	value=${arg##*=};
34fff7
+	if [ "${value:0:1}" != "" ]; then
34fff7
+            OLDIFS=$IFS;
34fff7
+            IFS=',';
34fff7
+            for arp_ip in $value; do
34fff7
+		if grep -q $arp_ip /sys/class/net/${DEVICE}/bonding/arp_ip_target; then
34fff7
+                    echo "-$arp_ip" > /sys/class/net/${DEVICE}/bonding/arp_ip_target
34fff7
+		fi
34fff7
+            done
34fff7
+            IFS=$OLDIFS;
34fff7
+	else
34fff7
+	    value=${value#+};
34fff7
+	    if grep -q $value /sys/class/net/${DEVICE}/bonding/arp_ip_target; then
34fff7
+                echo "-$value" > /sys/class/net/${DEVICE}/bonding/arp_ip_target
34fff7
+	    fi
34fff7
+	fi
34fff7
+    done
34fff7
+fi
34fff7
+
34fff7
+/etc/sysconfig/network-scripts/ifdown-ipv6 ${CONFIG}
34fff7
+
34fff7
+retcode=0
34fff7
+[ -n "$(pidof -x dhclient)" ] && {
34fff7
+   for VER in "" 6 ; do
34fff7
+	if [ -f "/var/run/dhclient$VER-${DEVICE}.pid" ]; then
34fff7
+		dhcpid=$(cat /var/run/dhclient$VER-${DEVICE}.pid)
34fff7
+		generate_lease_file_name $VER
34fff7
+		if [[ "$DHCPRELEASE" = [yY1]* ]];  then
34fff7
+			/sbin/dhclient -r -lf ${LEASEFILE} -pf /var/run/dhclient$VER-${DEVICE}.pid ${DEVICE} >/dev/null 2>&1
34fff7
+			retcode=$?
34fff7
+		else
34fff7
+			kill $dhcpid >/dev/null 2>&1
34fff7
+			retcode=$?
34fff7
+			reason=STOP$VER interface=${DEVICE} /sbin/dhclient-script
34fff7
+		fi
34fff7
+		if [ -f "/var/run/dhclient$VER-${DEVICE}.pid" ]; then
34fff7
+			rm -f /var/run/dhclient$VER-${DEVICE}.pid
34fff7
+			kill $dhcpid >/dev/null 2>&1
34fff7
+		fi
34fff7
+	fi
34fff7
+    done
34fff7
+}
34fff7
+# we can't just delete the configured address because that address
34fff7
+# may have been changed in the config file since the device was
34fff7
+# brought up.  Flush all addresses associated with this
34fff7
+# instance instead.
34fff7
+if [ -d "/sys/class/net/${REALDEVICE}" ]; then
34fff7
+	if [ "${REALDEVICE}" = "${DEVICE}" ]; then
34fff7
+		ip addr flush dev ${REALDEVICE} scope global 2>/dev/null
34fff7
+	else
34fff7
+		ip addr flush dev ${REALDEVICE} label ${DEVICE} scope global 2>/dev/null
34fff7
+	fi
34fff7
+
34fff7
+	if [ "${SLAVE}" = "yes" -a -n "${MASTER}" ]; then
34fff7
+		echo "-${DEVICE}" > /sys/class/net/${MASTER}/bonding/slaves 2>/dev/null
34fff7
+	fi
34fff7
+
34fff7
+	if [ "${REALDEVICE}" = "${DEVICE}" ]; then
34fff7
+		ip link set dev ${DEVICE} down 2>/dev/null
34fff7
+	fi
34fff7
+fi
34fff7
+[ "$retcode" = "0" ] && retcode=$?
34fff7
+
34fff7
+# wait up to 5 seconds for device to actually come down...
34fff7
+waited=0
34fff7
+while ! check_device_down ${DEVICE} && [ "$waited" -lt 50 ] ; do
34fff7
+    usleep 10000
34fff7
+    waited=$(($waited+1))
34fff7
+done
34fff7
+
34fff7
+if [ "$retcode" = 0 ] ; then
34fff7
+    /etc/sysconfig/network-scripts/ifdown-post $CONFIG
34fff7
+    # do NOT use $? because ifdown should return whether or not
34fff7
+    # the interface went down.
34fff7
+fi
34fff7
+
34fff7
+if [ -n "$PKEY" ]; then
34fff7
+    # PKey PKEY
34fff7
+    echo "$NEW_PKEY_ID" > /sys/class/net/${PHYSDEV}/delete_child
34fff7
+fi
34fff7
+
34fff7
+exit $retcode
34fff7
diff --git a/redhat/rdma.ifup-ib b/redhat/rdma.ifup-ib
34fff7
new file mode 100644
34fff7
index 00000000..bb4d4f71
34fff7
--- /dev/null
34fff7
+++ b/redhat/rdma.ifup-ib
34fff7
@@ -0,0 +1,308 @@
34fff7
+#!/bin/bash
34fff7
+# Network Interface Configuration System
34fff7
+# Copyright (c) 1996-2013 Red Hat, Inc. all rights reserved.
34fff7
+#
34fff7
+# This program is free software; you can redistribute it and/or modify
34fff7
+# it under the terms of the GNU General Public License, version 2,
34fff7
+# as published by the Free Software Foundation.
34fff7
+#
34fff7
+# This program is distributed in the hope that it will be useful,
34fff7
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
34fff7
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
34fff7
+# GNU General Public License for more details.
34fff7
+#
34fff7
+# You should have received a copy of the GNU General Public License
34fff7
+# along with this program; if not, write to the Free Software
34fff7
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
34fff7
+
34fff7
+. /etc/init.d/functions
34fff7
+
34fff7
+cd /etc/sysconfig/network-scripts
34fff7
+. ./network-functions
34fff7
+
34fff7
+[ -f ../network ] && . ../network
34fff7
+
34fff7
+CONFIG="${1}"
34fff7
+
34fff7
+need_config "${CONFIG}"
34fff7
+
34fff7
+source_config
34fff7
+
34fff7
+# Allow the user to override the detection of our physical device by passing
34fff7
+# it in.  No checking is done, if the user gives us a bogus dev, it's
34fff7
+# their problem.
34fff7
+[ -n "${PHYSDEV}" ] && REALDEVICE="$PHYSDEV"
34fff7
+
34fff7
+if [ "${BOOTPROTO}" = "dhcp" ]; then
34fff7
+    DYNCONFIG=true
34fff7
+fi
34fff7
+
34fff7
+# load the module associated with that device
34fff7
+# /sbin/modprobe ${REALDEVICE}
34fff7
+is_available_wait ${REALDEVICE} ${DEVTIMEOUT}
34fff7
+
34fff7
+# bail out, if the MAC does not fit
34fff7
+if [ -n "${HWADDR}" ]; then
34fff7
+	FOUNDMACADDR=$(get_hwaddr ${REALDEVICE} | tail -c 24)
34fff7
+	HWADDR=$(echo $HWADDR | tail -c 24)
34fff7
+	if [ "${FOUNDMACADDR}" != "${HWADDR}" ]; then
34fff7
+		net_log $"Device ${DEVICE} has different MAC address than expected, ignoring."
34fff7
+		exit 1
34fff7
+	fi
34fff7
+fi
34fff7
+
34fff7
+# now check the real state
34fff7
+is_available ${REALDEVICE} || {
34fff7
+      if [ -n "$alias" ]; then
34fff7
+         net_log $"$alias device ${DEVICE} does not seem to be present, delaying initialization."
34fff7
+      else
34fff7
+         net_log $"Device ${DEVICE} does not seem to be present, delaying initialization."
34fff7
+      fi
34fff7
+      exit 1
34fff7
+}
34fff7
+
34fff7
+# if we are a P_Key device, create the device if needed
34fff7
+if [ "${PKEY}" = yes ]; then
34fff7
+	[ -z "${PKEY_ID}" ] && {
34fff7
+		net_log $"InfiniBand IPoIB device: PKEY=yes requires a PKEY_ID"
34fff7
+		exit 1
34fff7
+	}
34fff7
+	[ -z "${PHYSDEV}" ] && {
34fff7
+		net_log $"InfiniBand IPoIB device: PKEY=yes requires a PHYSDEV"
34fff7
+		exit 1
34fff7
+	}
34fff7
+	# Normalize our PKEY_ID to have the high bit set
34fff7
+	NEW_PKEY_ID=`printf "0x%04x" $(( 0x8000 | ${PKEY_ID} ))`
34fff7
+	NEW_PKEY_NAME=`printf "%04x" ${NEW_PKEY_ID}`
34fff7
+	[ "${DEVICE}" != "${PHYSDEV}.${NEW_PKEY_NAME}" ] && {
34fff7
+		net_log $"Configured DEVICE name does not match what new device name would be.  This
34fff7
+is most likely because once the PKEY_ID was normalized, it no longer
34fff7
+resulted in the expected device naming, and so the DEVICE entry in the
34fff7
+config file needs to be updated to match. This can also be caused by
34fff7
+giving PKEY_ID as a hex number but without using the mandatory 0x prefix.
34fff7
+	Configured DEVICE=$DEVICE
34fff7
+	Configured PHYSDEV=$PHYSDEV
34fff7
+	Configured PKEY_ID=$PKEY_ID
34fff7
+	Calculated PKEY_ID=$NEW_PKEY_ID
34fff7
+	Calculated name=${PHYSDEV}.${NEW_PKEY_NAME}"
34fff7
+		exit 1
34fff7
+	}
34fff7
+	[ -d "/sys/class/net/${DEVICE}" ] ||
34fff7
+		echo "${NEW_PKEY_ID}" > "/sys/class/net/${PHYSDEV}/create_child"
34fff7
+	[ -d "/sys/class/net/${DEVICE}" ] || {
34fff7
+		echo "Failed to create child device $NEW_PKEY_ID of $PHYSDEV"
34fff7
+		exit 1
34fff7
+	}
34fff7
+	# When we get to setting up the IP address, we need REALDEVICE to
34fff7
+	# point to our new PKEY device
34fff7
+	REALDEVICE="${DEVICE}"
34fff7
+fi
34fff7
+
34fff7
+
34fff7
+if [ -n "${MACADDR}" ]; then
34fff7
+    net_log $"IPoIB devices do not support setting the MAC address of the interface"
34fff7
+    # ip link set dev ${DEVICE} address ${MACADDR}
34fff7
+fi
34fff7
+
34fff7
+# First, do we even support setting connected mode?
34fff7
+if [ -e /sys/class/net/${DEVICE}/mode ]; then
34fff7
+    # OK, set the mode in all cases, that way it gets reset on a down/up
34fff7
+    # cycle, allowing people to change the mode without rebooting
34fff7
+    if [ "${CONNECTED_MODE}" = yes ]; then
34fff7
+        echo connected > /sys/class/net/${DEVICE}/mode
34fff7
+	# cap the MTU where we should based upon mode
34fff7
+	[ -z "$MTU" ] && MTU=65520
34fff7
+	[ "$MTU" -gt 65520 ] && MTU=65520
34fff7
+    else
34fff7
+        echo datagram > /sys/class/net/${DEVICE}/mode
34fff7
+	# cap the MTU where we should based upon mode
34fff7
+	[ -z "$MTU" ] && MTU=2044
34fff7
+	[ "$MTU" -gt 2044 ] && MTU=2044
34fff7
+    fi
34fff7
+fi
34fff7
+
34fff7
+if [ -n "${MTU}" ]; then
34fff7
+    ip link set dev ${DEVICE} mtu ${MTU}
34fff7
+fi
34fff7
+
34fff7
+# slave device?
34fff7
+if [ "${SLAVE}" = yes -a "${ISALIAS}" = no -a "${MASTER}" != "" ]; then
34fff7
+    install_bonding_driver ${MASTER}
34fff7
+    grep -wq "${DEVICE}" /sys/class/net/${MASTER}/bonding/slaves 2>/dev/null || {
34fff7
+	/sbin/ip link set dev ${DEVICE} down
34fff7
+	echo "+${DEVICE}" > /sys/class/net/${MASTER}/bonding/slaves 2>/dev/null
34fff7
+    }
34fff7
+    ethtool_set
34fff7
+
34fff7
+    exit 0
34fff7
+fi
34fff7
+
34fff7
+# Bonding initialization. For DHCP, we need to enslave the devices early,
34fff7
+# so it can actually get an IP.
34fff7
+if [ "$ISALIAS" = no ] && is_bonding_device ${DEVICE} ; then
34fff7
+    install_bonding_driver ${DEVICE}
34fff7
+    /sbin/ip link set dev ${DEVICE} up
34fff7
+    for device in $(LANG=C grep -l "^[[:space:]]*MASTER=\"\?${DEVICE}\"\?\([[:space:]#]\|$\)" /etc/sysconfig/network-scripts/ifcfg-*) ; do
34fff7
+	    is_ignored_file "$device" && continue
34fff7
+	    /sbin/ifup ${device##*/}
34fff7
+    done
34fff7
+
34fff7
+    [ -n "${LINKDELAY}" ] && /bin/sleep ${LINKDELAY}
34fff7
+
34fff7
+    # add the bits to setup the needed post enslavement parameters
34fff7
+    for arg in $BONDING_OPTS ; do
34fff7
+        key=${arg%%=*};
34fff7
+        value=${arg##*=};
34fff7
+	if [ "${key}" = "primary" ]; then
34fff7
+            echo $value > /sys/class/net/${DEVICE}/bonding/$key
34fff7
+	fi
34fff7
+    done
34fff7
+fi
34fff7
+
34fff7
+
34fff7
+if [ -n "${DYNCONFIG}" ] && [ -x /sbin/dhclient ]; then
34fff7
+    if [[ "${PERSISTENT_DHCLIENT}" =  [yY1]* ]]; then
34fff7
+       ONESHOT="";
34fff7
+    else
34fff7
+       ONESHOT="-1";
34fff7
+    fi;
34fff7
+    generate_config_file_name
34fff7
+    generate_lease_file_name
34fff7
+    DHCLIENTARGS="${DHCLIENTARGS} -H ${DHCP_HOSTNAME:-${HOSTNAME%%.*}} ${ONESHOT} -q ${DHCLIENTCONF} -lf ${LEASEFILE} -pf /var/run/dhclient-${DEVICE}.pid"
34fff7
+    echo
34fff7
+    echo -n $"Determining IP information for ${DEVICE}..."
34fff7
+    if [[ "${PERSISTENT_DHCLIENT}" !=  [yY1]* ]] && check_link_down ${DEVICE}; then
34fff7
+	echo $" failed; no link present.  Check cable?"
34fff7
+	exit 1
34fff7
+    fi
34fff7
+
34fff7
+    ethtool_set
34fff7
+
34fff7
+    if /sbin/dhclient ${DHCLIENTARGS} ${DEVICE} ; then
34fff7
+	echo $" done."
34fff7
+	dhcpipv4="good"
34fff7
+    else
34fff7
+	echo $" failed."
34fff7
+	if [[ "${IPV4_FAILURE_FATAL}"  = [Yy1]* ]] ; then
34fff7
+	    exit 1
34fff7
+	fi
34fff7
+	if [[ "$IPV6INIT" != [yY1]* && "$DHCPV6C" != [yY1]* ]] ; then
34fff7
+	    exit 1
34fff7
+	fi
34fff7
+	net_log "Unable to obtain IPv4 DHCP address ${DEVICE}." warning
34fff7
+    fi
34fff7
+# end dynamic device configuration
34fff7
+else
34fff7
+    if [ -z "${IPADDR}" -a -z "${IPADDR0}" -a -z "${IPADDR1}" -a -z "${IPADDR2}" ]; then
34fff7
+         # enable device without IP, useful for e.g. PPPoE
34fff7
+	 ip link set dev ${REALDEVICE} up
34fff7
+	 ethtool_set
34fff7
+	 [ -n "${LINKDELAY}" ] && /bin/sleep ${LINKDELAY}
34fff7
+    else
34fff7
+
34fff7
+    expand_config
34fff7
+
34fff7
+    [ -n "${ARP}" ] && \
34fff7
+	ip link set dev ${REALDEVICE} $(toggle_value arp $ARP)
34fff7
+
34fff7
+    if ! ip link set dev ${REALDEVICE} up ; then
34fff7
+	net_log $"Failed to bring up ${DEVICE}."
34fff7
+	exit 1
34fff7
+    fi
34fff7
+
34fff7
+    ethtool_set
34fff7
+
34fff7
+    [ -n "${LINKDELAY}" ] && /bin/sleep ${LINKDELAY}
34fff7
+
34fff7
+    if [ "${DEVICE}" = "lo" ]; then
34fff7
+        SCOPE="scope host"
34fff7
+    else
34fff7
+        SCOPE=${SCOPE:-}
34fff7
+    fi
34fff7
+
34fff7
+    if [ -n "$SRCADDR" ]; then
34fff7
+       SRC="src $SRCADDR"
34fff7
+    else
34fff7
+       SRC=
34fff7
+    fi
34fff7
+
34fff7
+    # set IP address(es)
34fff7
+    for idx in {0..256} ; do
34fff7
+	if [ -z "${ipaddr[$idx]}" ]; then
34fff7
+	    break
34fff7
+	fi
34fff7
+
34fff7
+	if ! LC_ALL=C ip addr ls ${REALDEVICE} | LC_ALL=C grep -q "${ipaddr[$idx]}/${prefix[$idx]}" ; then
34fff7
+	    [ "${REALDEVICE}" != "lo" ] && [ "${arpcheck[$idx]}" != "no" ] && \
34fff7
+	    /sbin/arping -q -c 2 -w 3 -D -I ${REALDEVICE} ${ipaddr[$idx]}
34fff7
+	    if [ $? = 1 ]; then
34fff7
+		net_log $"Error, some other host already uses address ${ipaddr[$idx]}."
34fff7
+		exit 1
34fff7
+	    fi
34fff7
+
34fff7
+	    if ! ip addr add ${ipaddr[$idx]}/${prefix[$idx]} \
34fff7
+		brd ${broadcast[$idx]:-+} dev ${REALDEVICE} ${SCOPE} label ${DEVICE}; then
34fff7
+		net_log $"Error adding address ${ipaddr[$idx]} for ${DEVICE}."
34fff7
+	    fi
34fff7
+	fi
34fff7
+
34fff7
+	if [ -n "$SRCADDR" ]; then
34fff7
+           sysctl -w "net.ipv4.conf.${REALDEVICE}.arp_filter=1" >/dev/null 2>&1
34fff7
+	fi
34fff7
+
34fff7
+	# update ARP cache of neighboring computers
34fff7
+	if [ "${REALDEVICE}" != "lo" ]; then
34fff7
+	    /sbin/arping -q -A -c 1 -I ${REALDEVICE} ${ipaddr[$idx]}
34fff7
+	    ( sleep 2;
34fff7
+	      /sbin/arping -q -U -c 1 -I ${REALDEVICE} ${ipaddr[$idx]} ) > /dev/null 2>&1 < /dev/null &
34fff7
+	fi
34fff7
+    done
34fff7
+
34fff7
+    # Set a default route.
34fff7
+    if [ "${DEFROUTE}" != "no" ] && [ -z "${GATEWAYDEV}" -o "${GATEWAYDEV}" = "${REALDEVICE}" ]; then
34fff7
+	# set up default gateway. replace if one already exists
34fff7
+	if [ -n "${GATEWAY}" ] && [ "$(ipcalc --network ${GATEWAY} ${netmask[0]} 2>/dev/null)" = "NETWORK=${NETWORK}" ]; then
34fff7
+	    ip route replace default ${METRIC:+metric $METRIC} \
34fff7
+		via ${GATEWAY} ${WINDOW:+window $WINDOW} ${SRC} \
34fff7
+		${GATEWAYDEV:+dev $GATEWAYDEV} ||
34fff7
+			net_log $"Error adding default gateway ${GATEWAY} for ${DEVICE}."
34fff7
+	elif [ "${GATEWAYDEV}" = "${DEVICE}" ]; then
34fff7
+	    ip route replace default ${METRIC:+metric $METRIC} \
34fff7
+		${SRC} ${WINDOW:+window $WINDOW} dev ${REALDEVICE} ||
34fff7
+			net_log $"Erorr adding default gateway for ${REALDEVICE}."
34fff7
+	fi
34fff7
+    fi
34fff7
+    fi
34fff7
+fi
34fff7
+
34fff7
+# Add Zeroconf route.
34fff7
+if [ -z "${NOZEROCONF}" -a "${ISALIAS}" = "no" -a "${REALDEVICE}" != "lo" ]; then
34fff7
+    ip route add 169.254.0.0/16 dev ${REALDEVICE} metric $((1000 + $(cat /sys/class/net/${REALDEVICE}/ifindex))) scope link
34fff7
+fi
34fff7
+
34fff7
+# Inform firewall which network zone (empty means default) this interface belongs to
34fff7
+if [ -x /usr/bin/firewall-cmd -a "${REALDEVICE}" != "lo" ]; then
34fff7
+    /usr/bin/firewall-cmd --zone="${ZONE}" --change-interface="${DEVICE}" > /dev/null 2>&1
34fff7
+fi
34fff7
+
34fff7
+# IPv6 initialisation?
34fff7
+/etc/sysconfig/network-scripts/ifup-ipv6 ${CONFIG}
34fff7
+if [[ "${DHCPV6C}"  = [Yy1]* ]] && [ -x /sbin/dhclient ]; then
34fff7
+    generate_config_file_name 6
34fff7
+    generate_lease_file_name 6
34fff7
+    echo
34fff7
+    echo -n $"Determining IPv6 information for ${DEVICE}..."
34fff7
+    if /sbin/dhclient -6 -1 ${DHCPV6C_OPTIONS} ${DHCLIENTCONF} -lf ${LEASEFILE} -pf /var/run/dhclient6-${DEVICE}.pid -H ${DHCP_HOSTNAME:-${HOSTNAME%%.*}} ${DEVICE} ; then
34fff7
+        echo $" done."
34fff7
+    else
34fff7
+        echo $" failed."
34fff7
+        if [ "${dhcpipv4}" = "good" -o -n "${IPADDR}" ]; then
34fff7
+            net_log "Unable to obtain IPv6 DHCP address ${DEVICE}." warning
34fff7
+        else
34fff7
+            exit 1
34fff7
+        fi
34fff7
+    fi
34fff7
+fi
34fff7
+
34fff7
+exec /etc/sysconfig/network-scripts/ifup-post ${CONFIG} ${2}
34fff7
+
34fff7
-- 
34fff7
2.16.1
34fff7