In order to enhance kdump to support ipv6, support the static ip with ipv6, which ipv4 has supported already.
Due to the different format with ipv4 and ipv6, dracut uses bracket"[]" to quote the ipv6 address to identify it in the 2nd kernel.
Signed-off-by: Minfei Huang mhuang@redhat.com --- dracut-module-setup.sh | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 95b73f8..f82aac7 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -74,14 +74,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_address $_srcaddr; 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 }