Determine whether IPv4 or IPv6 is needed

According to `man nm-online`,
  "By default, connections have the ipv4.may-fail and
  ipv6.may-fail properties set to yes; this means that
  NetworkManager waits for one of the two address families to
  complete configuration before considering the connection
  activated. If you need a specific address family configured
  before network-online.target is reached, set the corresponding
  may-fail property to no."

If a NIC has an IPv4 or IPv6 address, set the corresponding may-fail
property to no. Otherwise, dumping vmcore over IPv6 could fail because
only IPv4 network is ready or vice versa.

Also disable IPv6 if only IPv4 is used and vice versa.

Signed-off-by: Coiby Xu <coxu@redhat.com>
Reviewed-by: Thomas Haller <thaller@redhat.com>
Reviewed-by: Philipp Rudo <prudo@redhat.com>
This commit is contained in:
Coiby Xu 2022-09-08 17:06:19 +08:00
parent d25b1ee31c
commit 9dfcacf72d

View File

@ -365,6 +365,24 @@ kdump_setup_ifname() {
echo "$_ifname"
}
use_ipv4_or_ipv6() {
local _netif=$1 _uuid=$2
if [[ -v "ipv4_usage[$_netif]" ]]; then
nmcli connection modify --temporary "$_uuid" ipv4.may-fail no &> >(ddebug)
fi
if [[ -v "ipv6_usage[$_netif]" ]]; then
nmcli connection modify --temporary "$_uuid" ipv6.may-fail no &> >(ddebug)
fi
if [[ -v "ipv4_usage[$_netif]" ]] && [[ ! -v "ipv6_usage[$_netif]" ]]; then
nmcli connection modify --temporary "$_uuid" ipv6.method disabled &> >(ddebug)
elif [[ ! -v "ipv4_usage[$_netif]" ]] && [[ -v "ipv6_usage[$_netif]" ]]; then
nmcli connection modify --temporary "$_uuid" ipv4.method disabled &> >(ddebug)
fi
}
_clone_nmconnection() {
local _clone_output _name _unique_id
@ -396,6 +414,8 @@ clone_and_modify_nmconnection() {
exit 1
fi
use_ipv4_or_ipv6 "$_dev" "$_uuid"
_cloned_nmconnection_file_path=$(nmcli --get-values UUID,FILENAME connection show | sed -n "s/^${_uuid}://p")
_tmp_nmconnection_file_path=$_DRACUT_KDUMP_NM_TMP_DIR/$(basename "$_nmconnection_file_path")
cp "$_cloned_nmconnection_file_path" "$_tmp_nmconnection_file_path"
@ -1106,7 +1126,7 @@ remove_cpu_online_rule() {
}
install() {
declare -A unique_netifs
declare -A unique_netifs ipv4_usage ipv6_usage
local arch
kdump_module_init