Bug 877084
| Summary: | missing hostname after upgrade to NetworkManager-0.9.7.0-6.git20121004.el7.x86_64 | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | Red Hat Enterprise Linux 7 | Reporter: | Matěj Cepl <mcepl> | ||||||
| Component: | NetworkManager | Assignee: | Dan Williams <dcbw> | ||||||
| Status: | CLOSED CURRENTRELEASE | QA Contact: | Desktop QE <desktop-qa-list> | ||||||
| Severity: | unspecified | Docs Contact: | |||||||
| Priority: | unspecified | ||||||||
| Version: | 7.0 | CC: | jklimes, psimerda, pvine, vbenes | ||||||
| Target Milestone: | rc | ||||||||
| Target Release: | --- | ||||||||
| Hardware: | Unspecified | ||||||||
| OS: | Unspecified | ||||||||
| Whiteboard: | |||||||||
| Fixed In Version: | NetworkManager-0.9.7.0-10.git20121004.el7 | Doc Type: | Bug Fix | ||||||
| Doc Text: | Story Points: | --- | |||||||
| Clone Of: | Environment: | ||||||||
| Last Closed: | 2014-06-13 12:36:27 UTC | Type: | Bug | ||||||
| Regression: | --- | Mount Type: | --- | ||||||
| Documentation: | --- | CRM: | |||||||
| Verified Versions: | Category: | --- | |||||||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||||
| Embargoed: | |||||||||
| Attachments: |
|
||||||||
|
Description
Matěj Cepl
2012-11-15 16:39:36 UTC
commit a7eb3476557dae28880333544c797705ee2f5b5a
Author: Dan Winship <danw>
Date: Tue Jun 19 10:07:17 2012 -0400
ifcfg-rh: /etc/hostname should override /etc/sysconfig/network
When determining the system hostname, /etc/hostname should override
/etc/sysconfig/network, so monitor both files.
When setting the hostname, set it in /etc/hostname, and delete the
/etc/sysconfig/network HOSTNAME entry if present.
https://bugzilla.redhat.com/show_bug.cgi?id=831735
With version NetworkManager-0.9.7.0-7.git20121004.el7.x86_64 I can still reproduce this bug on wired network. Surprisingly, everything works OK on wifi network. (In reply to comment #2) > With version NetworkManager-0.9.7.0-7.git20121004.el7.x86_64 I can still > reproduce this bug on wired network. Surprisingly, everything works OK on > wifi network. This will get fixed whenever we build the next el7 snapshot. It should be fixed in NetworkManager-0.9.7.0-10.git20121004.el7, now available. Created attachment 664980 [details] grep NetworkManager /var/log/messages (In reply to comment #4) > It should be fixed in NetworkManager-0.9.7.0-10.git20121004.el7, now > available. But it isn't. I still can reproduce with NetworkManager-0.9.7.0-10.git20121004.el7.x86_64 Setting hostname call was added to handler for connection activated state in bug 875085. Unfortunately, it shows up there is a race in updating DNS and doing reverse-lookup to get hostname. Apparently the commit for reducing resolv.conf changes broke this as well: http://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=500315329765831d242d51d6a46f1e05869c15d2 bad case: ========= ... NetworkManager[29712]: <debug> [1355769422.513260] [nm-policy-hostname.c:167] hostname4_thread_new(): (0xc5a5a0) started IPv4 reverse-lookup thread for address '1.2.3.4' NetworkManager[29712]: <debug> [1355769422.513332] [nm-dns-manager.c:1016] nm_dns_manager_end_updates(): (nm_dns_manager_end_updates): DNS configuration changed NetworkManager[29712]: <debug> [1355769422.513332] [nm-policy-hostname.c:95] hostname_thread_worker(): (0xc5a5a0) starting address reverse-lookup NetworkManager[29712]: <debug> [1355769422.513822] [nm-policy-hostname.c:107] hostname_thread_worker(): (0xc5a5a0) address reverse-lookup returned hostname 'localhost.localdomain' NetworkManager[29712]: <debug> [1355769422.513841] [nm-policy-hostname.c:119] hostname_thread_worker(): (0xc5a5a0) scheduling address reverse-lookup result handler NetworkManager[29712]: <debug> [1355769422.513349] [nm-dns-manager.c:1020] nm_dns_manager_end_updates(): (update_routing_and_dns): no DNS changes to commit (1) NetworkManager[29712]: <debug> [1355769422.515162] [nm-dns-manager.c:1016] nm_dns_manager_end_updates(): (nm_dns_manager_end_updates): DNS configuration changed NetworkManager[29712]: <debug> [1355769422.515177] [nm-dns-manager.c:1025] nm_dns_manager_end_updates(): (device_state_changed): committing DNS changes (0) NetworkManager[29712]: <debug> [1355769422.515190] [nm-dns-manager.c:592] update_dns(): updating resolv.conf [Thread 0x7fffe8bed700 (LWP 30052) exited] NetworkManager[29712]: <debug> [1355769422.549823] [nm-policy-hostname.c:84] hostname_thread_run_cb(): (0xc5a5a0) calling address reverse-lookup result handler NetworkManager[29712]: <debug> [1355769422.551364] [nm-policy-hostname.c:129] hostname_thread_free(): (0xc5a5a0) freeing reverse-lookup thread ... good case: ========== ... NetworkManager[29712]: <debug> [1355769434.874385] [nm-policy-hostname.c:167] hostname4_thread_new(): (0xc2e400) started IPv4 reverse-lookup thread for address '1.2.3.4' NetworkManager[29712]: <debug> [1355769434.874454] [nm-dns-manager.c:1016] nm_dns_manager_end_updates(): (nm_dns_manager_end_updates): DNS configuration changed NetworkManager[29712]: <debug> [1355769434.874476] [nm-dns-manager.c:1020] nm_dns_manager_end_updates(): (update_routing_and_dns): no DNS changes to commit (1) NetworkManager[29712]: <debug> [1355769434.874508] [nm-dns-manager.c:1016] nm_dns_manager_end_updates(): (nm_dns_manager_end_updates): DNS configuration changed NetworkManager[29712]: <debug> [1355769434.874655] [nm-dns-manager.c:1025] nm_dns_manager_end_updates(): (device_state_changed): committing DNS changes (0) NetworkManager[29712]: <debug> [1355769434.874677] [nm-dns-manager.c:592] update_dns(): updating resolv.conf NetworkManager[29712]: <debug> [1355769434.878490] [nm-policy-hostname.c:95] hostname_thread_worker(): (0xc2e400) starting address reverse-lookup NetworkManager[29712]: <debug> [1355769437.314422] [nm-dns-manager.c:998] nm_dns_manager_begin_updates(): (device_ip6_config_changed): queueing DNS updates (1) NetworkManager[29712]: <debug> [1355769437.315607] [nm-dns-manager.c:1016] nm_dns_manager_end_updates(): (nm_dns_manager_end_updates): DNS configuration did not change NetworkManager[29712]: <debug> [1355769437.315632] [nm-dns-manager.c:1020] nm_dns_manager_end_updates(): (device_ip6_config_changed): no DNS changes to commit (0) NetworkManager[29712]: <debug> [1355769439.883342] [nm-policy-hostname.c:107] hostname_thread_worker(): (0xc2e400) address reverse-lookup returned hostname 'dhcp129-108.brq.redhat.com' NetworkManager[29712]: <debug> [1355769439.883400] [nm-policy-hostname.c:119] hostname_thread_worker(): (0xc2e400) scheduling address reverse-lookup result handler ... So, looks to me like we're attempting to look up the hostname before we have set the DNS servers in resolv.conf perhaps? Which is likely because update_system_hostname() gets called before nm_dns_manager_end_updates(). So here's what we should do, I think... 1) Add a signal to the dns-manager for "config-changed" and emit that when resolv.conf actually gets written 2) Policy sets a boolean in private data for "hostname lookup needed" and starts a lookup 3) this boolean *only* gets cleared when we have a hostname from other sources, it does not get cleared when the hostname lookup thread finishes 4) when the policy gets the 'config-changed' signal from the dns-manager, it cancels any existing lookup, and if the "hostname lookup needed" boolean is set, starts a new lookup We need the boolean to ensure that if the hostname thread exited before the config-changed signal is emitted, that we kick off a new lookup. Does that sound workable? Just brainstorming here. Created attachment 693874 [details] [PATCH] fix the race in getting hostname through reverse-lookup The described procedure looks good. I've just changed the boolean to IPv4 and IPv6 addresses as we need them when re-running the lookup. Some quick tests shows the patch fixes the issue. See jklimes/hostname-fixes that includes the fix and another related clean-up: http://cgit.freedesktop.org/NetworkManager/NetworkManager/log/?h=jklimes/hostname-fixes (In reply to comment #9) > Created attachment 693874 [details] > [PATCH] fix the race in getting hostname through reverse-lookup > > The described procedure looks good. I've just changed the boolean to IPv4 > and IPv6 addresses as we need them when re-running the lookup. > > Some quick tests shows the patch fixes the issue. > > See jklimes/hostname-fixes that includes the fix and another related > clean-up: > http://cgit.freedesktop.org/NetworkManager/NetworkManager/log/?h=jklimes/ > hostname-fixes Looks good; one comment though. When converting the addresses for the debug print, if the address is the full size allowed, the buffer wont' be NULL terminated. So you'll want to do INET_ADDRSTRLEN + 1 and INET6_ADDRSTRLEN + 1 and then either memset() the buffer or set the last char to 0 before calling inet_ntop(), and pass sizeof(buf) - 1 to inet_ntop() too. (In reply to comment #10) > Looks good; one comment though. When converting the addresses for the debug > print, if the address is the full size allowed, the buffer wont' be NULL > terminated. So you'll want to do INET_ADDRSTRLEN + 1 and INET6_ADDRSTRLEN + > 1 and then either memset() the buffer or set the last char to 0 before > calling inet_ntop(), and pass sizeof(buf) - 1 to inet_ntop() too. Actually, this is not necessary. INET_ADDRSTRLEN and INET6_ADDRSTRLEN macros are defined so that the length is big enough to include maximum address string including NULL character. And inet_ntop() NULL-terminates the string. http://www.informit.com/articles/article.aspx?p=169505&seqNum=7 http://sourceware.org/git/?p=glibc.git;a=blob;f=resolv/inet_ntop.c;h=6e89f2d0589ad0132c6b35f5e736014d9da02583;hb=HEAD#l78 The code has been merged into master: 07c5651a364622dbb97960cfa24f730f490a4f1a 2c69caf2d516545b0cfcc2f805fff2bb56b28fe5 and cherry-picked to nm-0-9-8: cd480fe73b3082022f188e6c99c9aadff22caadf be2e0c8adc0bfafd6489ad4e208d779815d3df49 Thanks for the review! (In reply to comment #11) > (In reply to comment #10) > > Looks good; one comment though. When converting the addresses for the debug > > print, if the address is the full size allowed, the buffer wont' be NULL > > terminated. So you'll want to do INET_ADDRSTRLEN + 1 and INET6_ADDRSTRLEN + > > 1 and then either memset() the buffer or set the last char to 0 before > > calling inet_ntop(), and pass sizeof(buf) - 1 to inet_ntop() too. > > Actually, this is not necessary. INET_ADDRSTRLEN and INET6_ADDRSTRLEN macros > are defined so that the length is big enough to include maximum address > string including NULL character. And inet_ntop() NULL-terminates the string. And today I learned something new :) I even re-read inet_ntop() manpage to see if it said *anything* about ensuring NULL-termination and couldn't find anything at all. Oh well, less confusing code then. I'm sure there's various [INET_ADDRSTRLEN + 1] bits littered all around the code; perhaps at some point we should clean those up. after clean install hostname is set This request was resolved in Red Hat Enterprise Linux 7.0. Contact your manager or support representative in case you have further questions about the request. |