From 9dfcacf72d2cd135bf8b72c4bbc97f15efa21250 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 8 Sep 2022 17:06:19 +0800 Subject: [PATCH] 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 --- dracut-module-setup.sh | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 4a213e0..e5ca6f7 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" @@ -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