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