Browse code

Neutron L3: account for all default routes

Some systems may have more than one default route.
Set up iptables NAT rules on all v4 default route devices.
Accept RAs on all v6 default route devices.

Closes-Bug: #1624773

Change-Id: If58509297497ea33c6c156f083a4394000bd0561

Henry Gessau authored on 2016/09/18 08:28:53
Showing 1 changed files
... ...
@@ -88,8 +88,10 @@ SUBNETPOOL_PREFIX_V6=${SUBNETPOOL_PREFIX_V6:-2001:db8:8000::/48}
88 88
 SUBNETPOOL_SIZE_V4=${SUBNETPOOL_SIZE_V4:-24}
89 89
 SUBNETPOOL_SIZE_V6=${SUBNETPOOL_SIZE_V6:-64}
90 90
 
91
-default_route_dev=$(ip route | grep ^default | awk '{print $5}')
92
-die_if_not_set $LINENO default_route_dev "Failure retrieving default route device"
91
+default_v4_route_devs=$(ip -4 route | grep ^default | awk '{print $5}')
92
+die_if_not_set $LINENO default_v4_route_devs "Failure retrieving default IPv4 route devices"
93
+
94
+default_v6_route_devs=$(ip -6 route | grep ^default | awk '{print $5}')
93 95
 
94 96
 function _determine_config_l3 {
95 97
     local opts="--config-file $NEUTRON_CONF --config-file $Q_L3_CONF_FILE"
... ...
@@ -121,7 +123,9 @@ function _configure_neutron_l3_agent {
121 121
             _move_neutron_addresses_route "$PUBLIC_INTERFACE" "$OVS_PHYSICAL_BRIDGE" False False "inet6"
122 122
         fi
123 123
     else
124
-        sudo iptables -t nat -A POSTROUTING -o $default_route_dev -s $FLOATING_RANGE -j MASQUERADE
124
+        for d in $default_v4_route_devs; do
125
+            sudo iptables -t nat -A POSTROUTING -o $d -s $FLOATING_RANGE -j MASQUERADE
126
+        done
125 127
     fi
126 128
 }
127 129
 
... ...
@@ -371,11 +375,13 @@ function _neutron_configure_router_v6 {
371 371
 
372 372
     # This logic is specific to using the l3-agent for layer 3
373 373
     if is_service_enabled q-l3 || is_service_enabled neutron-l3; then
374
-        # Ensure IPv6 RAs are accepted on the interface with the default route.
374
+        # Ensure IPv6 RAs are accepted on interfaces with a default route.
375 375
         # This is needed for neutron-based devstack clouds to work in
376 376
         # IPv6-only clouds in the gate. Please do not remove this without
377 377
         # talking to folks in Infra.
378
-        sudo sysctl -w net.ipv6.conf.$default_route_dev.accept_ra=2
378
+        for d in $default_v6_route_devs; do
379
+            sudo sysctl -w net.ipv6.conf.$d.accept_ra=2
380
+        done
379 381
         # Ensure IPv6 forwarding is enabled on the host
380 382
         sudo sysctl -w net.ipv6.conf.all.forwarding=1
381 383
         # Configure and enable public bridge