Esempio n. 1
0
int send_map_request_miss(timer *t, void *arg)
{
    timer_map_request_argument *argument = (timer_map_request_argument *)arg;
    lispd_map_cache_entry *map_cache_entry = argument->map_cache_entry;
    nonces_list *nonces = map_cache_entry->nonces;
    lisp_addr_t *dst_rloc = NULL;

    if (nonces == NULL){
        nonces = new_nonces_list();
        if (nonces==NULL){
            lispd_log_msg(LISP_LOG_WARNING,"Send_map_request_miss: Unable to allocate memory for nonces.");
            return (BAD);
        }
        map_cache_entry->nonces = nonces;
    }

    if (nonces->retransmits - 1 < map_request_retries ){

        if (map_cache_entry->request_retry_timer == NULL){
            map_cache_entry->request_retry_timer = create_timer (MAP_REQUEST_RETRY_TIMER);
        }

        if (nonces->retransmits > 0){
            lispd_log_msg(LISP_LOG_DEBUG_1,"Retransmiting Map Request for EID: %s (%d retries)",
                    get_char_from_lisp_addr_t(map_cache_entry->mapping->eid_prefix),
                    nonces->retransmits);
        }

        /* Get the RLOC of the Map Resolver to be used */
        dst_rloc = get_map_resolver();

        if ((dst_rloc == NULL) || (build_and_send_map_request_msg(
                map_cache_entry->mapping,
                &(argument->src_eid),
                dst_rloc,
                1,
                0,
                0,
                0,
                &nonces->nonce[nonces->retransmits]))==BAD){
            lispd_log_msg (LISP_LOG_DEBUG_1, "send_map_request_miss: Couldn't send map request for a new map cache entry");

        }

        nonces->retransmits ++;
        start_timer(map_cache_entry->request_retry_timer, LISPD_INITIAL_MRQ_TIMEOUT,
                send_map_request_miss, (void *)argument);

    }else{
        lispd_log_msg(LISP_LOG_DEBUG_1,"No Map Reply fot EID %s/%d after %d retries. Removing map cache entry ...",
                        get_char_from_lisp_addr_t(map_cache_entry->mapping->eid_prefix),
                        map_cache_entry->mapping->eid_prefix_length,
                        nonces->retransmits -1);
        del_map_cache_entry_from_db(map_cache_entry->mapping->eid_prefix,
                map_cache_entry->mapping->eid_prefix_length);

    }
    return GOOD;
}
Esempio n. 2
0
void rloc_probing(timer *t, void *arg)
{
    lispd_map_cache_entry   *map_cache_entry = (lispd_map_cache_entry *)arg;
    lispd_identifier_elt    *identifier = map_cache_entry->identifier;
    lispd_locators_list 	*locators_lists[2];
    lispd_locators_list     *locators;
    lispd_locator_elt       *locator;
    int loc_ctr = 0;
    int ctr;

    /* First RLOC probing iteration: create timer*/
    if (!t)
        map_cache_entry->probe_timer = create_timer ("RLOC PROBING TIMER");

    if (map_cache_entry->probe_left == 0){
    	locators_lists[0] = identifier->head_v4_locators_list;
    	locators_lists[1] = identifier->head_v6_locators_list;
    	for (ctr = 0 ; ctr < 2 ; ctr++){
    		locators = locators_lists[ctr];
    		/* Send a map request probe for each locator of the identifier */
    		while (locators){
    			locator = locators->locator;
    			if (locator->rloc_probing_nonces != NULL){
    				// XXX alopez: It should never arrive here. Remove once tested
    				syslog (LOG_ERR,"First RLOC Probing -> rloc_probing_nonces not null");
    				exit(1);
    			}
    			locator->rloc_probing_nonces = new_nonces_list();
    			if (!locator->rloc_probing_nonces){
    				// XXX alopez: REPROGRAMAR
    			}
    			if ((err=build_and_send_map_request_msg(&(map_cache_entry->identifier->eid_prefix),
    			        map_cache_entry->identifier->eid_prefix_length,
    					locator->locator_addr, 0, 1, 0, 0,
    					&(locator->rloc_probing_nonces->nonce[0])))!= GOOD){
    				// TODO Actions according to the error
    			}
    			loc_ctr++;
    			locators = locators->next;
    		}
    	}
    	// XXX alopez: Removed once tested
    	if (loc_ctr != identifier->locator_count){
    		syslog(LOG_CRIT, "The number of locators (%d) is different from the number indicated by "
    				"locator_count (%d) ",loc_ctr, identifier->locator_count);
    		exit(1);
    	}
    	map_cache_entry->probe_left = loc_ctr;
    }else {
    	locators_lists[0] = identifier->head_v4_locators_list;
    	locators_lists[1] = identifier->head_v6_locators_list;
    	for (ctr = 0 ; ctr < 2 ; ctr++){
    		locators = locators_lists[ctr];
    		/*
    		 * For each locator check if probe has been received. If not, request new probe.
    		 * If reached the maximum number of retries, locator status set to down
    		 */
    		while (locators){
    			locator = locators->locator;
    			if (locator->rloc_probing_nonces == NULL){ /* Map Reply Probe received */
    				locators = locators->next;
    				continue;
    			}
    			/* No Map Reply Probe received -> Retransmit Map Request Probe */
    			if (locator->rloc_probing_nonces->retransmits -1 < LISPD_MAX_PROBE_RETRANSMIT){
    				if ((err=build_and_send_map_request_msg(&(map_cache_entry->identifier->eid_prefix),
                            map_cache_entry->identifier->eid_prefix_length,
    						locator->locator_addr, 0, 1, 0, 0,
    						&(locator->rloc_probing_nonces->nonce[0])))!= GOOD){
    					// TODO Actions according to the error
    				}
    			}else { /* No Map Reply Probe received for any Map Request Probe */
    				locator->state = DOWN;
    				free (locator->rloc_probing_nonces);
    				locator->rloc_probing_nonces = NULL;
    				map_cache_entry->probe_left --;
    			}
    		}
    	}
    }
    /*
     * Reprogrammin timer:
     *  Until all locators are probed or set down, reprogramming timer with timeout period,
     *  otherwise timer set to probing period time
     */
    if (map_cache_entry->probe_left > 0){
        start_timer(map_cache_entry->probe_timer, LISPD_INITIAL_PROBE_TIMEOUT,
                        rloc_probing, (void *)map_cache_entry);
    }else{
        start_timer(map_cache_entry->probe_timer, RLOC_PROBING_INTERVAL,
                        rloc_probing, (void *)map_cache_entry);
    }


}