5f01bd5d61
All indication in CI is that Centos Stream9's use of dhclient appears to point to compatability issues when interacting with dnsmasq. However, this doesn't appear to be the issue with the internal dhcp client. As such, lets constraint the RH default so that it no longer applies to Centos 9-stream. I've also added a documentation entry for DIB_DHCP_CLIENT which was previously undocumented. As an aside, I've already reached out to RH's NetworkManager team regarding this, but root cause is not entirely understood at this point. Change-Id: I235f75b385a8b0348c8fe064038c51409f8722c4 Story: 2010109 Task: 45677
94 lines
4.3 KiB
Bash
Executable File
94 lines
4.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
if [ ${DIB_DEBUG_TRACE:-1} -gt 0 ]; then
|
|
set -x
|
|
fi
|
|
set -eu
|
|
set -o pipefail
|
|
|
|
SCRIPTDIR=$(dirname $0)
|
|
|
|
if [ -e "/etc/redhat-release" ]; then
|
|
# NOTE(TheJulia): RHEL, prior to RHEL8 used dhclient by default launched
|
|
# by NetworkManager. In RHEL8, this default switched to the "internal"
|
|
# dhcp client.
|
|
# This is problematic in RHEL8, with port blocking situations as dhclient
|
|
# has better behavior which includes shutting down the port between
|
|
# retries which is critical for recovery from LACP port blocking
|
|
# situations. As such, we'll force it to dhclient.
|
|
# For more information, see https://storyboard.openstack.org/#!/story/2008001
|
|
if [[ '7' =~ ${DIB_RELEASE} ]]; then
|
|
DIB_DHCP_CLIENT=${DIB_DHCP_CLIENT:-dhclient}
|
|
elif [[ '8' =~ ${DIB_RELEASE} ]]; then
|
|
DIB_DHCP_CLIENT=${DIB_DHCP_CLIENT:-dhclient}
|
|
fi
|
|
# NOTE(TheJulia): Centos 9-stream/RHEL9, appear to need to leverage the
|
|
# internal interface. See: https://storyboard.openstack.org/#!/story/2010109
|
|
fi
|
|
|
|
|
|
# Sets appropriate NetworkManager configuration, if the folder is present.
|
|
if [ -x "/etc/NetworkManager" ]; then
|
|
install -D -g root -o root -m 0644 ${SCRIPTDIR}/NetworkManager-conf.d-00-main.conf /etc/NetworkManager/conf.d/00-main.conf
|
|
sed -i "s/DIB_DHCP_CLIENT/${DIB_DHCP_CLIENT:-internal}/g" /etc/NetworkManager/conf.d/00-main.conf
|
|
sed -i "s/DIB_DHCP_TIMEOUT/${DIB_DHCP_TIMEOUT:-30}/g" /etc/NetworkManager/conf.d/00-main.conf
|
|
if [ "${DIB_DHCP_NETWORK_MANAGER_AUTO:-false}" == true ]; then
|
|
# Use NetworkManager for auto configuration, it will behave just as
|
|
# good as dhcp-all-interfaces.sh in most cases.
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
if [ -e "/etc/redhat-release" ]; then
|
|
# TODO(hjensas): Once ndisc6 package is available in EPEL8 drop this,
|
|
# and add the package back in pkg-map.
|
|
# See: https://bugzilla.redhat.com/show_bug.cgi?id=1779134
|
|
if type dnf &>/dev/null; then
|
|
dnf -v -y install ndisc6 || true
|
|
else
|
|
yum -v -y install ndisc6 || true
|
|
fi
|
|
fi
|
|
|
|
|
|
# this script is not needed on Gentoo.
|
|
if [ "$DISTRO_NAME" != "gentoo" ]; then
|
|
install -D -g root -o root -m 0755 ${SCRIPTDIR}/dhcp-all-interfaces.sh /usr/local/sbin/dhcp-all-interfaces.sh
|
|
sed -i "s/DIB_DHCP_TIMEOUT/${DIB_DHCP_TIMEOUT:-30}/" /usr/local/sbin/dhcp-all-interfaces.sh
|
|
fi
|
|
|
|
if [ -f /etc/dhcp/dhclient.conf ] ; then
|
|
# Set the dhclient timeout configurations to match DIB_DHCP_TIMEOUT,
|
|
if grep -o "^timeout " /etc/dhcp/dhclient.conf ; then
|
|
sed -i -e "s/^timeout .*/# \"timeout\" Value set by dhcp-all-interfaces\ntimeout ${DIB_DHCP_TIMEOUT:-30};/" /etc/dhcp/dhclient.conf
|
|
else
|
|
echo -e "# \"timeout\" Value set by dhcp-all-interfaces\ntimeout ${DIB_DHCP_TIMEOUT:-30};" >> /etc/dhcp/dhclient.conf
|
|
fi
|
|
if grep -o "^retry " /etc/dhcp/dhclient.conf ; then
|
|
sed -i -e '/^retry/s/^/# \"retry\" Value commented by dhcp-all-interfaces\n# /g' /etc/dhcp/dhclient.conf
|
|
fi
|
|
fi
|
|
|
|
if [ "$DIB_INIT_SYSTEM" == "upstart" ]; then
|
|
if [ -e "/etc/redhat-release" ] ; then
|
|
# the init system is upstart but networking is using sysv compatibility (i.e. Centos/RHEL 6)
|
|
install -D -g root -o root -m 0755 ${SCRIPTDIR}/dhcp-all-interfaces.init /etc/init.d/dhcp-all-interfaces
|
|
chkconfig dhcp-all-interfaces on
|
|
else
|
|
install -D -g root -o root -m 0755 ${SCRIPTDIR}/dhcp-all-interfaces.conf /etc/init/dhcp-all-interfaces.conf
|
|
fi
|
|
elif [ "$DIB_INIT_SYSTEM" == "systemd" ]; then
|
|
install -D -g root -o root -m 0644 ${SCRIPTDIR}/dhcp-interface@.service /usr/lib/systemd/system/dhcp-interface@.service
|
|
install -D -g root -o root -m 0644 ${SCRIPTDIR}/dhcp-all-interfaces-udev.rules /etc/udev/rules.d/99-dhcp-all-interfaces.rules
|
|
sed -i "s/TimeoutStartSec=DIB_DHCP_TIMEOUT/TimeoutStartSec=$(( ${DIB_DHCP_TIMEOUT:-30} * 2 ))s/" /usr/lib/systemd/system/dhcp-interface@.service
|
|
elif [ "$DIB_INIT_SYSTEM" == "sysv" ]; then
|
|
install -D -g root -o root -m 0755 ${SCRIPTDIR}/dhcp-all-interfaces.init /etc/init.d/dhcp-all-interfaces
|
|
update-rc.d dhcp-all-interfaces defaults
|
|
elif [ "$DISTRO_NAME" == "gentoo" ]; then
|
|
# let ipv6 use normal slaac
|
|
sed -i 's/slaac/#slaac/g' /etc/dhcpcd.conf
|
|
# don't let dhcpcd set domain name or hostname
|
|
sed -i 's/domain_name\,\ domain_search\,\ host_name/domain_search/g' /etc/dhcpcd.conf
|
|
rc-update add dhcpcd default
|
|
fi
|