예제 #1
0
// ----- check_deflection_in_area -------------------------------------------
int check_deflection_in_area(uint16_t uOspfDomain, ospf_area_t tArea)
{
  int iIndexI, iIndexJ;
  /* Builds the set of BR that belongs to area and are on the backbone */
  SPtrArray * pBRList = ospf_domain_get_br_on_bb_in_area(uOspfDomain, tArea);
  net_node_t * pBR, * pER;
  
  /* Build all possibile couple of border router in the set. 
   * For each couple build RSPT on ER 
   * */
  for(iIndexI = 0; iIndexI < ptr_array_length(pBRList); iIndexI++) { 
    ptr_array_get_at(pBRList, iIndexI, &pBR);
    for(iIndexJ = 0; iIndexJ < ptr_array_length(pBRList); iIndexJ++) { 
      if (iIndexI == iIndexJ)
        continue;
      ptr_array_get_at(pBRList, iIndexJ, &pER);
      fprintf(stdout, "BR ");
      ip_address_dump(stdout, pBR->tAddr);
      fprintf(stdout, " - ER ");
      ip_address_dump(stdout, pER->tAddr);
      fprintf(stdout, "\n Computing rspt on ER\n");
      SRadixTree * pRspt = ospf_node_compute_rspt(pER, uOspfDomain, tArea);
      assert(pRspt != NULL);
      SSptVertex * pBRVertex = radix_tree_get_exact(pRspt, 
		                                    pBR->tAddr, 32);
      
      assert(pBRVertex != NULL);
      
      
      radix_tree_destroy(&pRspt);
    }
  }
  return 0;
}
예제 #2
0
// ----- check_deflection ----------------------------------------------
int check_deflection(uint16_t IGPDomainNumber, cr_info_list_t tList) {
  LOG_DEBUG("check actual deflection in domain %d\n", IGPDomainNumber);
  int iIndex;
  SCRouterInfo * pCRInfo;

  for (iIndex = 0; iIndex < ptr_array_length(tList); iIndex++){
    ptr_array_get_at(tList, iIndex, &pCRInfo);
    
    fprintf(stdout, "CRInfo BR: ");
    ip_address_dump(stdout, pCRInfo->pBR->tAddr);
    fprintf(stdout, "\n");
    fprintf(stdout, "ERInfo ER: ");
    ip_address_dump(stdout, pCRInfo->pER->tAddr);
    
    fprintf(stdout, "Compute RSPT on ER\n");
    SRadixTree * pRspt = ospf_node_compute_rspt(pCRInfo->pER, 
		                                 IGPDomainNumber, 
						 pCRInfo->tArea);
    assert(pRspt != NULL);
    SSptVertex * pBRVertex = radix_tree_get_exact(pRspt, 
		                                  pCRInfo->pBR->tAddr, 32);
    assert(pBRVertex != NULL);
    csource_check_deflection(pBRVertex, pCRInfo); 
    radix_tree_destroy(&pRspt);
    
        
    //fprintf(stdout, "--- Per ogni dest in CRInfo\n");
    //fprintf(stdout, "------- Trova route in routing table in foglia\n");
    //fprintf(stdout, "------- if (advRouter(route) == ER(CRInfo) deflection!\n");
  }
return 0;
}
예제 #3
0
/**
 * Destroy a BGP domain.
 */
