Browse code

Pick just the first route when looking for the host interface

The current code will fail miserably if multiple default routes are
present (perfectly normal if they have different metrics). Fixing
the code to pick the first/top entry

Fixes LP# 1084470

Change-Id: Ieda16b575685071ff831c92e6b2a29737d6f849b

Davanum Srinivas authored on 2013/01/29 11:56:02
Showing 1 changed files
... ...
@@ -253,7 +253,7 @@ FIXED_NETWORK_SIZE=${FIXED_NETWORK_SIZE:-256}
253 253
 NETWORK_GATEWAY=${NETWORK_GATEWAY:-10.0.0.1}
254 254
 
255 255
 # Find the interface used for the default route
256
-HOST_IP_IFACE=${HOST_IP_IFACE:-$(ip route | sed -n '/^default/{ s/.*dev \(\w\+\)\s\+.*/\1/; p; }')}
256
+HOST_IP_IFACE=${HOST_IP_IFACE:-$(ip route | sed -n '/^default/{ s/.*dev \(\w\+\)\s\+.*/\1/; p; }' | head -1)}
257 257
 # Search for an IP unless an explicit is set by ``HOST_IP`` environment variable
258 258
 if [ -z "$HOST_IP" -o "$HOST_IP" == "dhcp" ]; then
259 259
     HOST_IP=""