From c6e97a945ea813c7d9bae43377035ba4980b8a11 Mon Sep 17 00:00:00 2001 From: Thomas Bachman Date: Thu, 8 Mar 2018 17:24:21 +0000 Subject: [PATCH] Add DHCP agent MAC address to gbp_details The MAC address and IP list of the ports belonging to the DHCP agent responsible for a given port are added to the get_gbp_details RPC. This allows the agent to support proxying ARPs for the DHCP agent's IP, using the appropriate MAC. Change-Id: Ia125dbc3207731a753d4fa1cafa50d4a4a928b89 --- .../drivers/cisco/apic/aim_mapping.py | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/gbpservice/neutron/services/grouppolicy/drivers/cisco/apic/aim_mapping.py b/gbpservice/neutron/services/grouppolicy/drivers/cisco/apic/aim_mapping.py index f94d12141..bef8b8e43 100644 --- a/gbpservice/neutron/services/grouppolicy/drivers/cisco/apic/aim_mapping.py +++ b/gbpservice/neutron/services/grouppolicy/drivers/cisco/apic/aim_mapping.py @@ -1959,18 +1959,21 @@ class AIMMappingDriver(nrd.CommonNeutronBase, aim_rpc.AIMMappingRPCMixin): plugin_context, filters={'id': [ip['subnet_id'] for ip in port['fixed_ips']]}) for subnet in subnets: - dhcp_ips = set() - for port in self._get_ports( + dhcp_ports = {} + subnet_dhcp_ips = set() + for dhcp_port in self._get_ports( plugin_context, filters={ 'network_id': [subnet['network_id']], 'device_owner': [n_constants.DEVICE_OWNER_DHCP]}): - dhcp_ips |= set([x['ip_address'] for x in port['fixed_ips'] - if x['subnet_id'] == subnet['id']]) - dhcp_ips = list(dhcp_ips) + dhcp_ips = set([x['ip_address'] for x in dhcp_port['fixed_ips'] + if x['subnet_id'] == subnet['id']]) + dhcp_ports.setdefault(dhcp_port['mac_address'], list(dhcp_ips)) + subnet_dhcp_ips |= dhcp_ips + subnet_dhcp_ips = list(subnet_dhcp_ips) if not subnet['dns_nameservers']: # Use DHCP namespace port IP - subnet['dns_nameservers'] = dhcp_ips + subnet['dns_nameservers'] = subnet_dhcp_ips # Set Default & Metadata routes if needed default_route = metadata_route = {} if subnet['ip_version'] == 4: @@ -1996,12 +1999,19 @@ class AIMMappingDriver(nrd.CommonNeutronBase, aim_rpc.AIMMappingRPCMixin): 'nexthop': subnet['gateway_ip']}) optimized = self._is_metadata_optimized(plugin_context, port) - if not metadata_route and dhcp_ips and (not optimized or - (optimized and not default_route)): - subnet['host_routes'].append( - {'destination': dhcp.METADATA_DEFAULT_CIDR, - 'nexthop': dhcp_ips[0]}) - subnet['dhcp_server_ips'] = dhcp_ips + # REVISIT: We need to decide if we should provide + # host-routes for all of the DHCP agents. For now + # use the first DHCP agent in our list for the + # metadata host-route next-hop IPs + if not metadata_route and dhcp_ports and ( + not optimized or (optimized and not default_route)): + for ip in dhcp_ports[dhcp_ports.keys()[0]]: + subnet['host_routes'].append( + {'destination': dhcp.METADATA_DEFAULT_CIDR, + 'nexthop': ip}) + subnet['dhcp_server_ips'] = subnet_dhcp_ips + if dhcp_ports: + subnet['dhcp_server_ports'] = dhcp_ports return subnets def _send_port_update_notification(self, plugin_context, port):