On 06/13/15 at 02:51pm, Minfei Huang wrote:
The ipv6 address has the special character colon ":", so we
can use the
new function to pick it out.
We can use the new function to parse the passed parameter. The passed
parameter is hostname/domain, if it is satisfied with the condition that
it is without colon ":", and contanis the [a-zA-Z].
Add a new function to simplify to get the ip address, if the specified
address is a domain/hostname in /etc/kdump.conf.
The function will parse the passed parameter, and use the "getent ahost"
to get the ip address, if passed parameter is domain/hostname.
Signed-off-by: Minfei Huang <mhuang(a)redhat.com>
---
dracut-module-setup.sh | 1 +
kdump-lib.sh | 45 ++++++++++++++++++++++++++++++++++-----------
2 files changed, 35 insertions(+), 11 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index fd60b24..657530b 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -668,6 +668,7 @@ install() {
inst "/bin/dd" "/bin/dd"
inst "/bin/tail" "/bin/tail"
inst "/bin/date" "/bin/date"
+ inst "/bin/getent" "/bin/getent"
inst "/bin/sync" "/bin/sync"
inst "/bin/cut" "/bin/cut"
inst "/sbin/makedumpfile" "/sbin/makedumpfile"
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 1fa6058..481876b 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -229,23 +229,46 @@ get_remote_host()
echo $_config_val
}
-# check the remote server ip address tpye
-is_ipv6_target()
+# Convert hostname to ip address, echo the original value if $1 is already an ip
address.
+# $1: hostname or ip address
+get_ip_address()
{
- local _server _server_tmp
+ local _ip_address
+
+ _ip_address=`getent ahosts $1 | head -n 1 | cut -d' ' -f1`
+ _ip_address=${_ip_address:-$1}
+ echo $_ip_address
+}
+
+is_ipv6_host()
+{
+ local _addr=$(get_ip_address $1)
+ echo $_addr | grep -q ":"
+}
+
+get_network_target()
+{
+ local _target
if is_ssh_dump_target; then
- _server=`get_option_value ssh`
+ _target=`get_option_value ssh`
elif is_nfs_dump_target; then
- _server=`get_option_value nfs`
+ _target=`get_option_value nfs`
fi
- [ -z "$_server" ] && return 1
- _server=`get_remote_host $_server`
- _server_tmp=$_server
- _server=`getent ahosts $_server | head -n 1 | cut -d' ' -f1`
- _server=${_server:-$_server_tmp}
- echo $_server | grep -q ":"
+ [ -z "$_target" ] && return
+
+ _target=`get_remote_host $_target`
+ echo $_target
+}
+
+# check the remote server ip address tpye
+is_ipv6_target()
+{
+ local _target=$(get_network_target)
+
+ [ -z "$_target" ] && return 1
+ echo $(is_ipv6_host $_target)
}
is_atomic()
Seems chaowang mistakenly merged one of your patches for ipv6:
commit 63476302aa09b7844ac0fff5aa3878bcc9a5bc0d
Author: Minfei Huang <mhuang(a)redhat.com>
Date: Fri Dec 5 16:24:30 2014 +0800
We should revert the patch, and rebase your patchset so that
we can get a clean ipv6 support intead of fix things based on
the original patch.
BTW, seems DNS problems should also be taken care of..
Ideally we need below changes
1. common functions
is_ipv6_addr()
2. kdump_setup_ifname
3. ssh knownhosts
4. dns
5. static ip
6. dhcp
7. iscsi
Thanks
Dave