From 47f76acbbac350ea18df6a9463876d38c3a13539 Mon Sep 17 00:00:00 2001 From: Jens Harbott Date: Thu, 29 Oct 2020 10:42:38 +0000 Subject: [PATCH] Determine default IPv4 route device only when needed Sometimes instances don't have an IPv4 default route, so only check for it when we actually need it. In a followup patch we could extend the code to check for an IPv6 default route instead or in addition. Related-Bug: 1902002 Change-Id: Ie6cd241721f6b1f8e030960921a696939b2dab10 --- lib/neutron-legacy | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/neutron-legacy b/lib/neutron-legacy index 2906f15736..436b0e3364 100644 --- a/lib/neutron-legacy +++ b/lib/neutron-legacy @@ -226,15 +226,17 @@ PHYSICAL_NETWORK=${PHYSICAL_NETWORK:-public} # Example: ``OVS_PHYSICAL_BRIDGE=br-eth1`` OVS_PHYSICAL_BRIDGE=${OVS_PHYSICAL_BRIDGE:-br-ex} -default_route_dev=$(ip route | grep ^default | awk '{print $5}') -die_if_not_set $LINENO default_route_dev "Failure retrieving default route device" # With the linuxbridge agent, if using VLANs for tenant networks, # or if using flat or VLAN provider networks, set in ``localrc`` to # the name of the network interface to use for the physical # network. # # Example: ``LB_PHYSICAL_INTERFACE=eth1`` -LB_PHYSICAL_INTERFACE=${LB_PHYSICAL_INTERFACE:-$default_route_dev} +if [[ $Q_AGENT == "linuxbridge" && -z ${LB_PHYSICAL_INTERFACE} ]]; then + default_route_dev=$(ip route | grep ^default | awk '{print $5}') + die_if_not_set $LINENO default_route_dev "Failure retrieving default route device" + LB_PHYSICAL_INTERFACE=$default_route_dev +fi # When Neutron tunnels are enabled it is needed to specify the # IP address of the end point in the local server. This IP is set