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.
In order to make static ip work in Kdump, we shall merge the patch "dracut-module-setup: Apply the manual DNS to the 2nd kernel" firstly.
Minfei Huang (4): dracut-kdump: Use the first filtered ip address as dump directory dracut-module-setup: Support the network for ipv6 protocol dracut-module-setup: Prefer ipv4 address as the hostname address dracut-module-setup: Enhance ISCSI to support ipv6 protocol
dracut-kdump.sh | 4 +-- dracut-module-setup.sh | 77 +++++++++++++++++++++++++++++++++----------------- kdump-lib.sh | 29 +++++++++++++++++++ 3 files changed, 82 insertions(+), 28 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 3eb80c0..66394e6 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -658,6 +658,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"
Previously, Kdump will save route to setup the network route in the 2nd kernel for ipv4 protocol. To support ipv6 protocol, make Kdump fetch correct nexthop, since the ruturning format is different.
In order to enhance kdump to support ipv6, support the static ip for ipv6 protocol, which ipv4 has supported already.
Introduce a new lib function get_remote_host which is used to factor out the ip address(ipv4 or ipv6) and hostname in /etc/kdump.conf.
Introduce a new lib function is_ipv6_address which is used to make sure whether the passed ip address is ipv4 or ipv6.
Introduce a new lib function is_hostname which is used to confirm whether the passed parameter is hostname, not the ip address.
Introduce a new function get_ip_route_field which is used to factor out the specified string in ip route info.
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 | 66 +++++++++++++++++++++++++++++++------------------- kdump-lib.sh | 29 ++++++++++++++++++++++ 2 files changed, 70 insertions(+), 25 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 66394e6..039fe3b 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -89,19 +89,37 @@ kdump_setup_dns() { #$2: srcaddr #if it use static ip echo it, or echo null kdump_static_ip() { - local _netmask _gateway - local _netdev="$1" _srcaddr="$2" - local _ipaddr=$(ip addr show dev $_netdev permanent | \ - awk "/ $_srcaddr/.* $_netdev$/{print $2}") + local _netdev="$1" _srcaddr="$2" _ipv6_flag + local _netmask _gateway _ipaddr _target _nexthop + + _ipaddr=$(ip addr show dev $_netdev | awk "/ $_srcaddr/.* /{print $2}") + + if is_ipv6_address $_srcaddr; then + _ipv6_flag="-6" + fi + 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}::" + _gateway=$(ip $_ipv6_flag route list dev $_netdev | awk '/^default /{print $3}') + + if [ "x" != "x"$_ipv6_flag ]; then + _netmask=${_ipaddr#*/} + _srcaddr="[$_srcaddr]" + _gateway="[$_gateway]" + else + _netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2) + fi + echo -n "${_srcaddr}::${_gateway}:${_netmask}::" fi
- /sbin/ip route show | grep -v default | grep "^[[:digit:]].*via.* $_netdev " |\ - while read line; do - echo $line | awk '{printf("rd.route=%s:%s:%s\n", $1, $3, $5)}' + /sbin/ip $_ipv6_flag route show | grep -v default | grep ".*via.* $_netdev " |\ + while read _route; do + _target=`echo $_route | cut -d ' ' -f1` + _nexthop=`echo $_route | cut -d ' ' -f3` + if [ "x" != "x"$_ipv6_flag ]; then + _target="[$_target]" + _nexthop="[$_nexthop]" + fi + echo "rd.route=$_target:$_nexthop:$_netdev" done >> ${initdir}/etc/cmdline.d/45route-static.conf }
@@ -276,32 +294,30 @@ kdump_setup_netdev() { kdump_setup_dns "$_netdev" }
+get_ip_route_field() +{ + if `echo $1 | grep -q $2`; then + echo ${1##*$2} | cut -d ' ' -f1 + fi +} + #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 _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}"
diff --git a/kdump-lib.sh b/kdump-lib.sh index e62b4e2..4d34206 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -201,3 +201,32 @@ is_atomic() { grep -q "ostree" /proc/cmdline } + +is_ipv6_address() +{ + echo $1 | grep -q ":" +} + +# get ip address or hostname from nfs/ssh config value +get_remote_host() +{ + local _config_val=$1 + + # ipv6 address in kdump.conf is around with "[]", + # factor out the ipv6 address + _config_val=${_config_val#*@} + _config_val=${_config_val%:/*} + _config_val=${_config_val#[} + _config_val=${_config_val%]} + echo $_config_val +} + +is_hostname() +{ + local _hostname=`echo $1 | grep ":"` + + if [ -n "$_hostname" ]; then + return 1 + fi + echo $1 | grep -q "[a-zA-Z]" +}
On 07/21/15 at 02:49pm, Minfei Huang wrote:
Previously, Kdump will save route to setup the network route in the 2nd kernel for ipv4 protocol. To support ipv6 protocol, make Kdump fetch correct nexthop, since the ruturning format is different.
In order to enhance kdump to support ipv6, support the static ip for ipv6 protocol, which ipv4 has supported already.
Introduce a new lib function get_remote_host which is used to factor out the ip address(ipv4 or ipv6) and hostname in /etc/kdump.conf.
Introduce a new lib function is_ipv6_address which is used to make sure whether the passed ip address is ipv4 or ipv6.
Introduce a new lib function is_hostname which is used to confirm whether the passed parameter is hostname, not the ip address.
Introduce a new function get_ip_route_field which is used to factor out the specified string in ip route info.
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 | 66 +++++++++++++++++++++++++++++++------------------- kdump-lib.sh | 29 ++++++++++++++++++++++ 2 files changed, 70 insertions(+), 25 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 66394e6..039fe3b 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -89,19 +89,37 @@ kdump_setup_dns() { #$2: srcaddr #if it use static ip echo it, or echo null kdump_static_ip() {
- local _netmask _gateway
- local _netdev="$1" _srcaddr="$2"
- local _ipaddr=$(ip addr show dev $_netdev permanent | \
awk "/ $_srcaddr\/.* $_netdev\$/{print \$2}")
- local _netdev="$1" _srcaddr="$2" _ipv6_flag
- local _netmask _gateway _ipaddr _target _nexthop
- _ipaddr=$(ip addr show dev $_netdev | awk "/ $_srcaddr/.* /{print $2}")
- if is_ipv6_address $_srcaddr; then
_ipv6_flag="-6"
- fi
- 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}::"
_gateway=$(ip $_ipv6_flag route list dev $_netdev | awk '/^default /{print $3}')
if [ "x" != "x"$_ipv6_flag ]; then
_netmask=${_ipaddr#*\/}
Could you add an example and a comment about ipv6 netmask, it is not easy to understand for people who do not know ipv6
Why ipcalc does not work for ipv6?
_srcaddr="[$_srcaddr]"
_gateway="[$_gateway]"
else
_netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2)
fi
fiecho -n "${_srcaddr}::${_gateway}:${_netmask}::"
- /sbin/ip route show | grep -v default | grep "^[[:digit:]].*via.* $_netdev " |\
- while read line; do
echo $line | awk '{printf("rd.route=%s:%s:%s\n", $1, $3, $5)}'
- /sbin/ip $_ipv6_flag route show | grep -v default | grep ".*via.* $_netdev " |\
- while read _route; do
_target=`echo $_route | cut -d ' ' -f1`
_nexthop=`echo $_route | cut -d ' ' -f3`
if [ "x" != "x"$_ipv6_flag ]; then
_target="[$_target]"
_nexthop="[$_nexthop]"
fi
done >> ${initdir}/etc/cmdline.d/45route-static.confecho "rd.route=$_target:$_nexthop:$_netdev"
}
@@ -276,32 +294,30 @@ kdump_setup_netdev() { kdump_setup_dns "$_netdev" }
+get_ip_route_field() +{
- if `echo $1 | grep -q $2`; then
echo ${1##*$2} | cut -d ' ' -f1
- fi
+}
#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 _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}"
diff --git a/kdump-lib.sh b/kdump-lib.sh index e62b4e2..4d34206 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -201,3 +201,32 @@ is_atomic() { grep -q "ostree" /proc/cmdline }
+is_ipv6_address() +{
- echo $1 | grep -q ":"
+}
+# get ip address or hostname from nfs/ssh config value +get_remote_host() +{
- local _config_val=$1
- # ipv6 address in kdump.conf is around with "[]",
- # factor out the ipv6 address
- _config_val=${_config_val#*@}
- _config_val=${_config_val%:/*}
- _config_val=${_config_val#[}
- _config_val=${_config_val%]}
- echo $_config_val
+}
+is_hostname() +{
- local _hostname=`echo $1 | grep ":"`
- if [ -n "$_hostname" ]; then
return 1
- fi
- echo $1 | grep -q "[a-zA-Z]"
+}
2.1.0
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 07/22/15 at 11:42am, Dave Young wrote:
On 07/21/15 at 02:49pm, Minfei Huang wrote:
Previously, Kdump will save route to setup the network route in the 2nd kernel for ipv4 protocol. To support ipv6 protocol, make Kdump fetch correct nexthop, since the ruturning format is different.
In order to enhance kdump to support ipv6, support the static ip for ipv6 protocol, which ipv4 has supported already.
Introduce a new lib function get_remote_host which is used to factor out the ip address(ipv4 or ipv6) and hostname in /etc/kdump.conf.
Introduce a new lib function is_ipv6_address which is used to make sure whether the passed ip address is ipv4 or ipv6.
Introduce a new lib function is_hostname which is used to confirm whether the passed parameter is hostname, not the ip address.
Introduce a new function get_ip_route_field which is used to factor out the specified string in ip route info.
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 | 66 +++++++++++++++++++++++++++++++------------------- kdump-lib.sh | 29 ++++++++++++++++++++++ 2 files changed, 70 insertions(+), 25 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 66394e6..039fe3b 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -89,19 +89,37 @@ kdump_setup_dns() { #$2: srcaddr #if it use static ip echo it, or echo null kdump_static_ip() {
- local _netmask _gateway
- local _netdev="$1" _srcaddr="$2"
- local _ipaddr=$(ip addr show dev $_netdev permanent | \
awk "/ $_srcaddr\/.* $_netdev\$/{print \$2}")
- local _netdev="$1" _srcaddr="$2" _ipv6_flag
- local _netmask _gateway _ipaddr _target _nexthop
- _ipaddr=$(ip addr show dev $_netdev | awk "/ $_srcaddr/.* /{print $2}")
- if is_ipv6_address $_srcaddr; then
_ipv6_flag="-6"
- fi
- 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}::"
_gateway=$(ip $_ipv6_flag route list dev $_netdev | awk '/^default /{print $3}')
if [ "x" != "x"$_ipv6_flag ]; then
_netmask=${_ipaddr#*\/}
Could you add an example and a comment about ipv6 netmask, it is not easy to understand for people who do not know ipv6
Will add it.
Why ipcalc does not work for ipv6?
It is different for netmask between ipv4 and ipv6. The ipv6 netmask is always the specified number 64 or 128.
Thanks Minfei
_srcaddr="[$_srcaddr]"
_gateway="[$_gateway]"
else
_netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2)
fi
fiecho -n "${_srcaddr}::${_gateway}:${_netmask}::"
- /sbin/ip route show | grep -v default | grep "^[[:digit:]].*via.* $_netdev " |\
- while read line; do
echo $line | awk '{printf("rd.route=%s:%s:%s\n", $1, $3, $5)}'
- /sbin/ip $_ipv6_flag route show | grep -v default | grep ".*via.* $_netdev " |\
- while read _route; do
_target=`echo $_route | cut -d ' ' -f1`
_nexthop=`echo $_route | cut -d ' ' -f3`
if [ "x" != "x"$_ipv6_flag ]; then
_target="[$_target]"
_nexthop="[$_nexthop]"
fi
done >> ${initdir}/etc/cmdline.d/45route-static.confecho "rd.route=$_target:$_nexthop:$_netdev"
}
@@ -276,32 +294,30 @@ kdump_setup_netdev() { kdump_setup_dns "$_netdev" }
+get_ip_route_field() +{
- if `echo $1 | grep -q $2`; then
echo ${1##*$2} | cut -d ' ' -f1
- fi
+}
#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 _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}"
diff --git a/kdump-lib.sh b/kdump-lib.sh index e62b4e2..4d34206 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -201,3 +201,32 @@ is_atomic() { grep -q "ostree" /proc/cmdline }
+is_ipv6_address() +{
- echo $1 | grep -q ":"
+}
+# get ip address or hostname from nfs/ssh config value +get_remote_host() +{
- local _config_val=$1
- # ipv6 address in kdump.conf is around with "[]",
- # factor out the ipv6 address
- _config_val=${_config_val#*@}
- _config_val=${_config_val%:/*}
- _config_val=${_config_val#[}
- _config_val=${_config_val%]}
- echo $_config_val
+}
+is_hostname() +{
- local _hostname=`echo $1 | grep ":"`
- if [ -n "$_hostname" ]; then
return 1
- fi
- echo $1 | grep -q "[a-zA-Z]"
+}
2.1.0
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 07/22/15 at 12:07pm, Minfei Huang wrote:
On 07/22/15 at 11:42am, Dave Young wrote:
On 07/21/15 at 02:49pm, Minfei Huang wrote:
Previously, Kdump will save route to setup the network route in the 2nd kernel for ipv4 protocol. To support ipv6 protocol, make Kdump fetch correct nexthop, since the ruturning format is different.
In order to enhance kdump to support ipv6, support the static ip for ipv6 protocol, which ipv4 has supported already.
Introduce a new lib function get_remote_host which is used to factor out the ip address(ipv4 or ipv6) and hostname in /etc/kdump.conf.
Introduce a new lib function is_ipv6_address which is used to make sure whether the passed ip address is ipv4 or ipv6.
Introduce a new lib function is_hostname which is used to confirm whether the passed parameter is hostname, not the ip address.
Introduce a new function get_ip_route_field which is used to factor out the specified string in ip route info.
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 | 66 +++++++++++++++++++++++++++++++------------------- kdump-lib.sh | 29 ++++++++++++++++++++++ 2 files changed, 70 insertions(+), 25 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 66394e6..039fe3b 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -89,19 +89,37 @@ kdump_setup_dns() { #$2: srcaddr #if it use static ip echo it, or echo null kdump_static_ip() {
- local _netmask _gateway
- local _netdev="$1" _srcaddr="$2"
- local _ipaddr=$(ip addr show dev $_netdev permanent | \
awk "/ $_srcaddr\/.* $_netdev\$/{print \$2}")
- local _netdev="$1" _srcaddr="$2" _ipv6_flag
- local _netmask _gateway _ipaddr _target _nexthop
- _ipaddr=$(ip addr show dev $_netdev | awk "/ $_srcaddr/.* /{print $2}")
- if is_ipv6_address $_srcaddr; then
_ipv6_flag="-6"
- fi
- 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}::"
_gateway=$(ip $_ipv6_flag route list dev $_netdev | awk '/^default /{print $3}')
if [ "x" != "x"$_ipv6_flag ]; then
_netmask=${_ipaddr#*\/}
Could you add an example and a comment about ipv6 netmask, it is not easy to understand for people who do not know ipv6
Will add it.
Why ipcalc does not work for ipv6?
It is different for netmask between ipv4 and ipv6. The ipv6 netmask is always the specified number 64 or 128.
It does not answer the question, why ipcalc can not return proper value for ipv6?
Thanks Minfei
_srcaddr="[$_srcaddr]"
_gateway="[$_gateway]"
else
_netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2)
fi
fiecho -n "${_srcaddr}::${_gateway}:${_netmask}::"
- /sbin/ip route show | grep -v default | grep "^[[:digit:]].*via.* $_netdev " |\
- while read line; do
echo $line | awk '{printf("rd.route=%s:%s:%s\n", $1, $3, $5)}'
- /sbin/ip $_ipv6_flag route show | grep -v default | grep ".*via.* $_netdev " |\
- while read _route; do
_target=`echo $_route | cut -d ' ' -f1`
_nexthop=`echo $_route | cut -d ' ' -f3`
if [ "x" != "x"$_ipv6_flag ]; then
_target="[$_target]"
_nexthop="[$_nexthop]"
fi
done >> ${initdir}/etc/cmdline.d/45route-static.confecho "rd.route=$_target:$_nexthop:$_netdev"
}
@@ -276,32 +294,30 @@ kdump_setup_netdev() { kdump_setup_dns "$_netdev" }
+get_ip_route_field() +{
- if `echo $1 | grep -q $2`; then
echo ${1##*$2} | cut -d ' ' -f1
- fi
+}
#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 _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}"
diff --git a/kdump-lib.sh b/kdump-lib.sh index e62b4e2..4d34206 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -201,3 +201,32 @@ is_atomic() { grep -q "ostree" /proc/cmdline }
+is_ipv6_address() +{
- echo $1 | grep -q ":"
+}
+# get ip address or hostname from nfs/ssh config value +get_remote_host() +{
- local _config_val=$1
- # ipv6 address in kdump.conf is around with "[]",
- # factor out the ipv6 address
- _config_val=${_config_val#*@}
- _config_val=${_config_val%:/*}
- _config_val=${_config_val#[}
- _config_val=${_config_val%]}
- echo $_config_val
+}
+is_hostname() +{
- local _hostname=`echo $1 | grep ":"`
- if [ -n "$_hostname" ]; then
return 1
- fi
- echo $1 | grep -q "[a-zA-Z]"
+}
2.1.0
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 07/22/15 at 12:42pm, Dave Young wrote:
On 07/22/15 at 12:07pm, Minfei Huang wrote:
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}::"
_gateway=$(ip $_ipv6_flag route list dev $_netdev | awk '/^default /{print $3}')
if [ "x" != "x"$_ipv6_flag ]; then
_netmask=${_ipaddr#*\/}
Could you add an example and a comment about ipv6 netmask, it is not easy to understand for people who do not know ipv6
Will add it.
Why ipcalc does not work for ipv6?
It is different for netmask between ipv4 and ipv6. The ipv6 netmask is always the specified number 64 or 128.
It does not answer the question, why ipcalc can not return proper value for ipv6?
I do not find a proper way to calculate the netmask by using ipcalc command. Thus I cut out the $_ipaddr to get the netmask.
Thanks Minfei
Kdump will parse the hostname to get the ip address, if hostname is specfied in /etc/kdump.conf. We will get the ip address(ipv4 or ipv6, according to the DNS server) by using "getent hosts".
For now, it is more reasonable that we shall get all of the ip address(including ipv4 and ipv6 address) which point to the hostname by using "getent ahosts". And we will prefer to use the ipv4 address, if both ipv4 and ipv6 address work.
The reason why we choose the ipv4 as preferred address is to solve the issue kdump will fail to connect the hostname machine(parsed as ipv6 address), due to the DNS server is ipv4 address in 2nd kernel.
Signed-off-by: Minfei Huang mhuang@redhat.com --- dracut-module-setup.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 039fe3b..703f66b 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -305,12 +305,18 @@ get_ip_route_field() #$1: config values of net line in kdump.conf #$2: srcaddr of network device kdump_install_net() { - local _server _netdev _srcaddr _route + local _server _netdev _srcaddr _route _serv_tmp local config_val="$1"
_server=$(get_remote_host $config_val)
- is_hostname $_server && _server=`getent hosts $_server | head -n 1 | cut -d' ' -f1` + if is_hostname $_server; then + _serv_tmp=`getent ahosts $_server | grep -v : | head -n 1` + if [ -z "$_serv_tmp" ]; then + _serv_tmp=`getent ahosts $_server | head -n 1` + fi + _server=`echo $_serv_tmp | cut -d' ' -f1` + fi
_route=`/sbin/ip -o route get to $_server 2>&1` [ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
On 07/21/15 at 02:49pm, Minfei Huang wrote:
Kdump will parse the hostname to get the ip address, if hostname is specfied in /etc/kdump.conf. We will get the ip address(ipv4 or ipv6, according to the DNS server) by using "getent hosts".
For now, it is more reasonable that we shall get all of the ip address(including ipv4 and ipv6 address) which point to the hostname by using "getent ahosts". And we will prefer to use the ipv4 address, if both ipv4 and ipv6 address work.
Agreed that ipv4 first is better because it was tested well..
The reason why we choose the ipv4 as preferred address is to solve the issue kdump will fail to connect the hostname machine(parsed as ipv6 address), due to the DNS server is ipv4 address in 2nd kernel.
Is there ipv6 dns in 1st kernel? Why only broken in 2nd kernel?
Signed-off-by: Minfei Huang mhuang@redhat.com
dracut-module-setup.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 039fe3b..703f66b 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -305,12 +305,18 @@ get_ip_route_field() #$1: config values of net line in kdump.conf #$2: srcaddr of network device kdump_install_net() {
- local _server _netdev _srcaddr _route
local _server _netdev _srcaddr _route _serv_tmp local config_val="$1"
_server=$(get_remote_host $config_val)
- is_hostname $_server && _server=`getent hosts $_server | head -n 1 | cut -d' ' -f1`
if is_hostname $_server; then
_serv_tmp=`getent ahosts $_server | grep -v : | head -n 1`
if [ -z "$_serv_tmp" ]; then
_serv_tmp=`getent ahosts $_server | head -n 1`
fi
_server=`echo $_serv_tmp | cut -d' ' -f1`
fi
_route=`/sbin/ip -o route get to $_server 2>&1` [ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
-- 2.1.0
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 07/22/15 at 11:45am, Dave Young wrote:
On 07/21/15 at 02:49pm, Minfei Huang wrote:
Kdump will parse the hostname to get the ip address, if hostname is specfied in /etc/kdump.conf. We will get the ip address(ipv4 or ipv6, according to the DNS server) by using "getent hosts".
For now, it is more reasonable that we shall get all of the ip address(including ipv4 and ipv6 address) which point to the hostname by using "getent ahosts". And we will prefer to use the ipv4 address, if both ipv4 and ipv6 address work.
Agreed that ipv4 first is better because it was tested well..
The reason why we choose the ipv4 as preferred address is to solve the issue kdump will fail to connect the hostname machine(parsed as ipv6 address), due to the DNS server is ipv4 address in 2nd kernel.
Is there ipv6 dns in 1st kernel? Why only broken in 2nd kernel?
We support ipv6 address in beaker environment.
The hostname will fail to be parsed to ipv6 address, if the machine only supports ipv6 address. The DNS server in beaker environment only supports ipv4 address.
Thanks Minfei
Signed-off-by: Minfei Huang mhuang@redhat.com
dracut-module-setup.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 039fe3b..703f66b 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -305,12 +305,18 @@ get_ip_route_field() #$1: config values of net line in kdump.conf #$2: srcaddr of network device kdump_install_net() {
- local _server _netdev _srcaddr _route
local _server _netdev _srcaddr _route _serv_tmp local config_val="$1"
_server=$(get_remote_host $config_val)
- is_hostname $_server && _server=`getent hosts $_server | head -n 1 | cut -d' ' -f1`
if is_hostname $_server; then
_serv_tmp=`getent ahosts $_server | grep -v : | head -n 1`
if [ -z "$_serv_tmp" ]; then
_serv_tmp=`getent ahosts $_server | head -n 1`
fi
_server=`echo $_serv_tmp | cut -d' ' -f1`
fi
_route=`/sbin/ip -o route get to $_server 2>&1` [ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
-- 2.1.0
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 07/22/15 at 12:18pm, Minfei Huang wrote:
On 07/22/15 at 11:45am, Dave Young wrote:
On 07/21/15 at 02:49pm, Minfei Huang wrote:
Kdump will parse the hostname to get the ip address, if hostname is specfied in /etc/kdump.conf. We will get the ip address(ipv4 or ipv6, according to the DNS server) by using "getent hosts".
For now, it is more reasonable that we shall get all of the ip address(including ipv4 and ipv6 address) which point to the hostname by using "getent ahosts". And we will prefer to use the ipv4 address, if both ipv4 and ipv6 address work.
Agreed that ipv4 first is better because it was tested well..
The reason why we choose the ipv4 as preferred address is to solve the issue kdump will fail to connect the hostname machine(parsed as ipv6 address), due to the DNS server is ipv4 address in 2nd kernel.
Is there ipv6 dns in 1st kernel? Why only broken in 2nd kernel?
We support ipv6 address in beaker environment.
The hostname will fail to be parsed to ipv6 address, if the machine only supports ipv6 address. The DNS server in beaker environment only supports ipv4 address.
Ok, thanks, I have no other comments, feel free to send an update with comments added for netmask.
Thanks Minfei
Signed-off-by: Minfei Huang mhuang@redhat.com
dracut-module-setup.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 039fe3b..703f66b 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -305,12 +305,18 @@ get_ip_route_field() #$1: config values of net line in kdump.conf #$2: srcaddr of network device kdump_install_net() {
- local _server _netdev _srcaddr _route
local _server _netdev _srcaddr _route _serv_tmp local config_val="$1"
_server=$(get_remote_host $config_val)
- is_hostname $_server && _server=`getent hosts $_server | head -n 1 | cut -d' ' -f1`
if is_hostname $_server; then
_serv_tmp=`getent ahosts $_server | grep -v : | head -n 1`
if [ -z "$_serv_tmp" ]; then
_serv_tmp=`getent ahosts $_server | head -n 1`
fi
_server=`echo $_serv_tmp | cut -d' ' -f1`
fi
_route=`/sbin/ip -o route get to $_server 2>&1` [ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
-- 2.1.0
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
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 703f66b..8a5b2ed 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -541,10 +541,12 @@ kdump_setup_iscsi_device() { kdump_setup_netdev $netdev $srcaddr
# 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