From 668875e1864a405091a8064f63db94ebc7c47983 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Nov 23 2022 01:42:18 +0000 Subject: Determine whether IPv4 or IPv6 is needed Resolves: bz2076416 Upstream: Fedora Conflict: None commit 9dfcacf72d2cd135bf8b72c4bbc97f15efa21250 Author: Coiby Xu Date: Thu Sep 8 17:06:19 2022 +0800 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 Reviewed-by: Thomas Haller Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index e74a026..299e105 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -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" @@ -1104,7 +1124,7 @@ remove_cpu_online_rule() { } install() { - declare -A unique_netifs + declare -A unique_netifs ipv4_usage ipv6_usage local arch kdump_module_init