From 11298a01f74c7952b924d001c548d9721eebf591 Mon Sep 17 00:00:00 2001 From: Adam Kacmarsky Date: Fri, 26 Jun 2015 14:49:47 -0600 Subject: [PATCH] Add IPv6 support for _move_neutron_addresses_route Added functionallity to allow IPv6 addresses to be moved to the OVS_PHYSICAL_BRIDGE from PUBLIC_INTERFACE automatically using _move_neutron_addresses_route. Only PUBLIC_INTERFACE and OVS_PHYSICAL_BRIDGE need to be set in localrc. HOST_IP must be set in localrc. HOST_IPV6 must be set in localrc if a global IPv6 address is configured on PUBLIC_INTERFACE. Change-Id: I8d2c055702e1c7cf08499a77f6843393762fd4c1 --- lib/neutron-legacy | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/lib/neutron-legacy b/lib/neutron-legacy index cb1d1ef2ad..ee98015708 100644 --- a/lib/neutron-legacy +++ b/lib/neutron-legacy @@ -788,6 +788,7 @@ function _move_neutron_addresses_route { local from_intf=$1 local to_intf=$2 local add_ovs_port=$3 + local af=$4 if [[ -n "$from_intf" && -n "$to_intf" ]]; then # Remove the primary IP address from $from_intf and add it to $to_intf, @@ -795,10 +796,18 @@ function _move_neutron_addresses_route { # on configure we will also add $from_intf as a port on $to_intf, # assuming it is an OVS bridge. - local IP_BRD=$(ip -4 a s dev $from_intf | awk '/inet/ { print $2, $3, $4; exit }') + local IP_BRD=$(ip -f $af a s dev $from_intf | awk '/inet/ { print $2, $3, $4; exit }') local DEFAULT_ROUTE_GW=$(ip r | awk "/default.+$from_intf/ { print \$3; exit }") local ADD_OVS_PORT="" + if [[ $af == "inet" ]]; then + IP_BRD=$(ip -f $af a s dev $from_intf | grep $HOST_IP | awk '{ print $2, $3, $4; exit }') + fi + + if [[ $af == "inet6" ]]; then + IP_BRD=$(ip -f $af a s dev $from_intf | grep $HOST_IPV6 | awk '{ print $2, $3, $4; exit }') + fi + if [ "$DEFAULT_ROUTE_GW" != "" ]; then ADD_DEFAULT_ROUTE="sudo ip r replace default via $DEFAULT_ROUTE_GW dev $to_intf" fi @@ -815,7 +824,13 @@ function _move_neutron_addresses_route { # runs that a clean run would need to clean up function cleanup_neutron { - _move_neutron_addresses_route "$OVS_PHYSICAL_BRIDGE" "$PUBLIC_INTERFACE" False + if [[ $(ip -f inet a s dev "$OVS_PHYSICAL_BRIDGE" | grep -c 'global') != 0 ]]; then + _move_neutron_addresses_route "$OVS_PHYSICAL_BRIDGE" "$PUBLIC_INTERFACE" False "inet" + fi + + if [[ $(ip -f inet6 a s dev "$OVS_PHYSICAL_BRIDGE" | grep -c 'global') != 0 ]]; then + _move_neutron_addresses_route "$OVS_PHYSICAL_BRIDGE" "$PUBLIC_INTERFACE" False "inet6" + fi if is_provider_network && is_ironic_hardware; then for IP in $(ip addr show dev $OVS_PHYSICAL_BRIDGE | grep ' inet ' | awk '{print $2}'); do @@ -997,8 +1012,12 @@ function _configure_neutron_l3_agent { neutron_plugin_configure_l3_agent - if [[ $(ip -4 a s dev "$PUBLIC_INTERFACE" | grep -c 'inet') != 0 ]]; then - _move_neutron_addresses_route "$PUBLIC_INTERFACE" "$OVS_PHYSICAL_BRIDGE" True + if [[ $(ip -f inet a s dev "$PUBLIC_INTERFACE" | grep -c 'global') != 0 ]]; then + _move_neutron_addresses_route "$PUBLIC_INTERFACE" "$OVS_PHYSICAL_BRIDGE" True "inet" + fi + + if [[ $(ip -f inet6 a s dev "$PUBLIC_INTERFACE" | grep -c 'global') != 0 ]]; then + _move_neutron_addresses_route "$PUBLIC_INTERFACE" "$OVS_PHYSICAL_BRIDGE" False "inet6" fi }