Currently, kexec-tools parses legacy ifcfg-* configuration files or NetworkManager .nmconnection connection profiles to build up dracut command line parameters like ip=. Then dracut parses these parameters and runs nm-initrd-generator to generate NetworkManager connection profiles. Taking a bonding network as an example, nm-initrd-generator generates two connections as follows, $ /usr/libexec/nm-initrd-generator -s -- bootdev=mybond0 rd.neednet kdumpnic=mybond0 bond=mybond0:kdump-eth0
*** Connection 'mybond0' ***
[connection] id=mybond0 uuid=ed87d02b-dd44-4f0e-8b11-37db7e89bb48 type=bond autoconnect-retries=1 interface-name=mybond0 multi-connect=1 permissions=
[bond] mode=balance-rr
[ipv4] dhcp-timeout=90 dns-search= method=auto
[ipv6] addr-gen-mode=eui64 dhcp-timeout=90 dns-search= method=auto
[proxy]
*** Connection 'kdump-eth0' ***
[connection] id=kdump-eth0 uuid=ed6a7448-b5f8-4f8a-b718-3e24ea1c924b type=ethernet autoconnect-retries=1 interface-name=kdump-eth0 master=ed87d02b-dd44-4f0e-8b11-37db7e89bb48 multi-connect=1 permissions= slave-type=bond wait-device-timeout=60000
[ethernet] mac-address-blacklist=
Later dracut starts NetworkManager to activate these profiles to bring up the network connections. This way of seting up kdump network is tedious, error-prone and unncessary. A better way is to directly copy the needed connection profiles to initrd. A potential benefit of this approach for the users is they can simply edit the connection profile directly like changing ipv4.dhcp-timeout instead of being forced to use the hard-coded value enforced by nm-initrd-generator.
This patch set reuses NetworkManager connection profiles to set up kdump network. It also reduces the memory consumption of network drivers and fix other issues at the same time. Here are the bug list that addressed by this patch set on bugzilla, - Bug 1962421 - [RHEL-9]"eth0: Failed to rename network interface 3 from 'eth0' to 'kdump-eth0': File exists" - Bug 2064708 - kdump: mkdumprd: failed to make kdump initrd for bridge network on z15 z/vm - bugs related to OOM caused by network driver - Bug 1950282 - shutdown those unneeded network interfaces to save memory for kdump - Bug 1958587 - the kdump initramfs includes unnecessary NIC drivers for SSH/NFS dumping target - Bug 1890021 - be2net is using too much memory during kdump - Bug 1662202 - [RHEL-8.1] aarch64: hpe-apache crashkernel OOM when dump to network targe
Coiby Xu (13): add function to copy NetworkManage connection profile to the initramfs support legacy ifcfg ask NM to wait the network device to be available don't let NetworkManager manage unneeded network interfaces stop dracut 35network-manager from running nm-initrd-generator set up kdump network bridge by directly copying NM connection profile to initrd set up kdump bonding network by directly copying NM connection profile to initrd fix error for vlan over team network interface set up kdump vlan network by directly copying NM connection profile to initrd set up kdump teaming network by directly copying NM connection profile to initrd clean up unneeded code after copying .nmconnection to initrd address the cases where a NIC has a different name in kdump kernel simplify setup_znet by copying connection profile to initrd
dracut-kdump.sh | 18 +- dracut-module-setup.sh | 385 ++++++++++++++--------------------------- 2 files changed, 133 insertions(+), 270 deletions(-)
Each network interface is manged by a NM connection. Given a network interface name, this function will be used to copy a NetworkManager (NM) connection profile i.e. a .nmconnection file to the kdump initramfs.
Signed-off-by: Coiby Xu coxu@redhat.com --- dracut-module-setup.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 02e7334..3b6b1c3 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -346,6 +346,16 @@ kdump_setup_ifname() { echo "$_ifname" }
+kdump_copy_nmconnection_file() { + local _dev _nmconnection_file_path _nmconnection_name _initrd_nmconnection_file_path + _dev="$1" + + _nmconnection_file_path=${nmconnection_map[$_dev]} + _nmconnection_name=$(basename "$_nmconnection_file_path") + _initrd_nmconnection_file_path="/etc/NetworkManager/system-connections/$_nmconnection_name" + inst "$_nmconnection_file_path" "$_initrd_nmconnection_file_path" +} + kdump_setup_bridge() { local _netdev=$1 local _brif _dev _mac _kdumpdev @@ -534,6 +544,12 @@ kdump_install_net() { local _destaddr _srcaddr _route _netdev _conpath kdumpnic local _static _proto _ip_conf _ip_opts _ifname_opts local _znet_netdev _znet_conpath + # each netowrk interface is managed by a NM connection profile + declare -A nmconnection_map + + while read -r _ifname _nmconn; do + nmconnection_map[$_ifname]="$_nmconn" + done <<< "$(nmcli -f device,filename connection show --active | tail -n +2)"
_destaddr=$(kdump_get_remote_ip "$1") _route=$(kdump_get_ip_route "$_destaddr")
Hi Coiby,
On Sat, 2 Apr 2022 11:23:45 +0800 Coiby Xu coxu@redhat.com wrote:
Each network interface is manged by a NM connection. Given a network interface name, this function will be used to copy a NetworkManager (NM) connection profile i.e. a .nmconnection file to the kdump initramfs.
Signed-off-by: Coiby Xu coxu@redhat.com
dracut-module-setup.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 02e7334..3b6b1c3 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -346,6 +346,16 @@ kdump_setup_ifname() { echo "$_ifname" }
+kdump_copy_nmconnection_file() {
- local _dev _nmconnection_file_path _nmconnection_name _initrd_nmconnection_file_path
- _dev="$1"
- _nmconnection_file_path=${nmconnection_map[$_dev]}
- _nmconnection_name=$(basename "$_nmconnection_file_path")
- _initrd_nmconnection_file_path="/etc/NetworkManager/system-connections/$_nmconnection_name"
- inst "$_nmconnection_file_path" "$_initrd_nmconnection_file_path"
+}
in the end this function gets quite large and (at least for me as a network simpleton) quite hard to read. Is there a way to split it up in multiple functions?
kdump_setup_bridge() { local _netdev=$1 local _brif _dev _mac _kdumpdev @@ -534,6 +544,12 @@ kdump_install_net() { local _destaddr _srcaddr _route _netdev _conpath kdumpnic local _static _proto _ip_conf _ip_opts _ifname_opts local _znet_netdev _znet_conpath
- # each netowrk interface is managed by a NM connection profile
- declare -A nmconnection_map
- while read -r _ifname _nmconn; do
nmconnection_map[$_ifname]="$_nmconn"
- done <<< "$(nmcli -f device,filename connection show --active | tail -n +2)"
nmcli has the -t, --terse option to suppress printing of the header line.
Thanks Philipp
_destaddr=$(kdump_get_remote_ip "$1") _route=$(kdump_get_ip_route "$_destaddr")
On Fri, Apr 22, 2022 at 05:30:03PM +0200, Philipp Rudo wrote:
Hi Coiby,
On Sat, 2 Apr 2022 11:23:45 +0800 Coiby Xu coxu@redhat.com wrote:
Each network interface is manged by a NM connection. Given a network interface name, this function will be used to copy a NetworkManager (NM) connection profile i.e. a .nmconnection file to the kdump initramfs.
Signed-off-by: Coiby Xu coxu@redhat.com
dracut-module-setup.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 02e7334..3b6b1c3 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -346,6 +346,16 @@ kdump_setup_ifname() { echo "$_ifname" }
+kdump_copy_nmconnection_file() {
- local _dev _nmconnection_file_path _nmconnection_name _initrd_nmconnection_file_path
- _dev="$1"
- _nmconnection_file_path=${nmconnection_map[$_dev]}
- _nmconnection_name=$(basename "$_nmconnection_file_path")
- _initrd_nmconnection_file_path="/etc/NetworkManager/system-connections/$_nmconnection_name"
- inst "$_nmconnection_file_path" "$_initrd_nmconnection_file_path"
+}
in the end this function gets quite large and (at least for me as a network simpleton) quite hard to read. Is there a way to split it up in multiple functions?
Thanks for the suggestion! I'll try to split it up and I guess unit-testing this function may also requires so.
kdump_setup_bridge() { local _netdev=$1 local _brif _dev _mac _kdumpdev @@ -534,6 +544,12 @@ kdump_install_net() { local _destaddr _srcaddr _route _netdev _conpath kdumpnic local _static _proto _ip_conf _ip_opts _ifname_opts local _znet_netdev _znet_conpath
- # each netowrk interface is managed by a NM connection profile
- declare -A nmconnection_map
- while read -r _ifname _nmconn; do
nmconnection_map[$_ifname]="$_nmconn"
- done <<< "$(nmcli -f device,filename connection show --active | tail -n +2)"
nmcli has the -t, --terse option to suppress printing of the header line.
Thanks for the tip!
Thanks Philipp
_destaddr=$(kdump_get_remote_ip "$1") _route=$(kdump_get_ip_route "$_destaddr")
NetworkManager defaults to use keyfile i.e. .nmconnnection file but still supports reading ifcfg-* file [1]. Make use of "nmcli connection clone --temporary" to automatically convert a ifcfg-* file to a .nmconnection file.
[1] https://fedoraproject.org/wiki/Changes/NetworkManager_keyfile_instead_of_ifc...
Signed-off-by: Coiby Xu coxu@redhat.com --- dracut-module-setup.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 3b6b1c3..91bebcb 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -348,12 +348,30 @@ kdump_setup_ifname() {
kdump_copy_nmconnection_file() { local _dev _nmconnection_file_path _nmconnection_name _initrd_nmconnection_file_path + local _cloned_nmconnection_file_path _uniq_name _old_uuid _old_name _uuid + _dev="$1"
_nmconnection_file_path=${nmconnection_map[$_dev]} _nmconnection_name=$(basename "$_nmconnection_file_path") _initrd_nmconnection_file_path="/etc/NetworkManager/system-connections/$_nmconnection_name" - inst "$_nmconnection_file_path" "$_initrd_nmconnection_file_path" + + _old_uuid=$(nmcli --get-values connection.uuid c show "$_nmconnection_file_path") + _old_name=$(nmcli --get-values connection.id c show "$_nmconnection_file_path") + _uniq_name=$(cat /proc/sys/kernel/random/uuid) + + nmcli connection clone --temporary "$_nmconnection_file_path" "$_uniq_name" + _uuid=$(nmcli --get-values connection.uuid c show "$_uniq_name") + # change back connection.id for the sake of readibility + nmcli connection modify --temporary "$_uuid" connection.id "$_old_name" + + _cloned_nmconnection_file_path=$(nmcli -g UUID,FILENAME connection show | sed -n "s/^${_uuid}://p") + inst "$_cloned_nmconnection_file_path" "$_initrd_nmconnection_file_path" + # change uuid back to old value in case it's refered by other connection + # profile e.g. connection.master could be Interface name of the master + # device or UUID of the master connection. + sed -i -r "s/(^uuid=).*$/\1${_old_uuid}/g" "${initdir}/$_initrd_nmconnection_file_path" + nmcli connection del "$_uuid" }
kdump_setup_bridge() {
Hi Coiby,
On Sat, 2 Apr 2022 11:23:46 +0800 Coiby Xu coxu@redhat.com wrote:
NetworkManager defaults to use keyfile i.e. .nmconnnection file but still supports reading ifcfg-* file [1]. Make use of "nmcli connection clone --temporary" to automatically convert a ifcfg-* file to a .nmconnection file.
[1] https://fedoraproject.org/wiki/Changes/NetworkManager_keyfile_instead_of_ifc...
Signed-off-by: Coiby Xu coxu@redhat.com
dracut-module-setup.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 3b6b1c3..91bebcb 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -348,12 +348,30 @@ kdump_setup_ifname() {
kdump_copy_nmconnection_file() { local _dev _nmconnection_file_path _nmconnection_name _initrd_nmconnection_file_path
- local _cloned_nmconnection_file_path _uniq_name _old_uuid _old_name _uuid
s/uniq/unique/ ?
_dev="$1"
_nmconnection_file_path=${nmconnection_map[$_dev]} _nmconnection_name=$(basename "$_nmconnection_file_path") _initrd_nmconnection_file_path="/etc/NetworkManager/system-connections/$_nmconnection_name"
- inst "$_nmconnection_file_path" "$_initrd_nmconnection_file_path"
- _old_uuid=$(nmcli --get-values connection.uuid c show "$_nmconnection_file_path")
- _old_name=$(nmcli --get-values connection.id c show "$_nmconnection_file_path")
- _uniq_name=$(cat /proc/sys/kernel/random/uuid)
- nmcli connection clone --temporary "$_nmconnection_file_path" "$_uniq_name"
- _uuid=$(nmcli --get-values connection.uuid c show "$_uniq_name")
- # change back connection.id for the sake of readibility
- nmcli connection modify --temporary "$_uuid" connection.id "$_old_name"
- _cloned_nmconnection_file_path=$(nmcli -g UUID,FILENAME connection show | sed -n "s/^${_uuid}://p")
I find it a little bit confusing that you are switching between the long --get-value and short -g as well as the long 'connection' and shot 'c'. I would prefer to have it consistent.
Thanks Philipp
- inst "$_cloned_nmconnection_file_path" "$_initrd_nmconnection_file_path"
- # change uuid back to old value in case it's refered by other connection
- # profile e.g. connection.master could be Interface name of the master
- # device or UUID of the master connection.
- sed -i -r "s/(^uuid=).*$/\1${_old_uuid}/g" "${initdir}/$_initrd_nmconnection_file_path"
- nmcli connection del "$_uuid"
}
kdump_setup_bridge() {
On Fri, Apr 22, 2022 at 05:29:49PM +0200, Philipp Rudo wrote:
Hi Coiby,
On Sat, 2 Apr 2022 11:23:46 +0800 Coiby Xu coxu@redhat.com wrote:
NetworkManager defaults to use keyfile i.e. .nmconnnection file but still supports reading ifcfg-* file [1]. Make use of "nmcli connection clone --temporary" to automatically convert a ifcfg-* file to a .nmconnection file.
[1] https://fedoraproject.org/wiki/Changes/NetworkManager_keyfile_instead_of_ifc...
Signed-off-by: Coiby Xu coxu@redhat.com
dracut-module-setup.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 3b6b1c3..91bebcb 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -348,12 +348,30 @@ kdump_setup_ifname() {
kdump_copy_nmconnection_file() { local _dev _nmconnection_file_path _nmconnection_name _initrd_nmconnection_file_path
- local _cloned_nmconnection_file_path _uniq_name _old_uuid _old_name _uuid
s/uniq/unique/ ?
_dev="$1"
_nmconnection_file_path=${nmconnection_map[$_dev]} _nmconnection_name=$(basename "$_nmconnection_file_path") _initrd_nmconnection_file_path="/etc/NetworkManager/system-connections/$_nmconnection_name"
- inst "$_nmconnection_file_path" "$_initrd_nmconnection_file_path"
- _old_uuid=$(nmcli --get-values connection.uuid c show "$_nmconnection_file_path")
- _old_name=$(nmcli --get-values connection.id c show "$_nmconnection_file_path")
- _uniq_name=$(cat /proc/sys/kernel/random/uuid)
- nmcli connection clone --temporary "$_nmconnection_file_path" "$_uniq_name"
- _uuid=$(nmcli --get-values connection.uuid c show "$_uniq_name")
- # change back connection.id for the sake of readibility
- nmcli connection modify --temporary "$_uuid" connection.id "$_old_name"
- _cloned_nmconnection_file_path=$(nmcli -g UUID,FILENAME connection show | sed -n "s/^${_uuid}://p")
I find it a little bit confusing that you are switching between the long --get-value and short -g as well as the long 'connection' and shot 'c'. I would prefer to have it consistent.
Thanks for catching this issue! I'll use the long version to make it consistent.
Thanks Philipp
- inst "$_cloned_nmconnection_file_path" "$_initrd_nmconnection_file_path"
- # change uuid back to old value in case it's refered by other connection
- # profile e.g. connection.master could be Interface name of the master
- # device or UUID of the master connection.
- sed -i -r "s/(^uuid=).*$/\1${_old_uuid}/g" "${initdir}/$_initrd_nmconnection_file_path"
- nmcli connection del "$_uuid"
}
kdump_setup_bridge() {
During boot, it may take some time for a device driver to detect the its devices. By default, NetworkManager doesn't wait for the device to be available (this is not an issue for the 1st kernel because NM keeps running in the 1st kernel). So we need to set connection.wait-device-timeout=60000 [1] as the same to nm-initrd-generator to tell NM to wait for 6s. Otherwise dracut-kdump-capture.service would fail because network isn't ready. Note the user's custom value for wait-device-timeout is respected.
Signed-off-by: Coiby Xu coxu@redhat.com --- dracut-module-setup.sh | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 91bebcb..75f82af 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -371,6 +371,12 @@ kdump_copy_nmconnection_file() { # profile e.g. connection.master could be Interface name of the master # device or UUID of the master connection. sed -i -r "s/(^uuid=).*$/\1${_old_uuid}/g" "${initdir}/$_initrd_nmconnection_file_path" + + # Ask NM to wait 60s for the network device to be available + # wait-device-timeout=60000 is inserted after "[connection]" so the + # user's custom value could overwrite it + sed -i -E 's/([connection])/\1\nwait-device-timeout=60000/' "${initdir}/$_initrd_nmconnection_file_path" + nmcli connection del "$_uuid" }
Hi Coiby,
On Sat, 2 Apr 2022 11:23:47 +0800 Coiby Xu coxu@redhat.com wrote:
During boot, it may take some time for a device driver to detect the its devices. By default, NetworkManager doesn't wait for the device to be available (this is not an issue for the 1st kernel because NM keeps running in the 1st kernel). So we need to set connection.wait-device-timeout=60000 [1] as the same to nm-initrd-generator to tell NM to wait for 6s. Otherwise dracut-kdump-capture.service would fail because network isn't ready. Note the user's custom value for wait-device-timeout is respected.
Signed-off-by: Coiby Xu coxu@redhat.com
dracut-module-setup.sh | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 91bebcb..75f82af 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -371,6 +371,12 @@ kdump_copy_nmconnection_file() { # profile e.g. connection.master could be Interface name of the master # device or UUID of the master connection. sed -i -r "s/(^uuid=).*$/\1${_old_uuid}/g" "${initdir}/$_initrd_nmconnection_file_path"
- # Ask NM to wait 60s for the network device to be available
- # wait-device-timeout=60000 is inserted after "[connection]" so the
- # user's custom value could overwrite it
- sed -i -E 's/([connection])/\1\nwait-device-timeout=60000/' "${initdir}/$_initrd_nmconnection_file_path"
you can use
sed -i '/[connection]/a wait-device-timeout=60000/' $file
to add a line after a match
Thanks Philipp
- nmcli connection del "$_uuid"
}
On Fri, Apr 22, 2022 at 05:29:41PM +0200, Philipp Rudo wrote:
Hi Coiby,
On Sat, 2 Apr 2022 11:23:47 +0800 Coiby Xu coxu@redhat.com wrote:
During boot, it may take some time for a device driver to detect the its devices. By default, NetworkManager doesn't wait for the device to be available (this is not an issue for the 1st kernel because NM keeps running in the 1st kernel). So we need to set connection.wait-device-timeout=60000 [1] as the same to nm-initrd-generator to tell NM to wait for 6s. Otherwise dracut-kdump-capture.service would fail because network isn't ready. Note the user's custom value for wait-device-timeout is respected.
Signed-off-by: Coiby Xu coxu@redhat.com
dracut-module-setup.sh | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 91bebcb..75f82af 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -371,6 +371,12 @@ kdump_copy_nmconnection_file() { # profile e.g. connection.master could be Interface name of the master # device or UUID of the master connection. sed -i -r "s/(^uuid=).*$/\1${_old_uuid}/g" "${initdir}/$_initrd_nmconnection_file_path"
- # Ask NM to wait 60s for the network device to be available
- # wait-device-timeout=60000 is inserted after "[connection]" so the
- # user's custom value could overwrite it
- sed -i -E 's/([connection])/\1\nwait-device-timeout=60000/' "${initdir}/$_initrd_nmconnection_file_path"
you can use
sed -i '/[connection]/a wait-device-timeout=60000/' $file
to add a line after a match
Great, thanks for the tip!
Thanks Philipp
- nmcli connection del "$_uuid"
}
On Mon, Apr 25, 2022 at 11:12:44AM +0800, Coiby Xu wrote:
On Fri, Apr 22, 2022 at 05:29:41PM +0200, Philipp Rudo wrote:
Hi Coiby,
On Sat, 2 Apr 2022 11:23:47 +0800 Coiby Xu coxu@redhat.com wrote:
During boot, it may take some time for a device driver to detect the its devices. By default, NetworkManager doesn't wait for the device to be available (this is not an issue for the 1st kernel because NM keeps running in the 1st kernel). So we need to set connection.wait-device-timeout=60000 [1] as the same to nm-initrd-generator to tell NM to wait for 6s. Otherwise dracut-kdump-capture.service would fail because network isn't ready. Note the user's custom value for wait-device-timeout is respected.
Signed-off-by: Coiby Xu coxu@redhat.com
dracut-module-setup.sh | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 91bebcb..75f82af 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -371,6 +371,12 @@ kdump_copy_nmconnection_file() { # profile e.g. connection.master could be Interface name of the master # device or UUID of the master connection. sed -i -r "s/(^uuid=).*$/\1${_old_uuid}/g" "${initdir}/$_initrd_nmconnection_file_path"
- # Ask NM to wait 60s for the network device to be available
- # wait-device-timeout=60000 is inserted after "[connection]" so the
- # user's custom value could overwrite it
- sed -i -E 's/([connection])/\1\nwait-device-timeout=60000/' "${initdir}/$_initrd_nmconnection_file_path"
you can use
sed -i '/[connection]/a wait-device-timeout=60000/' $file
to add a line after a match
Great, thanks for the tip!
I've applied to v1 with the trailing "/" removed i.e.
sed -i '/[connection]/a wait-device-timeout=60000' $file
thanks!
Thanks Philipp
- nmcli connection del "$_uuid"
}
-- Best regards, Coiby
By default, NetworkManger will manage all the network interfaces and try to set interface IFF_UP to get carrier state. Regardless of whether the network interface is connected to a cable or not, the NIC driver will allocate memory resources for e.g. ring buffers when setting IFF_UP. This could be a waste of memory. For example it's found i40e consumes ~15GB on a power machine. On this machine, i40e manages four interfaces but only one interface is valid. This patch use "managed=false" to tell NetworkManager to not manage network interfaces that are not needed by kdump by putting /etc/NetworkManager/conf.d/10-kdump-netif.conf in the initramfs.
Signed-off-by: Coiby Xu coxu@redhat.com --- dracut-module-setup.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 75f82af..d6ad3ba 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -348,7 +348,7 @@ kdump_setup_ifname() {
kdump_copy_nmconnection_file() { local _dev _nmconnection_file_path _nmconnection_name _initrd_nmconnection_file_path - local _cloned_nmconnection_file_path _uniq_name _old_uuid _old_name _uuid + local _cloned_nmconnection_file_path _uniq_name _old_uuid _old_name _uuid _per_mac
_dev="$1"
@@ -377,9 +377,31 @@ kdump_copy_nmconnection_file() { # user's custom value could overwrite it sed -i -E 's/([connection])/\1\nwait-device-timeout=60000/' "${initdir}/$_initrd_nmconnection_file_path"
+ _per_mac=$(kdump_get_perm_addr "$_dev") + if [[ "$_per_mac" != 'not set' ]]; then + echo -n "except:mac:$_per_mac," >> "/tmp/$$-netif_allowlist" + else + echo -n "except:interface-name:$_dev," >> "/tmp/$$-netif_allowlist" + fi + nmcli connection del "$_uuid" }
+kdump_install_nm_netif_allowlist() { + local _netif_allowlist + + _netif_allowlist=$(cat "/tmp/$$-netif_allowlist") + cat <<- EOF > "/tmp/$$-10-kdump-netif.conf" + [device-others] + match-device=${_netif_allowlist} + managed=false + EOF + + inst "/tmp/$$-10-kdump-netif.conf" "/etc/NetworkManager/conf.d/10-kdump-netif.conf" + rm -f "/tmp/$$-10-kdump-netif.conf" + rm -f "/tmp/$$-netif_allowlist" +} + kdump_setup_bridge() { local _netdev=$1 local _brif _dev _mac _kdumpdev
Hi Coiby,
On Sat, 2 Apr 2022 11:23:48 +0800 Coiby Xu coxu@redhat.com wrote:
By default, NetworkManger will manage all the network interfaces and try to set interface IFF_UP to get carrier state. Regardless of whether the network interface is connected to a cable or not, the NIC driver will allocate memory resources for e.g. ring buffers when setting IFF_UP. This could be a waste of memory. For example it's found i40e consumes ~15GB on a power machine. On this machine, i40e manages four interfaces but only one interface is valid. This patch use "managed=false" to tell NetworkManager to not manage network interfaces that are not needed by kdump by putting /etc/NetworkManager/conf.d/10-kdump-netif.conf in the initramfs.
Signed-off-by: Coiby Xu coxu@redhat.com
dracut-module-setup.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 75f82af..d6ad3ba 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -348,7 +348,7 @@ kdump_setup_ifname() {
kdump_copy_nmconnection_file() { local _dev _nmconnection_file_path _nmconnection_name _initrd_nmconnection_file_path
- local _cloned_nmconnection_file_path _uniq_name _old_uuid _old_name _uuid
local _cloned_nmconnection_file_path _uniq_name _old_uuid _old_name _uuid _per_mac
_dev="$1"
@@ -377,9 +377,31 @@ kdump_copy_nmconnection_file() { # user's custom value could overwrite it sed -i -E 's/([connection])/\1\nwait-device-timeout=60000/' "${initdir}/$_initrd_nmconnection_file_path"
- _per_mac=$(kdump_get_perm_addr "$_dev")
- if [[ "$_per_mac" != 'not set' ]]; then
echo -n "except:mac:$_per_mac," >> "/tmp/$$-netif_allowlist"
I know that this way of handling temporary files is common in dracut-modules-setup.sh. But personally I think it would be much better if you create a temporary directory in install() and put all the files in there. Then you only need a trap that removes the directory when leaving install() instead of removing every file individually.
- else
echo -n "except:interface-name:$_dev," >> "/tmp/$$-netif_allowlist"
- fi
- nmcli connection del "$_uuid"
}
+kdump_install_nm_netif_allowlist() {
- local _netif_allowlist
- _netif_allowlist=$(cat "/tmp/$$-netif_allowlist")
- cat <<- EOF > "/tmp/$$-10-kdump-netif.conf"
[device-others]
match-device=${_netif_allowlist}
Does that work when $$-netif_allowlist has multiple lines?
Thanks Philipp
managed=false
- EOF
- inst "/tmp/$$-10-kdump-netif.conf" "/etc/NetworkManager/conf.d/10-kdump-netif.conf"
- rm -f "/tmp/$$-10-kdump-netif.conf"
- rm -f "/tmp/$$-netif_allowlist"
+}
kdump_setup_bridge() { local _netdev=$1 local _brif _dev _mac _kdumpdev
On Fri, Apr 22, 2022 at 05:29:33PM +0200, Philipp Rudo wrote:
Hi Coiby,
On Sat, 2 Apr 2022 11:23:48 +0800 Coiby Xu coxu@redhat.com wrote:
By default, NetworkManger will manage all the network interfaces and try to set interface IFF_UP to get carrier state. Regardless of whether the network interface is connected to a cable or not, the NIC driver will allocate memory resources for e.g. ring buffers when setting IFF_UP. This could be a waste of memory. For example it's found i40e consumes ~15GB on a power machine. On this machine, i40e manages four interfaces but only one interface is valid. This patch use "managed=false" to tell NetworkManager to not manage network interfaces that are not needed by kdump by putting /etc/NetworkManager/conf.d/10-kdump-netif.conf in the initramfs.
Signed-off-by: Coiby Xu coxu@redhat.com
dracut-module-setup.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 75f82af..d6ad3ba 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -348,7 +348,7 @@ kdump_setup_ifname() {
kdump_copy_nmconnection_file() { local _dev _nmconnection_file_path _nmconnection_name _initrd_nmconnection_file_path
- local _cloned_nmconnection_file_path _uniq_name _old_uuid _old_name _uuid
local _cloned_nmconnection_file_path _uniq_name _old_uuid _old_name _uuid _per_mac
_dev="$1"
@@ -377,9 +377,31 @@ kdump_copy_nmconnection_file() { # user's custom value could overwrite it sed -i -E 's/([connection])/\1\nwait-device-timeout=60000/' "${initdir}/$_initrd_nmconnection_file_path"
- _per_mac=$(kdump_get_perm_addr "$_dev")
- if [[ "$_per_mac" != 'not set' ]]; then
echo -n "except:mac:$_per_mac," >> "/tmp/$$-netif_allowlist"
I know that this way of handling temporary files is common in dracut-modules-setup.sh. But personally I think it would be much better if you create a temporary directory in install() and put all the files in there. Then you only need a trap that removes the directory when leaving install() instead of removing every file individually.
Thanks for the suggestion to simplify the implementation! I'll give it a try.
- else
echo -n "except:interface-name:$_dev," >> "/tmp/$$-netif_allowlist"
- fi
- nmcli connection del "$_uuid"
}
+kdump_install_nm_netif_allowlist() {
- local _netif_allowlist
- _netif_allowlist=$(cat "/tmp/$$-netif_allowlist")
- cat <<- EOF > "/tmp/$$-10-kdump-netif.conf"
[device-others]
match-device=${_netif_allowlist}
Does that work when $$-netif_allowlist has multiple lines?
I don't think so. I have assumed ${_netif_allowlist} has only one line.
Thanks Philipp
managed=false
- EOF
- inst "/tmp/$$-10-kdump-netif.conf" "/etc/NetworkManager/conf.d/10-kdump-netif.conf"
- rm -f "/tmp/$$-10-kdump-netif.conf"
- rm -f "/tmp/$$-netif_allowlist"
+}
kdump_setup_bridge() { local _netdev=$1 local _brif _dev _mac _kdumpdev
Hi Coiby,
On Mon, 25 Apr 2022 11:43:35 +0800 Coiby Xu coxu@redhat.com wrote:
On Fri, Apr 22, 2022 at 05:29:33PM +0200, Philipp Rudo wrote:
Hi Coiby,
On Sat, 2 Apr 2022 11:23:48 +0800 Coiby Xu coxu@redhat.com wrote:
By default, NetworkManger will manage all the network interfaces and try to set interface IFF_UP to get carrier state. Regardless of whether the network interface is connected to a cable or not, the NIC driver will allocate memory resources for e.g. ring buffers when setting IFF_UP. This could be a waste of memory. For example it's found i40e consumes ~15GB on a power machine. On this machine, i40e manages four interfaces but only one interface is valid. This patch use "managed=false" to tell NetworkManager to not manage network interfaces that are not needed by kdump by putting /etc/NetworkManager/conf.d/10-kdump-netif.conf in the initramfs.
Signed-off-by: Coiby Xu coxu@redhat.com
dracut-module-setup.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 75f82af..d6ad3ba 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -348,7 +348,7 @@ kdump_setup_ifname() {
kdump_copy_nmconnection_file() { local _dev _nmconnection_file_path _nmconnection_name _initrd_nmconnection_file_path
- local _cloned_nmconnection_file_path _uniq_name _old_uuid _old_name _uuid
local _cloned_nmconnection_file_path _uniq_name _old_uuid _old_name _uuid _per_mac
_dev="$1"
@@ -377,9 +377,31 @@ kdump_copy_nmconnection_file() { # user's custom value could overwrite it sed -i -E 's/([connection])/\1\nwait-device-timeout=60000/' "${initdir}/$_initrd_nmconnection_file_path"
- _per_mac=$(kdump_get_perm_addr "$_dev")
- if [[ "$_per_mac" != 'not set' ]]; then
echo -n "except:mac:$_per_mac," >> "/tmp/$$-netif_allowlist"
I know that this way of handling temporary files is common in dracut-modules-setup.sh. But personally I think it would be much better if you create a temporary directory in install() and put all the files in there. Then you only need a trap that removes the directory when leaving install() instead of removing every file individually.
Thanks for the suggestion to simplify the implementation! I'll give it a try.
- else
echo -n "except:interface-name:$_dev," >> "/tmp/$$-netif_allowlist"
- fi
- nmcli connection del "$_uuid"
}
+kdump_install_nm_netif_allowlist() {
- local _netif_allowlist
- _netif_allowlist=$(cat "/tmp/$$-netif_allowlist")
- cat <<- EOF > "/tmp/$$-10-kdump-netif.conf"
[device-others]
match-device=${_netif_allowlist}
Does that work when $$-netif_allowlist has multiple lines?
I don't think so. I have assumed ${_netif_allowlist} has only one line.
I see my mistake. I only saw that you were appending to $$-netif_allowlist but not that you are always using "echo -n". So yes, the netif_allowlist should always be only a single line.
BTW, you could get rid of the local variable by simply moving the "cat" to the heredoc, i.e.
cat <<- EOF ... match-device=$(cat "/tmp/$$-netif_allowlist") ... EOF
or maybe even go full bash with $(< /tmp/$$-netif_allowlist)
Thanks Philipp
Thanks Philipp
managed=false
- EOF
- inst "/tmp/$$-10-kdump-netif.conf" "/etc/NetworkManager/conf.d/10-kdump-netif.conf"
- rm -f "/tmp/$$-10-kdump-netif.conf"
- rm -f "/tmp/$$-netif_allowlist"
+}
kdump_setup_bridge() { local _netdev=$1 local _brif _dev _mac _kdumpdev
On Mon, Apr 25, 2022 at 01:49:38PM +0200, Philipp Rudo wrote:
Hi Coiby,
BTW, you could get rid of the local variable by simply moving the "cat" to the heredoc, i.e.
cat <<- EOF ... match-device=$(cat "/tmp/$$-netif_allowlist") ... EOF
or maybe even go full bash with $(< /tmp/$$-netif_allowlist)
Thanks for the tip! I'll apply it in the future since v1 has some change that makes this suggestion invalid.
Thanks Philipp
Thanks Philipp
managed=false
- EOF
- inst "/tmp/$$-10-kdump-netif.conf" "/etc/NetworkManager/conf.d/10-kdump-netif.conf"
- rm -f "/tmp/$$-10-kdump-netif.conf"
- rm -f "/tmp/$$-netif_allowlist"
+}
kdump_setup_bridge() { local _netdev=$1 local _brif _dev _mac _kdumpdev
kexec-tools depends on dracut's 35network-manager module which will call nm-initrd-generator. We don't want nm-initrd-generator to generate connection profiles since we will copy them from 1st kernel to kdump kernel initramfs. NetworkManager >= 1.35.2 won't generate connection profiles if there's a connection dir with rd.neednet. For Fedora/RHEL, this connection dir is /etc/NetworkManager/system-connections. For the details, please refer to the NetworkManager commit 79885656d3 ("initrd: don't add a connection if there's a connection dir with rd.neednet") [1]. Before the release of NetworkManager >= 1.35.2, we need to mask /usr/libexec/nm-initrd-generator.
[1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_request...
Signed-off-by: Coiby Xu coxu@redhat.com --- dracut-module-setup.sh | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index d6ad3ba..afeac3c 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -655,6 +655,11 @@ kdump_install_net() { echo "rd.neednet" >> "${initdir}/etc/cmdline.d/50neednet.conf" fi
+ # Stop dracut 35network-manger to calling nm-initrd-generator. + # Note this line of code can be removed after NetworkManager >= 1.35.2 + # gets released. + echo > "${initdir}/usr/libexec/nm-initrd-generator" + # Save netdev used for kdump as cmdline # Whoever calling kdump_install_net() is setting up the default gateway, # ie. bootdev/kdumpnic. So don't override the setting if calling
Coiby Xu coxu@redhat.com 于2022年4月2日周六 11:24写道:
kexec-tools depends on dracut's 35network-manager module which will call nm-initrd-generator. We don't want nm-initrd-generator to generate connection profiles since we will copy them from 1st kernel to kdump kernel initramfs. NetworkManager >= 1.35.2 won't generate connection profiles if there's a connection dir with rd.neednet. For Fedora/RHEL, this connection dir is /etc/NetworkManager/system-connections. For the details, please refer to the NetworkManager commit 79885656d3 ("initrd: don't add a connection if there's a connection dir with rd.neednet") [1]. Before the release of NetworkManager >= 1.35.2, we need to mask /usr/libexec/nm-initrd-generator.
[1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_request...
Signed-off-by: Coiby Xu coxu@redhat.com
dracut-module-setup.sh | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index d6ad3ba..afeac3c 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -655,6 +655,11 @@ kdump_install_net() { echo "rd.neednet" >> "${initdir}/etc/cmdline.d/50neednet.conf" fi
- # Stop dracut 35network-manger to calling nm-initrd-generator.
- # Note this line of code can be removed after NetworkManager >= 1.35.2
- # gets released.
- echo > "${initdir}/usr/libexec/nm-initrd-generator"
initramfs for local dump won't include this file, so maybe only mask it only when it exists?
# Save netdev used for kdump as cmdline # Whoever calling kdump_install_net() is setting up the default gateway, # ie. bootdev/kdumpnic. So don't override the setting if calling
-- 2.34.1 _______________________________________________ kexec mailing list -- kexec@lists.fedoraproject.org To unsubscribe send an email to kexec-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
On Sat, Apr 23, 2022 at 10:29:39PM +0800, Kairui Song wrote:
Coiby Xu coxu@redhat.com 于2022年4月2日周六 11:24写道:
kexec-tools depends on dracut's 35network-manager module which will call nm-initrd-generator. We don't want nm-initrd-generator to generate connection profiles since we will copy them from 1st kernel to kdump kernel initramfs. NetworkManager >= 1.35.2 won't generate connection profiles if there's a connection dir with rd.neednet. For Fedora/RHEL, this connection dir is /etc/NetworkManager/system-connections. For the details, please refer to the NetworkManager commit 79885656d3 ("initrd: don't add a connection if there's a connection dir with rd.neednet") [1]. Before the release of NetworkManager >= 1.35.2, we need to mask /usr/libexec/nm-initrd-generator.
[1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_request...
Signed-off-by: Coiby Xu coxu@redhat.com
dracut-module-setup.sh | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index d6ad3ba..afeac3c 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -655,6 +655,11 @@ kdump_install_net() { echo "rd.neednet" >> "${initdir}/etc/cmdline.d/50neednet.conf" fi
- # Stop dracut 35network-manger to calling nm-initrd-generator.
- # Note this line of code can be removed after NetworkManager >= 1.35.2
- # gets released.
- echo > "${initdir}/usr/libexec/nm-initrd-generator"
initramfs for local dump won't include this file, so maybe only mask it only when it exists?
Fortunately, we mask this file only in kdump_install_net. For local dump, kdump_install_net is not called at all. So there is no need to check if it exists.
# Save netdev used for kdump as cmdline # Whoever calling kdump_install_net() is setting up the default gateway, # ie. bootdev/kdumpnic. So don't override the setting if calling
-- 2.34.1 _______________________________________________ kexec mailing list -- kexec@lists.fedoraproject.org To unsubscribe send an email to kexec-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
Signed-off-by: Coiby Xu coxu@redhat.com --- dracut-module-setup.sh | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index afeac3c..d53850b 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -404,30 +404,21 @@ kdump_install_nm_netif_allowlist() {
kdump_setup_bridge() { local _netdev=$1 - local _brif _dev _mac _kdumpdev + local _dev for _dev in "/sys/class/net/$_netdev/brif/"*; do [[ -e $_dev ]] || continue _dev=${_dev##*/} - _kdumpdev=$_dev if kdump_is_bond "$_dev"; then (kdump_setup_bond "$_dev" "$(get_nmcli_connection_apath_by_ifname "$_dev")") || exit 1 elif kdump_is_team "$_dev"; then kdump_setup_team "$_dev" elif kdump_is_vlan "$_dev"; then kdump_setup_vlan "$_dev" - else - _mac=$(kdump_get_mac_addr "$_dev") - _kdumpdev=$(kdump_setup_ifname "$_dev") - echo -n " ifname=$_kdumpdev:$_mac" >> "${initdir}/etc/cmdline.d/41bridge.conf" fi - _brif+="$_kdumpdev," + kdump_copy_nmconnection_file "$_dev" done - echo " bridge=$_netdev:${_brif%,}" >> "${initdir}/etc/cmdline.d/41bridge.conf" }
-# drauct takes bond=<bondname>[:<bondslaves>:[:<options>]] syntax to parse -# bond. For example: -# bond=bond0:eth0,eth1:mode=balance-rr kdump_setup_bond() { local _netdev="$1" local _conpath="$2" @@ -588,7 +579,7 @@ kdump_get_remote_ip() { # $1: destination host kdump_install_net() { local _destaddr _srcaddr _route _netdev _conpath kdumpnic - local _static _proto _ip_conf _ip_opts _ifname_opts + local _static _proto _ip_conf _ip_opts local _znet_netdev _znet_conpath # each netowrk interface is managed by a NM connection profile declare -A nmconnection_map @@ -602,7 +593,6 @@ kdump_install_net() { _srcaddr=$(kdump_get_ip_route_field "$_route" "src") _netdev=$(kdump_get_ip_route_field "$_route" "dev") _conpath=$(get_nmcli_connection_apath_by_ifname "$_netdev") - _netmac=$(kdump_get_mac_addr "$_netdev") kdumpnic=$(kdump_setup_ifname "$_netdev")
_znet_netdev=$(find_online_znet_device) @@ -635,6 +625,8 @@ kdump_install_net() { echo "$_ip_opts" >> "$_ip_conf" fi
+ echo -n > "/tmp/$$-netif_allowlist" + if kdump_is_bridge "$_netdev"; then kdump_setup_bridge "$_netdev" elif kdump_is_bond "$_netdev"; then @@ -643,10 +635,9 @@ kdump_install_net() { kdump_setup_team "$_netdev" elif kdump_is_vlan "$_netdev"; then kdump_setup_vlan "$_netdev" - else - _ifname_opts=" ifname=$kdumpnic:$_netmac" - echo "$_ifname_opts" >> "$_ip_conf" fi + kdump_copy_nmconnection_file "$_netdev" + kdump_install_nm_netif_allowlist
kdump_setup_dns "$_netdev" "$_conpath"
Signed-off-by: Coiby Xu coxu@redhat.com --- dracut-module-setup.sh | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index d53850b..1b351e9 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -409,7 +409,7 @@ kdump_setup_bridge() { [[ -e $_dev ]] || continue _dev=${_dev##*/} if kdump_is_bond "$_dev"; then - (kdump_setup_bond "$_dev" "$(get_nmcli_connection_apath_by_ifname "$_dev")") || exit 1 + (kdump_setup_bond "$_dev") || exit 1 elif kdump_is_team "$_dev"; then kdump_setup_team "$_dev" elif kdump_is_vlan "$_dev"; then @@ -421,30 +421,10 @@ kdump_setup_bridge() {
kdump_setup_bond() { local _netdev="$1" - local _conpath="$2" - local _dev _mac _slaves _kdumpdev _bondoptions + local _dev for _dev in $(cat "/sys/class/net/$_netdev/bonding/slaves"); do - _mac=$(kdump_get_perm_addr "$_dev") - _kdumpdev=$(kdump_setup_ifname "$_dev") - echo -n " ifname=$_kdumpdev:$_mac" >> "${initdir}/etc/cmdline.d/42bond.conf" - _slaves+="$_kdumpdev," + kdump_copy_nmconnection_file "$_dev" done - echo -n " bond=$_netdev:${_slaves%,}" >> "${initdir}/etc/cmdline.d/42bond.conf" - - _bondoptions=$(get_nmcli_field_by_conpath "bond.options" "$_conpath") - - if [[ -z $_bondoptions ]]; then - dwarning "Failed to get bond configuration via nmlci output. Now try sourcing ifcfg script." - source_ifcfg_file "$_netdev" - _bondoptions="$(echo "$BONDING_OPTS" | xargs echo | tr " " ",")" - fi - - if [[ -z $_bondoptions ]]; then - derror "Get empty bond options" - exit 1 - fi - - echo ":$_bondoptions" >> "${initdir}/etc/cmdline.d/42bond.conf" }
kdump_setup_team() { @@ -482,7 +462,7 @@ kdump_setup_vlan() { derror "Vlan over bridge is not supported!" exit 1 elif kdump_is_bond "$_phydev"; then - (kdump_setup_bond "$_phydev" "$(get_nmcli_connection_apath_by_ifname "$_phydev")") || exit 1 + (kdump_setup_bond "$_phydev") || exit 1 echo " vlan=$(kdump_setup_ifname "$_netdev"):$_phydev" > "${initdir}/etc/cmdline.d/43vlan.conf" else _kdumpdev="$(kdump_setup_ifname "$_phydev")" @@ -630,7 +610,7 @@ kdump_install_net() { if kdump_is_bridge "$_netdev"; then kdump_setup_bridge "$_netdev" elif kdump_is_bond "$_netdev"; then - (kdump_setup_bond "$_netdev" "$_conpath") || exit 1 + (kdump_setup_bond "$_netdev") || exit 1 elif kdump_is_team "$_netdev"; then kdump_setup_team "$_netdev" elif kdump_is_vlan "$_netdev"; then
6f9235887f7817085aabfcc67bf4a6d68e474264 ("module-setup.sh: enable vlan on team interface") skips establishing teaming network by mistake. Although it could use one of slave netifs to establish connection to transfer vmcore to remote fs, it breaks the implicit assumption of creating an identical network topology to the 1st kernel.
Fixes: 6f92358 ("module-setup.sh: enable vlan on team interface") Signed-off-by: Coiby Xu coxu@redhat.com --- dracut-module-setup.sh | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 1b351e9..ad5babc 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -464,6 +464,9 @@ kdump_setup_vlan() { elif kdump_is_bond "$_phydev"; then (kdump_setup_bond "$_phydev") || exit 1 echo " vlan=$(kdump_setup_ifname "$_netdev"):$_phydev" > "${initdir}/etc/cmdline.d/43vlan.conf" + elif kdump_is_team "$_phydev"; then + (kdump_setup_team "$_phydev") || exit 1 + echo " vlan=$(kdump_setup_ifname "$_netdev"):$_phydev" > "${initdir}/etc/cmdline.d/43vlan.conf" else _kdumpdev="$(kdump_setup_ifname "$_phydev")" echo " vlan=$(kdump_setup_ifname "$_netdev"):$_kdumpdev ifname=$_kdumpdev:$_netmac" > "${initdir}/etc/cmdline.d/43vlan.conf"
A vlan interface is created on top of another interface, such as an Ethernet, bonding, team which is called parent interface. When the parent interface is physical, there is no need to copy the connection profile of the physical interface to initrd. Only allowing NM to manage this physical parent interface would be sufficient.
Also rename phydev to parent_netif to improve code readability.
Signed-off-by: Coiby Xu coxu@redhat.com --- dracut-module-setup.sh | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index ad5babc..64f9141 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -450,26 +450,21 @@ kdump_setup_team() {
kdump_setup_vlan() { local _netdev=$1 - local _phydev - local _netmac - local _kdumpdev + local _parent_netif
- _phydev="$(awk '/^Device:/{print $2}' /proc/net/vlan/"$_netdev")" - _netmac="$(kdump_get_mac_addr "$_phydev")" + _parent_netif="$(awk '/^Device:/{print $2}' /proc/net/vlan/"$_netdev")"
#Just support vlan over bond and team - if kdump_is_bridge "$_phydev"; then + if kdump_is_bridge "$_parent_netif"; then derror "Vlan over bridge is not supported!" exit 1 - elif kdump_is_bond "$_phydev"; then - (kdump_setup_bond "$_phydev") || exit 1 - echo " vlan=$(kdump_setup_ifname "$_netdev"):$_phydev" > "${initdir}/etc/cmdline.d/43vlan.conf" - elif kdump_is_team "$_phydev"; then - (kdump_setup_team "$_phydev") || exit 1 - echo " vlan=$(kdump_setup_ifname "$_netdev"):$_phydev" > "${initdir}/etc/cmdline.d/43vlan.conf" + elif kdump_is_bond "$_parent_netif"; then + (kdump_setup_bond "$_parent_netif") || exit 1 + kdump_copy_nmconnection_file "$_parent_netif" + elif kdump_is_team "$_parent_netif"; then + (kdump_setup_team "$_parent_netif") || exit 1 else - _kdumpdev="$(kdump_setup_ifname "$_phydev")" - echo " vlan=$(kdump_setup_ifname "$_netdev"):$_kdumpdev ifname=$_kdumpdev:$_netmac" > "${initdir}/etc/cmdline.d/43vlan.conf" + echo -n "except:interface-name:$_parent_netif," >> "/tmp/$$-netif_allowlist" fi }
Signed-off-by: Coiby Xu coxu@redhat.com --- dracut-module-setup.sh | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 64f9141..4e64872 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -429,23 +429,10 @@ kdump_setup_bond() {
kdump_setup_team() { local _netdev=$1 - local _dev _mac _slaves _kdumpdev + local _dev for _dev in $(teamnl "$_netdev" ports | awk -F':' '{print $2}'); do - _mac=$(kdump_get_perm_addr "$_dev") - _kdumpdev=$(kdump_setup_ifname "$_dev") - echo -n " ifname=$_kdumpdev:$_mac" >> "${initdir}/etc/cmdline.d/44team.conf" - _slaves+="$_kdumpdev," + kdump_copy_nmconnection_file "$_dev" done - echo " team=$_netdev:${_slaves%,}" >> "${initdir}/etc/cmdline.d/44team.conf" - #Buggy version teamdctl outputs to stderr! - #Try to use the latest version of teamd. - if ! teamdctl "$_netdev" config dump > "${initdir}/tmp/$$-$_netdev.conf"; then - derror "teamdctl failed." - exit 1 - fi - inst_dir /etc/teamd - inst_simple "${initdir}/tmp/$$-$_netdev.conf" "/etc/teamd/$_netdev.conf" - rm -f "${initdir}/tmp/$$-$_netdev.conf" }
kdump_setup_vlan() { @@ -463,6 +450,7 @@ kdump_setup_vlan() { kdump_copy_nmconnection_file "$_parent_netif" elif kdump_is_team "$_parent_netif"; then (kdump_setup_team "$_parent_netif") || exit 1 + kdump_copy_nmconnection_file "$_parent_netif" else echo -n "except:interface-name:$_parent_netif," >> "/tmp/$$-netif_allowlist" fi
Hi Coiby,
one more thing
On Sat, 2 Apr 2022 11:23:54 +0800 Coiby Xu coxu@redhat.com wrote:
Signed-off-by: Coiby Xu coxu@redhat.com
dracut-module-setup.sh | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 64f9141..4e64872 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -429,23 +429,10 @@ kdump_setup_bond() {
kdump_setup_team() { local _netdev=$1
- local _dev _mac _slaves _kdumpdev
- local _dev for _dev in $(teamnl "$_netdev" ports | awk -F':' '{print $2}'); do
as you are basically rewriting this function you could also switch from a for-loop to the preferred while-read-loop [1]. Same for kdump_setup_{bridge,bond}.
Thanks Philipp
[1] https://github.com/koalaman/shellcheck/wiki/SC2013
_mac=$(kdump_get_perm_addr "$_dev")
_kdumpdev=$(kdump_setup_ifname "$_dev")
echo -n " ifname=$_kdumpdev:$_mac" >> "${initdir}/etc/cmdline.d/44team.conf"
_slaves+="$_kdumpdev,"
donekdump_copy_nmconnection_file "$_dev"
- echo " team=$_netdev:${_slaves%,}" >> "${initdir}/etc/cmdline.d/44team.conf"
- #Buggy version teamdctl outputs to stderr!
- #Try to use the latest version of teamd.
- if ! teamdctl "$_netdev" config dump > "${initdir}/tmp/$$-$_netdev.conf"; then
derror "teamdctl failed."
exit 1
- fi
- inst_dir /etc/teamd
- inst_simple "${initdir}/tmp/$$-$_netdev.conf" "/etc/teamd/$_netdev.conf"
- rm -f "${initdir}/tmp/$$-$_netdev.conf"
}
kdump_setup_vlan() { @@ -463,6 +450,7 @@ kdump_setup_vlan() { kdump_copy_nmconnection_file "$_parent_netif" elif kdump_is_team "$_parent_netif"; then (kdump_setup_team "$_parent_netif") || exit 1
else echo -n "except:interface-name:$_parent_netif," >> "/tmp/$$-netif_allowlist" fikdump_copy_nmconnection_file "$_parent_netif"
On Mon, Apr 25, 2022 at 02:12:04PM +0200, Philipp Rudo wrote:
Hi Coiby,
one more thing
On Sat, 2 Apr 2022 11:23:54 +0800 Coiby Xu coxu@redhat.com wrote:
Signed-off-by: Coiby Xu coxu@redhat.com
dracut-module-setup.sh | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 64f9141..4e64872 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -429,23 +429,10 @@ kdump_setup_bond() {
kdump_setup_team() { local _netdev=$1
- local _dev _mac _slaves _kdumpdev
- local _dev for _dev in $(teamnl "$_netdev" ports | awk -F':' '{print $2}'); do
as you are basically rewriting this function you could also switch from a for-loop to the preferred while-read-loop [1]. Same for kdump_setup_{bridge,bond}.
Correctly me if I'm wrong, but according to [1], while-read-loop is for read lines than words and the for-loop in kdump_setup_{bridge,bond,team} is supposed to read words. Interestingly, shellcheck doesn't complain the for-loop here and also in _bridge. It only complains _bond. So in v1, I simply disable shellcheck for _bond.
Thanks Philipp
[1] https://github.com/koalaman/shellcheck/wiki/SC2013
_mac=$(kdump_get_perm_addr "$_dev")
_kdumpdev=$(kdump_setup_ifname "$_dev")
echo -n " ifname=$_kdumpdev:$_mac" >> "${initdir}/etc/cmdline.d/44team.conf"
_slaves+="$_kdumpdev,"
donekdump_copy_nmconnection_file "$_dev"
- echo " team=$_netdev:${_slaves%,}" >> "${initdir}/etc/cmdline.d/44team.conf"
- #Buggy version teamdctl outputs to stderr!
- #Try to use the latest version of teamd.
- if ! teamdctl "$_netdev" config dump > "${initdir}/tmp/$$-$_netdev.conf"; then
derror "teamdctl failed."
exit 1
- fi
- inst_dir /etc/teamd
- inst_simple "${initdir}/tmp/$$-$_netdev.conf" "/etc/teamd/$_netdev.conf"
- rm -f "${initdir}/tmp/$$-$_netdev.conf"
}
kdump_setup_vlan() { @@ -463,6 +450,7 @@ kdump_setup_vlan() { kdump_copy_nmconnection_file "$_parent_netif" elif kdump_is_team "$_parent_netif"; then (kdump_setup_team "$_parent_netif") || exit 1
else echo -n "except:interface-name:$_parent_netif," >> "/tmp/$$-netif_allowlist" fikdump_copy_nmconnection_file "$_parent_netif"
Clean up the related code to build up dracut cmdline parameter such rd.route, ip and etc. And there is no need to to setup dns when copying .nmconnection directly to initrd either.
Note the bootdev dracut command line parameter is only used by dracut's 35network-legacy and network-manager doesn't use it, remove related code as well.
Signed-off-by: Coiby Xu coxu@redhat.com --- dracut-module-setup.sh | 147 +---------------------------------------- 1 file changed, 2 insertions(+), 145 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 4e64872..c05666e 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -84,39 +84,6 @@ source_ifcfg_file() { fi }
-kdump_setup_dns() { - local _netdev="$1" - local _conpath="$2" - local _nameserver _dns _tmp array - local _dnsfile=${initdir}/etc/cmdline.d/42dns.conf - - _tmp=$(get_nmcli_field_by_conpath "IP4.DNS" "$_conpath") - # shellcheck disable=SC2206 - array=(${_tmp//|/ }) - if [[ ${array[*]} ]]; then - for _dns in "${array[@]}"; do - echo "nameserver=$_dns" >> "$_dnsfile" - done - else - dwarning "Failed to get DNS info via nmcli output. Now try sourcing ifcfg script" - source_ifcfg_file "$_netdev" - [[ -n $DNS1 ]] && echo "nameserver=$DNS1" > "$_dnsfile" - [[ -n $DNS2 ]] && echo "nameserver=$DNS2" >> "$_dnsfile" - fi - - while read -r content; do - _nameserver=$(echo "$content" | grep ^nameserver) - [[ -z $_nameserver ]] && continue - - _dns=$(echo "$_nameserver" | awk '{print $2}') - [[ -z $_dns ]] && continue - - if [[ ! -f $_dnsfile ]] || ! grep -q "$_dns" "$_dnsfile"; then - echo "nameserver=$_dns" >> "$_dnsfile" - fi - done < "/etc/resolv.conf" -} - # $1: repeat times # $2: string to be repeated # $3: separator @@ -227,89 +194,6 @@ cal_netmask_by_prefix() { fi }
-#$1: netdev name -#$2: srcaddr -#if it use static ip echo it, or echo null -kdump_static_ip() { - local _netdev="$1" _srcaddr="$2" kdumpnic="$3" _ipv6_flag - local _netmask _gateway _ipaddr _target _nexthop _prefix - - _ipaddr=$(ip addr show dev "$_netdev" permanent | awk "/ $_srcaddr/.* /{print $2}") - - if is_ipv6_address "$_srcaddr"; then - _ipv6_flag="-6" - fi - - if [[ -n $_ipaddr ]]; then - _gateway=$(ip $_ipv6_flag route list dev "$_netdev" \ - | awk '/^default /{print $3}' | head -n 1) - - if [[ "x" != "x"$_ipv6_flag ]]; then - # _ipaddr="2002::56ff:feb6:56d5/64", _netmask is the number after "/" - _netmask=${_ipaddr#*/} - _srcaddr="[$_srcaddr]" - _gateway="[$_gateway]" - else - _prefix=$(cut -d'/' -f2 <<< "$_ipaddr") - if ! _netmask=$(cal_netmask_by_prefix "$_prefix" "$_ipv6_flag"); then - derror "Failed to calculate netmask for $_ipaddr" - exit 1 - fi - fi - echo -n "${_srcaddr}::${_gateway}:${_netmask}::" - fi - - /sbin/ip $_ipv6_flag route show | grep -v default \ - | grep ".*via.* $_netdev " | grep -v "^[[:space:]]*nexthop" \ - | while read -r _route; do - _target=$(echo "$_route" | awk '{print $1}') - _nexthop=$(echo "$_route" | awk '{print $3}') - if [[ "x" != "x"$_ipv6_flag ]]; then - _target="[$_target]" - _nexthop="[$_nexthop]" - fi - echo "rd.route=$_target:$_nexthop:$kdumpnic" - done >> "${initdir}/etc/cmdline.d/45route-static.conf" - - kdump_handle_mulitpath_route "$_netdev" "$_srcaddr" "$kdumpnic" -} - -kdump_handle_mulitpath_route() { - local _netdev="$1" _srcaddr="$2" kdumpnic="$3" _ipv6_flag - local _target _nexthop _route _weight _max_weight _rule - - if is_ipv6_address "$_srcaddr"; then - _ipv6_flag="-6" - fi - - while IFS="" read -r _route; do - if [[ $_route =~ [[:space:]]+nexthop ]]; then - _route=${_route##[[:space:]]} - # Parse multipath route, using previous _target - [[ $_target == 'default' ]] && continue - [[ $_route =~ .*via.*\ $_netdev ]] || continue - - _weight=$(echo "$_route" | cut -d ' ' -f7) - if [[ $_weight -gt $_max_weight ]]; then - _nexthop=$(echo "$_route" | cut -d ' ' -f3) - _max_weight=$_weight - if [[ "x" != "x"$_ipv6_flag ]]; then - _rule="rd.route=[$_target]:[$_nexthop]:$kdumpnic" - else - _rule="rd.route=$_target:$_nexthop:$kdumpnic" - fi - fi - else - [[ -n $_rule ]] && echo "$_rule" - _target=$(echo "$_route" | cut -d ' ' -f1) - _rule="" _max_weight=0 _weight=0 - fi - done >> "${initdir}/etc/cmdline.d/45route-static.conf" \ - <<< "$(/sbin/ip $_ipv6_flag route show)" - - [[ -n $_rule ]] && echo "$_rule" >> "${initdir}/etc/cmdline.d/45route-static.conf" -} - kdump_get_mac_addr() { cat "/sys/class/net/$1/address" } @@ -544,8 +428,7 @@ kdump_get_remote_ip() { # initramfs accessing giving destination # $1: destination host kdump_install_net() { - local _destaddr _srcaddr _route _netdev _conpath kdumpnic - local _static _proto _ip_conf _ip_opts + local _destaddr _route _netdev _conpath kdumpnic local _znet_netdev _znet_conpath # each netowrk interface is managed by a NM connection profile declare -A nmconnection_map @@ -556,7 +439,6 @@ kdump_install_net() {
_destaddr=$(kdump_get_remote_ip "$1") _route=$(kdump_get_ip_route "$_destaddr") - _srcaddr=$(kdump_get_ip_route_field "$_route" "src") _netdev=$(kdump_get_ip_route_field "$_route" "dev") _conpath=$(get_nmcli_connection_apath_by_ifname "$_netdev") kdumpnic=$(kdump_setup_ifname "$_netdev") @@ -570,27 +452,6 @@ kdump_install_net() { fi fi
- _static=$(kdump_static_ip "$_netdev" "$_srcaddr" "$kdumpnic") - if [[ -n $_static ]]; then - _proto=none - elif is_ipv6_address "$_srcaddr"; then - _proto=auto6 - else - _proto=dhcp - fi - - _ip_conf="${initdir}/etc/cmdline.d/40ip.conf" - _ip_opts=" ip=${_static}$kdumpnic:${_proto}" - - # dracut doesn't allow duplicated configuration for same NIC, even they're exactly the same. - # so we have to avoid adding duplicates - # We should also check /proc/cmdline for existing ip=xx arg. - # For example, iscsi boot will specify ip=xxx arg in cmdline. - if [[ ! -f $_ip_conf ]] || ! grep -q "$_ip_opts" "$_ip_conf" \ - && ! grep -q "ip=[^[:space:]]*$_netdev" /proc/cmdline; then - echo "$_ip_opts" >> "$_ip_conf" - fi - echo -n > "/tmp/$$-netif_allowlist"
if kdump_is_bridge "$_netdev"; then @@ -605,8 +466,6 @@ kdump_install_net() { kdump_copy_nmconnection_file "$_netdev" kdump_install_nm_netif_allowlist
- kdump_setup_dns "$_netdev" "$_conpath" - if [[ ! -f ${initdir}/etc/cmdline.d/50neednet.conf ]]; then # network-manager module needs this parameter echo "rd.neednet" >> "${initdir}/etc/cmdline.d/50neednet.conf" @@ -624,10 +483,8 @@ kdump_install_net() { # the default gate way for network dump, eth1 in the fence kdump path will # call kdump_install_net again and we don't want eth1 to be the default # gateway. - if [[ ! -f ${initdir}/etc/cmdline.d/60kdumpnic.conf ]] \ - && [[ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]]; then + if [[ ! -f ${initdir}/etc/cmdline.d/60kdumpnic.conf ]]; then echo "kdumpnic=$kdumpnic" > "${initdir}/etc/cmdline.d/60kdumpnic.conf" - echo "bootdev=$kdumpnic" > "${initdir}/etc/cmdline.d/70bootdev.conf" fi }
A NIC may get a different name in the kdump kernel from 1st kernel in cases like, - kernel assigned network interface names are not persistent e.g. [1] - there is an udev rule to rename the NIC in the 1st kernel but the kdump initrd may not have that rule e.g. [2]
If NM tries to match a NIC with a connection profile based on NIC name i.e. connection.interface-name, it will fail the above bases. So we should remove the line connection.interface-name=XX from the connection file. With this line deleted, multiple NICs may be matched by a connection profile but we don't need to worry about a wrong NIC is brought up by NM since we have explicitly asked NM to only bring up the NICs needed by kdump via /etc/NetworkManager/conf.d/10-kdump-netif.conf. Note we don't need to do this for user created NIC like vlan, bridge and bond.
An remaining issue is passing the name of a NIC via the kdumpnic dracut command line parameter which requires passing ifname=<interface>:<MAC> to have fixed NIC name. But we can simply drop this requirement. kdumpnic is needed because kdump needs to get the IP by NIC name and use the IP to created a dumping folder named "{IP}-{DATE}". We can simply pass the IP to the kdump kernel directly via a new dracut command line parameter kdumpip instead. In addition to the benefit of simplifying the code, there are other three benefits brought by this approach, - make use of whatever network to transfer the vmcore. Because as long as we have the network to we don't care which NIC is active. - if obtained IP in the kdump kernel is different from the one in the 1st kernel. "{IP}-{DATE}" would better tell where the dumped vmcore comes from. - without passing ifname=<interface>:<MAC> to to kdump initrd, the issue of there are two interfaces with the same MAC address for Azure Hyper-V NIC SR-IOV [3] is resolved automatically.
[1] https://bugzilla.redhat.com/show_bug.cgi?id=1121778 [2] https://bugzilla.redhat.com/show_bug.cgi?id=810107 [3] https://bugzilla.redhat.com/show_bug.cgi?id=1962421
Signed-off-by: Coiby Xu coxu@redhat.com --- dracut-kdump.sh | 18 ++++-------------- dracut-module-setup.sh | 38 ++++++++++++++------------------------ 2 files changed, 18 insertions(+), 38 deletions(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh index b69bc98..e27be61 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -475,22 +475,12 @@ save_vmcore_dmesg_ssh() get_host_ip() { if is_nfs_dump_target || is_ssh_dump_target; then - kdumpnic=$(getarg kdumpnic=) - if [ -z "$kdumpnic" ]; then - derror "failed to get kdumpnic!" + kdumpip=$(getarg kdumpip=) + if [ -z "$kdumpip" ]; then + derror "failed to get kdumpip!" return 1 fi - if ! kdumphost=$(ip addr show dev "$kdumpnic" | grep '[ ]*inet'); then - derror "wrong kdumpnic: $kdumpnic" - return 1 - fi - kdumphost=$(echo "$kdumphost" | head -n 1 | awk '{print $2}') - kdumphost="${kdumphost%%/*}" - if [ -z "$kdumphost" ]; then - derror "wrong kdumpnic: $kdumpnic" - return 1 - fi - HOST_IP=$kdumphost + HOST_IP=$kdumpip fi return 0 } diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index c05666e..8b28141 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -210,26 +210,6 @@ kdump_get_perm_addr() { fi }
-# Prefix kernel assigned names with "kdump-". EX: eth0 -> kdump-eth0 -# Because kernel assigned names are not persistent between 1st and 2nd -# kernel. We could probably end up with eth0 being eth1, eth0 being -# eth1, and naming conflict happens. -kdump_setup_ifname() { - local _ifname - - # If ifname already has 'kdump-' prefix, we must be switching from - # fadump to kdump. Skip prefixing 'kdump-' in this case as adding - # another prefix may truncate the ifname. Since an ifname with - # 'kdump-' is already persistent, this should be fine. - if [[ $1 =~ eth* ]] && [[ ! $1 =~ ^kdump-* ]]; then - _ifname="kdump-$1" - else - _ifname="$1" - fi - - echo "$_ifname" -} - kdump_copy_nmconnection_file() { local _dev _nmconnection_file_path _nmconnection_name _initrd_nmconnection_file_path local _cloned_nmconnection_file_path _uniq_name _old_uuid _old_name _uuid _per_mac @@ -264,6 +244,8 @@ kdump_copy_nmconnection_file() { _per_mac=$(kdump_get_perm_addr "$_dev") if [[ "$_per_mac" != 'not set' ]]; then echo -n "except:mac:$_per_mac," >> "/tmp/$$-netif_allowlist" + # Ask NM to not match a connection profile based on interface-name + sed -i -E "s/^interface-name=.*$//g" "${initdir}/$_initrd_nmconnection_file_path" else echo -n "except:interface-name:$_dev," >> "/tmp/$$-netif_allowlist" fi @@ -428,7 +410,7 @@ kdump_get_remote_ip() { # initramfs accessing giving destination # $1: destination host kdump_install_net() { - local _destaddr _route _netdev _conpath kdumpnic + local _destaddr _route _netdev _conpath _kdumpip local _znet_netdev _znet_conpath # each netowrk interface is managed by a NM connection profile declare -A nmconnection_map @@ -441,9 +423,16 @@ kdump_install_net() { _route=$(kdump_get_ip_route "$_destaddr") _netdev=$(kdump_get_ip_route_field "$_route" "dev") _conpath=$(get_nmcli_connection_apath_by_ifname "$_netdev") - kdumpnic=$(kdump_setup_ifname "$_netdev")
+ if ! _kdumpip=$(ip addr show dev "$_netdev" | grep '[ ]*inet'); then + derror "Failed to get IP of $_netdev" + return 1 + fi + + _kdumpip=$(echo "$_kdumpip" | head -n 1 | awk '{print $2}') + _kdumpip="${_kdumpip%%/*}" _znet_netdev=$(find_online_znet_device) + if [[ -n $_znet_netdev ]]; then _znet_conpath=$(get_nmcli_connection_apath_by_ifname "$_znet_netdev") if ! (kdump_setup_znet "$_znet_netdev" "$_znet_conpath"); then @@ -463,6 +452,7 @@ kdump_install_net() { elif kdump_is_vlan "$_netdev"; then kdump_setup_vlan "$_netdev" fi + kdump_copy_nmconnection_file "$_netdev" kdump_install_nm_netif_allowlist
@@ -483,8 +473,8 @@ kdump_install_net() { # the default gate way for network dump, eth1 in the fence kdump path will # call kdump_install_net again and we don't want eth1 to be the default # gateway. - if [[ ! -f ${initdir}/etc/cmdline.d/60kdumpnic.conf ]]; then - echo "kdumpnic=$kdumpnic" > "${initdir}/etc/cmdline.d/60kdumpnic.conf" + if [[ ! -f ${initdir}/etc/cmdline.d/60kdumpip.conf ]]; then + echo "kdumpip=$_kdumpip" > "${initdir}/etc/cmdline.d/60kdumpip.conf" fi }
Coiby Xu coxu@redhat.com 于2022年4月2日周六 11:25写道:
A NIC may get a different name in the kdump kernel from 1st kernel in cases like,
- kernel assigned network interface names are not persistent e.g. [1]
- there is an udev rule to rename the NIC in the 1st kernel but the kdump initrd may not have that rule e.g. [2]
If NM tries to match a NIC with a connection profile based on NIC name i.e. connection.interface-name, it will fail the above bases. So we should remove the line connection.interface-name=XX from the connection file. With this line deleted, multiple NICs may be matched by a connection profile but we don't need to worry about a wrong NIC is brought up by NM since we have explicitly asked NM to only bring up the NICs needed by kdump via /etc/NetworkManager/conf.d/10-kdump-netif.conf. Note we don't need to do this for user created NIC like vlan, bridge and bond.
An remaining issue is passing the name of a NIC via the kdumpnic dracut command line parameter which requires passing ifname=<interface>:<MAC> to have fixed NIC name. But we can simply drop this requirement. kdumpnic is needed because kdump needs to get the IP by NIC name and use the IP to created a dumping folder named "{IP}-{DATE}". We can simply pass the IP to the kdump kernel directly via a new dracut command line parameter kdumpip instead. In addition to the benefit of simplifying the code, there are other three benefits brought by this approach,
- make use of whatever network to transfer the vmcore. Because as long as we have the network to we don't care which NIC is active.
- if obtained IP in the kdump kernel is different from the one in the 1st kernel. "{IP}-{DATE}" would better tell where the dumped vmcore comes from.
- without passing ifname=<interface>:<MAC> to to kdump initrd, the issue of there are two interfaces with the same MAC address for Azure Hyper-V NIC SR-IOV [3] is resolved automatically.
[1] https://bugzilla.redhat.com/show_bug.cgi?id=1121778 [2] https://bugzilla.redhat.com/show_bug.cgi?id=810107 [3] https://bugzilla.redhat.com/show_bug.cgi?id=1962421
Signed-off-by: Coiby Xu coxu@redhat.com
dracut-kdump.sh | 18 ++++-------------- dracut-module-setup.sh | 38 ++++++++++++++------------------------ 2 files changed, 18 insertions(+), 38 deletions(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh index b69bc98..e27be61 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -475,22 +475,12 @@ save_vmcore_dmesg_ssh() get_host_ip() { if is_nfs_dump_target || is_ssh_dump_target; then
kdumpnic=$(getarg kdumpnic=)
if [ -z "$kdumpnic" ]; then
derror "failed to get kdumpnic!"
kdumpip=$(getarg kdumpip=)
if [ -z "$kdumpip" ]; then
derror "failed to get kdumpip!" return 1 fi
if ! kdumphost=$(ip addr show dev "$kdumpnic" | grep '[ ]*inet'); then
derror "wrong kdumpnic: $kdumpnic"
return 1
fi
kdumphost=$(echo "$kdumphost" | head -n 1 | awk '{print $2}')
kdumphost="${kdumphost%%/*}"
if [ -z "$kdumphost" ]; then
derror "wrong kdumpnic: $kdumpnic"
return 1
fi
HOST_IP=$kdumphost
HOST_IP=$kdumpip fi return 0
} diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index c05666e..8b28141 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -210,26 +210,6 @@ kdump_get_perm_addr() { fi }
-# Prefix kernel assigned names with "kdump-". EX: eth0 -> kdump-eth0 -# Because kernel assigned names are not persistent between 1st and 2nd -# kernel. We could probably end up with eth0 being eth1, eth0 being -# eth1, and naming conflict happens. -kdump_setup_ifname() {
- local _ifname
- # If ifname already has 'kdump-' prefix, we must be switching from
- # fadump to kdump. Skip prefixing 'kdump-' in this case as adding
- # another prefix may truncate the ifname. Since an ifname with
- # 'kdump-' is already persistent, this should be fine.
- if [[ $1 =~ eth* ]] && [[ ! $1 =~ ^kdump-* ]]; then
_ifname="kdump-$1"
- else
_ifname="$1"
- fi
- echo "$_ifname"
-}
kdump_copy_nmconnection_file() { local _dev _nmconnection_file_path _nmconnection_name _initrd_nmconnection_file_path local _cloned_nmconnection_file_path _uniq_name _old_uuid _old_name _uuid _per_mac @@ -264,6 +244,8 @@ kdump_copy_nmconnection_file() { _per_mac=$(kdump_get_perm_addr "$_dev") if [[ "$_per_mac" != 'not set' ]]; then echo -n "except:mac:$_per_mac," >> "/tmp/$$-netif_allowlist"
# Ask NM to not match a connection profile based on interface-name
else echo -n "except:interface-name:$_dev," >> "/tmp/$$-netif_allowlist" fised -i -E "s/^interface-name=.*$//g" "${initdir}/$_initrd_nmconnection_file_path"
@@ -428,7 +410,7 @@ kdump_get_remote_ip() { # initramfs accessing giving destination # $1: destination host kdump_install_net() {
- local _destaddr _route _netdev _conpath kdumpnic
- local _destaddr _route _netdev _conpath _kdumpip local _znet_netdev _znet_conpath # each netowrk interface is managed by a NM connection profile declare -A nmconnection_map
@@ -441,9 +423,16 @@ kdump_install_net() { _route=$(kdump_get_ip_route "$_destaddr") _netdev=$(kdump_get_ip_route_field "$_route" "dev") _conpath=$(get_nmcli_connection_apath_by_ifname "$_netdev")
- kdumpnic=$(kdump_setup_ifname "$_netdev")
- if ! _kdumpip=$(ip addr show dev "$_netdev" | grep '[ ]*inet'); then
derror "Failed to get IP of $_netdev"
return 1
- fi
- _kdumpip=$(echo "$_kdumpip" | head -n 1 | awk '{print $2}')
- _kdumpip="${_kdumpip%%/*}" _znet_netdev=$(find_online_znet_device)
- if [[ -n $_znet_netdev ]]; then _znet_conpath=$(get_nmcli_connection_apath_by_ifname "$_znet_netdev") if ! (kdump_setup_znet "$_znet_netdev" "$_znet_conpath"); then
@@ -463,6 +452,7 @@ kdump_install_net() { elif kdump_is_vlan "$_netdev"; then kdump_setup_vlan "$_netdev" fi
- kdump_copy_nmconnection_file "$_netdev" kdump_install_nm_netif_allowlist
@@ -483,8 +473,8 @@ kdump_install_net() { # the default gate way for network dump, eth1 in the fence kdump path will # call kdump_install_net again and we don't want eth1 to be the default # gateway.
- if [[ ! -f ${initdir}/etc/cmdline.d/60kdumpnic.conf ]]; then
echo "kdumpnic=$kdumpnic" > "${initdir}/etc/cmdline.d/60kdumpnic.conf"
- if [[ ! -f ${initdir}/etc/cmdline.d/60kdumpip.conf ]]; then
fiecho "kdumpip=$_kdumpip" > "${initdir}/etc/cmdline.d/60kdumpip.conf"
}
-- 2.34.1
Great idea!
Just one concern, could there be any wired DHCP corner case? Like if the kdump kernel took a longer time to boot, eg. 5 min, and then your DHCP IP just expired during that time window, the kdump kernel will be using an expired IP and conflict with other machines. The minimal lease time of DHCP address is 1 hr, could be a rare corner case, but in-theory possible.
kexec mailing list -- kexec@lists.fedoraproject.org To unsubscribe send an email to kexec-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
On Sat, Apr 23, 2022 at 10:47:57PM +0800, Kairui Song wrote:
Coiby Xu coxu@redhat.com 于2022年4月2日周六 11:25写道:
A NIC may get a different name in the kdump kernel from 1st kernel in cases like,
- kernel assigned network interface names are not persistent e.g. [1]
- there is an udev rule to rename the NIC in the 1st kernel but the kdump initrd may not have that rule e.g. [2]
If NM tries to match a NIC with a connection profile based on NIC name i.e. connection.interface-name, it will fail the above bases. So we should remove the line connection.interface-name=XX from the connection file. With this line deleted, multiple NICs may be matched by a connection profile but we don't need to worry about a wrong NIC is brought up by NM since we have explicitly asked NM to only bring up the NICs needed by kdump via /etc/NetworkManager/conf.d/10-kdump-netif.conf. Note we don't need to do this for user created NIC like vlan, bridge and bond.
An remaining issue is passing the name of a NIC via the kdumpnic dracut command line parameter which requires passing ifname=<interface>:<MAC> to have fixed NIC name. But we can simply drop this requirement. kdumpnic is needed because kdump needs to get the IP by NIC name and use the IP to created a dumping folder named "{IP}-{DATE}". We can simply pass the IP to the kdump kernel directly via a new dracut command line parameter kdumpip instead. In addition to the benefit of simplifying the code, there are other three benefits brought by this approach,
- make use of whatever network to transfer the vmcore. Because as long as we have the network to we don't care which NIC is active.
- if obtained IP in the kdump kernel is different from the one in the 1st kernel. "{IP}-{DATE}" would better tell where the dumped vmcore comes from.
- without passing ifname=<interface>:<MAC> to to kdump initrd, the issue of there are two interfaces with the same MAC address for Azure Hyper-V NIC SR-IOV [3] is resolved automatically.
[1] https://bugzilla.redhat.com/show_bug.cgi?id=1121778 [2] https://bugzilla.redhat.com/show_bug.cgi?id=810107 [3] https://bugzilla.redhat.com/show_bug.cgi?id=1962421
Signed-off-by: Coiby Xu coxu@redhat.com
dracut-kdump.sh | 18 ++++-------------- dracut-module-setup.sh | 38 ++++++++++++++------------------------ 2 files changed, 18 insertions(+), 38 deletions(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh index b69bc98..e27be61 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -475,22 +475,12 @@ save_vmcore_dmesg_ssh() get_host_ip() { if is_nfs_dump_target || is_ssh_dump_target; then
kdumpnic=$(getarg kdumpnic=)
if [ -z "$kdumpnic" ]; then
derror "failed to get kdumpnic!"
kdumpip=$(getarg kdumpip=)
if [ -z "$kdumpip" ]; then
derror "failed to get kdumpip!" return 1 fi
if ! kdumphost=$(ip addr show dev "$kdumpnic" | grep '[ ]*inet'); then
derror "wrong kdumpnic: $kdumpnic"
return 1
fi
kdumphost=$(echo "$kdumphost" | head -n 1 | awk '{print $2}')
kdumphost="${kdumphost%%/*}"
if [ -z "$kdumphost" ]; then
derror "wrong kdumpnic: $kdumpnic"
return 1
fi
HOST_IP=$kdumphost
HOST_IP=$kdumpip fi return 0
} diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index c05666e..8b28141 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -210,26 +210,6 @@ kdump_get_perm_addr() { fi }
-# Prefix kernel assigned names with "kdump-". EX: eth0 -> kdump-eth0 -# Because kernel assigned names are not persistent between 1st and 2nd -# kernel. We could probably end up with eth0 being eth1, eth0 being -# eth1, and naming conflict happens. -kdump_setup_ifname() {
- local _ifname
- # If ifname already has 'kdump-' prefix, we must be switching from
- # fadump to kdump. Skip prefixing 'kdump-' in this case as adding
- # another prefix may truncate the ifname. Since an ifname with
- # 'kdump-' is already persistent, this should be fine.
- if [[ $1 =~ eth* ]] && [[ ! $1 =~ ^kdump-* ]]; then
_ifname="kdump-$1"
- else
_ifname="$1"
- fi
- echo "$_ifname"
-}
kdump_copy_nmconnection_file() { local _dev _nmconnection_file_path _nmconnection_name _initrd_nmconnection_file_path local _cloned_nmconnection_file_path _uniq_name _old_uuid _old_name _uuid _per_mac @@ -264,6 +244,8 @@ kdump_copy_nmconnection_file() { _per_mac=$(kdump_get_perm_addr "$_dev") if [[ "$_per_mac" != 'not set' ]]; then echo -n "except:mac:$_per_mac," >> "/tmp/$$-netif_allowlist"
# Ask NM to not match a connection profile based on interface-name
else echo -n "except:interface-name:$_dev," >> "/tmp/$$-netif_allowlist" fised -i -E "s/^interface-name=.*$//g" "${initdir}/$_initrd_nmconnection_file_path"
@@ -428,7 +410,7 @@ kdump_get_remote_ip() { # initramfs accessing giving destination # $1: destination host kdump_install_net() {
- local _destaddr _route _netdev _conpath kdumpnic
- local _destaddr _route _netdev _conpath _kdumpip local _znet_netdev _znet_conpath # each netowrk interface is managed by a NM connection profile declare -A nmconnection_map
@@ -441,9 +423,16 @@ kdump_install_net() { _route=$(kdump_get_ip_route "$_destaddr") _netdev=$(kdump_get_ip_route_field "$_route" "dev") _conpath=$(get_nmcli_connection_apath_by_ifname "$_netdev")
- kdumpnic=$(kdump_setup_ifname "$_netdev")
- if ! _kdumpip=$(ip addr show dev "$_netdev" | grep '[ ]*inet'); then
derror "Failed to get IP of $_netdev"
return 1
- fi
- _kdumpip=$(echo "$_kdumpip" | head -n 1 | awk '{print $2}')
- _kdumpip="${_kdumpip%%/*}" _znet_netdev=$(find_online_znet_device)
- if [[ -n $_znet_netdev ]]; then _znet_conpath=$(get_nmcli_connection_apath_by_ifname "$_znet_netdev") if ! (kdump_setup_znet "$_znet_netdev" "$_znet_conpath"); then
@@ -463,6 +452,7 @@ kdump_install_net() { elif kdump_is_vlan "$_netdev"; then kdump_setup_vlan "$_netdev" fi
- kdump_copy_nmconnection_file "$_netdev" kdump_install_nm_netif_allowlist
@@ -483,8 +473,8 @@ kdump_install_net() { # the default gate way for network dump, eth1 in the fence kdump path will # call kdump_install_net again and we don't want eth1 to be the default # gateway.
- if [[ ! -f ${initdir}/etc/cmdline.d/60kdumpnic.conf ]]; then
echo "kdumpnic=$kdumpnic" > "${initdir}/etc/cmdline.d/60kdumpnic.conf"
- if [[ ! -f ${initdir}/etc/cmdline.d/60kdumpip.conf ]]; then
fiecho "kdumpip=$_kdumpip" > "${initdir}/etc/cmdline.d/60kdumpip.conf"
}
-- 2.34.1
Great idea!
Thanks!
Just one concern, could there be any wired DHCP corner case? Like if the kdump kernel took a longer time to boot, eg. 5 min, and then your DHCP IP just expired during that time window, the kdump kernel will be using an expired IP and conflict with other machines. The minimal lease time of DHCP address is 1 hr, could be a rare corner case, but in-theory possible.
It seems I don't fully understand you. In the kdump kernel, we still use DHCP to have a IP so there should be conflict. kdumpip is only used to create to a dumping folder named "{IP}-{DATE}" and we don't assign kdumpip to a NIC.
kexec mailing list -- kexec@lists.fedoraproject.org To unsubscribe send an email to kexec-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
Ok, thanks for the clarification.
Coiby Xu coxu@redhat.com 于 2022年4月25日周一 上午11:35写道:
On Sat, Apr 23, 2022 at 10:47:57PM +0800, Kairui Song wrote:
Coiby Xu coxu@redhat.com 于2022年4月2日周六 11:25写道:
A NIC may get a different name in the kdump kernel from 1st kernel in cases like,
- kernel assigned network interface names are not persistent e.g. [1]
- there is an udev rule to rename the NIC in the 1st kernel but the kdump initrd may not have that rule e.g. [2]
If NM tries to match a NIC with a connection profile based on NIC name i.e. connection.interface-name, it will fail the above bases. So we should remove the line connection.interface-name=XX from the connection file. With this line deleted, multiple NICs may be matched by a connection profile but we don't need to worry about a wrong NIC is brought up by NM since we have explicitly asked NM to only bring up the NICs needed by kdump via /etc/NetworkManager/conf.d/10-kdump-netif.conf. Note we don't need to do this for user created NIC like vlan, bridge and bond.
An remaining issue is passing the name of a NIC via the kdumpnic dracut command line parameter which requires passing ifname=<interface>:<MAC> to have fixed NIC name. But we can simply drop this requirement. kdumpnic is needed because kdump needs to get the IP by NIC name and use the IP to created a dumping folder named "{IP}-{DATE}". We can simply pass the IP to the kdump kernel directly via a new dracut command line parameter kdumpip instead. In addition to the benefit of simplifying the code, there are other three benefits brought by this approach,
- make use of whatever network to transfer the vmcore. Because as long as we have the network to we don't care which NIC is active.
- if obtained IP in the kdump kernel is different from the one in the 1st kernel. "{IP}-{DATE}" would better tell where the dumped vmcore comes from.
- without passing ifname=<interface>:<MAC> to to kdump initrd, the issue of there are two interfaces with the same MAC address for Azure Hyper-V NIC SR-IOV [3] is resolved automatically.
[1] https://bugzilla.redhat.com/show_bug.cgi?id=1121778 [2] https://bugzilla.redhat.com/show_bug.cgi?id=810107 [3] https://bugzilla.redhat.com/show_bug.cgi?id=1962421
Signed-off-by: Coiby Xu coxu@redhat.com
dracut-kdump.sh | 18 ++++-------------- dracut-module-setup.sh | 38 ++++++++++++++------------------------ 2 files changed, 18 insertions(+), 38 deletions(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh index b69bc98..e27be61 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -475,22 +475,12 @@ save_vmcore_dmesg_ssh() get_host_ip() { if is_nfs_dump_target || is_ssh_dump_target; then
kdumpnic=$(getarg kdumpnic=)
if [ -z "$kdumpnic" ]; then
derror "failed to get kdumpnic!"
kdumpip=$(getarg kdumpip=)
if [ -z "$kdumpip" ]; then
derror "failed to get kdumpip!" return 1 fi
if ! kdumphost=$(ip addr show dev "$kdumpnic" | grep '[ ]*inet'); then
derror "wrong kdumpnic: $kdumpnic"
return 1
fi
kdumphost=$(echo "$kdumphost" | head -n 1 | awk '{print $2}')
kdumphost="${kdumphost%%/*}"
if [ -z "$kdumphost" ]; then
derror "wrong kdumpnic: $kdumpnic"
return 1
fi
HOST_IP=$kdumphost
HOST_IP=$kdumpip fi return 0
} diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index c05666e..8b28141 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -210,26 +210,6 @@ kdump_get_perm_addr() { fi }
-# Prefix kernel assigned names with "kdump-". EX: eth0 -> kdump-eth0 -# Because kernel assigned names are not persistent between 1st and 2nd -# kernel. We could probably end up with eth0 being eth1, eth0 being -# eth1, and naming conflict happens. -kdump_setup_ifname() {
- local _ifname
- # If ifname already has 'kdump-' prefix, we must be switching from
- # fadump to kdump. Skip prefixing 'kdump-' in this case as adding
- # another prefix may truncate the ifname. Since an ifname with
- # 'kdump-' is already persistent, this should be fine.
- if [[ $1 =~ eth* ]] && [[ ! $1 =~ ^kdump-* ]]; then
_ifname="kdump-$1"
- else
_ifname="$1"
- fi
- echo "$_ifname"
-}
kdump_copy_nmconnection_file() { local _dev _nmconnection_file_path _nmconnection_name _initrd_nmconnection_file_path local _cloned_nmconnection_file_path _uniq_name _old_uuid _old_name _uuid _per_mac @@ -264,6 +244,8 @@ kdump_copy_nmconnection_file() { _per_mac=$(kdump_get_perm_addr "$_dev") if [[ "$_per_mac" != 'not set' ]]; then echo -n "except:mac:$_per_mac," >> "/tmp/$$-netif_allowlist"
# Ask NM to not match a connection profile based on interface-name
else echo -n "except:interface-name:$_dev," >> "/tmp/$$-netif_allowlist" fised -i -E "s/^interface-name=.*$//g" "${initdir}/$_initrd_nmconnection_file_path"
@@ -428,7 +410,7 @@ kdump_get_remote_ip() { # initramfs accessing giving destination # $1: destination host kdump_install_net() {
- local _destaddr _route _netdev _conpath kdumpnic
- local _destaddr _route _netdev _conpath _kdumpip local _znet_netdev _znet_conpath # each netowrk interface is managed by a NM connection profile declare -A nmconnection_map
@@ -441,9 +423,16 @@ kdump_install_net() { _route=$(kdump_get_ip_route "$_destaddr") _netdev=$(kdump_get_ip_route_field "$_route" "dev") _conpath=$(get_nmcli_connection_apath_by_ifname "$_netdev")
- kdumpnic=$(kdump_setup_ifname "$_netdev")
- if ! _kdumpip=$(ip addr show dev "$_netdev" | grep '[ ]*inet'); then
derror "Failed to get IP of $_netdev"
return 1
- fi
- _kdumpip=$(echo "$_kdumpip" | head -n 1 | awk '{print $2}')
- _kdumpip="${_kdumpip%%/*}" _znet_netdev=$(find_online_znet_device)
- if [[ -n $_znet_netdev ]]; then _znet_conpath=$(get_nmcli_connection_apath_by_ifname "$_znet_netdev") if ! (kdump_setup_znet "$_znet_netdev" "$_znet_conpath"); then
@@ -463,6 +452,7 @@ kdump_install_net() { elif kdump_is_vlan "$_netdev"; then kdump_setup_vlan "$_netdev" fi
- kdump_copy_nmconnection_file "$_netdev" kdump_install_nm_netif_allowlist
@@ -483,8 +473,8 @@ kdump_install_net() { # the default gate way for network dump, eth1 in the fence kdump path will # call kdump_install_net again and we don't want eth1 to be the default # gateway.
- if [[ ! -f ${initdir}/etc/cmdline.d/60kdumpnic.conf ]]; then
echo "kdumpnic=$kdumpnic" > "${initdir}/etc/cmdline.d/60kdumpnic.conf"
- if [[ ! -f ${initdir}/etc/cmdline.d/60kdumpip.conf ]]; then
fiecho "kdumpip=$_kdumpip" > "${initdir}/etc/cmdline.d/60kdumpip.conf"
}
-- 2.34.1
Great idea!
Thanks!
Just one concern, could there be any wired DHCP corner case? Like if the kdump kernel took a longer time to boot, eg. 5 min, and then your DHCP IP just expired during that time window, the kdump kernel will be using an expired IP and conflict with other machines. The minimal lease time of DHCP address is 1 hr, could be a rare corner case, but in-theory possible.
It seems I don't fully understand you. In the kdump kernel, we still use DHCP to have a IP so there should be conflict. kdumpip is only used to create to a dumping folder named "{IP}-{DATE}" and we don't assign kdumpip to a NIC.
Oh, yes, you are right, I didn't read the patch carefully enough. Since kdumpip is only used to create the dump dir, then this is fine.
Now I'm a bit concerned that kdumpip being embedded inside the initramfs. kdumpip could be dynamic, but the initramfs isn't. This is probably okay? since it's only used to naming the dump dir...
IIUC, now the dump dir's ip prefix could be out-of-sync with the actual IP address of the machine when the dump happens, and will be in out-of-sync status for a long time until the initramfs get rebuilt. Just not sure if this will confuse anyone...
List Archives: https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
-- Best regards, Coiby
On Mon, Apr 25, 2022 at 04:55:03PM +0800, Kairui Song wrote:
Ok, thanks for the clarification.
You are welcome!
[...]
Just one concern, could there be any wired DHCP corner case? Like if the kdump kernel took a longer time to boot, eg. 5 min, and then your DHCP IP just expired during that time window, the kdump kernel will be using an expired IP and conflict with other machines. The minimal lease time of DHCP address is 1 hr, could be a rare corner case, but in-theory possible.
It seems I don't fully understand you. In the kdump kernel, we still use DHCP to have a IP so there should be conflict. kdumpip is only used to create to a dumping folder named "{IP}-{DATE}" and we don't assign kdumpip to a NIC.
Oh, yes, you are right, I didn't read the patch carefully enough. Since kdumpip is only used to create the dump dir, then this is fine.
Now I'm a bit concerned that kdumpip being embedded inside the initramfs. kdumpip could be dynamic, but the initramfs isn't. This is probably okay? since it's only used to naming the dump dir...
IIUC, now the dump dir's ip prefix could be out-of-sync with the actual IP address of the machine when the dump happens, and will be in out-of-sync status for a long time until the initramfs get rebuilt. Just not sure if this will confuse anyone...
Thanks for coming up with this scenario! I thought in the case where we have a different IP in the kdump kernel, the original IP of the 1st kernel can better tell us where the dump happens. But I haven't took the above scenario into consideration. How about we using FAQN i.e. `hostname --fqdn` and the date to name the dumping folder instead?
Coiby Xu coxu@redhat.com 于2022年4月25日周一 17:35写道:
On Mon, Apr 25, 2022 at 04:55:03PM +0800, Kairui Song wrote:
Ok, thanks for the clarification.
You are welcome!
[...]
Just one concern, could there be any wired DHCP corner case? Like if the kdump kernel took a longer time to boot, eg. 5 min, and then your DHCP IP just expired during that time window, the kdump kernel will be using an expired IP and conflict with other machines. The minimal lease time of DHCP address is 1 hr, could be a rare corner case, but in-theory possible.
It seems I don't fully understand you. In the kdump kernel, we still use DHCP to have a IP so there should be conflict. kdumpip is only used to create to a dumping folder named "{IP}-{DATE}" and we don't assign kdumpip to a NIC.
Oh, yes, you are right, I didn't read the patch carefully enough. Since kdumpip is only used to create the dump dir, then this is fine.
Now I'm a bit concerned that kdumpip being embedded inside the initramfs. kdumpip could be dynamic, but the initramfs isn't. This is probably okay? since it's only used to naming the dump dir...
IIUC, now the dump dir's ip prefix could be out-of-sync with the actual IP address of the machine when the dump happens, and will be in out-of-sync status for a long time until the initramfs get rebuilt. Just not sure if this will confuse anyone...
Thanks for coming up with this scenario! I thought in the case where we have a different IP in the kdump kernel, the original IP of the 1st kernel can better tell us where the dump happens. But I haven't took the above scenario into consideration. How about we using FAQN i.e. `hostname --fqdn` and the date to name the dumping folder instead?
Looks like a solution, just one thing I'm not sure, is `hostname --fqdn` unique enough? If a lot of VMs are installed using the same VM image (very common in many cloud environment), and the VM image all have a fixed hostname, all dump dirs could have the same prefix...
-- Best regards, Coiby
On Tue, Apr 26, 2022 at 05:39:46PM +0800, Kairui Song wrote:
Coiby Xu coxu@redhat.com 于2022年4月25日周一 17:35写道:
On Mon, Apr 25, 2022 at 04:55:03PM +0800, Kairui Song wrote:
Ok, thanks for the clarification.
You are welcome!
[...]
Just one concern, could there be any wired DHCP corner case? Like if the kdump kernel took a longer time to boot, eg. 5 min, and then your DHCP IP just expired during that time window, the kdump kernel will be using an expired IP and conflict with other machines. The minimal lease time of DHCP address is 1 hr, could be a rare corner case, but in-theory possible.
It seems I don't fully understand you. In the kdump kernel, we still use DHCP to have a IP so there should be conflict. kdumpip is only used to create to a dumping folder named "{IP}-{DATE}" and we don't assign kdumpip to a NIC.
Oh, yes, you are right, I didn't read the patch carefully enough. Since kdumpip is only used to create the dump dir, then this is fine.
Now I'm a bit concerned that kdumpip being embedded inside the initramfs. kdumpip could be dynamic, but the initramfs isn't. This is probably okay? since it's only used to naming the dump dir...
IIUC, now the dump dir's ip prefix could be out-of-sync with the actual IP address of the machine when the dump happens, and will be in out-of-sync status for a long time until the initramfs get rebuilt. Just not sure if this will confuse anyone...
Thanks for coming up with this scenario! I thought in the case where we have a different IP in the kdump kernel, the original IP of the 1st kernel can better tell us where the dump happens. But I haven't took the above scenario into consideration. How about we using FAQN i.e. `hostname --fqdn` and the date to name the dumping folder instead?
Looks like a solution, just one thing I'm not sure, is `hostname --fqdn` unique enough? If a lot of VMs are installed using the same VM image (very common in many cloud environment), and the VM image all have a fixed hostname, all dump dirs could have the same prefix...
Thanks for raising this concern! In v1, kdump now tries to get {IP} after booting the kdump initrd.
-- Best regards, Coiby
/usr/lib/udev/ccw_init [1] shipped by s390utils extracts the values of SUBCHANNELS, NETTYPE and LAYER2 from /etc/sysconfig/network-scripts/ifcfg-* or /etc/NetworkManager/system-connections/*.nmconnection to activate znet network device. If the connection profile is copied to initrd, there is no need to set up the "rd.znet" dracut cmdline parameter.
There are two cases addressed by this commit, 1. znet network interface is a slave of bonding/teaming/vlan/bridging network. The connection profile has been copied to initrd by kdump_copy_nmconnection_file and it contains the info needed by ccw_init. 2. znet network interface is a slave of bonding/teaming/vlan/bridging network. The corresponding ifcfg-*/*.nmconnection file may not contain info like SUBCHANNELS [2]. In this case, copy the ifcfg-*/*.nmconnection file that has this info to the kdump initrd. Also to prevent the copied connection profile from being chosen by NM, set connection.autoconnect=false for this connection profile.
Note 1. ccw_init doesn't care if SUBCHANNELS, NETTYPE and LAYER2 comes from an active NM profile or not. If an inactive NM profile contains this info, it needs to be copied to the kdump initrd as well. 2. "rd.znet_ifname=$_netdev:${SUBCHANNELS}" is no needed because now there is no renaming of s390x network interfaces when reusing NetworkManager profiles. rd.znet_ifname was introduced in commit ce0305d ("Add a new option 'rd.znet_ifname' in order to use it in udev rules") to address the special case of non-persistent MAC address by renaming a network interface by SUBCHANNELS.
[1] https://src.fedoraproject.org/rpms/s390utils/blob/rawhide/f/ccw_init [2] https://bugzilla.redhat.com/show_bug.cgi?id=2064708
Signed-off-by: Coiby Xu coxu@redhat.com --- dracut-module-setup.sh | 72 ++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 35 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 8b28141..712e5af 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -350,34 +350,46 @@ find_online_znet_device() { echo -n "$ifname" }
-# setup s390 znet cmdline -# $1: netdev (ifname) -# $2: nmcli connection path +_find_znet_nmconnection() { + LANG=C grep -E -i -l \ + "^s390-subchannels=([0-9].[0-9].[a-f0-9]+;){0,2}" \ + "$1/*.nmconnection" | LC_ALL=C sed -e "$2" +} + +# setup s390 znet +# +# Note part of code is extracted from ccw_init provided by s390utils kdump_setup_znet() { - local _netdev="$1" - local _conpath="$2" - local s390_prefix="802-3-ethernet.s390-" - local _options="" - local NETTYPE - local SUBCHANNELS - - NETTYPE=$(get_nmcli_field_by_conpath "${s390_prefix}nettype" "$_conpath") - SUBCHANNELS=$(get_nmcli_field_by_conpath "${s390_prefix}subchannels" "$_conpath") - _options=$(get_nmcli_field_by_conpath "${s390_prefix}options" "$_conpath") - - if [[ -z $NETTYPE || -z $SUBCHANNELS || -z $_options ]]; then - dwarning "Failed to get znet configuration via nmlci output. Now try sourcing ifcfg script." - source_ifcfg_file "$_netdev" - for i in $OPTIONS; do - _options=${_options},$i - done + local _config_file _uniq_name _NM_conf_dir + local __sed_discard_ignored_files='/(~|.bak|.old|.orig|.rpmnew|.rpmorig|.rpmsave)$/d' + + _NM_conf_dir="/etc/NetworkManager/system-connections" + + _config_file=$(_find_znet_nmconnection "$initdir/$_NM_conf_dir" "$__sed_discard_ignored_files") + if [[ -n "$_config_file" ]]; then + ddebug "$_config_file has already contained the znet config" + return fi
- if [[ -z $NETTYPE || -z $SUBCHANNELS || -z $_options ]]; then - exit 1 + _config_file=$(LANG=C grep -E -i -l \ + "^[[:space:]]*SUBCHANNELS=['"]?([0-9].[0-9].[a-f0-9]+,){0,2}" \ + /etc/sysconfig/network-scripts/ifcfg-* \ + | LC_ALL=C sed -e "$__sed_discard_ignored_files") + + if [[ -n "$_config_file" ]]; then + LANG=c grep 'SUBCHANNELS|NETTYPE|OPTIONS' "$_config_file" > "$initdir/$_config_file" + else + _config_file=$(_find_znet_nmconnection "$_NM_conf_dir" "$__sed_discard_ignored_files") + fi + + if [[ -n "$_config_file" ]]; then + _uniq_name=$(cat /proc/sys/kernel/random/uuid) + nmcli connection clone --temporary "$_config_file" "$_uniq_name" + nmcli connection modify --temporary "$_uniq_name" connection.autoconnect false + inst "/run/NetworkManager/system-connections/${_uniq_name}.nmconnection" "${_NM_conf_dir}/${_uniq_name}.nmconnection" + nmcli connection del "$_uniq_name" fi
- echo "rd.znet=${NETTYPE},${SUBCHANNELS},${_options} rd.znet_ifname=$_netdev:${SUBCHANNELS}" > "${initdir}/etc/cmdline.d/30znet.conf" }
kdump_get_ip_route() { @@ -410,8 +422,7 @@ kdump_get_remote_ip() { # initramfs accessing giving destination # $1: destination host kdump_install_net() { - local _destaddr _route _netdev _conpath _kdumpip - local _znet_netdev _znet_conpath + local _destaddr _route _netdev _kdumpip # each netowrk interface is managed by a NM connection profile declare -A nmconnection_map
@@ -422,7 +433,6 @@ kdump_install_net() { _destaddr=$(kdump_get_remote_ip "$1") _route=$(kdump_get_ip_route "$_destaddr") _netdev=$(kdump_get_ip_route_field "$_route" "dev") - _conpath=$(get_nmcli_connection_apath_by_ifname "$_netdev")
if ! _kdumpip=$(ip addr show dev "$_netdev" | grep '[ ]*inet'); then derror "Failed to get IP of $_netdev" @@ -431,15 +441,6 @@ kdump_install_net() {
_kdumpip=$(echo "$_kdumpip" | head -n 1 | awk '{print $2}') _kdumpip="${_kdumpip%%/*}" - _znet_netdev=$(find_online_znet_device) - - if [[ -n $_znet_netdev ]]; then - _znet_conpath=$(get_nmcli_connection_apath_by_ifname "$_znet_netdev") - if ! (kdump_setup_znet "$_znet_netdev" "$_znet_conpath"); then - derror "Failed to set up znet" - exit 1 - fi - fi
echo -n > "/tmp/$$-netif_allowlist"
@@ -454,6 +455,7 @@ kdump_install_net() { fi
kdump_copy_nmconnection_file "$_netdev" + [[ -n "$(find_online_znet_device)" ]] && kdump_setup_znet kdump_install_nm_netif_allowlist
if [[ ! -f ${initdir}/etc/cmdline.d/50neednet.conf ]]; then
Hi Coiby,
I'm no networking expert so I cannot help much on this part. But all in all this series looks like a good improvement. Anyway, a first round with some small comments for minor improvements, though.
Thanks Philipp
On Sat, 2 Apr 2022 11:23:44 +0800 Coiby Xu coxu@redhat.com wrote:
Currently, kexec-tools parses legacy ifcfg-* configuration files or NetworkManager .nmconnection connection profiles to build up dracut command line parameters like ip=. Then dracut parses these parameters and runs nm-initrd-generator to generate NetworkManager connection profiles. Taking a bonding network as an example, nm-initrd-generator generates two connections as follows, $ /usr/libexec/nm-initrd-generator -s -- bootdev=mybond0 rd.neednet kdumpnic=mybond0 bond=mybond0:kdump-eth0
*** Connection 'mybond0' ***
[connection] id=mybond0 uuid=ed87d02b-dd44-4f0e-8b11-37db7e89bb48 type=bond autoconnect-retries=1 interface-name=mybond0 multi-connect=1 permissions=
[bond] mode=balance-rr
[ipv4] dhcp-timeout=90 dns-search= method=auto
[ipv6] addr-gen-mode=eui64 dhcp-timeout=90 dns-search= method=auto
[proxy]
*** Connection 'kdump-eth0' ***
[connection] id=kdump-eth0 uuid=ed6a7448-b5f8-4f8a-b718-3e24ea1c924b type=ethernet autoconnect-retries=1 interface-name=kdump-eth0 master=ed87d02b-dd44-4f0e-8b11-37db7e89bb48 multi-connect=1 permissions= slave-type=bond wait-device-timeout=60000
[ethernet] mac-address-blacklist=
Later dracut starts NetworkManager to activate these profiles to bring up the network connections. This way of seting up kdump network is tedious, error-prone and unncessary. A better way is to directly copy the needed connection profiles to initrd. A potential benefit of this approach for the users is they can simply edit the connection profile directly like changing ipv4.dhcp-timeout instead of being forced to use the hard-coded value enforced by nm-initrd-generator.
This patch set reuses NetworkManager connection profiles to set up kdump network. It also reduces the memory consumption of network drivers and fix other issues at the same time. Here are the bug list that addressed by this patch set on bugzilla,
- Bug 1962421 - [RHEL-9]"eth0: Failed to rename network interface 3 from 'eth0' to 'kdump-eth0': File exists"
- Bug 2064708 - kdump: mkdumprd: failed to make kdump initrd for bridge network on z15 z/vm
- bugs related to OOM caused by network driver
- Bug 1950282 - shutdown those unneeded network interfaces to save memory for kdump
- Bug 1958587 - the kdump initramfs includes unnecessary NIC drivers for SSH/NFS dumping target
- Bug 1890021 - be2net is using too much memory during kdump
- Bug 1662202 - [RHEL-8.1] aarch64: hpe-apache crashkernel OOM when dump to network targe
Coiby Xu (13): add function to copy NetworkManage connection profile to the initramfs support legacy ifcfg ask NM to wait the network device to be available don't let NetworkManager manage unneeded network interfaces stop dracut 35network-manager from running nm-initrd-generator set up kdump network bridge by directly copying NM connection profile to initrd set up kdump bonding network by directly copying NM connection profile to initrd fix error for vlan over team network interface set up kdump vlan network by directly copying NM connection profile to initrd set up kdump teaming network by directly copying NM connection profile to initrd clean up unneeded code after copying .nmconnection to initrd address the cases where a NIC has a different name in kdump kernel simplify setup_znet by copying connection profile to initrd
dracut-kdump.sh | 18 +- dracut-module-setup.sh | 385 ++++++++++++++--------------------------- 2 files changed, 133 insertions(+), 270 deletions(-)
Hi Philipp,
On Fri, Apr 22, 2022 at 05:30:43PM +0200, Philipp Rudo wrote:
Hi Coiby,
I'm no networking expert so I cannot help much on this part. But all in all this series looks like a good improvement. Anyway, a first round with some small comments for minor improvements, though.
Thanks for reviewing the patch set and suggesting various improvements!
Thanks Philipp
On Sat, 2 Apr 2022 11:23:44 +0800 Coiby Xu coxu@redhat.com wrote:
Currently, kexec-tools parses legacy ifcfg-* configuration files or NetworkManager .nmconnection connection profiles to build up dracut command line parameters like ip=. Then dracut parses these parameters and runs nm-initrd-generator to generate NetworkManager connection profiles. Taking a bonding network as an example, nm-initrd-generator generates two connections as follows, $ /usr/libexec/nm-initrd-generator -s -- bootdev=mybond0 rd.neednet kdumpnic=mybond0 bond=mybond0:kdump-eth0
*** Connection 'mybond0' ***
[connection] id=mybond0 uuid=ed87d02b-dd44-4f0e-8b11-37db7e89bb48 type=bond autoconnect-retries=1 interface-name=mybond0 multi-connect=1 permissions=
[bond] mode=balance-rr
[ipv4] dhcp-timeout=90 dns-search= method=auto
[ipv6] addr-gen-mode=eui64 dhcp-timeout=90 dns-search= method=auto
[proxy]
*** Connection 'kdump-eth0' ***
[connection] id=kdump-eth0 uuid=ed6a7448-b5f8-4f8a-b718-3e24ea1c924b type=ethernet autoconnect-retries=1 interface-name=kdump-eth0 master=ed87d02b-dd44-4f0e-8b11-37db7e89bb48 multi-connect=1 permissions= slave-type=bond wait-device-timeout=60000
[ethernet] mac-address-blacklist=
Later dracut starts NetworkManager to activate these profiles to bring up the network connections. This way of seting up kdump network is tedious, error-prone and unncessary. A better way is to directly copy the needed connection profiles to initrd. A potential benefit of this approach for the users is they can simply edit the connection profile directly like changing ipv4.dhcp-timeout instead of being forced to use the hard-coded value enforced by nm-initrd-generator.
This patch set reuses NetworkManager connection profiles to set up kdump network. It also reduces the memory consumption of network drivers and fix other issues at the same time. Here are the bug list that addressed by this patch set on bugzilla,
- Bug 1962421 - [RHEL-9]"eth0: Failed to rename network interface 3 from 'eth0' to 'kdump-eth0': File exists"
- Bug 2064708 - kdump: mkdumprd: failed to make kdump initrd for bridge network on z15 z/vm
- bugs related to OOM caused by network driver
- Bug 1950282 - shutdown those unneeded network interfaces to save memory for kdump
- Bug 1958587 - the kdump initramfs includes unnecessary NIC drivers for SSH/NFS dumping target
- Bug 1890021 - be2net is using too much memory during kdump
- Bug 1662202 - [RHEL-8.1] aarch64: hpe-apache crashkernel OOM when dump to network targe
Coiby Xu (13): add function to copy NetworkManage connection profile to the initramfs support legacy ifcfg ask NM to wait the network device to be available don't let NetworkManager manage unneeded network interfaces stop dracut 35network-manager from running nm-initrd-generator set up kdump network bridge by directly copying NM connection profile to initrd set up kdump bonding network by directly copying NM connection profile to initrd fix error for vlan over team network interface set up kdump vlan network by directly copying NM connection profile to initrd set up kdump teaming network by directly copying NM connection profile to initrd clean up unneeded code after copying .nmconnection to initrd address the cases where a NIC has a different name in kdump kernel simplify setup_znet by copying connection profile to initrd
dracut-kdump.sh | 18 +- dracut-module-setup.sh | 385 ++++++++++++++--------------------------- 2 files changed, 133 insertions(+), 270 deletions(-)
Coiby Xu coxu@redhat.com 于2022年4月2日周六 11:24写道:
Currently, kexec-tools parses legacy ifcfg-* configuration files or NetworkManager .nmconnection connection profiles to build up dracut command line parameters like ip=. Then dracut parses these parameters and runs nm-initrd-generator to generate NetworkManager connection profiles. Taking a bonding network as an example, nm-initrd-generator generates two connections as follows, $ /usr/libexec/nm-initrd-generator -s -- bootdev=mybond0 rd.neednet kdumpnic=mybond0 bond=mybond0:kdump-eth0
*** Connection 'mybond0' ***
[connection] id=mybond0 uuid=ed87d02b-dd44-4f0e-8b11-37db7e89bb48 type=bond autoconnect-retries=1 interface-name=mybond0 multi-connect=1 permissions=
[bond] mode=balance-rr
[ipv4] dhcp-timeout=90 dns-search= method=auto
[ipv6] addr-gen-mode=eui64 dhcp-timeout=90 dns-search= method=auto
[proxy]
*** Connection 'kdump-eth0' ***
[connection] id=kdump-eth0 uuid=ed6a7448-b5f8-4f8a-b718-3e24ea1c924b type=ethernet autoconnect-retries=1 interface-name=kdump-eth0 master=ed87d02b-dd44-4f0e-8b11-37db7e89bb48 multi-connect=1 permissions= slave-type=bond wait-device-timeout=60000
[ethernet] mac-address-blacklist=
Later dracut starts NetworkManager to activate these profiles to bring up the network connections. This way of seting up kdump network is tedious, error-prone and unncessary. A better way is to directly copy the needed connection profiles to initrd. A potential benefit of this approach for the users is they can simply edit the connection profile directly like changing ipv4.dhcp-timeout instead of being forced to use the hard-coded value enforced by nm-initrd-generator.
This patch set reuses NetworkManager connection profiles to set up kdump network. It also reduces the memory consumption of network drivers and fix other issues at the same time. Here are the bug list that addressed by this patch set on bugzilla,
- Bug 1962421 - [RHEL-9]"eth0: Failed to rename network interface 3 from 'eth0' to 'kdump-eth0': File exists"
- Bug 2064708 - kdump: mkdumprd: failed to make kdump initrd for bridge network on z15 z/vm - bugs related to OOM caused by network driver
Hi Coiby,
This looks great, but one thing I don't understand, how is this going to help reduce the memory consumption? Shoudn't network drivers be the same, no matter how they are loaded?
- Bug 1950282 - shutdown those unneeded network interfaces to save memory for kdump - Bug 1958587 - the kdump initramfs includes unnecessary NIC drivers for SSH/NFS dumping target - Bug 1890021 - be2net is using too much memory during kdump - Bug 1662202 - [RHEL-8.1] aarch64: hpe-apache crashkernel OOM when dump to network targe
Coiby Xu (13): add function to copy NetworkManage connection profile to the initramfs support legacy ifcfg ask NM to wait the network device to be available don't let NetworkManager manage unneeded network interfaces stop dracut 35network-manager from running nm-initrd-generator set up kdump network bridge by directly copying NM connection profile to initrd set up kdump bonding network by directly copying NM connection profile to initrd fix error for vlan over team network interface set up kdump vlan network by directly copying NM connection profile to initrd set up kdump teaming network by directly copying NM connection profile to initrd clean up unneeded code after copying .nmconnection to initrd address the cases where a NIC has a different name in kdump kernel simplify setup_znet by copying connection profile to initrd
dracut-kdump.sh | 18 +- dracut-module-setup.sh | 385 ++++++++++++++--------------------------- 2 files changed, 133 insertions(+), 270 deletions(-)
-- 2.34.1 _______________________________________________ kexec mailing list -- kexec@lists.fedoraproject.org To unsubscribe send an email to kexec-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
On Sat, Apr 23, 2022 at 10:32:28PM +0800, Kairui Song wrote:
Coiby Xu coxu@redhat.com 于2022年4月2日周六 11:24写道:
[...]
This patch set reuses NetworkManager connection profiles to set up kdump network. It also reduces the memory consumption of network drivers and fix other issues at the same time. Here are the bug list that addressed by this patch set on bugzilla,
- Bug 1962421 - [RHEL-9]"eth0: Failed to rename network interface 3 from 'eth0' to 'kdump-eth0': File exists"
- Bug 2064708 - kdump: mkdumprd: failed to make kdump initrd for bridge network on z15 z/vm - bugs related to OOM caused by network driver
Hi Coiby,
Hi Kairui,
Glad to see you again:)
This looks great, but one thing I don't understand, how is this going to help reduce the memory consumption? Shoudn't network drivers be the same, no matter how they are loaded?
I forgot to temporarily remove Bug 1958587 from the list which may confuse you. Currently this version only saves memory for the case where a network driver manages multiple NICs in [RFC 04/13] don't let NetworkManager manage unneeded network interfaces. Because when NetworkManager manges a NIC, it will trigger the driver to allocate memory resources (for rx or tx ring buffers for example) regardless of the NIC is active or not. By asking NM to stopping managing these unneeded devices, it could save kdump memory. I planned to use dracut's "--hostonly-nics" introduced by you to get rid of unnecessary NIC drivers in this version as well but currently it's in the dracut kdump module we find out the NICs needed by kdump and as a dracut module it can't add the "--hostonly-nics" option to dracut. So I created a dracut PR [1] to allow specifying empty --hostonly-nics. In next version I'll only install the network drivers needed as [1] has been merged.
[1] https://github.com/dracutdevs/dracut/pull/1789
- Bug 1950282 - shutdown those unneeded network interfaces to save memory for kdump - Bug 1958587 - the kdump initramfs includes unnecessary NIC drivers for SSH/NFS dumping target - Bug 1890021 - be2net is using too much memory during kdump - Bug 1662202 - [RHEL-8.1] aarch64: hpe-apache crashkernel OOM when dump to network targe
Coiby Xu (13): add function to copy NetworkManage connection profile to the initramfs support legacy ifcfg ask NM to wait the network device to be available don't let NetworkManager manage unneeded network interfaces stop dracut 35network-manager from running nm-initrd-generator set up kdump network bridge by directly copying NM connection profile to initrd set up kdump bonding network by directly copying NM connection profile to initrd fix error for vlan over team network interface set up kdump vlan network by directly copying NM connection profile to initrd set up kdump teaming network by directly copying NM connection profile to initrd clean up unneeded code after copying .nmconnection to initrd address the cases where a NIC has a different name in kdump kernel simplify setup_znet by copying connection profile to initrd
dracut-kdump.sh | 18 +- dracut-module-setup.sh | 385 ++++++++++++++--------------------------- 2 files changed, 133 insertions(+), 270 deletions(-)
-- 2.34.1 _______________________________________________ kexec mailing list -- kexec@lists.fedoraproject.org To unsubscribe send an email to kexec-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
Coiby Xu coxu@redhat.com 于2022年4月25日周一 11:10写道:
On Sat, Apr 23, 2022 at 10:32:28PM +0800, Kairui Song wrote:
Coiby Xu coxu@redhat.com 于2022年4月2日周六 11:24写道:
[...]
This patch set reuses NetworkManager connection profiles to set up kdump network. It also reduces the memory consumption of network drivers and fix other issues at the same time. Here are the bug list that addressed by this patch set on bugzilla,
- Bug 1962421 - [RHEL-9]"eth0: Failed to rename network interface 3 from 'eth0' to 'kdump-eth0': File exists"
- Bug 2064708 - kdump: mkdumprd: failed to make kdump initrd for bridge network on z15 z/vm - bugs related to OOM caused by network driver
Hi Coiby,
Hi Kairui,
Glad to see you again:)
This looks great, but one thing I don't understand, how is this going to help reduce the memory consumption? Shoudn't network drivers be the same, no matter how they are loaded?
I forgot to temporarily remove Bug 1958587 from the list which may confuse you. Currently this version only saves memory for the case where a network driver manages multiple NICs in [RFC 04/13] don't let NetworkManager manage unneeded network interfaces. Because when NetworkManager manges a NIC, it will trigger the driver to allocate memory resources (for rx or tx ring buffers for example) regardless of the NIC is active or not. By asking NM to stopping managing these unneeded devices, it could save kdump memory. I planned to use dracut's "--hostonly-nics" introduced by you to get rid of unnecessary NIC drivers in this version as well but currently it's in the dracut kdump module we find out the NICs needed by kdump and as a dracut module it can't add the "--hostonly-nics" option to dracut. So I created a dracut PR [1] to allow specifying empty --hostonly-nics. In next version I'll only install the network drivers needed as [1] has been merged.
Ah, I get it now. I was thinking about how should kexec-tools determine which interface to kept when implementing that --hostonly-nic, this patch is a clean and great answer, thanks!