Some users may choose to manage /etc/resolve.conf manually. In this case, network dumping will not work because DNS resolution doesn't work. Copy /etc/resolve.conf to kdump initrd if this file is not managed by systemd-resolved or NetworkManager.
Fixes: 63c3805c ("Set up kdump network by directly copying NM connection profile to initrd") Reported-by: Curtis Taylor cutaylor@redhat.com Cc: Jie Li jieli@redhat.com Signed-off-by: Coiby Xu coxu@redhat.com --- dracut-module-setup.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index ff53d084..e6355973 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -563,6 +563,19 @@ kdump_collect_netif_usage() { fi }
+kdump_install_resolv_conf() { + + local _resolv_conf=/etc/resolv.conf + + # Some users may choose to manage /etc/resolve.conf manually. + # + # We can tell this case by confirming this file is not manged by + # systemd-resolved or NetworkManager. + if ! grep -qs "^nameserver 127.0.0.53" "$_resolv_conf" && ! grep -qs "^# Generated by NetworkManager" "$_resolv_conf"; then + dracut_install "$_resolv_conf" + fi +} + # Setup dracut to bring up network interface that enable # initramfs accessing giving destination kdump_install_net() { @@ -575,6 +588,7 @@ kdump_install_net() { kdump_setup_znet kdump_install_nm_netif_allowlist "$_netifs" kdump_install_nic_driver "$_netifs" + kdump_install_resolv_conf fi }
Resolves: https://issues.redhat.com/browse/RHEL-11897
Some users may choose to manage /etc/resolve.conf manually (e.g. by setting dns=none in NetworkManager.conf [1]). In this case, network dumping will not work because DNS resolution doesn't work. Copy /etc/resolve.conf to kdump initrd if this file is not managed by systemd-resolved or NetworkManager.
[1] https://bugzilla.gnome.org/show_bug.cgi?id=690404
Fixes: 63c3805c ("Set up kdump network by directly copying NM connection profile to initrd") Reported-by: Curtis Taylor cutaylor@redhat.com Cc: Jie Li jieli@redhat.com Signed-off-by: Coiby Xu coxu@redhat.com --- v2 - use 'grep "|"' instead of 'grep | grep' for multiple patterns matching - improve commit message --- dracut-module-setup.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index ff53d084..d062f7fd 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -563,6 +563,19 @@ kdump_collect_netif_usage() { fi }
+kdump_install_resolv_conf() { + + local _resolv_conf=/etc/resolv.conf + + # Some users may choose to manage /etc/resolve.conf manually. + # + # We can tell this case by confirming this file is not manged by + # systemd-resolved or NetworkManager. + if ! grep -qs "^nameserver 127.0.0.53|^# Generated by NetworkManager" "$_resolv_conf"; then + dracut_install "$_resolv_conf" + fi +} + # Setup dracut to bring up network interface that enable # initramfs accessing giving destination kdump_install_net() { @@ -575,6 +588,7 @@ kdump_install_net() { kdump_setup_znet kdump_install_nm_netif_allowlist "$_netifs" kdump_install_nic_driver "$_netifs" + kdump_install_resolv_conf fi }
Hi Coiby,
On Fri, 10 Nov 2023 at 08:40, Coiby Xu coxu@redhat.com wrote:
Some users may choose to manage /etc/resolve.conf manually. In this case, network dumping will not work because DNS resolution doesn't work. Copy /etc/resolve.conf to kdump initrd if this file is not managed by systemd-resolved or NetworkManager.
Fixes: 63c3805c ("Set up kdump network by directly copying NM connection profile to initrd") Reported-by: Curtis Taylor cutaylor@redhat.com Cc: Jie Li jieli@redhat.com Signed-off-by: Coiby Xu coxu@redhat.com
dracut-module-setup.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index ff53d084..e6355973 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -563,6 +563,19 @@ kdump_collect_netif_usage() { fi }
+kdump_install_resolv_conf() {
- local _resolv_conf=/etc/resolv.conf
- # Some users may choose to manage /etc/resolve.conf manually.
- #
- # We can tell this case by confirming this file is not manged by
- # systemd-resolved or NetworkManager.
- if ! grep -qs "^nameserver 127.0.0.53" "$_resolv_conf" && ! grep -qs "^# Generated by NetworkManager" "$_resolv_conf"; then
Is the 127.0.0.53, is it systemd-resolved specific? How about just check the status of systemd-resolvd by checking return value of below: systemctl -q is-active systemd-resolved
Otherwise for NetworkManager setup, it could be that people just edit the NM generated resolv.conf, but keep the comment line there: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/htm...
If we just blindly install the resolv.conf, I think it will be overwritten by NM in kdump kernel initramfs during bootup if people use NM, so it does not matter to have it copied without any checking.
dracut_install "$_resolv_conf"
- fi
+}
# Setup dracut to bring up network interface that enable # initramfs accessing giving destination kdump_install_net() { @@ -575,6 +588,7 @@ kdump_install_net() { kdump_setup_znet kdump_install_nm_netif_allowlist "$_netifs" kdump_install_nic_driver "$_netifs"
fikdump_install_resolv_conf
}
-- 2.41.0 _______________________________________________ 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, report it: https://pagure.io/fedora-infrastructure/new_issue
Thanks Dave
On Fri, Nov 10, 2023 at 09:46:03AM +0800, Dave Young wrote:
Hi Coiby,
Hi Dave,
Thanks for reviewing the patch!
On Fri, 10 Nov 2023 at 08:40, Coiby Xu coxu@redhat.com wrote:
Some users may choose to manage /etc/resolve.conf manually. In this case, network dumping will not work because DNS resolution doesn't work. Copy /etc/resolve.conf to kdump initrd if this file is not managed by systemd-resolved or NetworkManager.
Fixes: 63c3805c ("Set up kdump network by directly copying NM connection profile to initrd") Reported-by: Curtis Taylor cutaylor@redhat.com Cc: Jie Li jieli@redhat.com Signed-off-by: Coiby Xu coxu@redhat.com
dracut-module-setup.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index ff53d084..e6355973 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -563,6 +563,19 @@ kdump_collect_netif_usage() { fi }
+kdump_install_resolv_conf() {
- local _resolv_conf=/etc/resolv.conf
- # Some users may choose to manage /etc/resolve.conf manually.
- #
- # We can tell this case by confirming this file is not manged by
- # systemd-resolved or NetworkManager.
- if ! grep -qs "^nameserver 127.0.0.53" "$_resolv_conf" && ! grep -qs "^# Generated by NetworkManager" "$_resolv_conf"; then
Is the 127.0.0.53, is it systemd-resolved specific? How about just check the status of systemd-resolvd by checking return value of below: systemctl -q is-active systemd-resolved
Yes, I think it's systemd-resolved specific according to "man systemd-resolved". I've applied this suggestion in v3 as it's simpler. Thanks!
Otherwise for NetworkManager setup, it could be that people just edit the NM generated resolv.conf, but keep the comment line there: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/htm...
If we just blindly install the resolv.conf, I think it will be overwritten by NM in kdump kernel initramfs during bootup if people use NM, so it does not matter to have it copied without any checking.
Thanks for sharing the helpful doc which made I realize I missed the case where users could also manually configure resolv.conf by using a symbolic file. In v3, I've addressed this case. And yes, grep -qs "^# Generated by NetworkManager" is unreliable and unnecessary, thanks for pointing out it!
dracut_install "$_resolv_conf"
- fi
+}
# Setup dracut to bring up network interface that enable # initramfs accessing giving destination kdump_install_net() { @@ -575,6 +588,7 @@ kdump_install_net() { kdump_setup_znet kdump_install_nm_netif_allowlist "$_netifs" kdump_install_nic_driver "$_netifs"
fikdump_install_resolv_conf
}
-- 2.41.0 _______________________________________________ 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, report it: https://pagure.io/fedora-infrastructure/new_issue
Thanks Dave
Resolves: https://issues.redhat.com/browse/RHEL-11897
Some users may choose to manage /etc/resolve.conf manually [1] by setting dns=none or use a symbolic link resolve.conf [2]. In this case, network dumping will not work because DNS resolution fails. Use the same /etc/resolve.conf in kdump initrd to fix this problem.
[1] https://bugzilla.gnome.org/show_bug.cgi?id=690404 [2] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/htm...
Fixes: 63c3805c ("Set up kdump network by directly copying NM connection profile to initrd") Reported-by: Curtis Taylor cutaylor@redhat.com Cc: Jie Li jieli@redhat.com Signed-off-by: Coiby Xu coxu@redhat.com --- v3 - Dave - use "systemctl -q is-active systemd-resolved" to tell if /etc/resolv.conf is managed by systemd-resolved - drop needless and unreliable check on whether resolv.conf is generated by NM
- configure dns=none for NM to prevent resolv.conf being overwritten by NM - take care of the case where user-configured resolv.conf is a symbolic file
v2 - use 'grep "|"' instead of 'grep | grep' for multiple patterns matching - improve commit message --- dracut-module-setup.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index ff53d084..8368ee47 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -563,6 +563,31 @@ kdump_collect_netif_usage() { fi }
+kdump_install_resolv_conf() { + local _resolv_conf=/etc/resolv.conf _nm_conf_dir=/etc/NetworkManager/conf.d + + # Some users may choose to manage /etc/resolve.conf manually [1] + # by setting dns=none or use a symbolic link resolve.conf [2]. + # So resolve.conf should be installed to kdump initrd as well. To prevent + # NM frome overwritting the user-configured resolve.conf in kdump initrd, + # also set dns=none for NM. + # + # Note: + # 1. When resolv.conf is managed by systemd-resolved.service, it could also be a + # symbolic link So exclude this case by teling if systemd-resolved is enabled + # + # 2. It's harmless to bindly copy /etc/resolve.conf to the initrd because + # by default in initramfs this file will be overwritten by NetworkManager. + # + # [1] https://bugzilla.gnome.org/show_bug.cgi?id=690404 + # [2] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/htm... + systemctl -q is-enabled systemd-resolved && return 0 + inst "$(readlink -f "$_resolv_conf")" "$_resolv_conf" + if NetworkManager --print-config | grep -qs "^dns=none" || [[ -L "$_resolv_conf" ]]; then + echo "[main]\ndns=none" > "$_nm_conf_dir"/90-dns-none.conf + fi +} + # Setup dracut to bring up network interface that enable # initramfs accessing giving destination kdump_install_net() { @@ -575,6 +600,7 @@ kdump_install_net() { kdump_setup_znet kdump_install_nm_netif_allowlist "$_netifs" kdump_install_nic_driver "$_netifs" + kdump_install_resolv_conf fi }
Hi Coiby,
Thanks for the update! I still have some questions though, please see the inline comments.
On Tue, 14 Nov 2023 at 17:22, Coiby Xu coxu@redhat.com wrote:
Resolves: https://issues.redhat.com/browse/RHEL-11897
Some users may choose to manage /etc/resolve.conf manually [1] by setting dns=none or use a symbolic link resolve.conf [2]. In this case, network dumping will not work because DNS resolution fails. Use the same /etc/resolve.conf in kdump initrd to fix this problem.
[1] https://bugzilla.gnome.org/show_bug.cgi?id=690404 [2] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/htm...
Fixes: 63c3805c ("Set up kdump network by directly copying NM connection profile to initrd") Reported-by: Curtis Taylor cutaylor@redhat.com Cc: Jie Li jieli@redhat.com Signed-off-by: Coiby Xu coxu@redhat.com
v3
Dave
- use "systemctl -q is-active systemd-resolved" to tell if /etc/resolv.conf is managed by systemd-resolved
- drop needless and unreliable check on whether resolv.conf is generated by NM
configure dns=none for NM to prevent resolv.conf being overwritten by NM
take care of the case where user-configured resolv.conf is a symbolic file
v2
- use 'grep "|"' instead of 'grep | grep' for multiple patterns matching
- improve commit message
dracut-module-setup.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index ff53d084..8368ee47 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -563,6 +563,31 @@ kdump_collect_netif_usage() { fi }
+kdump_install_resolv_conf() {
- local _resolv_conf=/etc/resolv.conf _nm_conf_dir=/etc/NetworkManager/conf.d
- # Some users may choose to manage /etc/resolve.conf manually [1]
- # by setting dns=none or use a symbolic link resolve.conf [2].
- # So resolve.conf should be installed to kdump initrd as well. To prevent
- # NM frome overwritting the user-configured resolve.conf in kdump initrd,
- # also set dns=none for NM.
- #
- # Note:
- # 1. When resolv.conf is managed by systemd-resolved.service, it could also be a
- # symbolic link So exclude this case by teling if systemd-resolved is enabled
- #
- # 2. It's harmless to bindly copy /etc/resolve.conf to the initrd because
s/bindly/blindly
- # by default in initramfs this file will be overwritten by NetworkManager.
- #
- # [1] https://bugzilla.gnome.org/show_bug.cgi?id=690404
- # [2] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/htm...
- systemctl -q is-enabled systemd-resolved && return 0
- inst "$(readlink -f "$_resolv_conf")" "$_resolv_conf"
- if NetworkManager --print-config | grep -qs "^dns=none" || [[ -L "$_resolv_conf" ]]; then
What is the reason to check the [[ -L "$_resolv_conf" ]] here? it would be better to have the dns-none chunk to handle the dns-none case only and it will be easier to understand.
echo "[main]\ndns=none" > "$_nm_conf_dir"/90-dns-none.conf
BTW, would this be better to add in dracut hostonly code?
- fi
+}
# Setup dracut to bring up network interface that enable # initramfs accessing giving destination kdump_install_net() { @@ -575,6 +600,7 @@ kdump_install_net() { kdump_setup_znet kdump_install_nm_netif_allowlist "$_netifs" kdump_install_nic_driver "$_netifs"
fikdump_install_resolv_conf
}
-- 2.41.0 _______________________________________________ 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, report it: https://pagure.io/fedora-infrastructure/new_issue
On Wed, Nov 15, 2023 at 10:54:36AM +0800, RuiRui Yang wrote:
Hi Coiby,
Thanks for the update! I still have some questions though, please see the inline comments.
Hi Dave,
Thanks for the quick response!
On Tue, 14 Nov 2023 at 17:22, Coiby Xu coxu@redhat.com wrote: [...]
+kdump_install_resolv_conf() {
- local _resolv_conf=/etc/resolv.conf _nm_conf_dir=/etc/NetworkManager/conf.d
- # Some users may choose to manage /etc/resolve.conf manually [1]
- # by setting dns=none or use a symbolic link resolve.conf [2].
- # So resolve.conf should be installed to kdump initrd as well. To prevent
- # NM frome overwritting the user-configured resolve.conf in kdump initrd,
- # also set dns=none for NM.
- #
- # Note:
- # 1. When resolv.conf is managed by systemd-resolved.service, it could also be a
- # symbolic link So exclude this case by teling if systemd-resolved is enabled
- #
- # 2. It's harmless to bindly copy /etc/resolve.conf to the initrd because
s/bindly/blindly
Thanks for catching this typo!
- # by default in initramfs this file will be overwritten by NetworkManager.
- #
- # [1] https://bugzilla.gnome.org/show_bug.cgi?id=690404
- # [2] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/htm...
- systemctl -q is-enabled systemd-resolved && return 0
- inst "$(readlink -f "$_resolv_conf")" "$_resolv_conf"
- if NetworkManager --print-config | grep -qs "^dns=none" || [[ -L "$_resolv_conf" ]]; then
What is the reason to check the [[ -L "$_resolv_conf" ]] here? it would be better to have the dns-none chunk to handle the dns-none case only and it will be easier to understand.
Because users could also self-manage /etc/resolve.conf via a symbolic link. When resolve.conf is a symbolic file, NM won't touch resolve.conf even without dns=none.
echo "[main]\ndns=none" > "$_nm_conf_dir"/90-dns-none.conf
BTW, would this be better to add in dracut hostonly code?
dns=none is strongly coupled with the code before, so it doesn't seemm to ake sense to fragment the code? Btw, I'm not sure if dracut wants this code because currently the only user is the kdump dracut module which is still out of tree.
On Wed, 15 Nov 2023 at 11:40, Coiby Xu coxu@redhat.com wrote:
On Wed, Nov 15, 2023 at 10:54:36AM +0800, RuiRui Yang wrote:
Hi Coiby,
Thanks for the update! I still have some questions though, please see the inline comments.
Hi Dave,
Thanks for the quick response!
On Tue, 14 Nov 2023 at 17:22, Coiby Xu coxu@redhat.com wrote: [...]
+kdump_install_resolv_conf() {
- local _resolv_conf=/etc/resolv.conf _nm_conf_dir=/etc/NetworkManager/conf.d
- # Some users may choose to manage /etc/resolve.conf manually [1]
- # by setting dns=none or use a symbolic link resolve.conf [2].
- # So resolve.conf should be installed to kdump initrd as well. To prevent
- # NM frome overwritting the user-configured resolve.conf in kdump initrd,
- # also set dns=none for NM.
- #
- # Note:
- # 1. When resolv.conf is managed by systemd-resolved.service, it could also be a
- # symbolic link So exclude this case by teling if systemd-resolved is enabled
- #
- # 2. It's harmless to bindly copy /etc/resolve.conf to the initrd because
s/bindly/blindly
Thanks for catching this typo!
- # by default in initramfs this file will be overwritten by NetworkManager.
- #
- # [1] https://bugzilla.gnome.org/show_bug.cgi?id=690404
- # [2] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/htm...
- systemctl -q is-enabled systemd-resolved && return 0
- inst "$(readlink -f "$_resolv_conf")" "$_resolv_conf"
- if NetworkManager --print-config | grep -qs "^dns=none" || [[ -L "$_resolv_conf" ]]; then
What is the reason to check the [[ -L "$_resolv_conf" ]] here? it would be better to have the dns-none chunk to handle the dns-none case only and it will be easier to understand.
Because users could also self-manage /etc/resolve.conf via a symbolic link. When resolve.conf is a symbolic file, NM won't touch resolve.conf even without dns=none.
Hi Coiby, ok, thanks for the explanation.
It seems dracut "inst" will automatically install the original file and the target symlink, if so as you said we do not need to add the dns=none for this case and it will just work?
Not sure about 'inst "$(readlink -f "$_resolv_conf")" "$_resolv_conf"', at least 'inst "$_resolv_conf" "$_resolv_conf"' works fine for me.
echo "[main]\ndns=none" > "$_nm_conf_dir"/90-dns-none.conf
BTW, would this be better to add in dracut hostonly code?
dns=none is strongly coupled with the code before, so it doesn't seem to ake sense to fragment the code? Btw, I'm not sure if dracut wants this code because currently the only user is the kdump dracut module which is still out of tree.
Hostonly exists before the kdump dracut module created, so there are more users who will manually generate the initrd with host only mode to do something although we can not have an example for this specific case. I previously always tried to move code to dracut as much as possible. But since you guys are maintaining the code now, I have no strong opinion on this. Please just take what you think is better if no any other objections.
-- Best regards, Coiby
On Wed, Nov 15, 2023 at 01:40:10PM +0800, Dave Young wrote:
It seems dracut "inst" will automatically install the original file and the target symlink, if so as you said we do not need to add the dns=none for this case and it will just work?
Not sure about 'inst "$(readlink -f "$_resolv_conf")" "$_resolv_conf"', at least 'inst "$_resolv_conf" "$_resolv_conf"' works fine for me.
I forgot to mention I was mislead by one experiment where /etc/resolv.conf was linked to ../run/systemd/resolve/stub-resolv.conf. After using "inst /etc/resolv.conf", this file doesn't exist when booting into the initrd sh-5.2# ls -l /etc/resolv.conf lrwxrwxrwx 1 root root 39 Nov 15 10:10 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf sh-5.2# cat /etc/resolv.conf cat: /etc/resolv.conf: No such file or directory
Later I linked /etc/custom-resolv.conf to /etc/resolv.conf. Then it works as expected.
echo "[main]\ndns=none" > "$_nm_conf_dir"/90-dns-none.conf
BTW, would this be better to add in dracut hostonly code?
dns=none is strongly coupled with the code before, so it doesn't seem to ake sense to fragment the code? Btw, I'm not sure if dracut wants this code because currently the only user is the kdump dracut module which is still out of tree.
Hostonly exists before the kdump dracut module created, so there are more users who will manually generate the initrd with host only mode to do something although we can not have an example for this specific case. I previously always tried to move code to dracut as much as possible. But since you guys are maintaining the code now, I have no strong opinion on this. Please just take what you think is better if no any other objections.
Thanks for sharing you experience! I'll try adding the code to dracut if it's also needed for other use cases.
Resolves: https://issues.redhat.com/browse/RHEL-11897
Some users may choose to manage /etc/resolve.conf manually [1] by setting dns=none or use a symbolic link resolve.conf [2]. In this case, network dumping will not work because DNS resolution fails. Use the same /etc/resolve.conf in kdump initrd to fix this problem.
[1] https://bugzilla.gnome.org/show_bug.cgi?id=690404 [2] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/htm...
Fixes: 63c3805c ("Set up kdump network by directly copying NM connection profile to initrd") Reported-by: Curtis Taylor cutaylor@redhat.com Cc: Jie Li jieli@redhat.com Signed-off-by: Coiby Xu coxu@redhat.com --- v4 - use dracut's inst to install the symbolic link and target file automatically [Dave] - drop the unneeded check of symbolic link to tell if dns=none for NM
v3 - Dave - use "systemctl -q is-active systemd-resolved" to tell if /etc/resolv.conf is managed by systemd-resolved - drop needless and unreliable check on whether resolv.conf is generated by NM
- configure dns=none for NM to prevent resolv.conf being overwritten by NM - take care of the case where user-configured resolv.conf is a symbolic file
v2 - use 'grep "|"' instead of 'grep | grep' for multiple patterns matching - improve commit message --- dracut-module-setup.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index ff53d084..ab6dc4f1 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -563,6 +563,33 @@ kdump_collect_netif_usage() { fi }
+kdump_install_resolv_conf() { + local _resolv_conf=/etc/resolv.conf _nm_conf_dir=/etc/NetworkManager/conf.d + + # Some users may choose to manage /etc/resolve.conf manually [1] + # by setting dns=none or use a symbolic link resolve.conf [2]. + # So resolve.conf should be installed to kdump initrd as well. To prevent + # NM frome overwritting the user-configured resolve.conf in kdump initrd, + # also set dns=none for NM. + # + # Note: + # 1. When resolv.conf is managed by systemd-resolved.service, it could also be a + # symbolic link. So exclude this case by teling if systemd-resolved is enabled. + # + # 2. It's harmless to blindly copy /etc/resolve.conf to the initrd because + # by default in initramfs this file will be overwritten by + # NetworkManager. If user manages it via a symbolic link, it's still + # preserved because NM won't touch a symbolic link file. + # + # [1] https://bugzilla.gnome.org/show_bug.cgi?id=690404 + # [2] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/htm... + systemctl -q is-enabled systemd-resolved && return 0 + inst "$_resolv_conf" + if NetworkManager --print-config | grep -qs "^dns=none"; then + echo "[main]\ndns=none" > "$_nm_conf_dir"/90-dns-none.conf + fi +} + # Setup dracut to bring up network interface that enable # initramfs accessing giving destination kdump_install_net() { @@ -575,6 +602,7 @@ kdump_install_net() { kdump_setup_znet kdump_install_nm_netif_allowlist "$_netifs" kdump_install_nic_driver "$_netifs" + kdump_install_resolv_conf fi }
On Wed, 22 Nov 2023 at 14:50, Coiby Xu coxu@redhat.com wrote:
Resolves: https://issues.redhat.com/browse/RHEL-11897
Some users may choose to manage /etc/resolve.conf manually [1] by setting dns=none or use a symbolic link resolve.conf [2]. In this case, network dumping will not work because DNS resolution fails. Use the same /etc/resolve.conf in kdump initrd to fix this problem.
[1] https://bugzilla.gnome.org/show_bug.cgi?id=690404 [2] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/htm...
Fixes: 63c3805c ("Set up kdump network by directly copying NM connection profile to initrd") Reported-by: Curtis Taylor cutaylor@redhat.com Cc: Jie Li jieli@redhat.com Signed-off-by: Coiby Xu coxu@redhat.com
v4
- use dracut's inst to install the symbolic link and target file automatically [Dave]
- drop the unneeded check of symbolic link to tell if dns=none for NM
v3
Dave
- use "systemctl -q is-active systemd-resolved" to tell if /etc/resolv.conf is managed by systemd-resolved
- drop needless and unreliable check on whether resolv.conf is generated by NM
configure dns=none for NM to prevent resolv.conf being overwritten by NM
take care of the case where user-configured resolv.conf is a symbolic file
v2
- use 'grep "|"' instead of 'grep | grep' for multiple patterns matching
- improve commit message
dracut-module-setup.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index ff53d084..ab6dc4f1 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -563,6 +563,33 @@ kdump_collect_netif_usage() { fi }
+kdump_install_resolv_conf() {
- local _resolv_conf=/etc/resolv.conf _nm_conf_dir=/etc/NetworkManager/conf.d
- # Some users may choose to manage /etc/resolve.conf manually [1]
- # by setting dns=none or use a symbolic link resolve.conf [2].
- # So resolve.conf should be installed to kdump initrd as well. To prevent
- # NM frome overwritting the user-configured resolve.conf in kdump initrd,
- # also set dns=none for NM.
- #
- # Note:
- # 1. When resolv.conf is managed by systemd-resolved.service, it could also be a
- # symbolic link. So exclude this case by teling if systemd-resolved is enabled.
- #
- # 2. It's harmless to blindly copy /etc/resolve.conf to the initrd because
- # by default in initramfs this file will be overwritten by
- # NetworkManager. If user manages it via a symbolic link, it's still
- # preserved because NM won't touch a symbolic link file.
- #
- # [1] https://bugzilla.gnome.org/show_bug.cgi?id=690404
- # [2] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/htm...
- systemctl -q is-enabled systemd-resolved && return 0
- inst "$_resolv_conf"
- if NetworkManager --print-config | grep -qs "^dns=none"; then
echo "[main]\ndns=none" > "$_nm_conf_dir"/90-dns-none.conf
- fi
+}
# Setup dracut to bring up network interface that enable # initramfs accessing giving destination kdump_install_net() { @@ -575,6 +602,7 @@ kdump_install_net() { kdump_setup_znet kdump_install_nm_netif_allowlist "$_netifs" kdump_install_nic_driver "$_netifs"
fikdump_install_resolv_conf
}
Hi Coiby, thanks for the update:
Reviewed-by: Dave Young dyoung@redhat.com
-- 2.42.0 -- _______________________________________________ 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, report it: https://pagure.io/fedora-infrastructure/new_issue
On Wed, Nov 22, 2023 at 06:44:44PM +0800, RuiRui Yang wrote:
On Wed, 22 Nov 2023 at 14:50, Coiby Xu coxu@redhat.com wrote:
Resolves: https://issues.redhat.com/browse/RHEL-11897
Some users may choose to manage /etc/resolve.conf manually [1] by setting dns=none or use a symbolic link resolve.conf [2]. In this case, network dumping will not work because DNS resolution fails. Use the same /etc/resolve.conf in kdump initrd to fix this problem.
[1] https://bugzilla.gnome.org/show_bug.cgi?id=690404 [2] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/htm...
Fixes: 63c3805c ("Set up kdump network by directly copying NM connection profile to initrd") Reported-by: Curtis Taylor cutaylor@redhat.com Cc: Jie Li jieli@redhat.com Signed-off-by: Coiby Xu coxu@redhat.com
v4
- use dracut's inst to install the symbolic link and target file automatically [Dave]
- drop the unneeded check of symbolic link to tell if dns=none for NM
v3
Dave
- use "systemctl -q is-active systemd-resolved" to tell if /etc/resolv.conf is managed by systemd-resolved
- drop needless and unreliable check on whether resolv.conf is generated by NM
configure dns=none for NM to prevent resolv.conf being overwritten by NM
take care of the case where user-configured resolv.conf is a symbolic file
v2
- use 'grep "|"' instead of 'grep | grep' for multiple patterns matching
- improve commit message
dracut-module-setup.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index ff53d084..ab6dc4f1 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -563,6 +563,33 @@ kdump_collect_netif_usage() { fi }
+kdump_install_resolv_conf() {
- local _resolv_conf=/etc/resolv.conf _nm_conf_dir=/etc/NetworkManager/conf.d
- # Some users may choose to manage /etc/resolve.conf manually [1]
- # by setting dns=none or use a symbolic link resolve.conf [2].
- # So resolve.conf should be installed to kdump initrd as well. To prevent
- # NM frome overwritting the user-configured resolve.conf in kdump initrd,
- # also set dns=none for NM.
- #
- # Note:
- # 1. When resolv.conf is managed by systemd-resolved.service, it could also be a
- # symbolic link. So exclude this case by teling if systemd-resolved is enabled.
- #
- # 2. It's harmless to blindly copy /etc/resolve.conf to the initrd because
- # by default in initramfs this file will be overwritten by
- # NetworkManager. If user manages it via a symbolic link, it's still
- # preserved because NM won't touch a symbolic link file.
- #
- # [1] https://bugzilla.gnome.org/show_bug.cgi?id=690404
- # [2] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/htm...
- systemctl -q is-enabled systemd-resolved && return 0
- inst "$_resolv_conf"
- if NetworkManager --print-config | grep -qs "^dns=none"; then
echo "[main]\ndns=none" > "$_nm_conf_dir"/90-dns-none.conf
- fi
+}
# Setup dracut to bring up network interface that enable # initramfs accessing giving destination kdump_install_net() { @@ -575,6 +602,7 @@ kdump_install_net() { kdump_setup_znet kdump_install_nm_netif_allowlist "$_netifs" kdump_install_nic_driver "$_netifs"
fikdump_install_resolv_conf
}
Hi Coiby, thanks for the update:
Reviewed-by: Dave Young dyoung@redhat.com
This patch was merged, thanks for the code review!