From a3430270f3b652317a85c9eabe76962bd64f4543 Mon Sep 17 00:00:00 2001 From: Andreas Scheuring Date: Mon, 9 Mar 2015 16:55:32 +0100 Subject: [PATCH] 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 --- functions-common | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions-common b/functions-common index 4739e42e90..ed43e20d8d 100644 --- a/functions-common +++ b/functions-common @@ -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