Hi Coiby,
On Sat, 2 Apr 2022 11:23:45 +0800
Coiby Xu <coxu(a)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(a)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")