Support detection of interfaces with non-word chars in the name
The current regex only matches host interface names that consits of "word characters" (regex \w). Intefaces having other special chars like "-" or "." are not parsed. Examples that are not yet matched are br-ex (ovs bridge) or enccw0.0.1234 (s390 eth device name). In addition it's hard to understand the the regex. This fix is replacing the regex by a simple awk statement also matching those names. In addition the determination of the host_ip_iface was moved down into the if clause, as it is only used inside. Change-Id: I3d1b1afa32956e4e8c55c7e68cbafaf8e03e7da2 Closes-Bug: #1429903
This commit is contained in:
parent
5c619b43db
commit
a3430270f3
@ -542,11 +542,11 @@ function get_default_host_ip {
|
||||
local host_ip_iface=$3
|
||||
local host_ip=$4
|
||||
|
||||
# Find the interface used for the default route
|
||||
host_ip_iface=${host_ip_iface:-$(ip route | sed -n '/^default/{ s/.*dev \(\w\+\)\s\+.*/\1/; p; }' | head -1)}
|
||||
# Search for an IP unless an explicit is set by ``HOST_IP`` environment variable
|
||||
if [ -z "$host_ip" -o "$host_ip" == "dhcp" ]; then
|
||||
host_ip=""
|
||||
# Find the interface used for the default route
|
||||
host_ip_iface=${host_ip_iface:-$(ip route | awk '/default/ {print $5}' | head -1)}
|
||||
local host_ips=$(LC_ALL=C ip -f inet addr show ${host_ip_iface} | awk '/inet/ {split($2,parts,"/"); print parts[1]}')
|
||||
local ip
|
||||
for ip in $host_ips; do
|
||||
|
Loading…
Reference in New Issue
Block a user