int parse_database_mapping(cfg_t *cfg, lisp_xtr_t *xtr, shash_t *lcaf_ht) { int n,i; mapping_t *mapping; map_local_entry_t *map_loc_e; void *fwd_map_inf; n = cfg_size(cfg, "database-mapping"); for (i = 0; i < n; i++) { mapping = parse_mapping(cfg_getnsec(cfg, "database-mapping", i),&(xtr->super),lcaf_ht,TRUE); if (mapping == NULL){ continue; } map_loc_e = map_local_entry_new_init(mapping); if (map_loc_e == NULL){ mapping_del(mapping); continue; } fwd_map_inf = xtr->fwd_policy->new_map_loc_policy_inf(xtr->fwd_policy_dev_parm,mapping,NULL); if (fwd_map_inf == NULL){ OOR_LOG(LERR, "Couldn't create forward information for mapping with EID: %s. Discarding it...", lisp_addr_to_char(mapping_eid(mapping))); map_local_entry_del(map_loc_e); continue; } map_local_entry_set_fwd_info(map_loc_e, fwd_map_inf, xtr->fwd_policy->del_map_loc_policy_inf); if (add_local_db_map_local_entry(map_loc_e,xtr) != GOOD){ map_local_entry_del(map_loc_e); continue; } } return (GOOD); }
void lisp_reg_site_del(lisp_reg_site_t *rs) { stop_timers_from_obj(rs,ptrs_to_timers_ht,nonces_ht); mapping_del(rs->site_map); free(rs); }
void mman_release_all(void) { int i; LOCK(); /* kill all mappings in other components */ for (i = 0 ; i < COS_MAX_MEMORY ; i++) { struct frame *f = &frames[i]; struct mapping *m; if (frame_nrefs(f) <= 0) continue; m = f->c.m; assert(m); mapping_del(m); } /* kill local mappings */ /* for (i = 0 ; i < COS_MAX_MEMORY ; i++) { */ /* struct frame *f = &frames[i]; */ /* int idx; */ /* if (frame_nrefs(f) >= 0) continue; */ /* idx = cos_mmap_cntl(COS_MMAP_REVOKE, 0, cos_spd_id(), f->c.addr, 0); */ /* assert(idx == frame_index(f)); */ /* } */ UNLOCK(); }
static void gdb_mapping_del(void *p, size_t len) { if( !MAP_IN_RANGE(inout, p) && !MAP_IN_RANGE(raw, p) && !MAP_IN_RANGE(direct, p)) { mapping_del(p, len); } }
void map_local_entry_del(map_local_entry_t *mle) { if (mle == NULL){ return; } stop_timers_from_obj(mle,ptrs_to_timers_ht, nonces_ht); mapping_del(mle->mapping); if (mle->fwd_info != NULL){ mle->fwd_inf_del(mle->fwd_info); } free(mle); }
int mman_release_page(spdid_t spd, vaddr_t addr, int flags) { struct mapping *m; int ret = 0; LOCK(); m = mapping_lookup(spd, addr); if (!m) { ret = -1; /* -EINVAL */ goto done; } mapping_del(m); done: UNLOCK(); return ret; }
int configure_ms(cfg_t *cfg) { char *iface_name; iface_t *iface; lisp_site_prefix_t *site; shash_t *lcaf_ht; int i; lisp_ms_t *ms; mapping_t *mapping; /* create and configure xtr */ if (ctrl_dev_create(MS_MODE, &ctrl_dev) != GOOD) { OOR_LOG(LCRIT, "Failed to create MS. Aborting!"); exit_cleanup(); } ms = CONTAINER_OF(ctrl_dev, lisp_ms_t, super); /* create lcaf hash table */ lcaf_ht = parse_lcafs(cfg); /* CONTROL INTERFACE */ /* TODO: should work with all interfaces in the future */ iface_name = cfg_getstr(cfg, "control-iface"); if (iface_name) { iface = add_interface(iface_name); if (iface == NULL) { return(BAD); } } if (iface_address(iface, AF_INET) == NULL){ iface_setup_addr(iface, AF_INET); data_plane->datap_add_iface_addr(iface,AF_INET); lctrl->control_data_plane->control_dp_add_iface_addr(lctrl,iface,AF_INET); } if (iface_address(iface, AF_INET6) == NULL){ iface_setup_addr(iface, AF_INET6); data_plane->datap_add_iface_addr(iface,AF_INET6); lctrl->control_data_plane->control_dp_add_iface_addr(lctrl,iface,AF_INET6); } /* LISP-SITE CONFIG */ for (i = 0; i < cfg_size(cfg, "lisp-site"); i++) { cfg_t *ls = cfg_getnsec(cfg, "lisp-site", i); site = build_lisp_site_prefix(ms, cfg_getstr(ls, "eid-prefix"), cfg_getint(ls, "iid"), cfg_getint(ls, "key-type"), cfg_getstr(ls, "key"), cfg_getbool(ls, "accept-more-specifics") ? 1:0, cfg_getbool(ls, "proxy-reply") ? 1:0, cfg_getbool(ls, "merge") ? 1 : 0, lcaf_ht); if (site != NULL) { if (mdb_lookup_entry(ms->lisp_sites_db, site->eid_prefix) != NULL){ OOR_LOG(LDBG_1, "Configuration file: Duplicated lisp-site: %s . Discarding...", lisp_addr_to_char(site->eid_prefix)); lisp_site_prefix_del(site); continue; } OOR_LOG(LDBG_1, "Adding lisp site prefix %s to the lisp-sites " "database", lisp_addr_to_char(site->eid_prefix)); ms_add_lisp_site_prefix(ms, site); }else{ OOR_LOG(LERR, "Can't add lisp-site prefix %s. Discarded ...", cfg_getstr(ls, "eid-prefix")); } } /* LISP REGISTERED SITES CONFIG */ for (i = 0; i< cfg_size(cfg, "ms-static-registered-site"); i++ ) { cfg_t *mss = cfg_getnsec(cfg, "ms-static-registered-site", i); mapping = parse_mapping(mss,&(ms->super),lcaf_ht,FALSE); if (mapping == NULL){ OOR_LOG(LERR, "Can't create static register site for %s", cfg_getstr(mss, "eid-prefix")); continue; } /* If the mapping doesn't exist, add it the the database */ if (mdb_lookup_entry_exact(ms->reg_sites_db, mapping_eid(mapping)) == NULL){ if (ms_add_registered_site_prefix(ms, mapping) == GOOD){ OOR_LOG(LDBG_1, "Added static registered site for %s to the registered sites list!", lisp_addr_to_char(mapping_eid(mapping))); }else{ OOR_LOG(LERR, "Failed to add static registered site for %s to the registered sites list!", lisp_addr_to_char(mapping_eid(mapping))); mapping_del(mapping); } }else{ OOR_LOG(LERR, "Configuration file: Duplicated static registered site for %s. Discarded ...", cfg_getstr(mss, "eid-prefix")); mapping_del(mapping); continue; } } /* destroy the hash table */ shash_destroy(lcaf_ht); return(GOOD); }
int configure_rtr(cfg_t *cfg) { lisp_xtr_t *xtr; shash_t *lcaf_ht; mapping_t *mapping; map_local_entry_t *map_loc_e; void *fwd_map_inf; int n,i; /* CREATE AND CONFIGURE RTR (xTR in fact) */ if (ctrl_dev_create(RTR_MODE, &ctrl_dev) != GOOD) { OOR_LOG(LCRIT, "Failed to create RTR. Aborting!"); return (BAD); } lcaf_ht = parse_lcafs(cfg); xtr = CONTAINER_OF(ctrl_dev, lisp_xtr_t, super); if (configure_tunnel_router(cfg, xtr, lcaf_ht)!=GOOD){ return (BAD); } /* INTERFACES CONFIG */ n = cfg_size(cfg, "rtr-ifaces"); if (n) { cfg_t *rifs = cfg_getsec(cfg, "rtr-ifaces"); int nr = cfg_size(rifs, "rtr-iface"); for(i = 0; i < nr; i++) { cfg_t *ri = cfg_getnsec(rifs, "rtr-iface", i); if (add_rtr_iface(xtr, cfg_getstr(ri, "iface"), cfg_getint(ri, "ip_version"), cfg_getint(ri, "priority"), cfg_getint(ri, "weight")) == GOOD) { OOR_LOG(LDBG_1, "Configured interface %s for RTR", cfg_getstr(ri, "iface")); } else{ OOR_LOG(LERR, "Can't configure iface %s for RTR", cfg_getstr(ri, "iface")); } } } /* RTR DATABASE MAPPINGS (like for instance replication lists) */ n = cfg_size(cfg, "rtr-database-mapping"); for (i = 0; i < n; i++) { mapping = parse_mapping(cfg_getnsec(cfg, "rtr-database-mapping",i),&(xtr->super),lcaf_ht,TRUE); if (mapping == NULL){ continue; } map_loc_e = map_local_entry_new_init(mapping); if (map_loc_e == NULL){ mapping_del(mapping); continue; } fwd_map_inf = xtr->fwd_policy->new_map_loc_policy_inf(xtr->fwd_policy_dev_parm,mapping,NULL); if (fwd_map_inf == NULL){ OOR_LOG(LERR, "Couldn't create forward information for rtr database mapping with EID: %s. Discarding it...", lisp_addr_to_char(mapping_eid(mapping))); map_local_entry_del(map_loc_e); continue; } map_local_entry_set_fwd_info(map_loc_e, fwd_map_inf, xtr->fwd_policy->del_map_loc_policy_inf); if (add_local_db_map_local_entry(map_loc_e,xtr) != GOOD){ map_local_entry_del(map_loc_e); continue; } if (add_local_db_map_local_entry(map_loc_e,xtr) != GOOD){ map_local_entry_del(map_loc_e); } } /* Deallocate PiTRs and PeTRs elements */ glist_destroy(xtr->pitrs); xtr->pitrs = NULL; shash_destroy(lcaf_ht); return(GOOD); }
int configure_tunnel_router(cfg_t *cfg, lisp_xtr_t *xtr, shash_t *lcaf_ht) { int i,n,ret; char *map_resolver; char *encap; mapping_t *mapping; /* FWD POLICY STRUCTURES */ xtr->fwd_policy = fwd_policy_class_find("flow_balancing"); xtr->fwd_policy_dev_parm = xtr->fwd_policy->new_dev_policy_inf(ctrl_dev,NULL); if ((encap = cfg_getstr(cfg, "encapsulation")) != NULL) { if (strcmp(encap, "LISP") == 0) { xtr->encap_type = ENCP_LISP; }else if (strcmp(encap, "VXLAN-GPE") == 0){ xtr->encap_type = ENCP_VXLAN_GPE; }else{ OOR_LOG(LERR, "Unknown encapsulation type: %s",encap); return (BAD); } } /* RETRIES */ ret = cfg_getint(cfg, "map-request-retries"); xtr->map_request_retries = (ret != 0) ? ret : DEFAULT_MAP_REQUEST_RETRIES; /* RLOC PROBING CONFIG */ cfg_t *dm = cfg_getnsec(cfg, "rloc-probing", 0); if (dm != NULL) { xtr->probe_interval = cfg_getint(dm, "rloc-probe-interval"); xtr->probe_retries = cfg_getint(dm, "rloc-probe-retries"); xtr->probe_retries_interval = cfg_getint(dm, "rloc-probe-retries-interval"); validate_rloc_probing_parameters(&xtr->probe_interval, &xtr->probe_retries, &xtr->probe_retries_interval); } else { OOR_LOG(LDBG_1, "Configuration file: RLOC probing not defined. " "Setting default values: RLOC Probing Interval: %d sec.", RLOC_PROBING_INTERVAL); xtr->probe_interval = RLOC_PROBING_INTERVAL; xtr->probe_retries = DEFAULT_RLOC_PROBING_RETRIES; xtr->probe_retries_interval = DEFAULT_RLOC_PROBING_RETRIES_INTERVAL; } /* MAP-RESOLVER CONFIG */ n = cfg_size(cfg, "map-resolver"); for(i = 0; i < n; i++) { if ((map_resolver = cfg_getnstr(cfg, "map-resolver", i)) != NULL) { if (add_server(map_resolver, xtr->map_resolvers) == GOOD){ OOR_LOG(LDBG_1, "Added %s to map-resolver list", map_resolver); }else{ OOR_LOG(LCRIT,"Can't add %s Map Resolver.",map_resolver); } } } /* STATIC MAP-CACHE CONFIG */ n = cfg_size(cfg, "static-map-cache"); for (i = 0; i < n; i++) { cfg_t *smc = cfg_getnsec(cfg, "static-map-cache", i); mapping = parse_mapping(smc,&(xtr->super),lcaf_ht,FALSE); if (mapping == NULL){ OOR_LOG(LERR, "Can't add static Map Cache entry with EID prefix %s. Discarded ...", cfg_getstr(smc, "eid-prefix")); continue; } if (mcache_lookup_exact(xtr->map_cache, mapping_eid(mapping)) == NULL){ if (tr_mcache_add_static_mapping(xtr, mapping) == GOOD){ OOR_LOG(LDBG_1, "Added static Map Cache entry with EID prefix %s in the database.", lisp_addr_to_char(mapping_eid(mapping))); }else{ OOR_LOG(LERR, "Can't add static Map Cache entry with EID prefix %s. Discarded ...", mapping_eid(mapping)); mapping_del(mapping); } }else{ OOR_LOG(LERR, "Configuration file: Duplicated static Map Cache entry with EID prefix %s." "Discarded ...",cfg_getstr(smc, "eid-prefix")); mapping_del(mapping); continue; } continue; } return (GOOD); }