Talked with Dave Young, we decide to simplify the patch to only support non local ipv6 address from this patchset, and will support local ipv6 address in later patch. The reason why do this is it is hard to handle and review the patchset which supports both modes.
Minfei Huang (4): dracut-kdump: Use the first filtered ip address as dump directory dracut-module-setup: Support the static route for ipv6 protocol dracut-module-setup: Setup network route to support ipv6 protocol dracut-module-setup: Enhance ISCSI to support ipv6 protocol
dracut-kdump.sh | 4 +-- dracut-module-setup.sh | 70 ++++++++++++++++++++++++++++---------------------- kdump-lib.sh | 33 ++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 33 deletions(-)
For now, Kdump will use ipv4 address as dump directory, and it works, if ipv4 is enabled.
Once Kdump start to support ipv6 protocol, we may only setup the ipv6 address exclusively. Modify the code to make Kdump work in either ipv4 and ipv6 protocol.
Signed-off-by: Minfei Huang mhuang@redhat.com Acked-by: Dave Young dyoung@redhat.com --- dracut-kdump.sh | 4 ++-- dracut-module-setup.sh | 1 + 2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh index dc948d1..4aab205 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -121,9 +121,9 @@ 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 '` + _host=`ip addr show dev $kdumpnic|grep '[ ]*inet'` [ $? -ne 0 ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1 - _host="${_host##*inet }" + _host=`echo $_host | head -n 1 | 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 228fae2..d2f6a02 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -663,6 +663,7 @@ install() { inst "/bin/date" "/bin/date" inst "/bin/sync" "/bin/sync" inst "/bin/cut" "/bin/cut" + inst "/bin/head" "/bin/head" inst "/sbin/makedumpfile" "/sbin/makedumpfile" inst "/sbin/vmcore-dmesg" "/sbin/vmcore-dmesg" inst "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh"
Introduce a lib function to get the specified route field.
Previously, Kdump will save exact route to setup the network route in 2nd kernel for ipv4 protocol. To support ipv6 protocol, make Kdump fetch correct nexthop, since the ruturning format is different.
Due to the different format between ipv4 and ipv6 protocol, quote the ipv6 address with bracket "[]" to make dracut notify.
Signed-off-by: Minfei Huang mhuang@redhat.com --- dracut-module-setup.sh | 43 +++++++++++++++++++++++++++++-------------- kdump-lib.sh | 5 +++++ 2 files changed, 34 insertions(+), 14 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index d2f6a02..75737fd 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -211,26 +211,41 @@ kdump_setup_znet() { echo rd.znet=${NETTYPE},${SUBCHANNELS}${_options} > ${initdir}/etc/cmdline.d/30znet.conf }
+get_ip_route_field() +{ + if `echo $1 | grep -q $2`; then + echo ${1##*$2} | cut -d ' ' -f1 + fi +} + +# +# For the same subnet region, following is the route format +# ipv4: +# _route='192.168.200.137 dev eth1 src 192.168.200.129' +# ipv6: +# _route='2001:11::11f dev eth1 src 2001:11::120 metric 0' +# For the different subnet region, following is the route format +# ipv4: +# _route='192.168.201.215 via 192.168.200.137 dev eth1 src 192.168.200.129' +# ipv6: +# _route='2001:10::120 via 2001:11::11f dev eth1 src 2001:11::120 metric 0' get_routes() { local _netdev="$1" _target="$2" local _route _nexthop
- _route=`/sbin/ip route get to $_target 2>&1` -# -# in the same subnet region, following is the route format -# _route='192.168.200.137 dev eth1 src 192.168.200.129 -# cache ' -# -# in the different subnet region, following is the route format -# _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 + _route=`/sbin/ip -o route get to $_target 2>&1` + + # route going to a different subnet via a router + _nexthop=$(get_ip_route_field "$_route" "via") _netdev=$(kdump_setup_ifname $_netdev)
+ if $(is_ipv6_address `echo $_route | cut -d " " -f1`); then + if [ -n $_nexthop ]; then + _nexthop="[$_nexthop]" + fi + _target="[$_target]" + fi + echo "rd.route=$_target:$_nexthop:$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf }
diff --git a/kdump-lib.sh b/kdump-lib.sh index e62b4e2..1b98a6f 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -201,3 +201,8 @@ is_atomic() { grep -q "ostree" /proc/cmdline } + +is_ipv6_address() +{ + echo $1 | grep -q ":" +}
On 07/13/15 at 01:16pm, Minfei Huang wrote:
Introduce a lib function to get the specified route field.
Previously, Kdump will save exact route to setup the network route in 2nd kernel for ipv4 protocol. To support ipv6 protocol, make Kdump fetch correct nexthop, since the ruturning format is different.
Due to the different format between ipv4 and ipv6 protocol, quote the ipv6 address with bracket "[]" to make dracut notify.
Signed-off-by: Minfei Huang mhuang@redhat.com
dracut-module-setup.sh | 43 +++++++++++++++++++++++++++++-------------- kdump-lib.sh | 5 +++++ 2 files changed, 34 insertions(+), 14 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index d2f6a02..75737fd 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -211,26 +211,41 @@ kdump_setup_znet() { echo rd.znet=${NETTYPE},${SUBCHANNELS}${_options} > ${initdir}/etc/cmdline.d/30znet.conf }
+get_ip_route_field() +{
- if `echo $1 | grep -q $2`; then
echo ${1##*$2} | cut -d ' ' -f1
- fi
+}
+# +# For the same subnet region, following is the route format +# ipv4: +# _route='192.168.200.137 dev eth1 src 192.168.200.129' +# ipv6: +# _route='2001:11::11f dev eth1 src 2001:11::120 metric 0' +# For the different subnet region, following is the route format +# ipv4: +# _route='192.168.201.215 via 192.168.200.137 dev eth1 src 192.168.200.129' +# ipv6: +# _route='2001:10::120 via 2001:11::11f dev eth1 src 2001:11::120 metric 0' get_routes() { local _netdev="$1" _target="$2" local _route _nexthop
- _route=`/sbin/ip route get to $_target 2>&1`
-# -# in the same subnet region, following is the route format -# _route='192.168.200.137 dev eth1 src 192.168.200.129 -# cache ' -# -# in the different subnet region, following is the route format -# _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
_route=`/sbin/ip -o route get to $_target 2>&1`
# route going to a different subnet via a router
_nexthop=$(get_ip_route_field "$_route" "via") _netdev=$(kdump_setup_ifname $_netdev)
if $(is_ipv6_address `echo $_route | cut -d " " -f1`); then
if [ -n $_nexthop ]; then
_nexthop="[$_nexthop]"
fi
_target="[$_target]"
fi
echo "rd.route=$_target:$_nexthop:$_netdev" >> ${initdir}/etc/cmdline.d/45route-static.conf
}
diff --git a/kdump-lib.sh b/kdump-lib.sh index e62b4e2..1b98a6f 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -201,3 +201,8 @@ is_atomic() { grep -q "ostree" /proc/cmdline }
+is_ipv6_address() +{
- echo $1 | grep -q ":"
+}
2.1.0
Ack
Thanks Dave
Instroduce lib function get_remote_host to be used to strip the characters around the ip address or hostname.
Instroduce lib function is_hostname to identify the specified string is ip address(ipv4/ipv6) or hostname. If the specified string is hostname, we can use command "getent hosts" to parse it and get the ip address(ipv4/ipv6).
In order to setup the network in 2nd kernel, we need the network device and target ip address. we use the command "ip route" to get the route info.
Signed-off-by: Minfei Huang mhuang@redhat.com --- dracut-module-setup.sh | 22 ++++++---------------- kdump-lib.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 16 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 75737fd..f47e57e 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -300,28 +300,18 @@ kdump_setup_netdev() { #$1: config values of net line in kdump.conf #$2: srcaddr of network device kdump_install_net() { - local _server _netdev _srcaddr + local _server _netdev _srcaddr _route local config_val="$1"
- _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` + is_hostname $_server && _server=`getent hosts $_server | head -n 1 | cut -d' ' -f1`
- _netdev=`/sbin/ip route get to $_server 2>&1` + _route=`/sbin/ip -o 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 + _srcaddr=$(get_ip_route_field "$_route" "src") + _netdev=$(get_ip_route_field "$_route" "dev")
kdump_setup_netdev "${_netdev}" "${_srcaddr}" "${_server}"
diff --git a/kdump-lib.sh b/kdump-lib.sh index 1b98a6f..b83516b 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -206,3 +206,31 @@ is_ipv6_address() { echo $1 | grep -q ":" } + +# get ip address or hostname from nfs/ssh config value +get_remote_host() +{ + local _config_val=$1 + + # in ipv6, the _config_val format is [xxxx:xxxx::xxxx%eth0]:/mnt/nfs or + # username at xxxx:xxxx::xxxx%eth0. what we need is just xxxx:xxxx::xxxx + _config_val=${_config_val#*@} + _config_val=${_config_val%:/*} + _config_val=${_config_val#[} + _config_val=${_config_val%]} + _config_val=${_config_val%%*} + echo $_config_val +} + +# if the passed parameter is hostname/domain, it will be satisfied with +# condition which it is without colon ":", and contains the [a-zA-Z] +# $1: hostname/ip address +is_hostname() +{ + local _hostname=`echo $1 | grep ":"` + + if [ -n "$_hostname" ]; then + return 1 + fi + echo $1 | grep -q "[a-zA-Z]" +}
On 07/13/15 at 01:16pm, Minfei Huang wrote:
Instroduce lib function get_remote_host to be used to strip the characters around the ip address or hostname.
Instroduce lib function is_hostname to identify the specified string is ip address(ipv4/ipv6) or hostname. If the specified string is hostname, we can use command "getent hosts" to parse it and get the ip address(ipv4/ipv6).
In order to setup the network in 2nd kernel, we need the network device and target ip address. we use the command "ip route" to get the route info.
Signed-off-by: Minfei Huang mhuang@redhat.com
dracut-module-setup.sh | 22 ++++++---------------- kdump-lib.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 16 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 75737fd..f47e57e 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -300,28 +300,18 @@ kdump_setup_netdev() { #$1: config values of net line in kdump.conf #$2: srcaddr of network device kdump_install_net() {
- local _server _netdev _srcaddr
- local _server _netdev _srcaddr _route local config_val="$1"
- _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`
- is_hostname $_server && _server=`getent hosts $_server | head -n 1 | cut -d' ' -f1`
- _netdev=`/sbin/ip route get to $_server 2>&1`
- _route=`/sbin/ip -o 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
_srcaddr=$(get_ip_route_field "$_route" "src")
_netdev=$(get_ip_route_field "$_route" "dev")
kdump_setup_netdev "${_netdev}" "${_srcaddr}" "${_server}"
diff --git a/kdump-lib.sh b/kdump-lib.sh index 1b98a6f..b83516b 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -206,3 +206,31 @@ is_ipv6_address() { echo $1 | grep -q ":" }
+# get ip address or hostname from nfs/ssh config value +get_remote_host() +{
- local _config_val=$1
- # in ipv6, the _config_val format is [xxxx:xxxx::xxxx%eth0]:/mnt/nfs or
- # username at xxxx:xxxx::xxxx%eth0. what we need is just xxxx:xxxx::xxxx
Since we do not support link scopt addresses yet, should remove the %eth0 comment and code, add some early check code to error out in case link scopt or document it somewhere ie in howto.txt.
I missed this part last time, care to resend this patch only?
Otherwise, ack the patch
- _config_val=${_config_val#*@}
- _config_val=${_config_val%:/*}
- _config_val=${_config_val#[}
- _config_val=${_config_val%]}
- _config_val=${_config_val%%*}
- echo $_config_val
+}
+# if the passed parameter is hostname/domain, it will be satisfied with +# condition which it is without colon ":", and contains the [a-zA-Z] +# $1: hostname/ip address +is_hostname() +{
- local _hostname=`echo $1 | grep ":"`
- if [ -n "$_hostname" ]; then
return 1
- fi
- echo $1 | grep -q "[a-zA-Z]"
+}
2.1.0
On 07/13/15 at 01:44pm, Dave Young wrote:
On 07/13/15 at 01:16pm, Minfei Huang wrote:
Instroduce lib function get_remote_host to be used to strip the characters around the ip address or hostname.
Instroduce lib function is_hostname to identify the specified string is ip address(ipv4/ipv6) or hostname. If the specified string is hostname, we can use command "getent hosts" to parse it and get the ip address(ipv4/ipv6).
In order to setup the network in 2nd kernel, we need the network device and target ip address. we use the command "ip route" to get the route info.
Signed-off-by: Minfei Huang mhuang@redhat.com
dracut-module-setup.sh | 22 ++++++---------------- kdump-lib.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 16 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 75737fd..f47e57e 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -300,28 +300,18 @@ kdump_setup_netdev() { #$1: config values of net line in kdump.conf #$2: srcaddr of network device kdump_install_net() {
- local _server _netdev _srcaddr
- local _server _netdev _srcaddr _route local config_val="$1"
- _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`
- is_hostname $_server && _server=`getent hosts $_server | head -n 1 | cut -d' ' -f1`
- _netdev=`/sbin/ip route get to $_server 2>&1`
- _route=`/sbin/ip -o 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
_srcaddr=$(get_ip_route_field "$_route" "src")
_netdev=$(get_ip_route_field "$_route" "dev")
kdump_setup_netdev "${_netdev}" "${_srcaddr}" "${_server}"
diff --git a/kdump-lib.sh b/kdump-lib.sh index 1b98a6f..b83516b 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -206,3 +206,31 @@ is_ipv6_address() { echo $1 | grep -q ":" }
+# get ip address or hostname from nfs/ssh config value +get_remote_host() +{
- local _config_val=$1
- # in ipv6, the _config_val format is [xxxx:xxxx::xxxx%eth0]:/mnt/nfs or
- # username at xxxx:xxxx::xxxx%eth0. what we need is just xxxx:xxxx::xxxx
Since we do not support link scopt addresses yet, should remove the %eth0 comment and code, add some early check code to error out in case link scopt or document it somewhere ie in howto.txt.
I missed this part last time, care to resend this patch only?
Otherwise, ack the patch
Ok. I will remove the local link scrop address related code and annotation.
Thanks Minfei
- _config_val=${_config_val#*@}
- _config_val=${_config_val%:/*}
- _config_val=${_config_val#[}
- _config_val=${_config_val%]}
- _config_val=${_config_val%%*}
- echo $_config_val
+}
+# if the passed parameter is hostname/domain, it will be satisfied with +# condition which it is without colon ":", and contains the [a-zA-Z] +# $1: hostname/ip address +is_hostname() +{
- local _hostname=`echo $1 | grep ":"`
- if [ -n "$_hostname" ]; then
return 1
- fi
- echo $1 | grep -q "[a-zA-Z]"
+}
2.1.0
Hi, Dave.
I would like putting the annotation in the kdump.conf.5.
diff --git a/kdump.conf.5 b/kdump.conf.5 index f1c2a2c..4fe07c2 100644 --- a/kdump.conf.5 +++ b/kdump.conf.5 @@ -36,14 +36,16 @@ partition devices, such as /dev/vg/<devname>. .RS Will mount fs and copy /proc/vmcore to <mnt>/var/crash/%HOST-%DATE/, supports DNS. Note that a fqdn should be used as the server name in the -mount point +mount point. For now, kdump only supports non-local ipv6 address, which +is around with bracket "[]". .RE
.B ssh user@server .RS Will scp /proc/vmcore to user@server:/var/crash/%HOST-%DATE/, supports DNS. NOTE: make sure user has necessary write permissions on -server and that a fqdn is used as the server name +server and that a fqdn is used as the server name. For now, kdump only +supports non-local ipv6 address, which is around with bracket "[]". .RE
.B sshkey <path>
How do you think?
On 07/13/15 at 01:44pm, Dave Young wrote:
On 07/13/15 at 01:16pm, Minfei Huang wrote:
Instroduce lib function get_remote_host to be used to strip the characters around the ip address or hostname.
Instroduce lib function is_hostname to identify the specified string is ip address(ipv4/ipv6) or hostname. If the specified string is hostname, we can use command "getent hosts" to parse it and get the ip address(ipv4/ipv6).
In order to setup the network in 2nd kernel, we need the network device and target ip address. we use the command "ip route" to get the route info.
Signed-off-by: Minfei Huang mhuang@redhat.com
dracut-module-setup.sh | 22 ++++++---------------- kdump-lib.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 16 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 75737fd..f47e57e 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -300,28 +300,18 @@ kdump_setup_netdev() { #$1: config values of net line in kdump.conf #$2: srcaddr of network device kdump_install_net() {
- local _server _netdev _srcaddr
- local _server _netdev _srcaddr _route local config_val="$1"
- _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`
- is_hostname $_server && _server=`getent hosts $_server | head -n 1 | cut -d' ' -f1`
- _netdev=`/sbin/ip route get to $_server 2>&1`
- _route=`/sbin/ip -o 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
_srcaddr=$(get_ip_route_field "$_route" "src")
_netdev=$(get_ip_route_field "$_route" "dev")
kdump_setup_netdev "${_netdev}" "${_srcaddr}" "${_server}"
diff --git a/kdump-lib.sh b/kdump-lib.sh index 1b98a6f..b83516b 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -206,3 +206,31 @@ is_ipv6_address() { echo $1 | grep -q ":" }
+# get ip address or hostname from nfs/ssh config value +get_remote_host() +{
- local _config_val=$1
- # in ipv6, the _config_val format is [xxxx:xxxx::xxxx%eth0]:/mnt/nfs or
- # username at xxxx:xxxx::xxxx%eth0. what we need is just xxxx:xxxx::xxxx
Since we do not support link scopt addresses yet, should remove the %eth0 comment and code, add some early check code to error out in case link scopt or document it somewhere ie in howto.txt.
I missed this part last time, care to resend this patch only?
Otherwise, ack the patch
- _config_val=${_config_val#*@}
- _config_val=${_config_val%:/*}
- _config_val=${_config_val#[}
- _config_val=${_config_val%]}
- _config_val=${_config_val%%*}
- echo $_config_val
+}
+# if the passed parameter is hostname/domain, it will be satisfied with +# condition which it is without colon ":", and contains the [a-zA-Z] +# $1: hostname/ip address +is_hostname() +{
- local _hostname=`echo $1 | grep ":"`
- if [ -n "$_hostname" ]; then
return 1
- fi
- echo $1 | grep -q "[a-zA-Z]"
+}
2.1.0
Hi, Minfei
On 07/13/15 at 02:11pm, Minfei Huang wrote:
Hi, Dave.
I would like putting the annotation in the kdump.conf.5.
I think add it in howto make more sense, because there's a lot of types of supported targets, we can not add every details in manpage.
Just add a line in howto.txt about support ipv6 setup except link scope addresses.
diff --git a/kdump.conf.5 b/kdump.conf.5 index f1c2a2c..4fe07c2 100644 --- a/kdump.conf.5 +++ b/kdump.conf.5 @@ -36,14 +36,16 @@ partition devices, such as /dev/vg/<devname>. .RS Will mount fs and copy /proc/vmcore to <mnt>/var/crash/%HOST-%DATE/, supports DNS. Note that a fqdn should be used as the server name in the -mount point +mount point. For now, kdump only supports non-local ipv6 address, which +is around with bracket "[]". .RE
.B ssh user@server .RS Will scp /proc/vmcore to user@server:/var/crash/%HOST-%DATE/, supports DNS. NOTE: make sure user has necessary write permissions on -server and that a fqdn is used as the server name +server and that a fqdn is used as the server name. For now, kdump only +supports non-local ipv6 address, which is around with bracket "[]". .RE
.B sshkey <path>
How do you think?
On 07/13/15 at 01:44pm, Dave Young wrote:
On 07/13/15 at 01:16pm, Minfei Huang wrote:
Instroduce lib function get_remote_host to be used to strip the characters around the ip address or hostname.
Instroduce lib function is_hostname to identify the specified string is ip address(ipv4/ipv6) or hostname. If the specified string is hostname, we can use command "getent hosts" to parse it and get the ip address(ipv4/ipv6).
In order to setup the network in 2nd kernel, we need the network device and target ip address. we use the command "ip route" to get the route info.
Signed-off-by: Minfei Huang mhuang@redhat.com
dracut-module-setup.sh | 22 ++++++---------------- kdump-lib.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 16 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 75737fd..f47e57e 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -300,28 +300,18 @@ kdump_setup_netdev() { #$1: config values of net line in kdump.conf #$2: srcaddr of network device kdump_install_net() {
- local _server _netdev _srcaddr
- local _server _netdev _srcaddr _route local config_val="$1"
- _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`
- is_hostname $_server && _server=`getent hosts $_server | head -n 1 | cut -d' ' -f1`
- _netdev=`/sbin/ip route get to $_server 2>&1`
- _route=`/sbin/ip -o 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
_srcaddr=$(get_ip_route_field "$_route" "src")
_netdev=$(get_ip_route_field "$_route" "dev")
kdump_setup_netdev "${_netdev}" "${_srcaddr}" "${_server}"
diff --git a/kdump-lib.sh b/kdump-lib.sh index 1b98a6f..b83516b 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -206,3 +206,31 @@ is_ipv6_address() { echo $1 | grep -q ":" }
+# get ip address or hostname from nfs/ssh config value +get_remote_host() +{
- local _config_val=$1
- # in ipv6, the _config_val format is [xxxx:xxxx::xxxx%eth0]:/mnt/nfs or
- # username at xxxx:xxxx::xxxx%eth0. what we need is just xxxx:xxxx::xxxx
Since we do not support link scopt addresses yet, should remove the %eth0 comment and code, add some early check code to error out in case link scopt or document it somewhere ie in howto.txt.
I missed this part last time, care to resend this patch only?
Otherwise, ack the patch
- _config_val=${_config_val#*@}
- _config_val=${_config_val%:/*}
- _config_val=${_config_val#[}
- _config_val=${_config_val%]}
- _config_val=${_config_val%%*}
- echo $_config_val
+}
+# if the passed parameter is hostname/domain, it will be satisfied with +# condition which it is without colon ":", and contains the [a-zA-Z] +# $1: hostname/ip address +is_hostname() +{
- local _hostname=`echo $1 | grep ":"`
- if [ -n "$_hostname" ]; then
return 1
- fi
- echo $1 | grep -q "[a-zA-Z]"
+}
2.1.0
Due to the different format between ipv4 and ipv6 protocol, quote the ipv6 address with bracket "[]" to make dracut notify.
Signed-off-by: Minfei Huang mhuang@redhat.com Acked-by: Dave Young dyoung@redhat.com --- dracut-module-setup.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index f47e57e..3c9dd9f 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -529,10 +529,12 @@ kdump_setup_iscsi_device() { kdump_setup_netdev $netdev $srcaddr $tgt_ipaddr
# 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.
+ if is_ipv6_address $tgt_ipaddr; then + tgt_ipaddr="[$tgt_ipaddr]" + fi netroot_str="netroot=iscsi:${userpwd_str}${userpwd_in_str}@$tgt_ipaddr::::$tgt_name"
[[ -f $netroot_conf ]] || touch $netroot_conf