void bgp_domain_destroy(bgp_domain_t ** domain_ref)
{
  if (*domain_ref != NULL) {
    radix_tree_destroy(&((*domain_ref)->routers));
    FREE(*domain_ref);
    *domain_ref= NULL;
  }
}
예제 #4
0
파일: domain.c 프로젝트: YongMan/Xen-4.3.1
struct domain *domain_create(
    domid_t domid, unsigned int domcr_flags, uint32_t ssidref)
{
    struct domain *d, **pd;
    enum { INIT_xsm = 1u<<0, INIT_watchdog = 1u<<1, INIT_rangeset = 1u<<2,
           INIT_evtchn = 1u<<3, INIT_gnttab = 1u<<4, INIT_arch = 1u<<5 };
    int err, init_status = 0;
    int poolid = CPUPOOLID_NONE;

    if ( (d = alloc_domain_struct()) == NULL )
        return ERR_PTR(-ENOMEM);

    d->domain_id = domid;

    lock_profile_register_struct(LOCKPROF_TYPE_PERDOM, d, domid, "Domain");

    if ( (err = xsm_alloc_security_domain(d)) != 0 )
        goto fail;
    init_status |= INIT_xsm;

    watchdog_domain_init(d);
    init_status |= INIT_watchdog;

    atomic_set(&d->refcnt, 1);
    spin_lock_init_prof(d, domain_lock);
    spin_lock_init_prof(d, page_alloc_lock);
    spin_lock_init(&d->hypercall_deadlock_mutex);
    INIT_PAGE_LIST_HEAD(&d->page_list);
    INIT_PAGE_LIST_HEAD(&d->xenpage_list);

    spin_lock_init(&d->node_affinity_lock);
    d->node_affinity = NODE_MASK_ALL;
    d->auto_node_affinity = 1;

    spin_lock_init(&d->shutdown_lock);
    d->shutdown_code = -1;

    err = -ENOMEM;
    if ( !zalloc_cpumask_var(&d->domain_dirty_cpumask) )
        goto fail;

    if ( domcr_flags & DOMCRF_hvm )
        d->is_hvm = 1;

    if ( domid == 0 )
    {
        d->is_pinned = opt_dom0_vcpus_pin;
        d->disable_migrate = 1;
    }

    rangeset_domain_initialise(d);
    init_status |= INIT_rangeset;

    d->iomem_caps = rangeset_new(d, "I/O Memory", RANGESETF_prettyprint_hex);
    d->irq_caps   = rangeset_new(d, "Interrupts", 0);
    if ( (d->iomem_caps == NULL) || (d->irq_caps == NULL) )
        goto fail;

    if ( domcr_flags & DOMCRF_dummy )
        return d;

    if ( !is_idle_domain(d) )
    {
        if ( (err = xsm_domain_create(XSM_HOOK, d, ssidref)) != 0 )
            goto fail;

        d->is_paused_by_controller = 1;
        atomic_inc(&d->pause_count);

        if ( domid )
            d->nr_pirqs = nr_static_irqs + extra_domU_irqs;
        else
            d->nr_pirqs = nr_static_irqs + extra_dom0_irqs;
        if ( d->nr_pirqs > nr_irqs )
            d->nr_pirqs = nr_irqs;

        radix_tree_init(&d->pirq_tree);

        if ( (err = evtchn_init(d)) != 0 )
            goto fail;
        init_status |= INIT_evtchn;

        if ( (err = grant_table_create(d)) != 0 )
            goto fail;
        init_status |= INIT_gnttab;

        poolid = 0;

        err = -ENOMEM;
        d->mem_event = xzalloc(struct mem_event_per_domain);
        if ( !d->mem_event )
            goto fail;
    }

    if ( (err = arch_domain_create(d, domcr_flags)) != 0 )
        goto fail;
    init_status |= INIT_arch;

    if ( (err = cpupool_add_domain(d, poolid)) != 0 )
        goto fail;

    if ( (err = sched_init_domain(d)) != 0 )
        goto fail;

    if ( !is_idle_domain(d) )
    {
        spin_lock(&domlist_update_lock);
        pd = &domain_list; /* NB. domain_list maintained in order of domid. */
        for ( pd = &domain_list; *pd != NULL; pd = &(*pd)->next_in_list )
            if ( (*pd)->domain_id > d->domain_id )
                break;
        d->next_in_list = *pd;
        d->next_in_hashbucket = domain_hash[DOMAIN_HASH(domid)];
        rcu_assign_pointer(*pd, d);
        rcu_assign_pointer(domain_hash[DOMAIN_HASH(domid)], d);
        spin_unlock(&domlist_update_lock);
    }

    return d;

 fail:
    d->is_dying = DOMDYING_dead;
    atomic_set(&d->refcnt, DOMAIN_DESTROYED);
    xfree(d->mem_event);
    if ( init_status & INIT_arch )
        arch_domain_destroy(d);
    if ( init_status & INIT_gnttab )
        grant_table_destroy(d);
    if ( init_status & INIT_evtchn )
    {
        evtchn_destroy(d);
        evtchn_destroy_final(d);
        radix_tree_destroy(&d->pirq_tree, free_pirq_struct);
    }
    if ( init_status & INIT_rangeset )
        rangeset_domain_destroy(d);
    if ( init_status & INIT_watchdog )
        watchdog_domain_destroy(d);
    if ( init_status & INIT_xsm )
        xsm_free_security_domain(d);
    free_cpumask_var(d->domain_dirty_cpumask);
    free_domain_struct(d);
    return ERR_PTR(err);
}
예제 #5
0
파일: block-cache.c 프로젝트: OpenXT/blktap
static inline void
radix_tree_free(radix_tree_t *tree)
{
	radix_tree_destroy(tree);
}