v6: - construct the patches, split more small patches - wrap the similar functional code to make it more clearly v5: - modify the get_route function v4: - consistent the netdevice name to add the prefix "kdump-" before the ethX v3: - Support the static route v2: - Fix some bugs
Minfei Huang (4): mkdumprd: Add proper prefix "kdump-" before ethX in 2nd kernel kdump-lib: Add new lib to identify the ipv6 address or not dracut-module-setup: Wrap the similar functional code to the function ipv6: Enhance kdump to support ipv6
dracut-kdump.sh | 8 +- dracut-module-setup.sh | 204 ++++++++++++++++++++++++++++++++++--------------- kdump-lib.sh | 26 +++++-- mkdumprd | 17 ++++- 4 files changed, 185 insertions(+), 70 deletions(-)
The ipv6 link scope needs to append the netdevice to identify the ipv6 address.
Due to add prefix "kdump-" before ethX(commit: ba7660f) in the 2nd kernel, we should correct the mount parameter and /etc/kdump.conf to add the prefix "kdump-" before ethX, if use the ipv6 link scope.
Signed-off-by: Minfei Huang mhuang@redhat.com --- dracut-module-setup.sh | 19 +++++++++++++++++++ kdump-lib.sh | 2 +- mkdumprd | 17 ++++++++++++++++- 3 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index d65c8c0..c704a65 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -363,6 +363,25 @@ kdump_install_conf() { default_dump_target_install_conf
kdump_configure_fence_kdump "/tmp/$$-kdump.conf" + + if is_ipv6_target; then + local _srcaddr + if is_ssh_dump_target; then + _srcaddr=$(get_option_value ssh) + elif is_nfs_dump_target; then + _srcaddr=$(get_option_value nfs) + fi + + if [ "x" != "x"$_srcaddr ] && `echo $_srcaddr | grep -q "%"`; then + local _netdev=${_srcaddr#*%} + _netdev=${_netdev%]*} + local _pre_netdev=$(kdump_setup_ifname $_netdev) + if [ "x"$_netdev != "x"$_pre_netdev ]; then + sed -i "s#$_netdev#$_pre_netdev#" "/tmp/$$-kdump.conf" + fi + fi + fi + inst "/tmp/$$-kdump.conf" "/etc/kdump.conf" rm -f /tmp/$$-kdump.conf } diff --git a/kdump-lib.sh b/kdump-lib.sh index f24f08d..b886c5d 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -146,7 +146,7 @@ check_save_path_fs() kdump_setup_ifname() { local _ifname
- if [[ $1 =~ eth* ]]; then + if [[ "$1" =~ eth* ]]; then _ifname="kdump-$1" else _ifname="$1" diff --git a/mkdumprd b/mkdumprd index a30d9ca..a066d7b 100644 --- a/mkdumprd +++ b/mkdumprd @@ -78,8 +78,23 @@ add_dracut_module() { add_dracut_arg "--add" "$1" }
+# The ipv6 link scope which appends the netdevice to identify the ipv6 +# address is start with prefix "fe80", so we should correct the mount +# parameter to add the prefix "kdump-" before ethX. add_dracut_mount() { - add_dracut_arg "--mount" "$1" + local _val="$1" + + if is_ipv6_target && is_nfs_dump_target; then + local _srcaddr=$(get_option_value nfs) + if `echo "$_val" | grep -q "^[fe80"`; then + local _prefix="${_val%%%*}" + local _netdev="${_val#*%}" + _netdev=$(kdump_setup_ifname "$_netdev") + _val="$_prefix"%"$_netdev" + fi + fi + + add_dracut_arg "--mount" "$_val" }
add_dracut_sshkey() {
Hi, Minfei
A few comments from me, Bao, can you review it as well especially the network part?
On 12/15/14 at 11:20am, Minfei Huang wrote:
The ipv6 link scope needs to append the netdevice to identify the ipv6 address.
Due to add prefix "kdump-" before ethX(commit: ba7660f) in the 2nd kernel, we should correct the mount parameter and /etc/kdump.conf to add the prefix "kdump-" before ethX, if use the ipv6 link scope.
Signed-off-by: Minfei Huang mhuang@redhat.com
dracut-module-setup.sh | 19 +++++++++++++++++++ kdump-lib.sh | 2 +- mkdumprd | 17 ++++++++++++++++- 3 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index d65c8c0..c704a65 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -363,6 +363,25 @@ kdump_install_conf() { default_dump_target_install_conf
kdump_configure_fence_kdump "/tmp/$$-kdump.conf"
- if is_ipv6_target; then
Seems only ipv6 addresses could contains '%', so how about remove the above check?
local _srcaddr
if is_ssh_dump_target; then
_srcaddr=$(get_option_value ssh)
elif is_nfs_dump_target; then
_srcaddr=$(get_option_value nfs)
fi
If call it in the config passing while loop then it will be cleaner.
if [ "x" != "x"$_srcaddr ] && `echo $_srcaddr | grep -q "%"`; then
local _netdev=${_srcaddr#*\%}
_netdev=${_netdev%]*}
local _pre_netdev=$(kdump_setup_ifname $_netdev)
if [ "x"$_netdev != "x"$_pre_netdev ]; then
sed -i "s#$_netdev#$_pre_netdev#" "/tmp/$$-kdump.conf"
fi
fi
- fi
Above can become a function like kdump_ipv6_fixup(), call it like below:
while read config_opt config_val; do [snip] ssh|nfs) kdump_install_net "$config_val" kdump_ipv6_fixup "$config_val"
inst "/tmp/$$-kdump.conf" "/etc/kdump.conf" rm -f /tmp/$$-kdump.conf
} diff --git a/kdump-lib.sh b/kdump-lib.sh index f24f08d..b886c5d 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -146,7 +146,7 @@ check_save_path_fs() kdump_setup_ifname() { local _ifname
- if [[ $1 =~ eth* ]]; then
- if [[ "$1" =~ eth* ]]; then
It is not relevant to the patch?
_ifname="kdump-$1" else _ifname="$1"
diff --git a/mkdumprd b/mkdumprd index a30d9ca..a066d7b 100644 --- a/mkdumprd +++ b/mkdumprd @@ -78,8 +78,23 @@ add_dracut_module() { add_dracut_arg "--add" "$1" }
+# The ipv6 link scope which appends the netdevice to identify the ipv6 +# address is start with prefix "fe80", so we should correct the mount +# parameter to add the prefix "kdump-" before ethX. add_dracut_mount() {
- add_dracut_arg "--mount" "$1"
- local _val="$1"
- if is_ipv6_target && is_nfs_dump_target; then
local _srcaddr=$(get_option_value nfs)
if `echo "$_val" | grep -q "^\[fe80"`; then
fe80.* should be a link-local address, what about non-local addresses? Correct me if I'm wrong I think I know little about ipv6, basicly we should cover all kinds of ipv6 addresses.
local _prefix="${_val%%\%*}"
local _netdev="${_val#*\%}"
_netdev=$(kdump_setup_ifname "$_netdev")
Shouldn't the setup being called in module_setup.sh instead of mkdumprd, Is there a better way to handle this in a general function in module_setup.sh?
_val="$_prefix"%"$_netdev"
fi
- fi
- add_dracut_arg "--mount" "$_val"
}
add_dracut_sshkey() {
1.8.3.1
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 12/29/14 at 03:24pm, Dave Young wrote:
Hi, Minfei
A few comments from me, Bao, can you review it as well especially the network part?
On 12/15/14 at 11:20am, Minfei Huang wrote:
The ipv6 link scope needs to append the netdevice to identify the ipv6 address.
Due to add prefix "kdump-" before ethX(commit: ba7660f) in the 2nd kernel, we should correct the mount parameter and /etc/kdump.conf to add the prefix "kdump-" before ethX, if use the ipv6 link scope.
Signed-off-by: Minfei Huang mhuang@redhat.com
dracut-module-setup.sh | 19 +++++++++++++++++++ kdump-lib.sh | 2 +- mkdumprd | 17 ++++++++++++++++- 3 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index d65c8c0..c704a65 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -363,6 +363,25 @@ kdump_install_conf() { default_dump_target_install_conf
kdump_configure_fence_kdump "/tmp/$$-kdump.conf"
- if is_ipv6_target; then
Seems only ipv6 addresses could contains '%', so how about remove the above check?
You means remove the code "if is_ipv6_target"?
local _srcaddr
if is_ssh_dump_target; then
_srcaddr=$(get_option_value ssh)
elif is_nfs_dump_target; then
_srcaddr=$(get_option_value nfs)
fi
If call it in the config passing while loop then it will be cleaner.
if [ "x" != "x"$_srcaddr ] && `echo $_srcaddr | grep -q "%"`; then
local _netdev=${_srcaddr#*\%}
_netdev=${_netdev%]*}
local _pre_netdev=$(kdump_setup_ifname $_netdev)
if [ "x"$_netdev != "x"$_pre_netdev ]; then
sed -i "s#$_netdev#$_pre_netdev#" "/tmp/$$-kdump.conf"
fi
fi
- fi
Above can become a function like kdump_ipv6_fixup(), call it like below:
while read config_opt config_val; do
[snip] ssh|nfs) kdump_install_net "$config_val" kdump_ipv6_fixup "$config_val"
Good idea. will use it.
inst "/tmp/$$-kdump.conf" "/etc/kdump.conf" rm -f /tmp/$$-kdump.conf
} diff --git a/kdump-lib.sh b/kdump-lib.sh index f24f08d..b886c5d 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -146,7 +146,7 @@ check_save_path_fs() kdump_setup_ifname() { local _ifname
- if [[ $1 =~ eth* ]]; then
- if [[ "$1" =~ eth* ]]; then
It is not relevant to the patch?
The parameter may contain the blank, if calls by other functions, like the function add_dracut_module. So in order to make it correct, quote the parameter.
_ifname="kdump-$1" else _ifname="$1"
diff --git a/mkdumprd b/mkdumprd index a30d9ca..a066d7b 100644 --- a/mkdumprd +++ b/mkdumprd @@ -78,8 +78,23 @@ add_dracut_module() { add_dracut_arg "--add" "$1" }
+# The ipv6 link scope which appends the netdevice to identify the ipv6 +# address is start with prefix "fe80", so we should correct the mount +# parameter to add the prefix "kdump-" before ethX. add_dracut_mount() {
- add_dracut_arg "--mount" "$1"
- local _val="$1"
- if is_ipv6_target && is_nfs_dump_target; then
local _srcaddr=$(get_option_value nfs)
if `echo "$_val" | grep -q "^\[fe80"`; then
fe80.* should be a link-local address, what about non-local addresses? Correct me if I'm wrong I think I know little about ipv6, basicly we should cover all kinds of ipv6 addresses.
See the above comment.
The ipv6 link scope will append the network device to identify the ipv6 address. But non-local address does not need.
We can not filte it using character "%", because the _val value contains the character "%".
local _prefix="${_val%%\%*}"
local _netdev="${_val#*\%}"
_netdev=$(kdump_setup_ifname "$_netdev")
Shouldn't the setup being called in module_setup.sh instead of mkdumprd, Is there a better way to handle this in a general function in module_setup.sh?
The kdump will use command findmnt to get the SOURCE/MNTPOINT in script mkdumprd. So we can modify the ipv6 link scope only in the script mkdumprd.
_val="$_prefix"%"$_netdev"
fi
- fi
- add_dracut_arg "--mount" "$_val"
}
add_dracut_sshkey() {
1.8.3.1
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 01/04/15 at 07:15pm, Minfei Huang wrote:
On 12/29/14 at 03:24pm, Dave Young wrote:
Hi, Minfei
A few comments from me, Bao, can you review it as well especially the network part?
On 12/15/14 at 11:20am, Minfei Huang wrote:
The ipv6 link scope needs to append the netdevice to identify the ipv6 address.
Due to add prefix "kdump-" before ethX(commit: ba7660f) in the 2nd kernel, we should correct the mount parameter and /etc/kdump.conf to add the prefix "kdump-" before ethX, if use the ipv6 link scope.
Signed-off-by: Minfei Huang mhuang@redhat.com
dracut-module-setup.sh | 19 +++++++++++++++++++ kdump-lib.sh | 2 +- mkdumprd | 17 ++++++++++++++++- 3 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index d65c8c0..c704a65 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -363,6 +363,25 @@ kdump_install_conf() { default_dump_target_install_conf
kdump_configure_fence_kdump "/tmp/$$-kdump.conf"
- if is_ipv6_target; then
Seems only ipv6 addresses could contains '%', so how about remove the above check?
You means remove the code "if is_ipv6_target"?
Yes.
local _srcaddr
if is_ssh_dump_target; then
_srcaddr=$(get_option_value ssh)
elif is_nfs_dump_target; then
_srcaddr=$(get_option_value nfs)
fi
If call it in the config passing while loop then it will be cleaner.
if [ "x" != "x"$_srcaddr ] && `echo $_srcaddr | grep -q "%"`; then
local _netdev=${_srcaddr#*\%}
_netdev=${_netdev%]*}
local _pre_netdev=$(kdump_setup_ifname $_netdev)
if [ "x"$_netdev != "x"$_pre_netdev ]; then
sed -i "s#$_netdev#$_pre_netdev#" "/tmp/$$-kdump.conf"
fi
fi
- fi
Above can become a function like kdump_ipv6_fixup(), call it like below:
while read config_opt config_val; do
[snip] ssh|nfs) kdump_install_net "$config_val" kdump_ipv6_fixup "$config_val"
Good idea. will use it.
inst "/tmp/$$-kdump.conf" "/etc/kdump.conf" rm -f /tmp/$$-kdump.conf
} diff --git a/kdump-lib.sh b/kdump-lib.sh index f24f08d..b886c5d 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -146,7 +146,7 @@ check_save_path_fs() kdump_setup_ifname() { local _ifname
- if [[ $1 =~ eth* ]]; then
- if [[ "$1" =~ eth* ]]; then
It is not relevant to the patch?
The parameter may contain the blank, if calls by other functions, like the function add_dracut_module. So in order to make it correct, quote the parameter.
Agree, I means it can be in another cleanup patch, but it is trival so I will not insist.
_ifname="kdump-$1" else _ifname="$1"
diff --git a/mkdumprd b/mkdumprd index a30d9ca..a066d7b 100644 --- a/mkdumprd +++ b/mkdumprd @@ -78,8 +78,23 @@ add_dracut_module() { add_dracut_arg "--add" "$1" }
+# The ipv6 link scope which appends the netdevice to identify the ipv6 +# address is start with prefix "fe80", so we should correct the mount +# parameter to add the prefix "kdump-" before ethX. add_dracut_mount() {
- add_dracut_arg "--mount" "$1"
- local _val="$1"
- if is_ipv6_target && is_nfs_dump_target; then
local _srcaddr=$(get_option_value nfs)
if `echo "$_val" | grep -q "^\[fe80"`; then
fe80.* should be a link-local address, what about non-local addresses? Correct me if I'm wrong I think I know little about ipv6, basicly we should cover all kinds of ipv6 addresses.
See the above comment.
The ipv6 link scope will append the network device to identify the ipv6 address. But non-local address does not need.
We can not filte it using character "%", because the _val value contains the character "%".
Ok, got your point, but the checking for ipv6 target is still questionable. Like I commented in another patch, we should only cover ipv6 addresses in kdump.conf not the hostname case.
local _prefix="${_val%%\%*}"
local _netdev="${_val#*\%}"
_netdev=$(kdump_setup_ifname "$_netdev")
Shouldn't the setup being called in module_setup.sh instead of mkdumprd, Is there a better way to handle this in a general function in module_setup.sh?
The kdump will use command findmnt to get the SOURCE/MNTPOINT in script mkdumprd. So we can modify the ipv6 link scope only in the script mkdumprd.
Ok, make sense then.
_val="$_prefix"%"$_netdev"
fi
- fi
- add_dracut_arg "--mount" "$_val"
}
add_dracut_sshkey() {
1.8.3.1
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 01/05/15 at 10:19am, Dave Young wrote:
On 01/04/15 at 07:15pm, Minfei Huang wrote:
On 12/29/14 at 03:24pm, Dave Young wrote:
Hi, Minfei
A few comments from me, Bao, can you review it as well especially the network part?
On 12/15/14 at 11:20am, Minfei Huang wrote:
The ipv6 link scope needs to append the netdevice to identify the ipv6 address.
Due to add prefix "kdump-" before ethX(commit: ba7660f) in the 2nd kernel, we should correct the mount parameter and /etc/kdump.conf to add the prefix "kdump-" before ethX, if use the ipv6 link scope.
Signed-off-by: Minfei Huang mhuang@redhat.com
dracut-module-setup.sh | 19 +++++++++++++++++++ kdump-lib.sh | 2 +- mkdumprd | 17 ++++++++++++++++- 3 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index d65c8c0..c704a65 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -363,6 +363,25 @@ kdump_install_conf() { default_dump_target_install_conf
kdump_configure_fence_kdump "/tmp/$$-kdump.conf"
- if is_ipv6_target; then
Seems only ipv6 addresses could contains '%', so how about remove the above check?
You means remove the code "if is_ipv6_target"?
Yes.
local _srcaddr
if is_ssh_dump_target; then
_srcaddr=$(get_option_value ssh)
elif is_nfs_dump_target; then
_srcaddr=$(get_option_value nfs)
fi
If call it in the config passing while loop then it will be cleaner.
if [ "x" != "x"$_srcaddr ] && `echo $_srcaddr | grep -q "%"`; then
local _netdev=${_srcaddr#*\%}
_netdev=${_netdev%]*}
local _pre_netdev=$(kdump_setup_ifname $_netdev)
if [ "x"$_netdev != "x"$_pre_netdev ]; then
sed -i "s#$_netdev#$_pre_netdev#" "/tmp/$$-kdump.conf"
fi
fi
- fi
Above can become a function like kdump_ipv6_fixup(), call it like below:
while read config_opt config_val; do
[snip] ssh|nfs) kdump_install_net "$config_val" kdump_ipv6_fixup "$config_val"
Good idea. will use it.
inst "/tmp/$$-kdump.conf" "/etc/kdump.conf" rm -f /tmp/$$-kdump.conf
} diff --git a/kdump-lib.sh b/kdump-lib.sh index f24f08d..b886c5d 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -146,7 +146,7 @@ check_save_path_fs() kdump_setup_ifname() { local _ifname
- if [[ $1 =~ eth* ]]; then
- if [[ "$1" =~ eth* ]]; then
It is not relevant to the patch?
The parameter may contain the blank, if calls by other functions, like the function add_dracut_module. So in order to make it correct, quote the parameter.
Agree, I means it can be in another cleanup patch, but it is trival so I will not insist.
Yes, there are several trival patches to support ipv6. It is more confusing, if we patch it single.
_ifname="kdump-$1" else _ifname="$1"
diff --git a/mkdumprd b/mkdumprd index a30d9ca..a066d7b 100644 --- a/mkdumprd +++ b/mkdumprd @@ -78,8 +78,23 @@ add_dracut_module() { add_dracut_arg "--add" "$1" }
+# The ipv6 link scope which appends the netdevice to identify the ipv6 +# address is start with prefix "fe80", so we should correct the mount +# parameter to add the prefix "kdump-" before ethX. add_dracut_mount() {
- add_dracut_arg "--mount" "$1"
- local _val="$1"
- if is_ipv6_target && is_nfs_dump_target; then
local _srcaddr=$(get_option_value nfs)
if `echo "$_val" | grep -q "^\[fe80"`; then
fe80.* should be a link-local address, what about non-local addresses? Correct me if I'm wrong I think I know little about ipv6, basicly we should cover all kinds of ipv6 addresses.
See the above comment.
The ipv6 link scope will append the network device to identify the ipv6 address. But non-local address does not need.
We can not filte it using character "%", because the _val value contains the character "%".
Ok, got your point, but the checking for ipv6 target is still questionable. Like I commented in another patch, we should only cover ipv6 addresses in kdump.conf not the hostname case.
We may consider the case which the hostname/domain is only support ipv6 address. So we will parse the target value which is the domain/hostname only supported by ipv6 address in the is_ipv6_target function.
local _prefix="${_val%%\%*}"
local _netdev="${_val#*\%}"
_netdev=$(kdump_setup_ifname "$_netdev")
Shouldn't the setup being called in module_setup.sh instead of mkdumprd, Is there a better way to handle this in a general function in module_setup.sh?
The kdump will use command findmnt to get the SOURCE/MNTPOINT in script mkdumprd. So we can modify the ipv6 link scope only in the script mkdumprd.
Ok, make sense then.
_val="$_prefix"%"$_netdev"
fi
- fi
- add_dracut_arg "--mount" "$_val"
}
add_dracut_sshkey() {
1.8.3.1
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
Add the new lib which checks the ip/domain which you give. Return true, if the parameter is ipv6, otherwise return false.
Signed-off-by: Minfei Huang mhuang@redhat.com --- kdump-lib.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index b886c5d..acb085e 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -170,10 +170,26 @@ get_remote_host() echo $_config_val }
+get_ip_address() +{ + local _server=$1 _server_tmp + + _server_tmp=$_server + _server=`getent ahosts $_server | head -n 1 | cut -d' ' -f1` + _server=${_server:-$_server_tmp} + echo $_server +} + +is_ipv6_address() +{ + local _server=$(get_ip_address $1) + echo $_server | grep -q ":" +} + # check the remote server ip address tpye is_ipv6_target() { - local _server _server_tmp + local _server
if is_ssh_dump_target; then _server=`get_option_value ssh` @@ -183,8 +199,6 @@ is_ipv6_target()
[ -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 ":" + + echo $(get_ip_address $_server) | grep -q ":" }
Hi, Minfei
On 12/15/14 at 11:20am, Minfei Huang wrote:
Add the new lib which checks the ip/domain which you give. Return true, if the parameter is ipv6, otherwise return false.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index b886c5d..acb085e 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -170,10 +170,26 @@ get_remote_host() echo $_config_val }
+get_ip_address() +{
- local _server=$1 _server_tmp
- _server_tmp=$_server
- _server=`getent ahosts $_server | head -n 1 | cut -d' ' -f1`
- _server=${_server:-$_server_tmp}
- echo $_server
+}
+is_ipv6_address() +{
- local _server=$(get_ip_address $1)
- echo $_server | grep -q ":"
+}
# check the remote server ip address tpye is_ipv6_target() {
- local _server _server_tmp
local _server
if is_ssh_dump_target; then _server=`get_option_value ssh`
@@ -183,8 +199,6 @@ is_ipv6_target()
[ -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 ":"
- echo $(get_ip_address $_server) | grep -q ":"
}
Logically this should be the first patch in the series since patch 1/4 is using the function is_ipv6_target
-- 1.8.3.1
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 12/22/14 at 04:02pm, Dave Young wrote:
Hi, Minfei
On 12/15/14 at 11:20am, Minfei Huang wrote:
Add the new lib which checks the ip/domain which you give. Return true, if the parameter is ipv6, otherwise return false.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index b886c5d..acb085e 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -170,10 +170,26 @@ get_remote_host() echo $_config_val }
+get_ip_address() +{
- local _server=$1 _server_tmp
- _server_tmp=$_server
- _server=`getent ahosts $_server | head -n 1 | cut -d' ' -f1`
- _server=${_server:-$_server_tmp}
- echo $_server
+}
+is_ipv6_address() +{
- local _server=$(get_ip_address $1)
- echo $_server | grep -q ":"
+}
# check the remote server ip address tpye is_ipv6_target() {
- local _server _server_tmp
local _server
if is_ssh_dump_target; then _server=`get_option_value ssh`
@@ -183,8 +199,6 @@ is_ipv6_target()
[ -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 ":"
- echo $(get_ip_address $_server) | grep -q ":"
}
Logically this should be the first patch in the series since patch 1/4 is using the function is_ipv6_target
Oops, is_ipv6_target is already in our code, please ignore the comment.
On 12/22/14 at 04:02pm, Dave Young wrote:
Hi, Minfei
On 12/15/14 at 11:20am, Minfei Huang wrote:
Add the new lib which checks the ip/domain which you give. Return true, if the parameter is ipv6, otherwise return false.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index b886c5d..acb085e 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -170,10 +170,26 @@ get_remote_host() echo $_config_val }
+get_ip_address() +{
- local _server=$1 _server_tmp
- _server_tmp=$_server
- _server=`getent ahosts $_server | head -n 1 | cut -d' ' -f1`
- _server=${_server:-$_server_tmp}
- echo $_server
+}
+is_ipv6_address() +{
- local _server=$(get_ip_address $1)
- echo $_server | grep -q ":"
+}
# check the remote server ip address tpye is_ipv6_target() {
- local _server _server_tmp
local _server
if is_ssh_dump_target; then _server=`get_option_value ssh`
@@ -183,8 +199,6 @@ is_ipv6_target()
[ -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 ":"
- echo $(get_ip_address $_server) | grep -q ":"
}
Logically this should be the first patch in the series since patch 1/4 is using the function is_ipv6_target
The next patch will use the function is_ipv6_address, so I modify the function is_ipv6_target to re-use the code. And there is no bussiness with the previous patch which uses function is_ipv6_target.
Thanks Minfei
-- 1.8.3.1
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 12/15/14 at 11:20am, Minfei Huang wrote:
Add the new lib which checks the ip/domain which you give. Return true, if the parameter is ipv6, otherwise return false.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index b886c5d..acb085e 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -170,10 +170,26 @@ get_remote_host() echo $_config_val }
+get_ip_address() +{
- local _server=$1 _server_tmp
- _server_tmp=$_server
It is not necessary to assign initial value to _server, directly use $1 is ok. seems $_server_tmp is also redundant
- _server=`getent ahosts $_server | head -n 1 | cut -d' ' -f1`
- _server=${_server:-$_server_tmp}
Could you tell what's the purpose of above line?
- echo $_server
+}
+is_ipv6_address() +{
- local _server=$(get_ip_address $1)
If the function name is is_ipv6_addresses, it assume the input $1 is an address, so the caller should pass an ip address?
- echo $_server | grep -q ":"
+}
# check the remote server ip address tpye is_ipv6_target() {
- local _server _server_tmp
local _server
if is_ssh_dump_target; then _server=`get_option_value ssh`
@@ -183,8 +199,6 @@ is_ipv6_target()
[ -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 ":"
- echo $(get_ip_address $_server) | grep -q ":"
}
1.8.3.1
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 12/29/14 at 03:35pm, Dave Young wrote:
On 12/15/14 at 11:20am, Minfei Huang wrote:
Add the new lib which checks the ip/domain which you give. Return true, if the parameter is ipv6, otherwise return false.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index b886c5d..acb085e 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -170,10 +170,26 @@ get_remote_host() echo $_config_val }
+get_ip_address() +{
- local _server=$1 _server_tmp
- _server_tmp=$_server
It is not necessary to assign initial value to _server, directly use $1 is ok. seems $_server_tmp is also redundant
The original value of parameter may be used if the parameter is ip address. So the _server_tmp stores the original value.
- _server=`getent ahosts $_server | head -n 1 | cut -d' ' -f1`
- _server=${_server:-$_server_tmp}
Could you tell what's the purpose of above line?
We will get nothing by executing "getent" if the parameter is ip address. We use the obove line to promise the _server value is correct. If the parameter is ip address, give the original value to the _server.
- echo $_server
+}
+is_ipv6_address() +{
- local _server=$(get_ip_address $1)
If the function name is is_ipv6_addresses, it assume the input $1 is an address, so the caller should pass an ip address?
The function can handle the domain/ip as the parameter, not only the ip address. And what the function is_ipv6_address meaning is the final ip is v6, or not. Maybe we will parse the parameter(like domain) to get the real ip.
- echo $_server | grep -q ":"
+}
# check the remote server ip address tpye is_ipv6_target() {
- local _server _server_tmp
local _server
if is_ssh_dump_target; then _server=`get_option_value ssh`
@@ -183,8 +199,6 @@ is_ipv6_target()
[ -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 ":"
- echo $(get_ip_address $_server) | grep -q ":"
}
1.8.3.1
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 12/31/14 at 11:02am, Minfei Huang wrote:
On 12/29/14 at 03:35pm, Dave Young wrote:
On 12/15/14 at 11:20am, Minfei Huang wrote:
Add the new lib which checks the ip/domain which you give. Return true, if the parameter is ipv6, otherwise return false.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index b886c5d..acb085e 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -170,10 +170,26 @@ get_remote_host() echo $_config_val }
+get_ip_address() +{
- local _server=$1 _server_tmp
- _server_tmp=$_server
It is not necessary to assign initial value to _server, directly use $1 is ok. seems $_server_tmp is also redundant
The original value of parameter may be used if the parameter is ip address. So the _server_tmp stores the original value.
$1 will be ok for that purpose..
- _server=`getent ahosts $_server | head -n 1 | cut -d' ' -f1`
- _server=${_server:-$_server_tmp}
Could you tell what's the purpose of above line?
We will get nothing by executing "getent" if the parameter is ip address. We use the obove line to promise the _server value is correct. If the parameter is ip address, give the original value to the _server.
Ok, thanks for explanation.
- echo $_server
+}
+is_ipv6_address() +{
- local _server=$(get_ip_address $1)
If the function name is is_ipv6_addresses, it assume the input $1 is an address, so the caller should pass an ip address?
The function can handle the domain/ip as the parameter, not only the ip address. And what the function is_ipv6_address meaning is the final ip is v6, or not. Maybe we will parse the parameter(like domain) to get the real ip.
If the kdump.conf config value is hostname, we do not care if it is ipv6 or ipv4, right? I remember it will naturally works without this patchset.
- echo $_server | grep -q ":"
+}
# check the remote server ip address tpye is_ipv6_target() {
- local _server _server_tmp
local _server
if is_ssh_dump_target; then _server=`get_option_value ssh`
@@ -183,8 +199,6 @@ is_ipv6_target()
[ -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 ":"
- echo $(get_ip_address $_server) | grep -q ":"
}
1.8.3.1
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 01/04/15 at 01:26pm, Dave Young wrote:
On 12/31/14 at 11:02am, Minfei Huang wrote:
On 12/29/14 at 03:35pm, Dave Young wrote:
On 12/15/14 at 11:20am, Minfei Huang wrote:
Add the new lib which checks the ip/domain which you give. Return true, if the parameter is ipv6, otherwise return false.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index b886c5d..acb085e 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -170,10 +170,26 @@ get_remote_host() echo $_config_val }
+get_ip_address() +{
- local _server=$1 _server_tmp
- _server_tmp=$_server
It is not necessary to assign initial value to _server, directly use $1 is ok. seems $_server_tmp is also redundant
The original value of parameter may be used if the parameter is ip address. So the _server_tmp stores the original value.
$1 will be ok for that purpose..
- _server=`getent ahosts $_server | head -n 1 | cut -d' ' -f1`
- _server=${_server:-$_server_tmp}
Could you tell what's the purpose of above line?
We will get nothing by executing "getent" if the parameter is ip address. We use the obove line to promise the _server value is correct. If the parameter is ip address, give the original value to the _server.
Ok, thanks for explanation.
- echo $_server
+}
+is_ipv6_address() +{
- local _server=$(get_ip_address $1)
If the function name is is_ipv6_addresses, it assume the input $1 is an address, so the caller should pass an ip address?
The function can handle the domain/ip as the parameter, not only the ip address. And what the function is_ipv6_address meaning is the final ip is v6, or not. Maybe we will parse the parameter(like domain) to get the real ip.
If the kdump.conf config value is hostname, we do not care if it is ipv6 or ipv4, right? I remember it will naturally works without this patchset.
We would use the result which gets by executing command "getent ahosts $_server | head -n 1 | cut -d' ' -f1" as the ip address, if the kdump.conf config value is domain/hostname.
We would get the ip address by executing command "getent host $_server" previously. So it does not work if returns the ipv6 address.
Here is the case: mhuang $ getent hosts baidu.com 220.181.57.217 baidu.com 123.125.114.144 baidu.com 220.181.57.216 baidu.com mhuang $ getent hosts google.com 2404:6800:4005:801::1002 google.com
- echo $_server | grep -q ":"
+}
# check the remote server ip address tpye is_ipv6_target() {
- local _server _server_tmp
local _server
if is_ssh_dump_target; then _server=`get_option_value ssh`
@@ -183,8 +199,6 @@ is_ipv6_target()
[ -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 ":"
- echo $(get_ip_address $_server) | grep -q ":"
}
1.8.3.1
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 01/04/15 at 06:27pm, Minfei Huang wrote:
On 01/04/15 at 01:26pm, Dave Young wrote:
On 12/31/14 at 11:02am, Minfei Huang wrote:
On 12/29/14 at 03:35pm, Dave Young wrote:
On 12/15/14 at 11:20am, Minfei Huang wrote:
Add the new lib which checks the ip/domain which you give. Return true, if the parameter is ipv6, otherwise return false.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index b886c5d..acb085e 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -170,10 +170,26 @@ get_remote_host() echo $_config_val }
+get_ip_address() +{
- local _server=$1 _server_tmp
- _server_tmp=$_server
It is not necessary to assign initial value to _server, directly use $1 is ok. seems $_server_tmp is also redundant
The original value of parameter may be used if the parameter is ip address. So the _server_tmp stores the original value.
$1 will be ok for that purpose..
- _server=`getent ahosts $_server | head -n 1 | cut -d' ' -f1`
- _server=${_server:-$_server_tmp}
Could you tell what's the purpose of above line?
We will get nothing by executing "getent" if the parameter is ip address. We use the obove line to promise the _server value is correct. If the parameter is ip address, give the original value to the _server.
Ok, thanks for explanation.
- echo $_server
+}
+is_ipv6_address() +{
- local _server=$(get_ip_address $1)
If the function name is is_ipv6_addresses, it assume the input $1 is an address, so the caller should pass an ip address?
The function can handle the domain/ip as the parameter, not only the ip address. And what the function is_ipv6_address meaning is the final ip is v6, or not. Maybe we will parse the parameter(like domain) to get the real ip.
If the kdump.conf config value is hostname, we do not care if it is ipv6 or ipv4, right? I remember it will naturally works without this patchset.
We would use the result which gets by executing command "getent ahosts $_server | head -n 1 | cut -d' ' -f1" as the ip address, if the kdump.conf config value is domain/hostname.
We would get the ip address by executing command "getent host $_server" previously. So it does not work if returns the ipv6 address.
What do you mean for "it does not work", sorry I still do not understand your point.
Here is the case: mhuang $ getent hosts baidu.com 220.181.57.217 baidu.com 123.125.114.144 baidu.com 220.181.57.216 baidu.com mhuang $ getent hosts google.com 2404:6800:4005:801::1002 google.com
- echo $_server | grep -q ":"
+}
# check the remote server ip address tpye is_ipv6_target() {
- local _server _server_tmp
local _server
if is_ssh_dump_target; then _server=`get_option_value ssh`
@@ -183,8 +199,6 @@ is_ipv6_target()
[ -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 ":"
- echo $(get_ip_address $_server) | grep -q ":"
}
1.8.3.1
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 01/05/15 at 10:23am, Dave Young wrote:
On 01/04/15 at 06:27pm, Minfei Huang wrote:
On 01/04/15 at 01:26pm, Dave Young wrote:
On 12/31/14 at 11:02am, Minfei Huang wrote:
On 12/29/14 at 03:35pm, Dave Young wrote:
On 12/15/14 at 11:20am, Minfei Huang wrote:
Add the new lib which checks the ip/domain which you give. Return true, if the parameter is ipv6, otherwise return false.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index b886c5d..acb085e 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -170,10 +170,26 @@ get_remote_host() echo $_config_val }
+get_ip_address() +{
- local _server=$1 _server_tmp
- _server_tmp=$_server
It is not necessary to assign initial value to _server, directly use $1 is ok. seems $_server_tmp is also redundant
The original value of parameter may be used if the parameter is ip address. So the _server_tmp stores the original value.
$1 will be ok for that purpose..
- _server=`getent ahosts $_server | head -n 1 | cut -d' ' -f1`
- _server=${_server:-$_server_tmp}
Could you tell what's the purpose of above line?
We will get nothing by executing "getent" if the parameter is ip address. We use the obove line to promise the _server value is correct. If the parameter is ip address, give the original value to the _server.
Ok, thanks for explanation.
- echo $_server
+}
+is_ipv6_address() +{
- local _server=$(get_ip_address $1)
If the function name is is_ipv6_addresses, it assume the input $1 is an address, so the caller should pass an ip address?
The function can handle the domain/ip as the parameter, not only the ip address. And what the function is_ipv6_address meaning is the final ip is v6, or not. Maybe we will parse the parameter(like domain) to get the real ip.
If the kdump.conf config value is hostname, we do not care if it is ipv6 or ipv4, right? I remember it will naturally works without this patchset.
We would use the result which gets by executing command "getent ahosts $_server | head -n 1 | cut -d' ' -f1" as the ip address, if the kdump.conf config value is domain/hostname.
We would get the ip address by executing command "getent host $_server" previously. So it does not work if returns the ipv6 address.
What do you mean for "it does not work", sorry I still do not understand your point.
We can not make sure that ip address which returns by executing command "getent host $_server" is ipv4 address. For below instance, it would return the ipv6 address, if we get the ip address of domain "google.com". Thus, the kdump does not work well.
Here is the case: mhuang $ getent hosts baidu.com 220.181.57.217 baidu.com 123.125.114.144 baidu.com 220.181.57.216 baidu.com
Here is the instance:
mhuang $ getent hosts google.com 2404:6800:4005:801::1002 google.com
- echo $_server | grep -q ":"
+}
# check the remote server ip address tpye is_ipv6_target() {
- local _server _server_tmp
local _server
if is_ssh_dump_target; then _server=`get_option_value ssh`
@@ -183,8 +199,6 @@ is_ipv6_target()
[ -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 ":"
- echo $(get_ip_address $_server) | grep -q ":"
}
1.8.3.1
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 12/15/14 at 11:20am, Minfei Huang wrote:
Add the new lib which checks the ip/domain which you give. Return true, if the parameter is ipv6, otherwise return false.
It is more of a cleanup to split the get_ip_address, so maybe split it again as two patches will be good.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index b886c5d..acb085e 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -170,10 +170,26 @@ get_remote_host() echo $_config_val }
+get_ip_address() +{
- local _server=$1 _server_tmp
- _server_tmp=$_server
- _server=`getent ahosts $_server | head -n 1 | cut -d' ' -f1`
- _server=${_server:-$_server_tmp}
- echo $_server
+}
+is_ipv6_address() +{
- local _server=$(get_ip_address $1)
- echo $_server | grep -q ":"
+}
# check the remote server ip address tpye is_ipv6_target() {
- local _server _server_tmp
local _server
if is_ssh_dump_target; then _server=`get_option_value ssh`
@@ -183,8 +199,6 @@ is_ipv6_target()
[ -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 ":"
- echo $(get_ip_address $_server) | grep -q ":"
}
1.8.3.1
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 12/29/14 at 03:36pm, Dave Young wrote:
On 12/15/14 at 11:20am, Minfei Huang wrote:
Add the new lib which checks the ip/domain which you give. Return true, if the parameter is ipv6, otherwise return false.
It is more of a cleanup to split the get_ip_address, so maybe split it again as two patches will be good.
Agree. I will bisect this patch. The first patch adds new function get_ip_address, and the other patch just adds the new lib. Thus it may be more clear.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index b886c5d..acb085e 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -170,10 +170,26 @@ get_remote_host() echo $_config_val }
+get_ip_address() +{
- local _server=$1 _server_tmp
- _server_tmp=$_server
- _server=`getent ahosts $_server | head -n 1 | cut -d' ' -f1`
- _server=${_server:-$_server_tmp}
- echo $_server
+}
+is_ipv6_address() +{
- local _server=$(get_ip_address $1)
- echo $_server | grep -q ":"
+}
# check the remote server ip address tpye is_ipv6_target() {
- local _server _server_tmp
local _server
if is_ssh_dump_target; then _server=`get_option_value ssh`
@@ -183,8 +199,6 @@ is_ipv6_target()
[ -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 ":"
- echo $(get_ip_address $_server) | grep -q ":"
}
1.8.3.1
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
We have to get the network config by using ip route when setup the net or iscsi. So wrap the similar functional code to the function to make the kdump code clear.
Call the function kdump_setup_currect_net, we can setup the net or iscsi whichever you want.
Signed-off-by: Minfei Huang mhuang@redhat.com --- dracut-module-setup.sh | 73 +++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 37 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index c704a65..10f7c83 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -261,24 +261,15 @@ kdump_setup_netdev() { kdump_setup_dns "$_netdev" }
-#Function:kdump_install_net -#$1: config values of net line in kdump.conf -#$2: srcaddr of network device -kdump_install_net() { - local _server _netdev _srcaddr - local config_val="$1" - - _server=`echo $config_val | sed 's/.*@//' | cut -d':' -f1` - - _need_dns=`echo $_server|grep "[a-zA-Z]"` - [ -n "$_need_dns" ] && _server=`getent hosts $_server|cut -d' ' -f1` +kdump_setup_currect_net() { + local _server=$1 _netdev _srcaddr + local _type=$2
_netdev=`/sbin/ip route get to $_server 2>&1` [ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
#the field in the ip output changes if we go to another subnet - if [ -n "`echo $_netdev | grep via`" ] - then + if [ -n "`echo $_netdev | grep via`" ]; then # we are going to a different subnet _srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1` _netdev=`echo $_netdev|awk '{print $5;}'|head -n 1` @@ -290,20 +281,36 @@ kdump_install_net() {
kdump_setup_netdev "${_netdev}" "${_srcaddr}" "${_server}"
- #save netdev used for kdump as cmdline - # Whoever calling kdump_install_net() is setting up the default gateway, - # ie. bootdev/kdumpnic. So don't override the setting if calling - # kdump_install_net() for another time. For example, after setting eth0 as - # the default gate way for network dump, eth1 in the fence kdump path will - # call kdump_install_net again and we don't want eth1 to be the default - # gateway. - if [ ! -f ${initdir}${initdir}/etc/cmdline.d/60kdumpnic.conf ] && - [ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]; then - echo "kdumpnic=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/60kdumpnic.conf - echo "bootdev=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/70bootdev.conf + if [ $_type = "net" ]; then + #save netdev used for kdump as cmdline + # Whoever calling kdump_install_net() is setting up the default gateway, + # ie. bootdev/kdumpnic. So don't override the setting if calling + # kdump_install_net() for another time. For example, after setting eth0 as + # the default gate way for network dump, eth1 in the fence kdump path will + # call kdump_install_net again and we don't want eth1 to be the default + # gateway. + if [ ! -f ${initdir}${initdir}/etc/cmdline.d/60kdumpnic.conf ] && + [ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]; then + echo "kdumpnic=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/60kdumpnic.conf + echo "bootdev=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/70bootdev.conf + fi fi }
+#Function:kdump_install_net +#$1: config values of net line in kdump.conf +#$2: srcaddr of network device +kdump_install_net() { + local config_val="$1" _server _need_dns + + _server=`echo $config_val | sed 's/.*@//' | cut -d':' -f1` + + _need_dns=`echo $_server|grep "[a-zA-Z]"` + [ -n "$_need_dns" ] && _server=`getent hosts $_server|cut -d' ' -f1` + + kdump_setup_currect_net $_server "net" +} + default_dump_target_install_conf() { local _target _fstype @@ -434,13 +441,10 @@ kdump_get_iscsi_initiator() { # No ibft handling yet. kdump_setup_iscsi_device() { local path=$1 - local tgt_name; local tgt_ipaddr; - local username; local password; local userpwd_str; - local username_in; local password_in; local userpwd_in_str; - local netdev - local srcaddr - local idev - local netroot_str ; local initiator_str; + local tgt_name tgt_ipaddr + local username password userpwd_str + local username_in password_in userpwd_in_str + local netroot_str initiator_str local netroot_conf="${initdir}/etc/cmdline.d/50iscsi.conf" local initiator_conf="/etc/iscsi/initiatorname.iscsi"
@@ -472,12 +476,7 @@ kdump_setup_iscsi_device() {
[ -n "$username_in" ] && userpwd_in_str=":$username_in:$password_in"
- netdev=$(/sbin/ip route get to ${tgt_ipaddr} | \ - sed 's|.*dev (.*).*|\1|g') - srcaddr=$(echo $netdev | awk '{ print $3; exit }') - netdev=$(echo $netdev | awk '{ print $1; exit }') - - kdump_setup_netdev $netdev $srcaddr $tgt_ipaddr + kdump_setup_currect_net $tgt_ipaddr "iscsi"
# prepare netroot= command line # FIXME: IPV6 addresses require explicit [] around $tgt_ipaddr
On 12/15/14 at 11:20am, Minfei Huang wrote:
We have to get the network config by using ip route when setup the net or iscsi. So wrap the similar functional code to the function to make the kdump code clear.
Call the function kdump_setup_currect_net, we can setup the net or iscsi whichever you want.
Signed-off-by: Minfei Huang mhuang@redhat.com
dracut-module-setup.sh | 73 +++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 37 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index c704a65..10f7c83 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -261,24 +261,15 @@ kdump_setup_netdev() { kdump_setup_dns "$_netdev" }
-#Function:kdump_install_net -#$1: config values of net line in kdump.conf -#$2: srcaddr of network device -kdump_install_net() {
- local _server _netdev _srcaddr
- local config_val="$1"
- _server=`echo $config_val | sed 's/.*@//' | cut -d':' -f1`
- _need_dns=`echo $_server|grep "[a-zA-Z]"`
- [ -n "$_need_dns" ] && _server=`getent hosts $_server|cut -d' ' -f1`
+kdump_setup_currect_net() {
local _server=$1 _netdev _srcaddr
local _type=$2
_netdev=`/sbin/ip route get to $_server 2>&1` [ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
#the field in the ip output changes if we go to another subnet
- if [ -n "`echo $_netdev | grep via`" ]
- then
- if [ -n "`echo $_netdev | grep via`" ]; then # we are going to a different subnet _srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1` _netdev=`echo $_netdev|awk '{print $5;}'|head -n 1`
@@ -290,20 +281,36 @@ kdump_install_net() {
kdump_setup_netdev "${_netdev}" "${_srcaddr}" "${_server}"
- #save netdev used for kdump as cmdline
- # Whoever calling kdump_install_net() is setting up the default gateway,
- # ie. bootdev/kdumpnic. So don't override the setting if calling
- # kdump_install_net() for another time. For example, after setting eth0 as
- # the default gate way for network dump, eth1 in the fence kdump path will
- # call kdump_install_net again and we don't want eth1 to be the default
- # gateway.
- if [ ! -f ${initdir}${initdir}/etc/cmdline.d/60kdumpnic.conf ] &&
[ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]; then
echo "kdumpnic=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/60kdumpnic.conf
echo "bootdev=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/70bootdev.conf
- if [ $_type = "net" ]; then
I do not understand the _type, what is it for? is there other type which is not net?
If this is new code, please split the patch to two patches, one is cleanup and add common function, the other is for adding new functionalities.
#save netdev used for kdump as cmdline
# Whoever calling kdump_install_net() is setting up the default gateway,
# ie. bootdev/kdumpnic. So don't override the setting if calling
# kdump_install_net() for another time. For example, after setting eth0 as
# the default gate way for network dump, eth1 in the fence kdump path will
# call kdump_install_net again and we don't want eth1 to be the default
# gateway.
if [ ! -f ${initdir}${initdir}/etc/cmdline.d/60kdumpnic.conf ] &&
[ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]; then
echo "kdumpnic=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/60kdumpnic.conf
echo "bootdev=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/70bootdev.conf
fifi
}
+#Function:kdump_install_net +#$1: config values of net line in kdump.conf +#$2: srcaddr of network device
It is only using one argument, so since you are modifying it please update the comment. Also: s/net line/ssh|nfs line
+kdump_install_net() {
- local config_val="$1" _server _need_dns
- _server=`echo $config_val | sed 's/.*@//' | cut -d':' -f1`
- _need_dns=`echo $_server|grep "[a-zA-Z]"`
In case ipv6 addresses which contains [a-zA-Z] it does not need dns convertion...
- [ -n "$_need_dns" ] && _server=`getent hosts $_server|cut -d' ' -f1`
I remember getent hosts was replaced by getent ahosts, right?
- kdump_setup_currect_net $_server "net"
kdump-setup_currect_net looks not good, I assume you means 'correct'? How about _kdump_setup_net or just kdump_setup_net()?
I'm confused with the second argument, see previous comment.
+}
default_dump_target_install_conf() { local _target _fstype @@ -434,13 +441,10 @@ kdump_get_iscsi_initiator() { # No ibft handling yet. kdump_setup_iscsi_device() { local path=$1
- local tgt_name; local tgt_ipaddr;
- local username; local password; local userpwd_str;
- local username_in; local password_in; local userpwd_in_str;
- local netdev
- local srcaddr
- local idev
- local netroot_str ; local initiator_str;
- local tgt_name tgt_ipaddr
- local username password userpwd_str
- local username_in password_in userpwd_in_str
- local netroot_str initiator_str local netroot_conf="${initdir}/etc/cmdline.d/50iscsi.conf" local initiator_conf="/etc/iscsi/initiatorname.iscsi"
@@ -472,12 +476,7 @@ kdump_setup_iscsi_device() {
[ -n "$username_in" ] && userpwd_in_str=":$username_in:$password_in"
- netdev=$(/sbin/ip route get to ${tgt_ipaddr} | \
sed 's|.*dev \(.*\).*|\1|g')
- srcaddr=$(echo $netdev | awk '{ print $3; exit }')
- netdev=$(echo $netdev | awk '{ print $1; exit }')
- kdump_setup_netdev $netdev $srcaddr $tgt_ipaddr
- kdump_setup_currect_net $tgt_ipaddr "iscsi"
Hmm, looks like the type becomes iscsi here, if this is the case then how about doing something like below:
iscsi path: -> kdump_setup_net() $tgt_ipaddr
net path: -> kdump_setup_net() $_server -> kdump_setup_kdumpnic_bootdev() _server
# prepare netroot= command line # FIXME: IPV6 addresses require explicit [] around $tgt_ipaddr
-- 1.8.3.1
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 12/29/14 at 03:57pm, Dave Young wrote:
On 12/15/14 at 11:20am, Minfei Huang wrote:
We have to get the network config by using ip route when setup the net or iscsi. So wrap the similar functional code to the function to make the kdump code clear.
Call the function kdump_setup_currect_net, we can setup the net or iscsi whichever you want.
Signed-off-by: Minfei Huang mhuang@redhat.com
dracut-module-setup.sh | 73 +++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 37 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index c704a65..10f7c83 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -261,24 +261,15 @@ kdump_setup_netdev() { kdump_setup_dns "$_netdev" }
-#Function:kdump_install_net -#$1: config values of net line in kdump.conf -#$2: srcaddr of network device -kdump_install_net() {
- local _server _netdev _srcaddr
- local config_val="$1"
- _server=`echo $config_val | sed 's/.*@//' | cut -d':' -f1`
- _need_dns=`echo $_server|grep "[a-zA-Z]"`
- [ -n "$_need_dns" ] && _server=`getent hosts $_server|cut -d' ' -f1`
+kdump_setup_currect_net() {
local _server=$1 _netdev _srcaddr
local _type=$2
_netdev=`/sbin/ip route get to $_server 2>&1` [ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
#the field in the ip output changes if we go to another subnet
- if [ -n "`echo $_netdev | grep via`" ]
- then
- if [ -n "`echo $_netdev | grep via`" ]; then # we are going to a different subnet _srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1` _netdev=`echo $_netdev|awk '{print $5;}'|head -n 1`
@@ -290,20 +281,36 @@ kdump_install_net() {
kdump_setup_netdev "${_netdev}" "${_srcaddr}" "${_server}"
- #save netdev used for kdump as cmdline
- # Whoever calling kdump_install_net() is setting up the default gateway,
- # ie. bootdev/kdumpnic. So don't override the setting if calling
- # kdump_install_net() for another time. For example, after setting eth0 as
- # the default gate way for network dump, eth1 in the fence kdump path will
- # call kdump_install_net again and we don't want eth1 to be the default
- # gateway.
- if [ ! -f ${initdir}${initdir}/etc/cmdline.d/60kdumpnic.conf ] &&
[ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]; then
echo "kdumpnic=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/60kdumpnic.conf
echo "bootdev=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/70bootdev.conf
- if [ $_type = "net" ]; then
I do not understand the _type, what is it for? is there other type which is not net?
If this is new code, please split the patch to two patches, one is cleanup and add common function, the other is for adding new functionalities.
For some networks, we would specify the config after setuping the network device. Here the kdump code, we can make the parameter _type "net" or "iscsi".
#save netdev used for kdump as cmdline
# Whoever calling kdump_install_net() is setting up the default gateway,
# ie. bootdev/kdumpnic. So don't override the setting if calling
# kdump_install_net() for another time. For example, after setting eth0 as
# the default gate way for network dump, eth1 in the fence kdump path will
# call kdump_install_net again and we don't want eth1 to be the default
# gateway.
if [ ! -f ${initdir}${initdir}/etc/cmdline.d/60kdumpnic.conf ] &&
[ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]; then
echo "kdumpnic=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/60kdumpnic.conf
echo "bootdev=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/70bootdev.conf
fifi
}
+#Function:kdump_install_net +#$1: config values of net line in kdump.conf +#$2: srcaddr of network device
It is only using one argument, so since you are modifying it please update the comment. Also: s/net line/ssh|nfs line
Will comment it here.
+kdump_install_net() {
- local config_val="$1" _server _need_dns
- _server=`echo $config_val | sed 's/.*@//' | cut -d':' -f1`
- _need_dns=`echo $_server|grep "[a-zA-Z]"`
In case ipv6 addresses which contains [a-zA-Z] it does not need dns convertion...
It does not matter if we filte ipv6 address again. Otherwise we should varify the $_server value, domain/hostname or not.
- [ -n "$_need_dns" ] && _server=`getent hosts $_server|cut -d' ' -f1`
I remember getent hosts was replaced by getent ahosts, right?
Yes. will modify it.
- kdump_setup_currect_net $_server "net"
kdump-setup_currect_net looks not good, I assume you means 'correct'? How about _kdump_setup_net or just kdump_setup_net()?
I'm confused with the second argument, see previous comment.
Will name the function properly.
+}
default_dump_target_install_conf() { local _target _fstype @@ -434,13 +441,10 @@ kdump_get_iscsi_initiator() { # No ibft handling yet. kdump_setup_iscsi_device() { local path=$1
- local tgt_name; local tgt_ipaddr;
- local username; local password; local userpwd_str;
- local username_in; local password_in; local userpwd_in_str;
- local netdev
- local srcaddr
- local idev
- local netroot_str ; local initiator_str;
- local tgt_name tgt_ipaddr
- local username password userpwd_str
- local username_in password_in userpwd_in_str
- local netroot_str initiator_str local netroot_conf="${initdir}/etc/cmdline.d/50iscsi.conf" local initiator_conf="/etc/iscsi/initiatorname.iscsi"
@@ -472,12 +476,7 @@ kdump_setup_iscsi_device() {
[ -n "$username_in" ] && userpwd_in_str=":$username_in:$password_in"
- netdev=$(/sbin/ip route get to ${tgt_ipaddr} | \
sed 's|.*dev \(.*\).*|\1|g')
- srcaddr=$(echo $netdev | awk '{ print $3; exit }')
- netdev=$(echo $netdev | awk '{ print $1; exit }')
- kdump_setup_netdev $netdev $srcaddr $tgt_ipaddr
- kdump_setup_currect_net $tgt_ipaddr "iscsi"
Hmm, looks like the type becomes iscsi here, if this is the case then how about doing something like below:
iscsi path: -> kdump_setup_net() $tgt_ipaddr
net path: -> kdump_setup_net() $_server -> kdump_setup_kdumpnic_bootdev() _server
In net path, we need the $_netdev value which gets in the kdump_setup_currect_net. So it is better wrap in one function.
# prepare netroot= command line # FIXME: IPV6 addresses require explicit [] around $tgt_ipaddr
-- 1.8.3.1
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 01/04/15 at 06:59pm, Minfei Huang wrote:
On 12/29/14 at 03:57pm, Dave Young wrote:
On 12/15/14 at 11:20am, Minfei Huang wrote:
We have to get the network config by using ip route when setup the net or iscsi. So wrap the similar functional code to the function to make the kdump code clear.
Call the function kdump_setup_currect_net, we can setup the net or iscsi whichever you want.
Signed-off-by: Minfei Huang mhuang@redhat.com
dracut-module-setup.sh | 73 +++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 37 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index c704a65..10f7c83 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -261,24 +261,15 @@ kdump_setup_netdev() { kdump_setup_dns "$_netdev" }
-#Function:kdump_install_net -#$1: config values of net line in kdump.conf -#$2: srcaddr of network device -kdump_install_net() {
- local _server _netdev _srcaddr
- local config_val="$1"
- _server=`echo $config_val | sed 's/.*@//' | cut -d':' -f1`
- _need_dns=`echo $_server|grep "[a-zA-Z]"`
- [ -n "$_need_dns" ] && _server=`getent hosts $_server|cut -d' ' -f1`
+kdump_setup_currect_net() {
local _server=$1 _netdev _srcaddr
local _type=$2
_netdev=`/sbin/ip route get to $_server 2>&1` [ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
#the field in the ip output changes if we go to another subnet
- if [ -n "`echo $_netdev | grep via`" ]
- then
- if [ -n "`echo $_netdev | grep via`" ]; then # we are going to a different subnet _srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1` _netdev=`echo $_netdev|awk '{print $5;}'|head -n 1`
@@ -290,20 +281,36 @@ kdump_install_net() {
kdump_setup_netdev "${_netdev}" "${_srcaddr}" "${_server}"
- #save netdev used for kdump as cmdline
- # Whoever calling kdump_install_net() is setting up the default gateway,
- # ie. bootdev/kdumpnic. So don't override the setting if calling
- # kdump_install_net() for another time. For example, after setting eth0 as
- # the default gate way for network dump, eth1 in the fence kdump path will
- # call kdump_install_net again and we don't want eth1 to be the default
- # gateway.
- if [ ! -f ${initdir}${initdir}/etc/cmdline.d/60kdumpnic.conf ] &&
[ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]; then
echo "kdumpnic=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/60kdumpnic.conf
echo "bootdev=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/70bootdev.conf
- if [ $_type = "net" ]; then
I do not understand the _type, what is it for? is there other type which is not net?
If this is new code, please split the patch to two patches, one is cleanup and add common function, the other is for adding new functionalities.
For some networks, we would specify the config after setuping the network device. Here the kdump code, we can make the parameter _type "net" or "iscsi".
#save netdev used for kdump as cmdline
# Whoever calling kdump_install_net() is setting up the default gateway,
# ie. bootdev/kdumpnic. So don't override the setting if calling
# kdump_install_net() for another time. For example, after setting eth0 as
# the default gate way for network dump, eth1 in the fence kdump path will
# call kdump_install_net again and we don't want eth1 to be the default
# gateway.
if [ ! -f ${initdir}${initdir}/etc/cmdline.d/60kdumpnic.conf ] &&
[ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]; then
echo "kdumpnic=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/60kdumpnic.conf
echo "bootdev=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/70bootdev.conf
fifi
}
+#Function:kdump_install_net +#$1: config values of net line in kdump.conf +#$2: srcaddr of network device
It is only using one argument, so since you are modifying it please update the comment. Also: s/net line/ssh|nfs line
Will comment it here.
+kdump_install_net() {
- local config_val="$1" _server _need_dns
- _server=`echo $config_val | sed 's/.*@//' | cut -d':' -f1`
- _need_dns=`echo $_server|grep "[a-zA-Z]"`
In case ipv6 addresses which contains [a-zA-Z] it does not need dns convertion...
It does not matter if we filte ipv6 address again. Otherwise we should
s/filte/file?
varify the $_server value, domain/hostname or not.
But as for this function, it is not good, a variable _need_dns depends on code in other functions will twist the code. Make the variable defination clear is better to avoid bugs.
- [ -n "$_need_dns" ] && _server=`getent hosts $_server|cut -d' ' -f1`
I remember getent hosts was replaced by getent ahosts, right?
Yes. will modify it.
- kdump_setup_currect_net $_server "net"
kdump-setup_currect_net looks not good, I assume you means 'correct'? How about _kdump_setup_net or just kdump_setup_net()?
I'm confused with the second argument, see previous comment.
Will name the function properly.
+}
default_dump_target_install_conf() { local _target _fstype @@ -434,13 +441,10 @@ kdump_get_iscsi_initiator() { # No ibft handling yet. kdump_setup_iscsi_device() { local path=$1
- local tgt_name; local tgt_ipaddr;
- local username; local password; local userpwd_str;
- local username_in; local password_in; local userpwd_in_str;
- local netdev
- local srcaddr
- local idev
- local netroot_str ; local initiator_str;
- local tgt_name tgt_ipaddr
- local username password userpwd_str
- local username_in password_in userpwd_in_str
- local netroot_str initiator_str local netroot_conf="${initdir}/etc/cmdline.d/50iscsi.conf" local initiator_conf="/etc/iscsi/initiatorname.iscsi"
@@ -472,12 +476,7 @@ kdump_setup_iscsi_device() {
[ -n "$username_in" ] && userpwd_in_str=":$username_in:$password_in"
- netdev=$(/sbin/ip route get to ${tgt_ipaddr} | \
sed 's|.*dev \(.*\).*|\1|g')
- srcaddr=$(echo $netdev | awk '{ print $3; exit }')
- netdev=$(echo $netdev | awk '{ print $1; exit }')
- kdump_setup_netdev $netdev $srcaddr $tgt_ipaddr
- kdump_setup_currect_net $tgt_ipaddr "iscsi"
Hmm, looks like the type becomes iscsi here, if this is the case then how about doing something like below:
iscsi path: -> kdump_setup_net() $tgt_ipaddr
net path: -> kdump_setup_net() $_server -> kdump_setup_kdumpnic_bootdev() _server
In net path, we need the $_netdev value which gets in the kdump_setup_currect_net. So it is better wrap in one function.
I understand your purpose to add a common function, but it introduced more confuses the two types makes the logic more complicated.
# prepare netroot= command line # FIXME: IPV6 addresses require explicit [] around $tgt_ipaddr
-- 1.8.3.1
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 01/05/15 at 10:31am, Dave Young wrote:
On 01/04/15 at 06:59pm, Minfei Huang wrote:
On 12/29/14 at 03:57pm, Dave Young wrote:
On 12/15/14 at 11:20am, Minfei Huang wrote:
We have to get the network config by using ip route when setup the net or iscsi. So wrap the similar functional code to the function to make the kdump code clear.
Call the function kdump_setup_currect_net, we can setup the net or iscsi whichever you want.
Signed-off-by: Minfei Huang mhuang@redhat.com
dracut-module-setup.sh | 73 +++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 37 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index c704a65..10f7c83 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -261,24 +261,15 @@ kdump_setup_netdev() { kdump_setup_dns "$_netdev" }
-#Function:kdump_install_net -#$1: config values of net line in kdump.conf -#$2: srcaddr of network device -kdump_install_net() {
- local _server _netdev _srcaddr
- local config_val="$1"
- _server=`echo $config_val | sed 's/.*@//' | cut -d':' -f1`
- _need_dns=`echo $_server|grep "[a-zA-Z]"`
- [ -n "$_need_dns" ] && _server=`getent hosts $_server|cut -d' ' -f1`
+kdump_setup_currect_net() {
local _server=$1 _netdev _srcaddr
local _type=$2
_netdev=`/sbin/ip route get to $_server 2>&1` [ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
#the field in the ip output changes if we go to another subnet
- if [ -n "`echo $_netdev | grep via`" ]
- then
- if [ -n "`echo $_netdev | grep via`" ]; then # we are going to a different subnet _srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1` _netdev=`echo $_netdev|awk '{print $5;}'|head -n 1`
@@ -290,20 +281,36 @@ kdump_install_net() {
kdump_setup_netdev "${_netdev}" "${_srcaddr}" "${_server}"
- #save netdev used for kdump as cmdline
- # Whoever calling kdump_install_net() is setting up the default gateway,
- # ie. bootdev/kdumpnic. So don't override the setting if calling
- # kdump_install_net() for another time. For example, after setting eth0 as
- # the default gate way for network dump, eth1 in the fence kdump path will
- # call kdump_install_net again and we don't want eth1 to be the default
- # gateway.
- if [ ! -f ${initdir}${initdir}/etc/cmdline.d/60kdumpnic.conf ] &&
[ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]; then
echo "kdumpnic=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/60kdumpnic.conf
echo "bootdev=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/70bootdev.conf
- if [ $_type = "net" ]; then
I do not understand the _type, what is it for? is there other type which is not net?
If this is new code, please split the patch to two patches, one is cleanup and add common function, the other is for adding new functionalities.
For some networks, we would specify the config after setuping the network device. Here the kdump code, we can make the parameter _type "net" or "iscsi".
#save netdev used for kdump as cmdline
# Whoever calling kdump_install_net() is setting up the default gateway,
# ie. bootdev/kdumpnic. So don't override the setting if calling
# kdump_install_net() for another time. For example, after setting eth0 as
# the default gate way for network dump, eth1 in the fence kdump path will
# call kdump_install_net again and we don't want eth1 to be the default
# gateway.
if [ ! -f ${initdir}${initdir}/etc/cmdline.d/60kdumpnic.conf ] &&
[ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]; then
echo "kdumpnic=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/60kdumpnic.conf
echo "bootdev=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/70bootdev.conf
fifi
}
+#Function:kdump_install_net +#$1: config values of net line in kdump.conf +#$2: srcaddr of network device
It is only using one argument, so since you are modifying it please update the comment. Also: s/net line/ssh|nfs line
Will comment it here.
+kdump_install_net() {
- local config_val="$1" _server _need_dns
- _server=`echo $config_val | sed 's/.*@//' | cut -d':' -f1`
- _need_dns=`echo $_server|grep "[a-zA-Z]"`
In case ipv6 addresses which contains [a-zA-Z] it does not need dns convertion...
It does not matter if we filte ipv6 address again. Otherwise we should
s/filte/file?
The format, ipv4 xxx.xxx.xxx(x is the digit) and ipv6 xxxx:xxxx:xxxx:xxxx:xxxx:xxxx(x is the character), matchs the syntax that ipv4 only contains the digit and dot, ipv6 only contains the character a-zA-Z and colon. In other words, we can filte the domain/hostname out by using "grep [a-zA-Z]" and grep ".".
Use following filter _need_dns=`echo $_server|grep "[a-zA-Z]"|grep "."` can make sense.
varify the $_server value, domain/hostname or not.
But as for this function, it is not good, a variable _need_dns depends on code in other functions will twist the code. Make the variable defination clear is better to avoid bugs.
- [ -n "$_need_dns" ] && _server=`getent hosts $_server|cut -d' ' -f1`
I remember getent hosts was replaced by getent ahosts, right?
Yes. will modify it.
- kdump_setup_currect_net $_server "net"
kdump-setup_currect_net looks not good, I assume you means 'correct'? How about _kdump_setup_net or just kdump_setup_net()?
I'm confused with the second argument, see previous comment.
Will name the function properly.
+}
default_dump_target_install_conf() { local _target _fstype @@ -434,13 +441,10 @@ kdump_get_iscsi_initiator() { # No ibft handling yet. kdump_setup_iscsi_device() { local path=$1
- local tgt_name; local tgt_ipaddr;
- local username; local password; local userpwd_str;
- local username_in; local password_in; local userpwd_in_str;
- local netdev
- local srcaddr
- local idev
- local netroot_str ; local initiator_str;
- local tgt_name tgt_ipaddr
- local username password userpwd_str
- local username_in password_in userpwd_in_str
- local netroot_str initiator_str local netroot_conf="${initdir}/etc/cmdline.d/50iscsi.conf" local initiator_conf="/etc/iscsi/initiatorname.iscsi"
@@ -472,12 +476,7 @@ kdump_setup_iscsi_device() {
[ -n "$username_in" ] && userpwd_in_str=":$username_in:$password_in"
- netdev=$(/sbin/ip route get to ${tgt_ipaddr} | \
sed 's|.*dev \(.*\).*|\1|g')
- srcaddr=$(echo $netdev | awk '{ print $3; exit }')
- netdev=$(echo $netdev | awk '{ print $1; exit }')
- kdump_setup_netdev $netdev $srcaddr $tgt_ipaddr
- kdump_setup_currect_net $tgt_ipaddr "iscsi"
Hmm, looks like the type becomes iscsi here, if this is the case then how about doing something like below:
iscsi path: -> kdump_setup_net() $tgt_ipaddr
net path: -> kdump_setup_net() $_server -> kdump_setup_kdumpnic_bootdev() _server
In net path, we need the $_netdev value which gets in the kdump_setup_currect_net. So it is better wrap in one function.
I understand your purpose to add a common function, but it introduced more confuses the two types makes the logic more complicated.
There was a discussion with Bao and Chao before wrapping the common code to a function. We want to cleanup the setup network code in purpose, especial for getting ip route info. Maybe we still need discuss it.
# prepare netroot= command line # FIXME: IPV6 addresses require explicit [] around $tgt_ipaddr
-- 1.8.3.1
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
Currently kdump doesn't support ipv6 nfs/ssh dump. Ipv6 is the latest version of the Internet Protocal. So it is a significant feture for kdump to enhance to support ipv6.
Since dracut has supported ipv6 now, it is easy to change the kdump code to support ipv6. Just need pass the right _ip_opts to the second kernle. What is the main difference in userspace bettwen ipv4 and ipv6 is the ip address format. For ipv6 nfs dump: if ipv6 address type is link scope, /etc/kdump.conf should be edited like "nfs [fe80::5054:ff:fe48:ca80%eth0]:/mnt" else /etc/kdump.conf should be edited like "nfs [2001:db8:0:f101::2]:/mnt" For ipv6 ssh dump if ipv6 address type is link scope, /etc/kdump.conf should be edited like "ssh root at fe80::5054:ff:fe48:ca80%eth0" else /etc/kdump.conf should be edited like "ssh root at 2001:db8:0:f101::2"
What this patch do is: a): Modify kdump_setup_currect_net to handle ipv6 configuration in /etc/kdump.conf correctly. Get the ipv6 address from /etc/kdump.conf is more complicated than ipv4 because the difference configuration format mentioned above. b): Based on the ip address type, using corresponding ip address as HOST_IP in second kernel.
Note: 1): Currntly only f19 support remount a nfs target in ipv6. If using in f20, you can comment out "mount -o remount,rw $_mp || return 1" in kdump.sh line 105. 2): If Using static ipv6 address and configuring nfs/ssh with hostname of remote target, MUST add a ipv6 DNS in ifcfg-devname.
How to create a ipv6 enviromnet. 1): Reserving two beaker machine with family fedora. 2): Choosing a beaker machine as a nfs/ssh server and delete it's ipv4 address by "ip address del ipv4-address dev nicname" 3): Configuring the /etc/kdump.conf like mentioned above.
Signed-off-by: Minfei Huang mhuang@redhat.com --- dracut-kdump.sh | 8 +++- dracut-module-setup.sh | 126 +++++++++++++++++++++++++++++++++++++------------ 2 files changed, 101 insertions(+), 33 deletions(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 52ebbdd..e2c5965 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -121,9 +121,13 @@ get_host_ip() then kdumpnic=$(getarg kdumpnic=) [ -z "$kdumpnic" ] && echo "kdump: failed to get kdumpnic!" && return 1 - _host=`ip addr show dev $kdumpnic|grep 'inet '` + if is_ipv6_target; then + _host=`ip -6 addr show dev $kdumpnic|grep 'inet6'` + else + _host=`ip addr show dev $kdumpnic|grep 'inet '` + fi [ $? -ne 0 ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1 - _host="${_host##*inet }" + _host=`echo $_host | cut -d' ' -f2` _host="${_host%%/*}" [ -z "$_host" ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1 HOST_IP=$_host diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 10f7c83..072b6a5 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -70,14 +70,25 @@ kdump_setup_dns() { #$2: srcaddr #if it use static ip echo it, or echo null kdump_static_ip() { - local _netmask _gateway + local _netmask _gateway _ipaddr local _netdev="$1" _srcaddr="$2" - local _ipaddr=$(ip addr show dev $_netdev permanent | \ + + if is_ipv6_target; then + _ipaddr=$(ip -6 addr show dev $_netdev permanent | \ + awk "/ $_srcaddr/.* /{print $2}") + if [ -n "$_ipaddr" ]; then + _netmask=${_ipaddr#*/} + _gateway=$(ip -6 route list dev $_netdev | awk '/^default /{print $3}') + echo -n "[${_srcaddr}]::[${_gateway}]:${_netmask}::" + fi + else + _ipaddr=$(ip addr show dev $_netdev permanent | \ awk "/ $_srcaddr/.* $_netdev$/{print $2}") - if [ -n "$_ipaddr" ]; then - _netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2) - _gateway=$(ip route list dev $_netdev | awk '/^default /{print $3}') - echo -n "${_srcaddr}::${_gateway}:${_netmask}::" + if [ -n "$_ipaddr" ]; then + _netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2) + _gateway=$(ip route list dev $_netdev | awk '/^default /{print $3}') + echo -n "${_srcaddr}::${_gateway}:${_netmask}::" + fi fi }
@@ -195,9 +206,29 @@ get_routes() { local _netdev="$1" _target="$2" local _route _nexthop
- _route=`/sbin/ip route get to $_target 2>&1` + if is_ipv6_target; then + _route=`/sbin/ip -6 route get to $_target 2>&1` +# +# for the same subnet region, following is the format # -# in the same subnet region, following is the route format +# _route='2001:11::11f from :: dev eth1 src 2001:11::120 metric 0 +# cache' +# in the different subnet region, following is the route format +# _route='2001:10::120 from :: via 2001:11::11f dev eth1 src 2001:11::120 metric 0 +# cache' +# + _netdev=$(kdump_setup_ifname $_netdev) + if `echo $_route | grep -q "via"`; then + # route going to a different subnet via a router + _nexthop=`echo $_route | awk '{print $5}'` + echo "rd.route=[$_target]:[$_nexthop]:$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf + else + echo "rd.route=[$_target]::$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf + fi + else + _route=`/sbin/ip route get to $_target 2>&1` +# +# for the same subnet region, following is the format # _route='192.168.200.137 dev eth1 src 192.168.200.129 # cache ' # @@ -205,13 +236,14 @@ get_routes() { # _route='192.168.201.215 via 192.168.200.137 dev eth1 src 192.168.200.129 # cache ' # - if `echo $_route | grep -q "via"`; then - # route going to a different subnet via a router - _nexthop=`echo $_route | awk '{print $3}'` - fi - _netdev=$(kdump_setup_ifname $_netdev) + if `echo $_route | grep -q "via"`; then + # route going to a different subnet via a router + _nexthop=`echo $_route | awk '{print $3}'` + fi + _netdev=$(kdump_setup_ifname $_netdev)
- echo "rd.route=$_target:$_nexthop:$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf + echo "rd.route=$_target:$_nexthop:$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf + fi }
# Setup dracut to bringup a given network interface @@ -265,18 +297,32 @@ kdump_setup_currect_net() { local _server=$1 _netdev _srcaddr local _type=$2
- _netdev=`/sbin/ip route get to $_server 2>&1` - [ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1 - - #the field in the ip output changes if we go to another subnet - if [ -n "`echo $_netdev | grep via`" ]; then - # we are going to a different subnet - _srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1` - _netdev=`echo $_netdev|awk '{print $5;}'|head -n 1` + if is_ipv6_address $_server; then + _netdev=`/sbin/ip -6 route get to $_server 2>&1` + [ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1 + #the field in the ip output changes if we go to another subnet + if [ -n "`echo $_netdev | grep via`" ]; then + # we are going to a different subnet + _srcaddr=`echo $_netdev|awk '{print $9}'|head -n 1` + _netdev=`echo $_netdev|awk '{print $7;}'|head -n 1` + else + # we are on the same subnet + _srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1` + _netdev=`echo $_netdev|awk '{print $5}'|head -n 1` + fi else - # we are on the same subnet - _srcaddr=`echo $_netdev|awk '{print $5}'|head -n 1` - _netdev=`echo $_netdev|awk '{print $3}'|head -n 1` + _netdev=`/sbin/ip route get to $_server 2>&1` + [ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1 + #the field in the ip output changes if we go to another subnet + if [ -n "`echo $_netdev | grep via`" ]; then + # we are going to a different subnet + _srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1` + _netdev=`echo $_netdev|awk '{print $5;}'|head -n 1` + else + # we are on the same subnet + _srcaddr=`echo $_netdev|awk '{print $5}'|head -n 1` + _netdev=`echo $_netdev|awk '{print $3}'|head -n 1` + fi fi
kdump_setup_netdev "${_netdev}" "${_srcaddr}" "${_server}" @@ -303,10 +349,15 @@ kdump_setup_currect_net() { kdump_install_net() { local config_val="$1" _server _need_dns
- _server=`echo $config_val | sed 's/.*@//' | cut -d':' -f1` + _server=`get_remote_host $config_val`
- _need_dns=`echo $_server|grep "[a-zA-Z]"` - [ -n "$_need_dns" ] && _server=`getent hosts $_server|cut -d' ' -f1` + if is_ipv6_target; then + _need_dns=`echo $_server|grep "[:]"` + [ -z "$_need_dns" ] && _server=`getent hosts $_server| head -n 1 | cut -d' ' -f1` + else + _need_dns=`echo $_server|grep "[a-zA-Z]"` + [ -n "$_need_dns" ] && _server=`getent hosts $_server| head -n 1 | cut -d' ' -f1` + fi
kdump_setup_currect_net $_server "net" } @@ -442,6 +493,7 @@ kdump_get_iscsi_initiator() { kdump_setup_iscsi_device() { local path=$1 local tgt_name tgt_ipaddr + local _srcaddr _prefix _netdev local username password userpwd_str local username_in password_in userpwd_in_str local netroot_str initiator_str @@ -476,14 +528,24 @@ kdump_setup_iscsi_device() {
[ -n "$username_in" ] && userpwd_in_str=":$username_in:$password_in"
- kdump_setup_currect_net $tgt_ipaddr "iscsi" + _srcaddr=$(get_remote_host $tgt_ipaddr) + kdump_setup_currect_net $_srcaddr "iscsi"
# prepare netroot= command line - # FIXME: IPV6 addresses require explicit [] around $tgt_ipaddr # FIXME: Do we need to parse and set other parameters like protocol, port # iscsi_iface_name, netdev_name, LUN etc.
- netroot_str="netroot=iscsi:${userpwd_str}${userpwd_in_str}@$tgt_ipaddr::::$tgt_name" + if is_ipv6_address $_srcaddr; then + if `echo $tgt_ipaddr | grep -q "%"`; then + _prefix=${tgt_ipaddr%%*} + _netdev=${tgt_ipaddr#*%} + _netdev=$(kdump_setup_ifname $_netdev) + tgt_ipaddr=$_prefix%$_netdev + fi + netroot_str="netroot=iscsi:${userpwd_str}${userpwd_in_str}@[$tgt_ipaddr]::::$tgt_name" + else + netroot_str="netroot=iscsi:${userpwd_str}${userpwd_in_str}@$tgt_ipaddr::::$tgt_name" + fi
[[ -f $netroot_conf ]] || touch $netroot_conf
@@ -616,6 +678,8 @@ install() { inst "/bin/dd" "/bin/dd" inst "/bin/tail" "/bin/tail" inst "/bin/date" "/bin/date" + inst "/bin/getent" "/bin/getent" + inst "/bin/head" "/bin/head" inst "/bin/sync" "/bin/sync" inst "/bin/cut" "/bin/cut" inst "/sbin/makedumpfile" "/sbin/makedumpfile"
On 12/15/14 at 11:20am, Minfei Huang wrote:
Currently kdump doesn't support ipv6 nfs/ssh dump. Ipv6 is the latest version of the Internet Protocal. So it is a significant feture for kdump to enhance to support ipv6.
Since dracut has supported ipv6 now, it is easy to change the kdump code to support ipv6. Just need pass the right _ip_opts to the second kernle. What is the main difference in userspace bettwen ipv4 and ipv6 is the ip address format. For ipv6 nfs dump: if ipv6 address type is link scope, /etc/kdump.conf should be edited like "nfs [fe80::5054:ff:fe48:ca80%eth0]:/mnt" else /etc/kdump.conf should be edited like "nfs [2001:db8:0:f101::2]:/mnt" For ipv6 ssh dump if ipv6 address type is link scope, /etc/kdump.conf should be edited like "ssh root at fe80::5054:ff:fe48:ca80%eth0" else /etc/kdump.conf should be edited like "ssh root at 2001:db8:0:f101::2"
What this patch do is: a): Modify kdump_setup_currect_net to handle ipv6 configuration in /etc/kdump.conf correctly. Get the ipv6 address from /etc/kdump.conf is more complicated than ipv4 because the difference configuration format mentioned above. b): Based on the ip address type, using corresponding ip address as HOST_IP in second kernel.
Note: 1): Currntly only f19 support remount a nfs target in ipv6. If using in f20, you can comment out "mount -o remount,rw $_mp || return 1" in kdump.sh line 105.
It is from previous testing from Arthur, is above still valid?
2): If Using static ipv6 address and configuring nfs/ssh with hostname of remote target, MUST add a ipv6 DNS in ifcfg-devname.
Can we detect this and error out in case no such DNS? if not possible maybe we should document it in kdump howto to suggest user to add it in ifcfg.
How to create a ipv6 enviromnet. 1): Reserving two beaker machine with family fedora. 2): Choosing a beaker machine as a nfs/ssh server and delete it's ipv4 address by "ip address del ipv4-address dev nicname" 3): Configuring the /etc/kdump.conf like mentioned above.
Signed-off-by: Minfei Huang mhuang@redhat.com
dracut-kdump.sh | 8 +++- dracut-module-setup.sh | 126 +++++++++++++++++++++++++++++++++++++------------ 2 files changed, 101 insertions(+), 33 deletions(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 52ebbdd..e2c5965 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -121,9 +121,13 @@ get_host_ip() then kdumpnic=$(getarg kdumpnic=) [ -z "$kdumpnic" ] && echo "kdump: failed to get kdumpnic!" && return 1
_host=`ip addr show dev $kdumpnic|grep 'inet '`
if is_ipv6_target; then
_host=`ip -6 addr show dev $kdumpnic|grep 'inet6'`
else
_host=`ip addr show dev $kdumpnic|grep 'inet '`
fi [ $? -ne 0 ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1
_host="${_host##*inet }"
_host=`echo $_host | cut -d' ' -f2` _host="${_host%%/*}" [ -z "$_host" ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1 HOST_IP=$_host
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 10f7c83..072b6a5 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -70,14 +70,25 @@ kdump_setup_dns() { #$2: srcaddr #if it use static ip echo it, or echo null kdump_static_ip() {
- local _netmask _gateway
- local _netmask _gateway _ipaddr local _netdev="$1" _srcaddr="$2"
- local _ipaddr=$(ip addr show dev $_netdev permanent | \
- if is_ipv6_target; then
_ipaddr=$(ip -6 addr show dev $_netdev permanent | \
awk "/ $_srcaddr\/.* /{print \$2}")
if [ -n "$_ipaddr" ]; then
_netmask=${_ipaddr#*\/}
_gateway=$(ip -6 route list dev $_netdev | awk '/^default /{print $3}')
echo -n "[${_srcaddr}]::[${_gateway}]:${_netmask}::"
fi
- else
_ipaddr=$(ip addr show dev $_netdev permanent | \ awk "/ $_srcaddr\/.* $_netdev\$/{print \$2}")
- if [ -n "$_ipaddr" ]; then
_netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2)
_gateway=$(ip route list dev $_netdev | awk '/^default /{print $3}')
echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
if [ -n "$_ipaddr" ]; then
_netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2)
_gateway=$(ip route list dev $_netdev | awk '/^default /{print $3}')
echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
fifi
}
@@ -195,9 +206,29 @@ get_routes() { local _netdev="$1" _target="$2" local _route _nexthop
- _route=`/sbin/ip route get to $_target 2>&1`
- if is_ipv6_target; then
_route=`/sbin/ip -6 route get to $_target 2>&1`
+# +# for the same subnet region, following is the format # -# in the same subnet region, following is the route format +# _route='2001:11::11f from :: dev eth1 src 2001:11::120 metric 0 +# cache' +# in the different subnet region, following is the route format +# _route='2001:10::120 from :: via 2001:11::11f dev eth1 src 2001:11::120 metric 0 +# cache' +#
_netdev=$(kdump_setup_ifname $_netdev)
if `echo $_route | grep -q "via"`; then
# route going to a different subnet via a router
_nexthop=`echo $_route | awk '{print $5}'`
echo "rd.route=[$_target]:[$_nexthop]:$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf
else
echo "rd.route=[$_target]::$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf
fi
- else
_route=`/sbin/ip route get to $_target 2>&1`
+# +# for the same subnet region, following is the format # _route='192.168.200.137 dev eth1 src 192.168.200.129 # cache ' # @@ -205,13 +236,14 @@ get_routes() { # _route='192.168.201.215 via 192.168.200.137 dev eth1 src 192.168.200.129 # cache ' #
- if `echo $_route | grep -q "via"`; then
# route going to a different subnet via a router
_nexthop=`echo $_route | awk '{print $3}'`
- fi
- _netdev=$(kdump_setup_ifname $_netdev)
if `echo $_route | grep -q "via"`; then
# route going to a different subnet via a router
_nexthop=`echo $_route | awk '{print $3}'`
fi
_netdev=$(kdump_setup_ifname $_netdev)
- echo "rd.route=$_target:$_nexthop:$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf
echo "rd.route=$_target:$_nexthop:$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf
- fi
}
# Setup dracut to bringup a given network interface @@ -265,18 +297,32 @@ kdump_setup_currect_net() { local _server=$1 _netdev _srcaddr local _type=$2
- _netdev=`/sbin/ip route get to $_server 2>&1`
- [ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
- #the field in the ip output changes if we go to another subnet
- if [ -n "`echo $_netdev | grep via`" ]; then
# we are going to a different subnet
_srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $5;}'|head -n 1`
- if is_ipv6_address $_server; then
_netdev=`/sbin/ip -6 route get to $_server 2>&1`
[ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
#the field in the ip output changes if we go to another subnet
if [ -n "`echo $_netdev | grep via`" ]; then
# we are going to a different subnet
_srcaddr=`echo $_netdev|awk '{print $9}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $7;}'|head -n 1`
else
# we are on the same subnet
_srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $5}'|head -n 1`
elsefi
# we are on the same subnet
_srcaddr=`echo $_netdev|awk '{print $5}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $3}'|head -n 1`
_netdev=`/sbin/ip route get to $_server 2>&1`
[ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
#the field in the ip output changes if we go to another subnet
if [ -n "`echo $_netdev | grep via`" ]; then
# we are going to a different subnet
_srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $5;}'|head -n 1`
else
# we are on the same subnet
_srcaddr=`echo $_netdev|awk '{print $5}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $3}'|head -n 1`
fi
fi
kdump_setup_netdev "${_netdev}" "${_srcaddr}" "${_server}"
@@ -303,10 +349,15 @@ kdump_setup_currect_net() { kdump_install_net() { local config_val="$1" _server _need_dns
- _server=`echo $config_val | sed 's/.*@//' | cut -d':' -f1`
- _server=`get_remote_host $config_val`
- _need_dns=`echo $_server|grep "[a-zA-Z]"`
- [ -n "$_need_dns" ] && _server=`getent hosts $_server|cut -d' ' -f1`
if is_ipv6_target; then
_need_dns=`echo $_server|grep "[:]"`
[ -z "$_need_dns" ] && _server=`getent hosts $_server| head -n 1 | cut -d' ' -f1`
else
_need_dns=`echo $_server|grep "[a-zA-Z]"`
[ -n "$_need_dns" ] && _server=`getent hosts $_server| head -n 1 | cut -d' ' -f1`
fi
kdump_setup_currect_net $_server "net"
} @@ -442,6 +493,7 @@ kdump_get_iscsi_initiator() { kdump_setup_iscsi_device() { local path=$1 local tgt_name tgt_ipaddr
- local _srcaddr _prefix _netdev local username password userpwd_str local username_in password_in userpwd_in_str local netroot_str initiator_str
@@ -476,14 +528,24 @@ kdump_setup_iscsi_device() {
[ -n "$username_in" ] && userpwd_in_str=":$username_in:$password_in"
- kdump_setup_currect_net $tgt_ipaddr "iscsi"
_srcaddr=$(get_remote_host $tgt_ipaddr)
kdump_setup_currect_net $_srcaddr "iscsi"
# prepare netroot= command line
# FIXME: IPV6 addresses require explicit [] around $tgt_ipaddr # FIXME: Do we need to parse and set other parameters like protocol, port # iscsi_iface_name, netdev_name, LUN etc.
netroot_str="netroot=iscsi:${userpwd_str}${userpwd_in_str}@$tgt_ipaddr::::$tgt_name"
if is_ipv6_address $_srcaddr; then
if `echo $tgt_ipaddr | grep -q "%"`; then
_prefix=${tgt_ipaddr%\%*}
_netdev=${tgt_ipaddr#*\%}
_netdev=$(kdump_setup_ifname $_netdev)
tgt_ipaddr=$_prefix%$_netdev
fi
netroot_str="netroot=iscsi:${userpwd_str}${userpwd_in_str}@[$tgt_ipaddr]::::$tgt_name"
else
netroot_str="netroot=iscsi:${userpwd_str}${userpwd_in_str}@$tgt_ipaddr::::$tgt_name"
fi
[[ -f $netroot_conf ]] || touch $netroot_conf
@@ -616,6 +678,8 @@ install() { inst "/bin/dd" "/bin/dd" inst "/bin/tail" "/bin/tail" inst "/bin/date" "/bin/date"
- inst "/bin/getent" "/bin/getent"
- inst "/bin/head" "/bin/head" inst "/bin/sync" "/bin/sync" inst "/bin/cut" "/bin/cut" inst "/sbin/makedumpfile" "/sbin/makedumpfile"
-- 1.8.3.1
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 12/29/14 at 04:10pm, Dave Young wrote:
On 12/15/14 at 11:20am, Minfei Huang wrote:
Currently kdump doesn't support ipv6 nfs/ssh dump. Ipv6 is the latest version of the Internet Protocal. So it is a significant feture for kdump to enhance to support ipv6.
Since dracut has supported ipv6 now, it is easy to change the kdump code to support ipv6. Just need pass the right _ip_opts to the second kernle. What is the main difference in userspace bettwen ipv4 and ipv6 is the ip address format. For ipv6 nfs dump: if ipv6 address type is link scope, /etc/kdump.conf should be edited like "nfs [fe80::5054:ff:fe48:ca80%eth0]:/mnt" else /etc/kdump.conf should be edited like "nfs [2001:db8:0:f101::2]:/mnt" For ipv6 ssh dump if ipv6 address type is link scope, /etc/kdump.conf should be edited like "ssh root at fe80::5054:ff:fe48:ca80%eth0" else /etc/kdump.conf should be edited like "ssh root at 2001:db8:0:f101::2"
What this patch do is: a): Modify kdump_setup_currect_net to handle ipv6 configuration in /etc/kdump.conf correctly. Get the ipv6 address from /etc/kdump.conf is more complicated than ipv4 because the difference configuration format mentioned above. b): Based on the ip address type, using corresponding ip address as HOST_IP in second kernel.
Note: 1): Currntly only f19 support remount a nfs target in ipv6. If using in f20, you can comment out "mount -o remount,rw $_mp || return 1" in kdump.sh line 105.
It is from previous testing from Arthur, is above still valid?
This patch's comment is copied from the orignal ipv6 patch which posted by Arthur. oh, maybe I would re-write it.
2): If Using static ipv6 address and configuring nfs/ssh with hostname of remote target, MUST add a ipv6 DNS in ifcfg-devname.
Can we detect this and error out in case no such DNS? if not possible maybe we should document it in kdump howto to suggest user to add it in ifcfg.
How to create a ipv6 enviromnet. 1): Reserving two beaker machine with family fedora. 2): Choosing a beaker machine as a nfs/ssh server and delete it's ipv4 address by "ip address del ipv4-address dev nicname" 3): Configuring the /etc/kdump.conf like mentioned above.
Signed-off-by: Minfei Huang mhuang@redhat.com
dracut-kdump.sh | 8 +++- dracut-module-setup.sh | 126 +++++++++++++++++++++++++++++++++++++------------ 2 files changed, 101 insertions(+), 33 deletions(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 52ebbdd..e2c5965 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -121,9 +121,13 @@ get_host_ip() then kdumpnic=$(getarg kdumpnic=) [ -z "$kdumpnic" ] && echo "kdump: failed to get kdumpnic!" && return 1
_host=`ip addr show dev $kdumpnic|grep 'inet '`
if is_ipv6_target; then
_host=`ip -6 addr show dev $kdumpnic|grep 'inet6'`
else
_host=`ip addr show dev $kdumpnic|grep 'inet '`
fi [ $? -ne 0 ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1
_host="${_host##*inet }"
_host=`echo $_host | cut -d' ' -f2` _host="${_host%%/*}" [ -z "$_host" ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1 HOST_IP=$_host
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 10f7c83..072b6a5 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -70,14 +70,25 @@ kdump_setup_dns() { #$2: srcaddr #if it use static ip echo it, or echo null kdump_static_ip() {
- local _netmask _gateway
- local _netmask _gateway _ipaddr local _netdev="$1" _srcaddr="$2"
- local _ipaddr=$(ip addr show dev $_netdev permanent | \
- if is_ipv6_target; then
_ipaddr=$(ip -6 addr show dev $_netdev permanent | \
awk "/ $_srcaddr\/.* /{print \$2}")
if [ -n "$_ipaddr" ]; then
_netmask=${_ipaddr#*\/}
_gateway=$(ip -6 route list dev $_netdev | awk '/^default /{print $3}')
echo -n "[${_srcaddr}]::[${_gateway}]:${_netmask}::"
fi
- else
_ipaddr=$(ip addr show dev $_netdev permanent | \ awk "/ $_srcaddr\/.* $_netdev\$/{print \$2}")
- if [ -n "$_ipaddr" ]; then
_netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2)
_gateway=$(ip route list dev $_netdev | awk '/^default /{print $3}')
echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
if [ -n "$_ipaddr" ]; then
_netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2)
_gateway=$(ip route list dev $_netdev | awk '/^default /{print $3}')
echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
fifi
}
@@ -195,9 +206,29 @@ get_routes() { local _netdev="$1" _target="$2" local _route _nexthop
- _route=`/sbin/ip route get to $_target 2>&1`
- if is_ipv6_target; then
_route=`/sbin/ip -6 route get to $_target 2>&1`
+# +# for the same subnet region, following is the format # -# in the same subnet region, following is the route format +# _route='2001:11::11f from :: dev eth1 src 2001:11::120 metric 0 +# cache' +# in the different subnet region, following is the route format +# _route='2001:10::120 from :: via 2001:11::11f dev eth1 src 2001:11::120 metric 0 +# cache' +#
_netdev=$(kdump_setup_ifname $_netdev)
if `echo $_route | grep -q "via"`; then
# route going to a different subnet via a router
_nexthop=`echo $_route | awk '{print $5}'`
echo "rd.route=[$_target]:[$_nexthop]:$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf
else
echo "rd.route=[$_target]::$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf
fi
- else
_route=`/sbin/ip route get to $_target 2>&1`
+# +# for the same subnet region, following is the format # _route='192.168.200.137 dev eth1 src 192.168.200.129 # cache ' # @@ -205,13 +236,14 @@ get_routes() { # _route='192.168.201.215 via 192.168.200.137 dev eth1 src 192.168.200.129 # cache ' #
- if `echo $_route | grep -q "via"`; then
# route going to a different subnet via a router
_nexthop=`echo $_route | awk '{print $3}'`
- fi
- _netdev=$(kdump_setup_ifname $_netdev)
if `echo $_route | grep -q "via"`; then
# route going to a different subnet via a router
_nexthop=`echo $_route | awk '{print $3}'`
fi
_netdev=$(kdump_setup_ifname $_netdev)
- echo "rd.route=$_target:$_nexthop:$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf
echo "rd.route=$_target:$_nexthop:$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf
- fi
}
# Setup dracut to bringup a given network interface @@ -265,18 +297,32 @@ kdump_setup_currect_net() { local _server=$1 _netdev _srcaddr local _type=$2
- _netdev=`/sbin/ip route get to $_server 2>&1`
- [ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
- #the field in the ip output changes if we go to another subnet
- if [ -n "`echo $_netdev | grep via`" ]; then
# we are going to a different subnet
_srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $5;}'|head -n 1`
- if is_ipv6_address $_server; then
_netdev=`/sbin/ip -6 route get to $_server 2>&1`
[ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
#the field in the ip output changes if we go to another subnet
if [ -n "`echo $_netdev | grep via`" ]; then
# we are going to a different subnet
_srcaddr=`echo $_netdev|awk '{print $9}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $7;}'|head -n 1`
else
# we are on the same subnet
_srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $5}'|head -n 1`
elsefi
# we are on the same subnet
_srcaddr=`echo $_netdev|awk '{print $5}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $3}'|head -n 1`
_netdev=`/sbin/ip route get to $_server 2>&1`
[ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
#the field in the ip output changes if we go to another subnet
if [ -n "`echo $_netdev | grep via`" ]; then
# we are going to a different subnet
_srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $5;}'|head -n 1`
else
# we are on the same subnet
_srcaddr=`echo $_netdev|awk '{print $5}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $3}'|head -n 1`
fi
fi
kdump_setup_netdev "${_netdev}" "${_srcaddr}" "${_server}"
@@ -303,10 +349,15 @@ kdump_setup_currect_net() { kdump_install_net() { local config_val="$1" _server _need_dns
- _server=`echo $config_val | sed 's/.*@//' | cut -d':' -f1`
- _server=`get_remote_host $config_val`
- _need_dns=`echo $_server|grep "[a-zA-Z]"`
- [ -n "$_need_dns" ] && _server=`getent hosts $_server|cut -d' ' -f1`
if is_ipv6_target; then
_need_dns=`echo $_server|grep "[:]"`
[ -z "$_need_dns" ] && _server=`getent hosts $_server| head -n 1 | cut -d' ' -f1`
else
_need_dns=`echo $_server|grep "[a-zA-Z]"`
[ -n "$_need_dns" ] && _server=`getent hosts $_server| head -n 1 | cut -d' ' -f1`
fi
kdump_setup_currect_net $_server "net"
} @@ -442,6 +493,7 @@ kdump_get_iscsi_initiator() { kdump_setup_iscsi_device() { local path=$1 local tgt_name tgt_ipaddr
- local _srcaddr _prefix _netdev local username password userpwd_str local username_in password_in userpwd_in_str local netroot_str initiator_str
@@ -476,14 +528,24 @@ kdump_setup_iscsi_device() {
[ -n "$username_in" ] && userpwd_in_str=":$username_in:$password_in"
- kdump_setup_currect_net $tgt_ipaddr "iscsi"
_srcaddr=$(get_remote_host $tgt_ipaddr)
kdump_setup_currect_net $_srcaddr "iscsi"
# prepare netroot= command line
# FIXME: IPV6 addresses require explicit [] around $tgt_ipaddr # FIXME: Do we need to parse and set other parameters like protocol, port # iscsi_iface_name, netdev_name, LUN etc.
netroot_str="netroot=iscsi:${userpwd_str}${userpwd_in_str}@$tgt_ipaddr::::$tgt_name"
if is_ipv6_address $_srcaddr; then
if `echo $tgt_ipaddr | grep -q "%"`; then
_prefix=${tgt_ipaddr%\%*}
_netdev=${tgt_ipaddr#*\%}
_netdev=$(kdump_setup_ifname $_netdev)
tgt_ipaddr=$_prefix%$_netdev
fi
netroot_str="netroot=iscsi:${userpwd_str}${userpwd_in_str}@[$tgt_ipaddr]::::$tgt_name"
else
netroot_str="netroot=iscsi:${userpwd_str}${userpwd_in_str}@$tgt_ipaddr::::$tgt_name"
fi
[[ -f $netroot_conf ]] || touch $netroot_conf
@@ -616,6 +678,8 @@ install() { inst "/bin/dd" "/bin/dd" inst "/bin/tail" "/bin/tail" inst "/bin/date" "/bin/date"
- inst "/bin/getent" "/bin/getent"
- inst "/bin/head" "/bin/head" inst "/bin/sync" "/bin/sync" inst "/bin/cut" "/bin/cut" inst "/sbin/makedumpfile" "/sbin/makedumpfile"
-- 1.8.3.1
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 12/31/14 at 02:23pm, Minfei Huang wrote:
On 12/29/14 at 04:10pm, Dave Young wrote:
On 12/15/14 at 11:20am, Minfei Huang wrote:
Currently kdump doesn't support ipv6 nfs/ssh dump. Ipv6 is the latest version of the Internet Protocal. So it is a significant feture for kdump to enhance to support ipv6.
Since dracut has supported ipv6 now, it is easy to change the kdump code to support ipv6. Just need pass the right _ip_opts to the second kernle. What is the main difference in userspace bettwen ipv4 and ipv6 is the ip address format. For ipv6 nfs dump: if ipv6 address type is link scope, /etc/kdump.conf should be edited like "nfs [fe80::5054:ff:fe48:ca80%eth0]:/mnt" else /etc/kdump.conf should be edited like "nfs [2001:db8:0:f101::2]:/mnt" For ipv6 ssh dump if ipv6 address type is link scope, /etc/kdump.conf should be edited like "ssh root at fe80::5054:ff:fe48:ca80%eth0" else /etc/kdump.conf should be edited like "ssh root at 2001:db8:0:f101::2"
What this patch do is: a): Modify kdump_setup_currect_net to handle ipv6 configuration in /etc/kdump.conf correctly. Get the ipv6 address from /etc/kdump.conf is more complicated than ipv4 because the difference configuration format mentioned above. b): Based on the ip address type, using corresponding ip address as HOST_IP in second kernel.
Note: 1): Currntly only f19 support remount a nfs target in ipv6. If using in f20, you can comment out "mount -o remount,rw $_mp || return 1" in kdump.sh line 105.
It is from previous testing from Arthur, is above still valid?
This patch's comment is copied from the orignal ipv6 patch which posted by Arthur. oh, maybe I would re-write it.
Previously Arthur see a nfs bug that `mount -o remount,rw` fails for nfs in Fedora. You can do a simple verification, hopefully it has been fixed.
2): If Using static ipv6 address and configuring nfs/ssh with hostname of remote target, MUST add a ipv6 DNS in ifcfg-devname.
Can we detect this and error out in case no such DNS? if not possible maybe we should document it in kdump howto to suggest user to add it in ifcfg.
How to create a ipv6 enviromnet. 1): Reserving two beaker machine with family fedora. 2): Choosing a beaker machine as a nfs/ssh server and delete it's ipv4 address by "ip address del ipv4-address dev nicname" 3): Configuring the /etc/kdump.conf like mentioned above.
Signed-off-by: Minfei Huang mhuang@redhat.com
Thanks Dave
On 01/04/15 at 01:21pm, Dave Young wrote:
On 12/31/14 at 02:23pm, Minfei Huang wrote:
On 12/29/14 at 04:10pm, Dave Young wrote:
On 12/15/14 at 11:20am, Minfei Huang wrote:
Currently kdump doesn't support ipv6 nfs/ssh dump. Ipv6 is the latest version of the Internet Protocal. So it is a significant feture for kdump to enhance to support ipv6.
Since dracut has supported ipv6 now, it is easy to change the kdump code to support ipv6. Just need pass the right _ip_opts to the second kernle. What is the main difference in userspace bettwen ipv4 and ipv6 is the ip address format. For ipv6 nfs dump: if ipv6 address type is link scope, /etc/kdump.conf should be edited like "nfs [fe80::5054:ff:fe48:ca80%eth0]:/mnt" else /etc/kdump.conf should be edited like "nfs [2001:db8:0:f101::2]:/mnt" For ipv6 ssh dump if ipv6 address type is link scope, /etc/kdump.conf should be edited like "ssh root at fe80::5054:ff:fe48:ca80%eth0" else /etc/kdump.conf should be edited like "ssh root at 2001:db8:0:f101::2"
What this patch do is: a): Modify kdump_setup_currect_net to handle ipv6 configuration in /etc/kdump.conf correctly. Get the ipv6 address from /etc/kdump.conf is more complicated than ipv4 because the difference configuration format mentioned above. b): Based on the ip address type, using corresponding ip address as HOST_IP in second kernel.
Note: 1): Currntly only f19 support remount a nfs target in ipv6. If using in f20, you can comment out "mount -o remount,rw $_mp || return 1" in kdump.sh line 105.
It is from previous testing from Arthur, is above still valid?
This patch's comment is copied from the orignal ipv6 patch which posted by Arthur. oh, maybe I would re-write it.
Previously Arthur see a nfs bug that `mount -o remount,rw` fails for nfs in Fedora. You can do a simple verification, hopefully it has been fixed.
Thank you for reviewing.
I will verify the issue and modify the commit log accordingly.
2): If Using static ipv6 address and configuring nfs/ssh with hostname of remote target, MUST add a ipv6 DNS in ifcfg-devname.
Can we detect this and error out in case no such DNS? if not possible maybe we should document it in kdump howto to suggest user to add it in ifcfg.
How to create a ipv6 enviromnet. 1): Reserving two beaker machine with family fedora. 2): Choosing a beaker machine as a nfs/ssh server and delete it's ipv4 address by "ip address del ipv4-address dev nicname" 3): Configuring the /etc/kdump.conf like mentioned above.
Signed-off-by: Minfei Huang mhuang@redhat.com
Thanks Dave
On 12/15/14 at 11:20am, Minfei Huang wrote:
Currently kdump doesn't support ipv6 nfs/ssh dump. Ipv6 is the latest version of the Internet Protocal. So it is a significant feture for kdump to enhance to support ipv6.
Since dracut has supported ipv6 now, it is easy to change the kdump code to support ipv6. Just need pass the right _ip_opts to the second kernle. What is the main difference in userspace bettwen ipv4 and ipv6 is the ip address format. For ipv6 nfs dump: if ipv6 address type is link scope, /etc/kdump.conf should be edited like "nfs [fe80::5054:ff:fe48:ca80%eth0]:/mnt" else /etc/kdump.conf should be edited like "nfs [2001:db8:0:f101::2]:/mnt" For ipv6 ssh dump if ipv6 address type is link scope, /etc/kdump.conf should be edited like "ssh root at fe80::5054:ff:fe48:ca80%eth0" else /etc/kdump.conf should be edited like "ssh root at 2001:db8:0:f101::2"
What this patch do is: a): Modify kdump_setup_currect_net to handle ipv6 configuration in /etc/kdump.conf correctly. Get the ipv6 address from /etc/kdump.conf is more complicated than ipv4 because the difference configuration format mentioned above. b): Based on the ip address type, using corresponding ip address as HOST_IP in second kernel.
Note: 1): Currntly only f19 support remount a nfs target in ipv6. If using in f20, you can comment out "mount -o remount,rw $_mp || return 1" in kdump.sh line 105. 2): If Using static ipv6 address and configuring nfs/ssh with hostname of remote target, MUST add a ipv6 DNS in ifcfg-devname.
How to create a ipv6 enviromnet. 1): Reserving two beaker machine with family fedora. 2): Choosing a beaker machine as a nfs/ssh server and delete it's ipv4 address by "ip address del ipv4-address dev nicname" 3): Configuring the /etc/kdump.conf like mentioned above.
Signed-off-by: Minfei Huang mhuang@redhat.com
dracut-kdump.sh | 8 +++- dracut-module-setup.sh | 126 +++++++++++++++++++++++++++++++++++++------------ 2 files changed, 101 insertions(+), 33 deletions(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 52ebbdd..e2c5965 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -121,9 +121,13 @@ get_host_ip() then kdumpnic=$(getarg kdumpnic=) [ -z "$kdumpnic" ] && echo "kdump: failed to get kdumpnic!" && return 1
_host=`ip addr show dev $kdumpnic|grep 'inet '`
if is_ipv6_target; then
_host=`ip -6 addr show dev $kdumpnic|grep 'inet6'`
else
_host=`ip addr show dev $kdumpnic|grep 'inet '`
fi
In Fedora 19 `ip addr show` will print both inet and inet6 addresses, so for hostname based configs it will choose anything which is ok.
As for my test, it shows below, the inet6 addresses is a local link scope addr, so we should better use the ipv4 addresses if ipv4 is available. [dyoung@dhcp-**-** kexec-tools]$ ip addr show eno1|grep inet inet 10.66.128.45/23 brd 10.66.129.255 scope global eno1 inet6 fe80::82c1:6eff:fef7:da3c/64 scope link
Another way is improve is_ipv6_target as is_ipv6_addr for ipv6 target which is specified as ipv6 addresses in kdump.conf?
[ $? -ne 0 ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1
_host="${_host##*inet }"
_host=`echo $_host | cut -d' ' -f2` _host="${_host%%/*}" [ -z "$_host" ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1 HOST_IP=$_host
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 10f7c83..072b6a5 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -70,14 +70,25 @@ kdump_setup_dns() { #$2: srcaddr #if it use static ip echo it, or echo null kdump_static_ip() {
- local _netmask _gateway
- local _netmask _gateway _ipaddr local _netdev="$1" _srcaddr="$2"
- local _ipaddr=$(ip addr show dev $_netdev permanent | \
- if is_ipv6_target; then
ditto question about hostname and addresses
_ipaddr=$(ip -6 addr show dev $_netdev permanent | \
awk "/ $_srcaddr\/.* /{print \$2}")
if [ -n "$_ipaddr" ]; then
_netmask=${_ipaddr#*\/}
_gateway=$(ip -6 route list dev $_netdev | awk '/^default /{print $3}')
echo -n "[${_srcaddr}]::[${_gateway}]:${_netmask}::"
fi
- else
_ipaddr=$(ip addr show dev $_netdev permanent | \ awk "/ $_srcaddr\/.* $_netdev\$/{print \$2}")
- if [ -n "$_ipaddr" ]; then
_netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2)
_gateway=$(ip route list dev $_netdev | awk '/^default /{print $3}')
echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
if [ -n "$_ipaddr" ]; then
_netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2)
_gateway=$(ip route list dev $_netdev | awk '/^default /{print $3}')
echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
fifi
}
@@ -195,9 +206,29 @@ get_routes() { local _netdev="$1" _target="$2" local _route _nexthop
- _route=`/sbin/ip route get to $_target 2>&1`
- if is_ipv6_target; then
_route=`/sbin/ip -6 route get to $_target 2>&1`
+# +# for the same subnet region, following is the format # -# in the same subnet region, following is the route format +# _route='2001:11::11f from :: dev eth1 src 2001:11::120 metric 0 +# cache' +# in the different subnet region, following is the route format +# _route='2001:10::120 from :: via 2001:11::11f dev eth1 src 2001:11::120 metric 0 +# cache' +#
_netdev=$(kdump_setup_ifname $_netdev)
if `echo $_route | grep -q "via"`; then
# route going to a different subnet via a router
_nexthop=`echo $_route | awk '{print $5}'`
echo "rd.route=[$_target]:[$_nexthop]:$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf
else
echo "rd.route=[$_target]::$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf
fi
- else
_route=`/sbin/ip route get to $_target 2>&1`
+# +# for the same subnet region, following is the format # _route='192.168.200.137 dev eth1 src 192.168.200.129 # cache ' # @@ -205,13 +236,14 @@ get_routes() { # _route='192.168.201.215 via 192.168.200.137 dev eth1 src 192.168.200.129 # cache ' #
- if `echo $_route | grep -q "via"`; then
# route going to a different subnet via a router
_nexthop=`echo $_route | awk '{print $3}'`
- fi
- _netdev=$(kdump_setup_ifname $_netdev)
if `echo $_route | grep -q "via"`; then
# route going to a different subnet via a router
_nexthop=`echo $_route | awk '{print $3}'`
fi
_netdev=$(kdump_setup_ifname $_netdev)
- echo "rd.route=$_target:$_nexthop:$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf
echo "rd.route=$_target:$_nexthop:$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf
- fi
}
route related stuff, would leave to Baoquan to review..
# Setup dracut to bringup a given network interface @@ -265,18 +297,32 @@ kdump_setup_currect_net() { local _server=$1 _netdev _srcaddr local _type=$2
- _netdev=`/sbin/ip route get to $_server 2>&1`
- [ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
- #the field in the ip output changes if we go to another subnet
- if [ -n "`echo $_netdev | grep via`" ]; then
# we are going to a different subnet
_srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $5;}'|head -n 1`
- if is_ipv6_address $_server; then
_netdev=`/sbin/ip -6 route get to $_server 2>&1`
[ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
#the field in the ip output changes if we go to another subnet
if [ -n "`echo $_netdev | grep via`" ]; then
# we are going to a different subnet
_srcaddr=`echo $_netdev|awk '{print $9}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $7;}'|head -n 1`
else
# we are on the same subnet
_srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $5}'|head -n 1`
elsefi
# we are on the same subnet
_srcaddr=`echo $_netdev|awk '{print $5}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $3}'|head -n 1`
_netdev=`/sbin/ip route get to $_server 2>&1`
[ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
#the field in the ip output changes if we go to another subnet
if [ -n "`echo $_netdev | grep via`" ]; then
# we are going to a different subnet
_srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $5;}'|head -n 1`
else
# we are on the same subnet
_srcaddr=`echo $_netdev|awk '{print $5}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $3}'|head -n 1`
fi
fi
kdump_setup_netdev "${_netdev}" "${_srcaddr}" "${_server}"
@@ -303,10 +349,15 @@ kdump_setup_currect_net() { kdump_install_net() { local config_val="$1" _server _need_dns
- _server=`echo $config_val | sed 's/.*@//' | cut -d':' -f1`
- _server=`get_remote_host $config_val`
- _need_dns=`echo $_server|grep "[a-zA-Z]"`
- [ -n "$_need_dns" ] && _server=`getent hosts $_server|cut -d' ' -f1`
- if is_ipv6_target; then
_need_dns=`echo $_server|grep "[:]"`
A new function such as is_hostname() or ! is_ip_addr() will be better here.
[ -z "$_need_dns" ] && _server=`getent hosts $_server| head -n 1 | cut -d' ' -f1`
else
_need_dns=`echo $_server|grep "[a-zA-Z]"`
[ -n "$_need_dns" ] && _server=`getent hosts $_server| head -n 1 | cut -d' ' -f1`
fi
kdump_setup_currect_net $_server "net"
} @@ -442,6 +493,7 @@ kdump_get_iscsi_initiator() { kdump_setup_iscsi_device() { local path=$1 local tgt_name tgt_ipaddr
- local _srcaddr _prefix _netdev local username password userpwd_str local username_in password_in userpwd_in_str local netroot_str initiator_str
@@ -476,14 +528,24 @@ kdump_setup_iscsi_device() {
[ -n "$username_in" ] && userpwd_in_str=":$username_in:$password_in"
- kdump_setup_currect_net $tgt_ipaddr "iscsi"
- _srcaddr=$(get_remote_host $tgt_ipaddr)
- kdump_setup_currect_net $_srcaddr "iscsi"
"currect_net" sounds strange..
# prepare netroot= command line
# FIXME: IPV6 addresses require explicit [] around $tgt_ipaddr # FIXME: Do we need to parse and set other parameters like protocol, port # iscsi_iface_name, netdev_name, LUN etc.
netroot_str="netroot=iscsi:${userpwd_str}${userpwd_in_str}@$tgt_ipaddr::::$tgt_name"
if is_ipv6_address $_srcaddr; then
if `echo $tgt_ipaddr | grep -q "%"`; then
_prefix=${tgt_ipaddr%\%*}
_netdev=${tgt_ipaddr#*\%}
_netdev=$(kdump_setup_ifname $_netdev)
tgt_ipaddr=$_prefix%$_netdev
fi
netroot_str="netroot=iscsi:${userpwd_str}${userpwd_in_str}@[$tgt_ipaddr]::::$tgt_name"
else
netroot_str="netroot=iscsi:${userpwd_str}${userpwd_in_str}@$tgt_ipaddr::::$tgt_name"
fi
[[ -f $netroot_conf ]] || touch $netroot_conf
@@ -616,6 +678,8 @@ install() { inst "/bin/dd" "/bin/dd" inst "/bin/tail" "/bin/tail" inst "/bin/date" "/bin/date"
- inst "/bin/getent" "/bin/getent"
- inst "/bin/head" "/bin/head" inst "/bin/sync" "/bin/sync" inst "/bin/cut" "/bin/cut" inst "/sbin/makedumpfile" "/sbin/makedumpfile"
-- 1.8.3.1
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 01/04/15 at 01:50pm, Dave Young wrote:
On 12/15/14 at 11:20am, Minfei Huang wrote:
Currently kdump doesn't support ipv6 nfs/ssh dump. Ipv6 is the latest version of the Internet Protocal. So it is a significant feture for kdump to enhance to support ipv6.
Since dracut has supported ipv6 now, it is easy to change the kdump code to support ipv6. Just need pass the right _ip_opts to the second kernle. What is the main difference in userspace bettwen ipv4 and ipv6 is the ip address format. For ipv6 nfs dump: if ipv6 address type is link scope, /etc/kdump.conf should be edited like "nfs [fe80::5054:ff:fe48:ca80%eth0]:/mnt" else /etc/kdump.conf should be edited like "nfs [2001:db8:0:f101::2]:/mnt" For ipv6 ssh dump if ipv6 address type is link scope, /etc/kdump.conf should be edited like "ssh root at fe80::5054:ff:fe48:ca80%eth0" else /etc/kdump.conf should be edited like "ssh root at 2001:db8:0:f101::2"
What this patch do is: a): Modify kdump_setup_currect_net to handle ipv6 configuration in /etc/kdump.conf correctly. Get the ipv6 address from /etc/kdump.conf is more complicated than ipv4 because the difference configuration format mentioned above. b): Based on the ip address type, using corresponding ip address as HOST_IP in second kernel.
Note: 1): Currntly only f19 support remount a nfs target in ipv6. If using in f20, you can comment out "mount -o remount,rw $_mp || return 1" in kdump.sh line 105. 2): If Using static ipv6 address and configuring nfs/ssh with hostname of remote target, MUST add a ipv6 DNS in ifcfg-devname.
How to create a ipv6 enviromnet. 1): Reserving two beaker machine with family fedora. 2): Choosing a beaker machine as a nfs/ssh server and delete it's ipv4 address by "ip address del ipv4-address dev nicname" 3): Configuring the /etc/kdump.conf like mentioned above.
Signed-off-by: Minfei Huang mhuang@redhat.com
dracut-kdump.sh | 8 +++- dracut-module-setup.sh | 126 +++++++++++++++++++++++++++++++++++++------------ 2 files changed, 101 insertions(+), 33 deletions(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 52ebbdd..e2c5965 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -121,9 +121,13 @@ get_host_ip() then kdumpnic=$(getarg kdumpnic=) [ -z "$kdumpnic" ] && echo "kdump: failed to get kdumpnic!" && return 1
_host=`ip addr show dev $kdumpnic|grep 'inet '`
if is_ipv6_target; then
_host=`ip -6 addr show dev $kdumpnic|grep 'inet6'`
else
_host=`ip addr show dev $kdumpnic|grep 'inet '`
fi
In Fedora 19 `ip addr show` will print both inet and inet6 addresses, so for hostname based configs it will choose anything which is ok.
As for my test, it shows below, the inet6 addresses is a local link scope addr, so we should better use the ipv4 addresses if ipv4 is available. [dyoung@dhcp-**-** kexec-tools]$ ip addr show eno1|grep inet inet 10.66.128.45/23 brd 10.66.129.255 scope global eno1 inet6 fe80::82c1:6eff:fef7:da3c/64 scope link
Another way is improve is_ipv6_target as is_ipv6_addr for ipv6 target which is specified as ipv6 addresses in kdump.conf?
We will use the ip address which specifies in the kdump.conf config. If the target value is domain/hostname, we will use command "get ahost $_server" to get the first returned ip address.
[ $? -ne 0 ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1
_host="${_host##*inet }"
_host=`echo $_host | cut -d' ' -f2` _host="${_host%%/*}" [ -z "$_host" ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1 HOST_IP=$_host
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 10f7c83..072b6a5 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -70,14 +70,25 @@ kdump_setup_dns() { #$2: srcaddr #if it use static ip echo it, or echo null kdump_static_ip() {
- local _netmask _gateway
- local _netmask _gateway _ipaddr local _netdev="$1" _srcaddr="$2"
- local _ipaddr=$(ip addr show dev $_netdev permanent | \
- if is_ipv6_target; then
ditto question about hostname and addresses
What the function is_ipv6_target does is to parse and verify the kdump.conf's target value. So I think whatever the function names is_ipv6_target or is_ipv6_address is okay.
_ipaddr=$(ip -6 addr show dev $_netdev permanent | \
awk "/ $_srcaddr\/.* /{print \$2}")
if [ -n "$_ipaddr" ]; then
_netmask=${_ipaddr#*\/}
_gateway=$(ip -6 route list dev $_netdev | awk '/^default /{print $3}')
echo -n "[${_srcaddr}]::[${_gateway}]:${_netmask}::"
fi
- else
_ipaddr=$(ip addr show dev $_netdev permanent | \ awk "/ $_srcaddr\/.* $_netdev\$/{print \$2}")
- if [ -n "$_ipaddr" ]; then
_netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2)
_gateway=$(ip route list dev $_netdev | awk '/^default /{print $3}')
echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
if [ -n "$_ipaddr" ]; then
_netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2)
_gateway=$(ip route list dev $_netdev | awk '/^default /{print $3}')
echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
fifi
}
@@ -195,9 +206,29 @@ get_routes() { local _netdev="$1" _target="$2" local _route _nexthop
- _route=`/sbin/ip route get to $_target 2>&1`
- if is_ipv6_target; then
_route=`/sbin/ip -6 route get to $_target 2>&1`
+# +# for the same subnet region, following is the format # -# in the same subnet region, following is the route format +# _route='2001:11::11f from :: dev eth1 src 2001:11::120 metric 0 +# cache' +# in the different subnet region, following is the route format +# _route='2001:10::120 from :: via 2001:11::11f dev eth1 src 2001:11::120 metric 0 +# cache' +#
_netdev=$(kdump_setup_ifname $_netdev)
if `echo $_route | grep -q "via"`; then
# route going to a different subnet via a router
_nexthop=`echo $_route | awk '{print $5}'`
echo "rd.route=[$_target]:[$_nexthop]:$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf
else
echo "rd.route=[$_target]::$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf
fi
- else
_route=`/sbin/ip route get to $_target 2>&1`
+# +# for the same subnet region, following is the format # _route='192.168.200.137 dev eth1 src 192.168.200.129 # cache ' # @@ -205,13 +236,14 @@ get_routes() { # _route='192.168.201.215 via 192.168.200.137 dev eth1 src 192.168.200.129 # cache ' #
- if `echo $_route | grep -q "via"`; then
# route going to a different subnet via a router
_nexthop=`echo $_route | awk '{print $3}'`
- fi
- _netdev=$(kdump_setup_ifname $_netdev)
if `echo $_route | grep -q "via"`; then
# route going to a different subnet via a router
_nexthop=`echo $_route | awk '{print $3}'`
fi
_netdev=$(kdump_setup_ifname $_netdev)
- echo "rd.route=$_target:$_nexthop:$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf
echo "rd.route=$_target:$_nexthop:$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf
- fi
}
route related stuff, would leave to Baoquan to review..
Thank you Baoquan.
# Setup dracut to bringup a given network interface @@ -265,18 +297,32 @@ kdump_setup_currect_net() { local _server=$1 _netdev _srcaddr local _type=$2
- _netdev=`/sbin/ip route get to $_server 2>&1`
- [ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
- #the field in the ip output changes if we go to another subnet
- if [ -n "`echo $_netdev | grep via`" ]; then
# we are going to a different subnet
_srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $5;}'|head -n 1`
- if is_ipv6_address $_server; then
_netdev=`/sbin/ip -6 route get to $_server 2>&1`
[ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
#the field in the ip output changes if we go to another subnet
if [ -n "`echo $_netdev | grep via`" ]; then
# we are going to a different subnet
_srcaddr=`echo $_netdev|awk '{print $9}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $7;}'|head -n 1`
else
# we are on the same subnet
_srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $5}'|head -n 1`
elsefi
# we are on the same subnet
_srcaddr=`echo $_netdev|awk '{print $5}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $3}'|head -n 1`
_netdev=`/sbin/ip route get to $_server 2>&1`
[ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
#the field in the ip output changes if we go to another subnet
if [ -n "`echo $_netdev | grep via`" ]; then
# we are going to a different subnet
_srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $5;}'|head -n 1`
else
# we are on the same subnet
_srcaddr=`echo $_netdev|awk '{print $5}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $3}'|head -n 1`
fi
fi
kdump_setup_netdev "${_netdev}" "${_srcaddr}" "${_server}"
@@ -303,10 +349,15 @@ kdump_setup_currect_net() { kdump_install_net() { local config_val="$1" _server _need_dns
- _server=`echo $config_val | sed 's/.*@//' | cut -d':' -f1`
- _server=`get_remote_host $config_val`
- _need_dns=`echo $_server|grep "[a-zA-Z]"`
- [ -n "$_need_dns" ] && _server=`getent hosts $_server|cut -d' ' -f1`
- if is_ipv6_target; then
_need_dns=`echo $_server|grep "[:]"`
A new function such as is_hostname() or ! is_ip_addr() will be better here.
Do we need a function to implement it? just for a simple filter.
[ -z "$_need_dns" ] && _server=`getent hosts $_server| head -n 1 | cut -d' ' -f1`
else
_need_dns=`echo $_server|grep "[a-zA-Z]"`
[ -n "$_need_dns" ] && _server=`getent hosts $_server| head -n 1 | cut -d' ' -f1`
fi
kdump_setup_currect_net $_server "net"
} @@ -442,6 +493,7 @@ kdump_get_iscsi_initiator() { kdump_setup_iscsi_device() { local path=$1 local tgt_name tgt_ipaddr
- local _srcaddr _prefix _netdev local username password userpwd_str local username_in password_in userpwd_in_str local netroot_str initiator_str
@@ -476,14 +528,24 @@ kdump_setup_iscsi_device() {
[ -n "$username_in" ] && userpwd_in_str=":$username_in:$password_in"
- kdump_setup_currect_net $tgt_ipaddr "iscsi"
- _srcaddr=$(get_remote_host $tgt_ipaddr)
- kdump_setup_currect_net $_srcaddr "iscsi"
"currect_net" sounds strange..
Maybe we can name the function properly.
# prepare netroot= command line
# FIXME: IPV6 addresses require explicit [] around $tgt_ipaddr # FIXME: Do we need to parse and set other parameters like protocol, port # iscsi_iface_name, netdev_name, LUN etc.
netroot_str="netroot=iscsi:${userpwd_str}${userpwd_in_str}@$tgt_ipaddr::::$tgt_name"
if is_ipv6_address $_srcaddr; then
if `echo $tgt_ipaddr | grep -q "%"`; then
_prefix=${tgt_ipaddr%\%*}
_netdev=${tgt_ipaddr#*\%}
_netdev=$(kdump_setup_ifname $_netdev)
tgt_ipaddr=$_prefix%$_netdev
fi
netroot_str="netroot=iscsi:${userpwd_str}${userpwd_in_str}@[$tgt_ipaddr]::::$tgt_name"
else
netroot_str="netroot=iscsi:${userpwd_str}${userpwd_in_str}@$tgt_ipaddr::::$tgt_name"
fi
[[ -f $netroot_conf ]] || touch $netroot_conf
@@ -616,6 +678,8 @@ install() { inst "/bin/dd" "/bin/dd" inst "/bin/tail" "/bin/tail" inst "/bin/date" "/bin/date"
- inst "/bin/getent" "/bin/getent"
- inst "/bin/head" "/bin/head" inst "/bin/sync" "/bin/sync" inst "/bin/cut" "/bin/cut" inst "/sbin/makedumpfile" "/sbin/makedumpfile"
-- 1.8.3.1
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 01/04/15 at 06:42pm, Minfei Huang wrote:
On 01/04/15 at 01:50pm, Dave Young wrote:
On 12/15/14 at 11:20am, Minfei Huang wrote:
Currently kdump doesn't support ipv6 nfs/ssh dump. Ipv6 is the latest version of the Internet Protocal. So it is a significant feture for kdump to enhance to support ipv6.
Since dracut has supported ipv6 now, it is easy to change the kdump code to support ipv6. Just need pass the right _ip_opts to the second kernle. What is the main difference in userspace bettwen ipv4 and ipv6 is the ip address format. For ipv6 nfs dump: if ipv6 address type is link scope, /etc/kdump.conf should be edited like "nfs [fe80::5054:ff:fe48:ca80%eth0]:/mnt" else /etc/kdump.conf should be edited like "nfs [2001:db8:0:f101::2]:/mnt" For ipv6 ssh dump if ipv6 address type is link scope, /etc/kdump.conf should be edited like "ssh root at fe80::5054:ff:fe48:ca80%eth0" else /etc/kdump.conf should be edited like "ssh root at 2001:db8:0:f101::2"
What this patch do is: a): Modify kdump_setup_currect_net to handle ipv6 configuration in /etc/kdump.conf correctly. Get the ipv6 address from /etc/kdump.conf is more complicated than ipv4 because the difference configuration format mentioned above. b): Based on the ip address type, using corresponding ip address as HOST_IP in second kernel.
Note: 1): Currntly only f19 support remount a nfs target in ipv6. If using in f20, you can comment out "mount -o remount,rw $_mp || return 1" in kdump.sh line 105. 2): If Using static ipv6 address and configuring nfs/ssh with hostname of remote target, MUST add a ipv6 DNS in ifcfg-devname.
How to create a ipv6 enviromnet. 1): Reserving two beaker machine with family fedora. 2): Choosing a beaker machine as a nfs/ssh server and delete it's ipv4 address by "ip address del ipv4-address dev nicname" 3): Configuring the /etc/kdump.conf like mentioned above.
Signed-off-by: Minfei Huang mhuang@redhat.com
dracut-kdump.sh | 8 +++- dracut-module-setup.sh | 126 +++++++++++++++++++++++++++++++++++++------------ 2 files changed, 101 insertions(+), 33 deletions(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 52ebbdd..e2c5965 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -121,9 +121,13 @@ get_host_ip() then kdumpnic=$(getarg kdumpnic=) [ -z "$kdumpnic" ] && echo "kdump: failed to get kdumpnic!" && return 1
_host=`ip addr show dev $kdumpnic|grep 'inet '`
if is_ipv6_target; then
_host=`ip -6 addr show dev $kdumpnic|grep 'inet6'`
else
_host=`ip addr show dev $kdumpnic|grep 'inet '`
fi
In Fedora 19 `ip addr show` will print both inet and inet6 addresses, so for hostname based configs it will choose anything which is ok.
As for my test, it shows below, the inet6 addresses is a local link scope addr, so we should better use the ipv4 addresses if ipv4 is available. [dyoung@dhcp-**-** kexec-tools]$ ip addr show eno1|grep inet inet 10.66.128.45/23 brd 10.66.129.255 scope global eno1 inet6 fe80::82c1:6eff:fef7:da3c/64 scope link
Another way is improve is_ipv6_target as is_ipv6_addr for ipv6 target which is specified as ipv6 addresses in kdump.conf?
We will use the ip address which specifies in the kdump.conf config. If the target value is domain/hostname, we will use command "get ahost $_server" to get the first returned ip address.
Sorry, I mixed up target and source, in this code path kdumpnic ip address means crashed machine ip address. is_ipv6 stuff is another story.
As for local ip address, what I want to make clear is if we can use ip addr show instead of differenciate "ip" and "ip -6"
[ $? -ne 0 ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1
_host="${_host##*inet }"
_host=`echo $_host | cut -d' ' -f2` _host="${_host%%/*}" [ -z "$_host" ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1 HOST_IP=$_host
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 10f7c83..072b6a5 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -70,14 +70,25 @@ kdump_setup_dns() { #$2: srcaddr #if it use static ip echo it, or echo null kdump_static_ip() {
- local _netmask _gateway
- local _netmask _gateway _ipaddr local _netdev="$1" _srcaddr="$2"
- local _ipaddr=$(ip addr show dev $_netdev permanent | \
- if is_ipv6_target; then
ditto question about hostname and addresses
What the function is_ipv6_target does is to parse and verify the kdump.conf's target value. So I think whatever the function names is_ipv6_target or is_ipv6_address is okay.
is_ipv6_address is clearer if we only care about ip adresses instead of both hostname (ipv6 configured) and addresses.
_ipaddr=$(ip -6 addr show dev $_netdev permanent | \
awk "/ $_srcaddr\/.* /{print \$2}")
if [ -n "$_ipaddr" ]; then
_netmask=${_ipaddr#*\/}
_gateway=$(ip -6 route list dev $_netdev | awk '/^default /{print $3}')
echo -n "[${_srcaddr}]::[${_gateway}]:${_netmask}::"
fi
- else
_ipaddr=$(ip addr show dev $_netdev permanent | \ awk "/ $_srcaddr\/.* $_netdev\$/{print \$2}")
- if [ -n "$_ipaddr" ]; then
_netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2)
_gateway=$(ip route list dev $_netdev | awk '/^default /{print $3}')
echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
if [ -n "$_ipaddr" ]; then
_netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2)
_gateway=$(ip route list dev $_netdev | awk '/^default /{print $3}')
echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
fifi
}
@@ -195,9 +206,29 @@ get_routes() { local _netdev="$1" _target="$2" local _route _nexthop
- _route=`/sbin/ip route get to $_target 2>&1`
- if is_ipv6_target; then
_route=`/sbin/ip -6 route get to $_target 2>&1`
+# +# for the same subnet region, following is the format # -# in the same subnet region, following is the route format +# _route='2001:11::11f from :: dev eth1 src 2001:11::120 metric 0 +# cache' +# in the different subnet region, following is the route format +# _route='2001:10::120 from :: via 2001:11::11f dev eth1 src 2001:11::120 metric 0 +# cache' +#
_netdev=$(kdump_setup_ifname $_netdev)
if `echo $_route | grep -q "via"`; then
# route going to a different subnet via a router
_nexthop=`echo $_route | awk '{print $5}'`
echo "rd.route=[$_target]:[$_nexthop]:$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf
else
echo "rd.route=[$_target]::$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf
fi
- else
_route=`/sbin/ip route get to $_target 2>&1`
+# +# for the same subnet region, following is the format # _route='192.168.200.137 dev eth1 src 192.168.200.129 # cache ' # @@ -205,13 +236,14 @@ get_routes() { # _route='192.168.201.215 via 192.168.200.137 dev eth1 src 192.168.200.129 # cache ' #
- if `echo $_route | grep -q "via"`; then
# route going to a different subnet via a router
_nexthop=`echo $_route | awk '{print $3}'`
- fi
- _netdev=$(kdump_setup_ifname $_netdev)
if `echo $_route | grep -q "via"`; then
# route going to a different subnet via a router
_nexthop=`echo $_route | awk '{print $3}'`
fi
_netdev=$(kdump_setup_ifname $_netdev)
- echo "rd.route=$_target:$_nexthop:$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf
echo "rd.route=$_target:$_nexthop:$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf
- fi
}
route related stuff, would leave to Baoquan to review..
Thank you Baoquan.
# Setup dracut to bringup a given network interface @@ -265,18 +297,32 @@ kdump_setup_currect_net() { local _server=$1 _netdev _srcaddr local _type=$2
- _netdev=`/sbin/ip route get to $_server 2>&1`
- [ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
- #the field in the ip output changes if we go to another subnet
- if [ -n "`echo $_netdev | grep via`" ]; then
# we are going to a different subnet
_srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $5;}'|head -n 1`
- if is_ipv6_address $_server; then
_netdev=`/sbin/ip -6 route get to $_server 2>&1`
[ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
#the field in the ip output changes if we go to another subnet
if [ -n "`echo $_netdev | grep via`" ]; then
# we are going to a different subnet
_srcaddr=`echo $_netdev|awk '{print $9}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $7;}'|head -n 1`
else
# we are on the same subnet
_srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $5}'|head -n 1`
elsefi
# we are on the same subnet
_srcaddr=`echo $_netdev|awk '{print $5}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $3}'|head -n 1`
_netdev=`/sbin/ip route get to $_server 2>&1`
[ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
#the field in the ip output changes if we go to another subnet
if [ -n "`echo $_netdev | grep via`" ]; then
# we are going to a different subnet
_srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $5;}'|head -n 1`
else
# we are on the same subnet
_srcaddr=`echo $_netdev|awk '{print $5}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $3}'|head -n 1`
fi
fi
kdump_setup_netdev "${_netdev}" "${_srcaddr}" "${_server}"
@@ -303,10 +349,15 @@ kdump_setup_currect_net() { kdump_install_net() { local config_val="$1" _server _need_dns
- _server=`echo $config_val | sed 's/.*@//' | cut -d':' -f1`
- _server=`get_remote_host $config_val`
- _need_dns=`echo $_server|grep "[a-zA-Z]"`
- [ -n "$_need_dns" ] && _server=`getent hosts $_server|cut -d' ' -f1`
- if is_ipv6_target; then
_need_dns=`echo $_server|grep "[:]"`
A new function such as is_hostname() or ! is_ip_addr() will be better here.
Do we need a function to implement it? just for a simple filter.
This is for differenciate hostname and ip addresses because current patch is trying determine a hostname is ipv6 or ipv4. As long as this can be resolved I do not think such as function is must.
[ -z "$_need_dns" ] && _server=`getent hosts $_server| head -n 1 | cut -d' ' -f1`
else
_need_dns=`echo $_server|grep "[a-zA-Z]"`
[ -n "$_need_dns" ] && _server=`getent hosts $_server| head -n 1 | cut -d' ' -f1`
fi
kdump_setup_currect_net $_server "net"
} @@ -442,6 +493,7 @@ kdump_get_iscsi_initiator() { kdump_setup_iscsi_device() { local path=$1 local tgt_name tgt_ipaddr
- local _srcaddr _prefix _netdev local username password userpwd_str local username_in password_in userpwd_in_str local netroot_str initiator_str
@@ -476,14 +528,24 @@ kdump_setup_iscsi_device() {
[ -n "$username_in" ] && userpwd_in_str=":$username_in:$password_in"
- kdump_setup_currect_net $tgt_ipaddr "iscsi"
- _srcaddr=$(get_remote_host $tgt_ipaddr)
- kdump_setup_currect_net $_srcaddr "iscsi"
"currect_net" sounds strange..
Maybe we can name the function properly.
# prepare netroot= command line
# FIXME: IPV6 addresses require explicit [] around $tgt_ipaddr # FIXME: Do we need to parse and set other parameters like protocol, port # iscsi_iface_name, netdev_name, LUN etc.
netroot_str="netroot=iscsi:${userpwd_str}${userpwd_in_str}@$tgt_ipaddr::::$tgt_name"
if is_ipv6_address $_srcaddr; then
if `echo $tgt_ipaddr | grep -q "%"`; then
_prefix=${tgt_ipaddr%\%*}
_netdev=${tgt_ipaddr#*\%}
_netdev=$(kdump_setup_ifname $_netdev)
tgt_ipaddr=$_prefix%$_netdev
fi
netroot_str="netroot=iscsi:${userpwd_str}${userpwd_in_str}@[$tgt_ipaddr]::::$tgt_name"
else
netroot_str="netroot=iscsi:${userpwd_str}${userpwd_in_str}@$tgt_ipaddr::::$tgt_name"
fi
[[ -f $netroot_conf ]] || touch $netroot_conf
@@ -616,6 +678,8 @@ install() { inst "/bin/dd" "/bin/dd" inst "/bin/tail" "/bin/tail" inst "/bin/date" "/bin/date"
- inst "/bin/getent" "/bin/getent"
- inst "/bin/head" "/bin/head" inst "/bin/sync" "/bin/sync" inst "/bin/cut" "/bin/cut" inst "/sbin/makedumpfile" "/sbin/makedumpfile"
-- 1.8.3.1
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 01/05/15 at 10:41am, Dave Young wrote: [snip] .. [snip]
@@ -121,9 +121,13 @@ get_host_ip() then kdumpnic=$(getarg kdumpnic=) [ -z "$kdumpnic" ] && echo "kdump: failed to get kdumpnic!" && return 1
_host=`ip addr show dev $kdumpnic|grep 'inet '`
if is_ipv6_target; then
_host=`ip -6 addr show dev $kdumpnic|grep 'inet6'`
else
_host=`ip addr show dev $kdumpnic|grep 'inet '`
fi
In Fedora 19 `ip addr show` will print both inet and inet6 addresses, so for hostname based configs it will choose anything which is ok.
As for my test, it shows below, the inet6 addresses is a local link scope addr, so we should better use the ipv4 addresses if ipv4 is available. [dyoung@dhcp-**-** kexec-tools]$ ip addr show eno1|grep inet inet 10.66.128.45/23 brd 10.66.129.255 scope global eno1 inet6 fe80::82c1:6eff:fef7:da3c/64 scope link
Another way is improve is_ipv6_target as is_ipv6_addr for ipv6 target which is specified as ipv6 addresses in kdump.conf?
We will use the ip address which specifies in the kdump.conf config. If the target value is domain/hostname, we will use command "get ahost $_server" to get the first returned ip address.
Sorry, I mixed up target and source, in this code path kdumpnic ip address means crashed machine ip address. is_ipv6 stuff is another story.
Yes.
As for local ip address, what I want to make clear is if we can use ip addr show instead of differenciate "ip" and "ip -6"
We will get the ipv6 address by using "ip -6", if specified the target value is ipv6 adreess.
Fist of all, we will get the ip address in the kdump.conf config, if the value is domain/hostname, parse the it by using command "getent ahosts".
[ $? -ne 0 ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1
_host="${_host##*inet }"
_host=`echo $_host | cut -d' ' -f2` _host="${_host%%/*}" [ -z "$_host" ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1 HOST_IP=$_host
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 10f7c83..072b6a5 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -70,14 +70,25 @@ kdump_setup_dns() { #$2: srcaddr #if it use static ip echo it, or echo null kdump_static_ip() {
- local _netmask _gateway
- local _netmask _gateway _ipaddr local _netdev="$1" _srcaddr="$2"
- local _ipaddr=$(ip addr show dev $_netdev permanent | \
- if is_ipv6_target; then
ditto question about hostname and addresses
What the function is_ipv6_target does is to parse and verify the kdump.conf's target value. So I think whatever the function names is_ipv6_target or is_ipv6_address is okay.
is_ipv6_address is clearer if we only care about ip adresses instead of both hostname (ipv6 configured) and addresses.
is_ipv6_address may imply to parse the parameter ip address which is ipv6 or not. Due to the parameter is not only ip address, so I think is_ipv6_target is fine.
_ipaddr=$(ip -6 addr show dev $_netdev permanent | \
awk "/ $_srcaddr\/.* /{print \$2}")
[snip] ... [snip]
kdump_setup_netdev "${_netdev}" "${_srcaddr}" "${_server}"
@@ -303,10 +349,15 @@ kdump_setup_currect_net() { kdump_install_net() { local config_val="$1" _server _need_dns
- _server=`echo $config_val | sed 's/.*@//' | cut -d':' -f1`
- _server=`get_remote_host $config_val`
- _need_dns=`echo $_server|grep "[a-zA-Z]"`
- [ -n "$_need_dns" ] && _server=`getent hosts $_server|cut -d' ' -f1`
- if is_ipv6_target; then
_need_dns=`echo $_server|grep "[:]"`
A new function such as is_hostname() or ! is_ip_addr() will be better here.
Do we need a function to implement it? just for a simple filter.
This is for differenciate hostname and ip addresses because current patch is trying determine a hostname is ipv6 or ipv4. As long as this can be resolved I do not think such as function is must.
We may mix up the ipv4 address and ipv6 address, if we wrap it to a function. Following function can determine the hostname/domain or ip address(ipv4 and ipv6).
is_hostname() { echo $1 | grep "[a-zA-Z]" | grep -q "." }