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 <mhuang@redhat.com>
Acked-by: Baoquan He <bhe@redhat.com>
This commit is contained in:
Minfei Huang 2015-08-07 16:40:40 +08:00 committed by Baoquan He
parent e8e5a6a2d1
commit b57fd97ba5
1 changed files with 2 additions and 1 deletions

View File

@ -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 "/"