'Populate ports with subnets.
These ports already have fixed_ips populated.'

def _populate_mtu_and_subnets_for_ports(self, context, ports):

    network_ids = [p['network_id'] for p in self._each_port_having_fixed_ips(ports)]
    mtus_by_network = self._get_mtus_by_network_list(context, network_ids)
    subnets_by_network = self._get_subnets_by_network_list(context, network_ids)
    for port in self._each_port_having_fixed_ips(ports):
        port['subnets'] = []
        port['extra_subnets'] = []
        port['address_scopes'] = {constants.IP_VERSION_4: None, constants.IP_VERSION_6: None}
        scopes = {}
        for subnet in subnets_by_network[port['network_id']]:
            scope = subnet['address_scope_id']
            cidr = netaddr.IPNetwork(subnet['cidr'])
            scopes[cidr.version] = scope
            subnet_info = {'id': subnet['id'], 'cidr': subnet['cidr'], 'gateway_ip': subnet['gateway_ip'], 'dns_nameservers': subnet['dns_nameservers'], 'ipv6_ra_mode': subnet['ipv6_ra_mode'], 'subnetpool_id': subnet['subnetpool_id']}
            for fixed_ip in port['fixed_ips']:
                if (fixed_ip['subnet_id'] == subnet['id']):
                    port['subnets'].append(subnet_info)
                    prefixlen = cidr.prefixlen
                    fixed_ip['prefixlen'] = prefixlen
                    break
            else:
                port['extra_subnets'].append(subnet_info)
        port['address_scopes'].update(scopes)
        port['mtu'] = mtus_by_network.get(port['network_id'], 0)
