Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

netconsole: resolve domain name via 'getent' instead of 'hosts' #18

Merged
merged 1 commit into from
Nov 1, 2016
Merged

netconsole: resolve domain name via 'getent' instead of 'hosts' #18

merged 1 commit into from
Nov 1, 2016

Conversation

deekej
Copy link
Contributor

@deekej deekej commented Oct 28, 2016

This commit solves the issue described in RHBZ #1278519.

When the nameserver address lines are not present in /etc/resolv.conf, launching
/etc/init.d/netconsole start will result in this error:

Server address not specified in /etc/sysconfig/netconsole

This was caused by using hosts command for domain name resolution. This is now
fixed by using getent command instead.

I have improved the patch provided in the RHBZ, here is the basic overview:

  • To test if the IPV6INIT variable is set to yes, we are now using is_true
    instead of grep-ing the value from /etc/sysconfig/network directly.
  • Testing of initially set $SYSLOGADDR with regular expressions has been extended.
    The regex for IPv6 has been added, and it is unfortunately quite huge because of possible
    IPv6 variations (e.g. 4to6). It was taken from Stack Overflow and
    edited. (It does not accept the mask of IP address - e.g. /64 ). The regex has been tested via regexpal.com.
    (You can test it yourself -- copy-paste the regex there.)
  • In case no IP address is specified in $SYSLOGADDR, then we assume the domain name is used and try to resolve it. The default behaviour for
    this depends on if IPV6INIT is set, and other conditions. Excerpt from the patch:
The address resolution will follow up this scheme:
0) Is the use of IPv6 forced (by 'IPV6INIT=yes' in /etc/sysconfig/network)?
   If yes ->> use IPv6
1) If only IPv4 is available ->> use IPv4
2) If only IPv6 is available ->> use IPv6
3) If both IPv4 and IPv6 are available ->> use IPv4 by default

This should remain same for both RHEL6 and RHEL7/Fedora. I know that IPv6 is disabled on RHEL6, by default, and enabled in RHEL7/Fedora by default, but that is a separate (orthogonal) thing. When IPv6 is not forced, and both IPv4 and IPv6 are specified for the same domain name, the script will fallback to use of IPv4, which IMHO is desirable. IOW, the script is not forcing IPv6 on user unless there's no other IP available for that specific domain name.

I have successfully tested the patch on RHEL-6.8.

# 1) If only IPv4 is available ->> use IPv4
# 2) If only IPv6 is available ->> use IPv6
# 3) If both IPv4 and IPv6 are available ->> use IPv4 by default
if ! is_true "$IPV6INIT"; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the case where I have IPv6 enabled (default case in upstream), but my log server only has ipv4 address?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the patch to use IPv4 by default, and fallback to IPv6 if the resolution fails. Please, see the updated commit.

@deekej deekej dismissed lnykryn’s stale review October 31, 2016 16:29

Updated commit provided.

@lnykryn
Copy link
Member

lnykryn commented Nov 1, 2016

Seems to work :-)

@lnykryn lnykryn merged commit 78ebd68 into fedora-sysv:master Nov 1, 2016
@deekej deekej deleted the rhbz/1278519 branch November 1, 2016 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants