diff options
author | Jordan Augé <jordan.auge+fdio@cisco.com> | 2019-11-27 09:05:39 +0100 |
---|---|---|
committer | Jordan Augé <jordan.auge+fdio@cisco.com> | 2019-12-05 00:32:28 +0100 |
commit | 94350c13fe983a7cfb99dafecb0d029ed58361bf (patch) | |
tree | ed82fbed47a3ec2b9855e93402b3f75f3f403b57 /hicn-light | |
parent | dafa145fb5a4a10c1e600ee72fe639ac4f7e718d (diff) |
[HICN-420] MAP-Me code refactoring & face manager changes in support of mobility
Change-Id: Ifde50b4c161d1bda1326f18b705f575e539aea71
Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'hicn-light')
-rw-r--r-- | hicn-light/src/hicn/command_line/controller/hicnLightControl_main.c | 1 | ||||
-rw-r--r-- | hicn-light/src/hicn/config/configuration.c | 24 | ||||
-rw-r--r-- | hicn-light/src/hicn/core/connection.h | 1 | ||||
-rw-r--r-- | hicn-light/src/hicn/core/forwarder.c | 8 | ||||
-rw-r--r-- | hicn-light/src/hicn/core/mapme.c | 217 | ||||
-rw-r--r-- | hicn-light/src/hicn/core/mapme.h | 16 | ||||
-rw-r--r-- | hicn-light/src/hicn/core/name.c | 4 | ||||
-rw-r--r-- | hicn-light/src/hicn/core/name.h | 1 | ||||
-rw-r--r-- | hicn-light/src/hicn/processor/fibEntry.c | 103 | ||||
-rw-r--r-- | hicn-light/src/hicn/processor/fibEntry.h | 32 | ||||
-rw-r--r-- | hicn-light/src/hicn/processor/messageProcessor.c | 15 | ||||
-rw-r--r-- | hicn-light/src/hicn/processor/messageProcessor.h | 5 | ||||
-rw-r--r-- | hicn-light/src/hicn/utils/commands.h | 8 |
13 files changed, 273 insertions, 162 deletions
diff --git a/hicn-light/src/hicn/command_line/controller/hicnLightControl_main.c b/hicn-light/src/hicn/command_line/controller/hicnLightControl_main.c index 1f5d33e24..739326669 100644 --- a/hicn-light/src/hicn/command_line/controller/hicnLightControl_main.c +++ b/hicn-light/src/hicn/command_line/controller/hicnLightControl_main.c @@ -83,6 +83,7 @@ static int payloadLengthController[LAST_COMMAND_VALUE] = { sizeof(remove_policy_command), sizeof(update_connection_command), sizeof(connection_set_priority_command), + sizeof(connection_set_tags_command), #endif }; diff --git a/hicn-light/src/hicn/config/configuration.c b/hicn-light/src/hicn/config/configuration.c index 0466189cb..52dbf7a47 100644 --- a/hicn-light/src/hicn/config/configuration.c +++ b/hicn-light/src/hicn/config/configuration.c @@ -1197,6 +1197,26 @@ struct iovec *configuration_ConnectionSetPriority(Configuration *config, return utils_CreateAck(header, control, sizeof(connection_set_priority_command)); } +struct iovec *configuration_ConnectionSetTags(Configuration *config, + struct iovec *request) { + header_control_message *header = request[0].iov_base; + connection_set_tags_command *control = request[1].iov_base; + + Connection * conn = getConnectionBySymbolicOrId(config, control->symbolicOrConnid); + if (!conn) + return utils_CreateNack(header, control, sizeof(connection_set_tags_command)); + + connection_SetTags(conn, control->tags); + +#ifdef WITH_MAPME + /* Hook: connection event */ + forwarder_onConnectionEvent(config->forwarder, conn, + CONNECTION_EVENT_TAGS_CHANGED); +#endif /* WITH_MAPME */ + + return utils_CreateAck(header, control, sizeof(connection_set_tags_command)); +} + struct iovec *configuration_ProcessPolicyAdd(Configuration *config, struct iovec *request) { header_control_message *header = request[0].iov_base; @@ -1402,6 +1422,10 @@ struct iovec *configuration_DispatchCommand(Configuration *config, case CONNECTION_SET_PRIORITY: response = configuration_ConnectionSetPriority(config, control); break; + + case CONNECTION_SET_TAGS: + response = configuration_ConnectionSetTags(config, control); + break; #endif /* WITH_POLICY */ default: diff --git a/hicn-light/src/hicn/core/connection.h b/hicn-light/src/hicn/core/connection.h index 3b647dd7a..d0d093064 100644 --- a/hicn-light/src/hicn/core/connection.h +++ b/hicn-light/src/hicn/core/connection.h @@ -37,6 +37,7 @@ typedef enum { CONNECTION_EVENT_SET_UP, CONNECTION_EVENT_SET_DOWN, CONNECTION_EVENT_PRIORITY_CHANGED, + CONNECTION_EVENT_TAGS_CHANGED, } connection_event_t; #endif /* WITH_MAPME */ diff --git a/hicn-light/src/hicn/core/forwarder.c b/hicn-light/src/hicn/core/forwarder.c index 66551b0ec..628cbd761 100644 --- a/hicn-light/src/hicn/core/forwarder.c +++ b/hicn-light/src/hicn/core/forwarder.c @@ -571,11 +571,11 @@ FIB *forwarder_getFib(Forwarder *forwarder) { } void forwarder_onConnectionEvent(Forwarder *forwarder, const Connection *conn, connection_event_t event) { -#ifdef WITH_POLICY - messageProcessor_onConnectionEvent(forwarder->processor, conn, event); -#else +//#ifdef WITH_POLICY +// messageProcessor_onConnectionEvent(forwarder->processor, conn, event); +//#else mapme_onConnectionEvent(forwarder->mapme, conn, event); -#endif /* WITH_POLICY */ +//#endif /* WITH_POLICY */ } void forwarder_ProcessMapMe(Forwarder *forwarder, const uint8_t *msgBuffer, diff --git a/hicn-light/src/hicn/core/mapme.c b/hicn-light/src/hicn/core/mapme.c index 0eba02e49..d5475f229 100644 --- a/hicn-light/src/hicn/core/mapme.c +++ b/hicn-light/src/hicn/core/mapme.c @@ -146,6 +146,7 @@ ERR_MALLOC: void mapmeTFIB_Release(MapMeTFIB **tfibPtr) { MapMeTFIB *tfib = *tfibPtr; + /* TODO; Release all timers */ parcHashMap_Release(&tfib->nexthops); free(tfib); *tfibPtr = NULL; @@ -282,13 +283,13 @@ struct setFacePendingArgs { FibEntry *fibEntry; unsigned conn_id; bool send; - bool is_first; + bool is_producer; uint32_t num_retx; }; static bool mapme_setFacePending(const MapMe *mapme, const Name *name, FibEntry *fibEntry, unsigned conn_id, - bool send, bool is_first, uint32_t num_retx); + bool send, bool is_producer, bool clear_tfib, uint32_t num_retx); static void mapme_setFacePendingCallback(int fd, PARCEventType which_event, void *data) { @@ -300,7 +301,7 @@ static void mapme_setFacePendingCallback(int fd, PARCEventType which_event, INFO(args->mapme, "Timeout during retransmission. Re-sending"); mapme_setFacePending(args->mapme, args->name, args->fibEntry, args->conn_id, - args->send, args->is_first, args->num_retx); + args->send, args->is_producer, false, args->num_retx); } /** @@ -325,7 +326,7 @@ static hicn_mapme_type_t mapme_getTypeFromHeuristic(const MapMe *mapme, static bool mapme_setFacePending(const MapMe *mapme, const Name *name, FibEntry *fibEntry, unsigned conn_id, - bool send, bool is_first, uint32_t num_retx) { + bool send, bool is_producer, bool clear_tfib, uint32_t num_retx) { int rc; INFO(mapme, "[MAP-Me] SetFacePending connection=%d prefix=XX retx=%d", @@ -337,14 +338,46 @@ static bool mapme_setFacePending(const MapMe *mapme, const Name *name, Dispatcher *dispatcher = forwarder_GetDispatcher(mapme->forwarder); PARCEventTimer *timer; + /* + * On the producer side, we have to clear the TFIB everytime we change the list + * of adjacencies, otherwise retransmissions will occur to preserve them. + */ + if (clear_tfib) { + /* + * It is likely we cannot iterator and remove elements from the hashmap at + * the same time, so we proceed in two steps + */ + NumberSet * conns = numberSet_Create(); + + PARCIterator *it = parcHashMap_CreateKeyIterator(TFIB(fibEntry)->nexthops); + while (parcIterator_HasNext(it)) { + PARCUnsigned *cid = parcIterator_Next(it); + unsigned conn_id = parcUnsigned_GetUnsigned(cid); + numberSet_Add(conns, conn_id); + } + parcIterator_Release(&it); + + for (size_t i = 0; i < numberSet_Length(conns); i++) { + unsigned conn_id = numberSet_GetItem(conns, i); + PARCEventTimer *oldTimer = (PARCEventTimer *)mapmeTFIB_Get(TFIB(fibEntry), conn_id); + if (oldTimer) + parcEventTimer_Stop(oldTimer); + mapmeTFIB_Remove(TFIB(fibEntry), conn_id); + } + + numberSet_Release(&conns); + } + + // NOTE // - at producer, send always true, we always send something reliably so we // set the timer. // - in the network, we always forward an IU, and never an IN - if (is_first || send) { + //if (is_producer || send) { + if (send) { mapme_params_t params = { .protocol = IPPROTO_IPV6, - .type = is_first ? mapme_getTypeFromHeuristic(mapme, fibEntry) : UPDATE, + .type = is_producer ? mapme_getTypeFromHeuristic(mapme, fibEntry) : UPDATE, .seq = TFIB(fibEntry)->seq}; Message *special_interest = mapme_createMessage(mapme, name, ¶ms); if (!special_interest) { @@ -378,7 +411,7 @@ static bool mapme_setFacePending(const MapMe *mapme, const Name *name, args->fibEntry = fibEntry; args->conn_id = conn_id; args->send = send; - args->is_first = is_first; + args->is_producer = is_producer; args->num_retx = num_retx + 1; timer = dispatcher_CreateTimer(dispatcher, TIMER_NO_REPEAT, @@ -440,59 +473,103 @@ static bool mapme_hasLocalNextHops(const MapMe *mapme, return false; } +void +mapme_reconsiderFibEntry(const MapMe *mapme, FibEntry * fibEntry) +{ + /* + * Skip entries that do not correspond to a producer ( / have a locally + * served prefix / have no local connection as next hop) + */ + if (!mapme_hasLocalNextHops(mapme, fibEntry)) + return; + + /* Apply the policy of the fibEntry over all neighbours */ + NumberSet * available_nexthops = fibEntry_GetAvailableNextHops(fibEntry, ~0); + NumberSet * previous_nexthops = fibEntry_GetPreviousNextHops(fibEntry); + + /* Detect change */ + if (numberSet_Equals(available_nexthops, previous_nexthops)) { + numberSet_Release(&available_nexthops); + INFO(mapme, "[MAP-Me] No change in nexthops"); + return; + } + fibEntry_SetPreviousNextHops(fibEntry, available_nexthops); + + + /* Advertise prefix on all available next hops */ + if (!TFIB(fibEntry)) /* Create TFIB associated to FIB entry */ + mapme_CreateTFIB(fibEntry); + TFIB(fibEntry)->seq++; + + const Name *name = fibEntry_GetPrefix(fibEntry); + char *name_str = name_ToString(name); + bool clear_tfib = true; + for (size_t j = 0; j < numberSet_Length(available_nexthops); j++) { + unsigned nexthop_id = numberSet_GetItem(available_nexthops, j); + INFO(mapme, "[MAP-Me] sending IU/IN for name %s on connection %d", name_str, + nexthop_id); + mapme_setFacePending(mapme, name, fibEntry, nexthop_id, true, true, clear_tfib, 0); + clear_tfib = false; + } + free(name_str); + + numberSet_Release(&available_nexthops); +} + /* * Callback called everytime a new connection is created by the control protocol */ -void mapme_onConnectionEvent(const MapMe *mapme, const Connection *conn_added, connection_event_t event) { - switch(event) { - case CONNECTION_EVENT_CREATE: - case CONNECTION_EVENT_SET_UP: - { - FibEntryList *fiblist; - - /* Ignore local connections corresponding to applications for now */ - if (connection_IsLocal(conn_added)) - return; - - unsigned conn_added_id = connection_GetConnectionId(conn_added); - INFO(mapme, "[MAP-Me] New connection %d", conn_added_id); - - /* - * Iterate on FIB to find locally served prefix - * Ideally, we want to avoid a FIB scan everytime a face is added/removed - */ - fiblist = forwarder_GetFibEntries(mapme->forwarder); - for (size_t i = 0; i < fibEntryList_Length(fiblist); i++) { - FibEntry *fibEntry = (FibEntry *)fibEntryList_Get(fiblist, i); - const Name *name = fibEntry_GetPrefix(fibEntry); - - /* Skip entries that have no local connection as next hop */ - if (!mapme_hasLocalNextHops(mapme, fibEntry)) - continue; - - /* This entry corresponds to a locally served prefix, set - * Special Interest */ - if (!TFIB(fibEntry)) /* Create TFIB associated to FIB entry */ - mapme_CreateTFIB(fibEntry); - TFIB(fibEntry)->seq++; - - char *name_str = name_ToString(name); - INFO(mapme, "[MAP-Me] sending IU/IN for name %s on connection %d", name_str, - conn_added_id); - free(name_str); - - mapme_setFacePending(mapme, name, fibEntry, conn_added_id, true, true, 0); - } - break; +void +mapme_onConnectionEvent(const MapMe *mapme, const Connection *conn_added, connection_event_t event) { + /* Does the priority change impacts the default route selection; if so, + * advertise the prefix on this default route. If there are many default + * routes, either v4 v6, or many connections as next hops on this default + * route, then send to all. + */ + if (conn_added) { + if (connection_IsLocal(conn_added)) + return; + + unsigned conn_added_id = connection_GetConnectionId(conn_added); + switch(event) { + case CONNECTION_EVENT_CREATE: + INFO(mapme, "[MAP-Me] Connection %d got created", conn_added_id); + break; + case CONNECTION_EVENT_DELETE: + INFO(mapme, "[MAP-Me] Connection %d got deleted", conn_added_id); + break; + case CONNECTION_EVENT_UPDATE: + INFO(mapme, "[MAP-Me] Connection %d got updated", conn_added_id); + break; + case CONNECTION_EVENT_SET_UP: + INFO(mapme, "[MAP-Me] Connection %d went up", conn_added_id); + break; + case CONNECTION_EVENT_SET_DOWN: + INFO(mapme, "[MAP-Me] Connection %d went down", conn_added_id); + break; + case CONNECTION_EVENT_TAGS_CHANGED: + INFO(mapme, "[MAP-Me] Connection %d changed tags", conn_added_id); + break; + case CONNECTION_EVENT_PRIORITY_CHANGED: + INFO(mapme, "[MAP-Me] Connection %d changed priority to %d", + conn_added_id, connection_GetPriority(conn_added)); + break; } - case CONNECTION_EVENT_DELETE: - case CONNECTION_EVENT_SET_DOWN: - case CONNECTION_EVENT_UPDATE: - case CONNECTION_EVENT_PRIORITY_CHANGED: - break; } + + /* We need to send a MapMe update on the newly selected connections for + * each concerned fibEntry : connection is involved, or no more involved */ + FibEntryList *fiblist = forwarder_GetFibEntries(mapme->forwarder); + + /* Iterate a first time on the FIB to get the locally served prefixes */ + for (size_t i = 0; i < fibEntryList_Length(fiblist); i++) { + FibEntry *fibEntry = (FibEntry *)fibEntryList_Get(fiblist, i); + mapme_reconsiderFibEntry(mapme, fibEntry); + } + INFO(mapme, "[MAP-Me] Done"); } +#if 0 #ifdef WITH_POLICY void mapme_onPolicyUpdate(const MapMe *mapme, const Connection *conn_selected, FibEntry * fibEntry) { @@ -520,9 +597,10 @@ void mapme_onPolicyUpdate(const MapMe *mapme, const Connection *conn_selected, F conn_selected_id); free(name_str); - mapme_setFacePending(mapme, name, fibEntry, conn_selected_id, true, true, 0); + mapme_setFacePending(mapme, name, fibEntry, conn_selected_id, true, true, true, 0); } #endif /* WITH_POLICY */ +#endif /*------------------------------------------------------------------------------ * Special Interest handling @@ -615,6 +693,19 @@ static bool mapme_onSpecialInterest(const MapMe *mapme, mapme_CreateTFIB(fibEntry); } + /* + * In case of multihoming, we might receive a message about our own prefix, we + * should never take it into account, nor send the IU backwards as a sign of + * outdated propagation. + * + * Detection: we receive a message initially sent by ourselves, ie a message + * for which the prefix has a local next hop in the FIB. + */ + if (mapme_hasLocalNextHops(mapme, fibEntry)) { + INFO(mapme, "[MAP-Me] - Received original interest... Update complete"); + return true; + } + fibSeq = TFIB(fibEntry)->seq; if (seq > fibSeq) { INFO(mapme, @@ -634,7 +725,7 @@ static bool mapme_onSpecialInterest(const MapMe *mapme, INFO(mapme, "[MAP-Me] - Re-sending IU to pending connection %d", conn_id); mapme_setFacePending(mapme, fibEntry_GetPrefix(fibEntry), fibEntry, - conn_id, false, false, 0); + conn_id, false, false, false, 0); } parcIterator_Release(&iterator); } @@ -675,8 +766,8 @@ static bool mapme_onSpecialInterest(const MapMe *mapme, */ INFO(mapme, "[MAP-Me] - Canceled pending timer"); parcEventTimer_Stop(oldTimer); - mapmeTFIB_Remove(TFIB(fibEntry), conn_in_id); } + mapmeTFIB_Remove(TFIB(fibEntry), conn_in_id); /* Remove all next hops */ for (size_t k = 0; k < numberSet_Length(nexthops_old); k++) { @@ -699,7 +790,7 @@ static bool mapme_onSpecialInterest(const MapMe *mapme, INFO(mapme, "[MAP-Me] - Sending IU on current next hop connection %d", conn_id); mapme_setFacePending(mapme, fibEntry_GetPrefix(fibEntry), fibEntry, - conn_id, send, false, 0); + conn_id, send, false, false, 0); complete = false; } @@ -722,10 +813,12 @@ static bool mapme_onSpecialInterest(const MapMe *mapme, * producer and that we received back our own IU. In that case, we just * need to Ack and ignore it. */ +#if 0 if (mapme_hasLocalNextHops(mapme, fibEntry)) { INFO(mapme, "[MAP-Me] - Received original interest... Update complete"); return true; } +#endif INFO(mapme, "[MAP-Me] - Adding multipath next hop on connection %d", conn_in_id); @@ -743,7 +836,7 @@ static bool mapme_onSpecialInterest(const MapMe *mapme, "[MAP-Me] - Update interest %d -> %d sent backwards on connection %d", seq, fibSeq, conn_in_id); mapme_setFacePending(mapme, fibEntry_GetPrefix(fibEntry), fibEntry, - conn_in_id, send, false, 0); + conn_in_id, send, false, false, 0); } return true; @@ -781,6 +874,14 @@ void mapme_onSpecialInterestAck(const MapMe *mapme, const uint8_t *msgBuffer, seq_t fibSeq = TFIB(fibEntry)->seq; if (seq < fibSeq) { + + /* If we receive an old ack: + * - either the connection is still a next hop and we have to ignore + * the ack until we receive a further update with higher seqno + * - or the connection is no more to be informed and the ack is + * sufficient and we can remove future retransmissions + */ + INFO(mapme, "[MAP-Me] - Ignored special interest Ack with seq=%u, expected %u", seq, fibSeq); diff --git a/hicn-light/src/hicn/core/mapme.h b/hicn-light/src/hicn/core/mapme.h index 5888ccd21..81977ab2e 100644 --- a/hicn-light/src/hicn/core/mapme.h +++ b/hicn-light/src/hicn/core/mapme.h @@ -69,6 +69,14 @@ void mapme_Process(const MapMe *mapme, const uint8_t *msgBuffer, unsigned conn_id); /** + * @function mapme_reconsiderFibEntry + * @abstract Process a fib entry for changes that might trigger new updates + * @param [in] mapme - Pointer to the MAP-Me data structure. + * @param [in] fibEntry - The FIB entry to consider + */ +void mapme_reconsiderFibEntry(const MapMe *mapme, FibEntry * fibEntry); + +/** * @function mapme_onConnectionEvent * @abstract Callback following the addition of the face though the control * protocol. @@ -79,14 +87,6 @@ void mapme_Process(const MapMe *mapme, const uint8_t *msgBuffer, */ void mapme_onConnectionEvent(const MapMe *mapme, const Connection *conn, connection_event_t event); -#ifdef WITH_POLICY - -/** - * @function mapme_onPolicyUpdate - */ -void mapme_onPolicyUpdate(const MapMe *mapme, const Connection *conn_added, FibEntry * fibEntry); -#endif /* WITH_POLICY */ - /** * @function mapme_getNextHops * @abstract return the nexthops to forward interests defined by mapme, it diff --git a/hicn-light/src/hicn/core/name.c b/hicn-light/src/hicn/core/name.c index 76efa6a8e..805e7bfae 100644 --- a/hicn-light/src/hicn/core/name.c +++ b/hicn-light/src/hicn/core/name.c @@ -256,4 +256,8 @@ void name_setLen(Name *name, uint8_t len) { uint32_t name_GetSuffix(const Name * name) { return name->segment; } + +uint8_t name_GetLen(const Name * name) { + return nameBitvector_GetLength(name->content_name); +} #endif /* WITH_POLICY */ diff --git a/hicn-light/src/hicn/core/name.h b/hicn-light/src/hicn/core/name.h index 29c8439f8..db9438150 100644 --- a/hicn-light/src/hicn/core/name.h +++ b/hicn-light/src/hicn/core/name.h @@ -98,6 +98,7 @@ Name *name_CreateFromAddress(address_type addressType, ip_address_t addr, #ifdef WITH_POLICY uint32_t name_GetSuffix(const Name * name); +uint8_t name_GetLen(const Name * name); #endif /* WITH_POLICY */ #endif // name_h diff --git a/hicn-light/src/hicn/processor/fibEntry.c b/hicn-light/src/hicn/processor/fibEntry.c index 11a572c88..46917a9d2 100644 --- a/hicn-light/src/hicn/processor/fibEntry.c +++ b/hicn-light/src/hicn/processor/fibEntry.c @@ -61,10 +61,10 @@ struct fib_entry { // NumberSet *available_nexthops; #ifdef WITH_MAPME /* In case of no multipath, this stores the previous decision taken by policy */ - unsigned previous_nexthop; #endif /* WITH_MAPME */ #endif /* WITH_POLICY */ #ifdef WITH_MAPME + NumberSet * previous_nexthops; void *userData; void (*userDataRelease)(void **userData); #endif /* WITH_MAPME */ @@ -122,9 +122,6 @@ FibEntry *fibEntry_Create(Name *name, strategy_type fwdStrategy) { fibEntry->forwarder = forwarder; fibEntry->policy = POLICY_NONE; fibEntry->policy_counters = POLICY_COUNTERS_NONE; -#ifdef WITH_MAPME - fibEntry->previous_nexthop = ~0; -#endif /* WITH_MAPME */ #endif /* WITH_POLICY */ return fibEntry; @@ -223,12 +220,12 @@ fibEntry_GetAvailableNextHops(const FibEntry *fibEntry, unsigned in_connection) ConnectionList * list = connectionTable_GetEntries(table); for (size_t i = 0; i < connectionList_Length(list); i++) { Connection *conn = connectionList_Get(list, i); + if (connection_IsLocal(conn)) + continue; if (connection_GetAdminState(conn) == CONNECTION_STATE_DOWN) continue; if (connection_GetState(conn) == CONNECTION_STATE_DOWN) continue; - if (connection_IsLocal(conn)) - continue; numberSet_Add(nexthops, connection_GetConnectionId(conn)); } connectionList_Destroy(&list); @@ -445,46 +442,57 @@ fibEntry_GetAvailableNextHops(const FibEntry *fibEntry, unsigned in_connection) numberSet_Release(&filtered_nexthops); } - return available_nexthops; -} + /* Priority */ + NumberSet * priority_nexthops = numberSet_Create(); -policy_t fibEntry_GetPolicy(const FibEntry *fibEntry) { - return fibEntry->policy; -} - -void fibEntry_ReconsiderPolicy(FibEntry *fibEntry) { -#ifdef WITH_MAPME - NumberSet * available_nexthops = fibEntry_GetAvailableNextHops(fibEntry, ~0); - - if (numberSet_Length(available_nexthops) == 0) - goto END; - - /* Multipath */ - if ((fibEntry->policy.tags[POLICY_TAG_MULTIPATH].state != POLICY_STATE_PROHIBIT) && - (fibEntry->policy.tags[POLICY_TAG_MULTIPATH].state != POLICY_STATE_AVOID)) - goto END; - - unsigned nexthop = numberSet_GetItem(available_nexthops, 0); - if (nexthop != fibEntry->previous_nexthop) { - /* Policy has elected a new nexthop, signal it using MAP-Me */ - fibEntry->previous_nexthop = nexthop; - ConnectionTable * table = forwarder_GetConnectionTable(fibEntry->forwarder); - const Connection * conn = connectionTable_FindById(table, nexthop); - mapme_onPolicyUpdate(forwarder_getMapmeInstance(fibEntry->forwarder), conn, fibEntry); + uint32_t max_priority = 0; + for (size_t k = 0; k < numberSet_Length(available_nexthops); k++) { + unsigned conn_id = numberSet_GetItem(available_nexthops, k); + const Connection * conn = connectionTable_FindById(table, conn_id); + uint32_t priority = connection_GetPriority(conn); + if (priority < max_priority) { + continue; + } else if (priority == max_priority) { + numberSet_Add(priority_nexthops, conn_id); + } else { /* priority > max_priority */ + numberSet_Release(&priority_nexthops); + priority_nexthops = numberSet_Create(); + numberSet_Add(priority_nexthops, conn_id); + max_priority = priority; + } } -END: numberSet_Release(&available_nexthops); -#endif /* WITH_MAPME */ + + return priority_nexthops; +} + +policy_t fibEntry_GetPolicy(const FibEntry *fibEntry) { + return fibEntry->policy; } void fibEntry_SetPolicy(FibEntry *fibEntry, policy_t policy) { fibEntry->policy = policy; - fibEntry_ReconsiderPolicy(fibEntry); + mapme_reconsiderFibEntry(forwarder_getMapmeInstance(fibEntry->forwarder), fibEntry); } +NumberSet * +fibEntry_GetPreviousNextHops(const FibEntry *fibEntry) +{ + return fibEntry->previous_nexthops; +} #endif /* WITH_POLICY */ +void +fibEntry_SetPreviousNextHops(FibEntry *fibEntry, NumberSet * nexthops) +{ + if (fibEntry->previous_nexthops) + numberSet_Release(&fibEntry->previous_nexthops); + fibEntry->previous_nexthops = numberSet_Create(); + numberSet_AddSet(fibEntry->previous_nexthops, nexthops); +} + + void fibEntry_AddNexthop(FibEntry *fibEntry, unsigned connectionId) { parcAssertNotNull(fibEntry, "Parameter fibEntry must be non-null"); #ifdef WITH_POLICY @@ -576,39 +584,16 @@ const NumberSet *fibEntry_GetNexthopsFromForwardingStrategy( if (numberSet_Length(available_nexthops) == 0) { out = numberSet_Create(); } else { - - /* Priority */ - NumberSet * priority_nexthops = numberSet_Create(); - - uint32_t max_priority = 0; - for (size_t k = 0; k < numberSet_Length(available_nexthops); k++) { - unsigned conn_id = numberSet_GetItem(available_nexthops, k); - const Connection * conn = connectionTable_FindById(table, conn_id); - uint32_t priority = connection_GetPriority(conn); - if (priority < max_priority) { - continue; - } else if (priority == max_priority) { - numberSet_Add(priority_nexthops, conn_id); - } else { /* priority > max_priority */ - numberSet_Release(&priority_nexthops); - priority_nexthops = numberSet_Create(); - numberSet_Add(priority_nexthops, conn_id); - max_priority = priority; - } - } - /* Multipath */ if ((policy.tags[POLICY_TAG_MULTIPATH].state != POLICY_STATE_PROHIBIT) && (policy.tags[POLICY_TAG_MULTIPATH].state != POLICY_STATE_AVOID)) { - out = fibEntry->fwdStrategy->lookupNexthop(fibEntry->fwdStrategy, priority_nexthops, + out = fibEntry->fwdStrategy->lookupNexthop(fibEntry->fwdStrategy, available_nexthops, interestMessage); } else { - unsigned nexthop = numberSet_GetItem(priority_nexthops, 0); + unsigned nexthop = numberSet_GetItem(available_nexthops, 0); out = numberSet_Create(); numberSet_Add(out, nexthop); } - - numberSet_Release(&priority_nexthops); } numberSet_Release(&available_nexthops); diff --git a/hicn-light/src/hicn/processor/fibEntry.h b/hicn-light/src/hicn/processor/fibEntry.h index 11a00e836..7ec771b4c 100644 --- a/hicn-light/src/hicn/processor/fibEntry.h +++ b/hicn-light/src/hicn/processor/fibEntry.h @@ -81,16 +81,6 @@ FibEntry *fibEntry_Acquire(const FibEntry *fibEntry); void fibEntry_SetStrategy(FibEntry *fibEntry, strategy_type strategy); -#ifdef WITH_POLICY - -policy_t fibEntry_GetPolicy(const FibEntry *fibEntry); - -void fibEntry_ReconsiderPolicy(FibEntry *fibEntry); - -void fibEntry_SetPolicy(FibEntry *fibEntry, policy_t policy); - -#endif /* WITH_POLICY */ - void fibEntry_AddNexthop(FibEntry *fibEntry, unsigned connectionId); void fibEntry_RemoveNexthopByConnectionId(FibEntry *fibEntry, @@ -123,14 +113,30 @@ void fibEntry_ReceiveObjectMessage(const FibEntry *fibEntry, const Message *objectMessage, Ticks rtt); #ifdef WITH_POLICY +policy_t fibEntry_GetPolicy(const FibEntry *fibEntry); +void fibEntry_ReconsiderPolicy(FibEntry *fibEntry); +void fibEntry_SetPolicy(FibEntry *fibEntry, policy_t policy); +void fibEntry_UpdateStats(FibEntry *fibEntry, uint64_t now); +NumberSet * fibEntry_GetAvailableNextHops(const FibEntry *fibEntry, unsigned in_connection); +NumberSet * fibEntry_GetPreviousNextHops(const FibEntry *fibEntry); +void fibEntry_SetPreviousNextHops(FibEntry *fibEntry, NumberSet * nexthops); + void fibEntry_OnTimeout(FibEntry *fibEntry, const NumberSet *egressId); +const NumberSet *fibEntry_GetNexthopsFromForwardingStrategy( + FibEntry *fibEntry, const Message *interestMessage, bool is_retransmission); + +void fibEntry_ReceiveObjectMessage(FibEntry *fibEntry, + const NumberSet *egressId, + const Message *objectMessage, Ticks rtt); #else void fibEntry_OnTimeout(const FibEntry *fibEntry, const NumberSet *egressId); +const NumberSet *fibEntry_GetNexthopsFromForwardingStrategy( + const FibEntry *fibEntry, const Message *interestMessage); +void fibEntry_ReceiveObjectMessage(const FibEntry *fibEntry, + const NumberSet *egressId, + const Message *objectMessage, Ticks rtt); #endif /* WITH_POLICY */ -#ifdef WITH_POLICY -void fibEntry_UpdateStats(FibEntry *fibEntry, uint64_t now); -#endif /* WITH_POLICY */ strategy_type fibEntry_GetFwdStrategyType(const FibEntry *fibEntry); diff --git a/hicn-light/src/hicn/processor/messageProcessor.c b/hicn-light/src/hicn/processor/messageProcessor.c index 58220ac9c..ad9a4e6ac 100644 --- a/hicn-light/src/hicn/processor/messageProcessor.c +++ b/hicn-light/src/hicn/processor/messageProcessor.c @@ -393,21 +393,6 @@ bool messageProcessor_RemovePolicy(MessageProcessor *processor, return true; } - -#ifdef WITH_MAPME -void messageProcessor_onConnectionEvent(const MessageProcessor *processor, - const Connection *conn_added, connection_event_t event) -{ - FibEntryList *fiblist = forwarder_GetFibEntries(processor->forwarder); - for (size_t i = 0; i < fibEntryList_Length(fiblist); i++) { - FibEntry *fibEntry = (FibEntry *)fibEntryList_Get(fiblist, i); - fibEntry_ReconsiderPolicy(fibEntry); - } - fibEntryList_Destroy(&fiblist); - -} -#endif /* WITH_MAPME */ - #endif /* WITH_POLICY */ void messageProcessor_RemoveConnectionIdFromRoutes(MessageProcessor *processor, diff --git a/hicn-light/src/hicn/processor/messageProcessor.h b/hicn-light/src/hicn/processor/messageProcessor.h index 6804ba018..80cd22035 100644 --- a/hicn-light/src/hicn/processor/messageProcessor.h +++ b/hicn-light/src/hicn/processor/messageProcessor.h @@ -136,11 +136,6 @@ bool messageProcessor_AddOrUpdatePolicy(MessageProcessor *processor, bool messageProcessor_RemovePolicy(MessageProcessor *processor, remove_policy_command *control); -#ifdef WITH_MAPME -void messageProcessor_onConnectionEvent(const MessageProcessor *processor, - const Connection *conn_added, connection_event_t event); -#endif /* WITH_MAPME */ - #endif /* WITH_POLICY */ /** diff --git a/hicn-light/src/hicn/utils/commands.h b/hicn-light/src/hicn/utils/commands.h index c250216f0..bb566e688 100644 --- a/hicn-light/src/hicn/utils/commands.h +++ b/hicn-light/src/hicn/utils/commands.h @@ -76,6 +76,7 @@ typedef enum { REMOVE_POLICY, UPDATE_CONNECTION, CONNECTION_SET_PRIORITY, + CONNECTION_SET_TAGS, #endif /* WITH_POLICY */ LAST_COMMAND_VALUE } command_id; @@ -345,6 +346,11 @@ typedef struct { uint32_t priority; } connection_set_priority_command; +typedef struct { + char symbolicOrConnid[SYMBOLIC_NAME_LEN]; + policy_tags_t tags; +} connection_set_tags_command; + #endif /* WITH_POLICY */ //===== size of commands ====== @@ -403,6 +409,8 @@ static inline int payloadLengthDaemon(command_id id) { return sizeof(update_connection_command); case CONNECTION_SET_PRIORITY: return sizeof(connection_set_priority_command); + case CONNECTION_SET_TAGS: + return sizeof(connection_set_tags_command); #endif /* WITH_POLICY */ case LAST_COMMAND_VALUE: return 0; |