From b57fd97ba5614fc9f9fa628b38d71a46c797c937 Mon Sep 17 00:00:00 2001 From: Minfei Huang Date: Fri, 7 Aug 2015 16:40:40 +0800 Subject: [PATCH] module-setup: Choose the first matched gateway in kdump_static_ip The system may have multiple default route entry. Following is an example to show the details. # ip -6 route list dev eth0 2620:52:0:1040::/64 proto kernel metric 256 expires 2591978sec fe80::/64 proto kernel metric 256 default via fe80:52:0:1040::1 proto ra metric 1024 expires 1778sec hoplimit 64 default via fe80:52:0:1040::2 proto ra metric 1024 expires 1778sec hoplimit 64 Choose the first matched entry. Signed-off-by: Minfei Huang Acked-by: Baoquan He --- dracut-module-setup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index dbe9b10..9b398eb 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -99,7 +99,8 @@ kdump_static_ip() { fi if [ -n "$_ipaddr" ]; then - _gateway=$(ip $_ipv6_flag route list dev $_netdev | awk '/^default /{print $3}') + _gateway=$(ip $_ipv6_flag route list dev $_netdev | \ + awk '/^default /{print $3}' | head -n 1) if [ "x" != "x"$_ipv6_flag ]; then # _ipaddr="2002::56ff:feb6:56d5/64", _netmask is the number after "/"