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(a)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}::"
+ 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
}
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`
+ 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 "[:]"`
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(a)lists.fedoraproject.org
https://lists.fedoraproject.org/mailman/listinfo/kexec