On 12/11/14 at 03:07pm, Baoquan He wrote:
On 12/05/14 at 04:24pm, Minfei Huang wrote:
> Signed-off-by: Arthur Zou <zzou(a)redhat.com>
> Signed-off-by: Minfei Huang <mhuang(a)redhat.com>
> ---
> dracut-kdump.sh | 8 ++-
> dracut-module-setup.sh | 137 ++++++++++++++++++++++++++++++++++++++-----------
> kdump-lib.sh | 2 +-
> mkdumprd | 14 ++++-
> 4 files changed, 127 insertions(+), 34 deletions(-)
>
> diff --git a/dracut-kdump.sh b/dracut-kdump.sh
> index cbfe7c6..2d4551d 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 79a6c83..7479821 100755
> --- a/dracut-module-setup.sh
> +++ b/dracut-module-setup.sh
> @@ -70,14 +70,24 @@ 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
> + _gateway=$(ip -6 route list dev $_netdev | awk '/^default /{print
$3}')
> + echo -n "[${_srcaddr}]::[${_gateway}]:64::"
This netmask for ipv6 is hard coded as 64, why is it? I don't want to
push it, please add a explanation here for later understanding. You can
do it later, for now it works.
Maybe I can fix it by using dynamic prefix length. The variable _ipaddr
contains the prefix length, if not null. So I can fetch it.
> + 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,7 +205,27 @@ 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`
> +#
> +# in the same subnet region, following is the route format
I like writing it like this:
# for routes to the same subnet, following is the foramt:
# xxxxxxxxx
Ok, I will add it in next re-send patch.
> +#
> +# _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`
> #
> # in the same subnet region, following is the route format
> # _route='192.168.200.137 dev eth1 src 192.168.200.129
> @@ -205,13 +235,14 @@ get_routes() {
> # _route='192.168.201.215 via 192.168.200.137 dev eth1 src 192.168.200.129
> # cache '
I would like to put these description as function comment above function
definition, adding blocks of comment in the middle looks messy.
The position of note is better in my opinion. We can known what the
scirpt does according the above note. It is clearer.
> #
> - 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
> @@ -268,24 +299,44 @@ 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`
> + _server=`get_remote_host $config_val`
>
> - _netdev=`/sbin/ip route get to $_server 2>&1`
> - [ $? != 0 ] && echo "Bad kdump location: $config_val"
&& exit 1
> + 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
>
> - #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_target; 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}"
> @@ -363,6 +414,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
Could you wrap this into a function, this can make it look better as
other calling.
Ok. I will make a single patch to fix it.
> +
> inst "/tmp/$$-kdump.conf" "/etc/kdump.conf"
> rm -f /tmp/$$-kdump.conf
> }
> @@ -441,8 +511,13 @@ 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')
> + if is_ipv6_target; then
> + netdev=$(/sbin/ip -6 route get to ${tgt_ipaddr} | \
> + sed 's|.*dev \(.*\).*|\1|g')
> + else
> + netdev=$(/sbin/ip route get to ${tgt_ipaddr} | \
> + sed 's|.*dev \(.*\).*|\1|g')
> + fi
scsi need change for ipv6 too, it's the same doing as in
kdump_install_net.
Maybe I can fetch the same code.
> srcaddr=$(echo $netdev | awk '{ print $3; exit }')
> netdev=$(echo $netdev | awk '{ print $1; exit }')
>
> @@ -585,6 +660,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"
> 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..d7b5752 100644
> --- a/mkdumprd
> +++ b/mkdumprd
> @@ -79,7 +79,19 @@ add_dracut_module() {
> }
>
> 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() {
> --
> 1.8.3.1
>
> _______________________________________________
> kexec mailing list
> kexec(a)lists.fedoraproject.org
>
https://lists.fedoraproject.org/mailman/listinfo/kexec