aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-light
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2020-02-13 16:50:43 +0100
committerJordan Augé <jordan.auge+fdio@cisco.com>2020-02-13 16:57:03 +0100
commit1fb7b1be452111b9e26a100bc5dfdce266c30330 (patch)
treeee67c224ff4ca6f20919032ff1933b07f0b43707 /hicn-light
parentf9243a2bf823086404be1c41c7bcc1b27cfab7de (diff)
[HICN-518] new API in hicn-light to allow a producer to force MAP-Me messages to be resent
Change-Id: I2e17250c5e4f78341966507a4bf04d09b84bb9d0 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.c1
-rw-r--r--hicn-light/src/hicn/config/configuration.c57
-rw-r--r--hicn-light/src/hicn/core/mapme.c23
-rw-r--r--hicn-light/src/hicn/core/mapme.h12
-rw-r--r--hicn-light/src/hicn/strategies/lowLatency.c2
-rw-r--r--hicn-light/src/hicn/utils/commands.h9
6 files changed, 79 insertions, 25 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 f27eb3ba5..0a8e01f65 100644
--- a/hicn-light/src/hicn/command_line/controller/hicnLightControl_main.c
+++ b/hicn-light/src/hicn/command_line/controller/hicnLightControl_main.c
@@ -79,6 +79,7 @@ static int payloadLengthController[LAST_COMMAND_VALUE] = {
sizeof(mapme_activator_command),
sizeof(mapme_timing_command),
sizeof(mapme_timing_command),
+ sizeof(mapme_send_update_command),
sizeof(connection_set_admin_state_command),
#ifdef WITH_POLICY
sizeof(add_policy_command),
diff --git a/hicn-light/src/hicn/config/configuration.c b/hicn-light/src/hicn/config/configuration.c
index 509ad10ba..a5be84f32 100644
--- a/hicn-light/src/hicn/config/configuration.c
+++ b/hicn-light/src/hicn/config/configuration.c
@@ -1094,10 +1094,7 @@ struct iovec *configuration_MapMeEnable(Configuration *config,
parcMemory_Deallocate((void **)&result);
parcBufferComposer_Release(&composer);
- struct iovec *response =
- utils_CreateAck(header, control, sizeof(mapme_activator_command));
-
- return response;
+ return utils_CreateAck(header, control, sizeof(mapme_timing_command));
}
struct iovec *configuration_MapMeDiscovery(Configuration *config,
@@ -1118,10 +1115,7 @@ struct iovec *configuration_MapMeDiscovery(Configuration *config,
parcMemory_Deallocate((void **)&result);
parcBufferComposer_Release(&composer);
- struct iovec *response =
- utils_CreateAck(header, control, sizeof(mapme_activator_command));
-
- return response;
+ return utils_CreateAck(header, control, sizeof(mapme_timing_command));
}
struct iovec *configuration_MapMeTimescale(Configuration *config,
@@ -1141,10 +1135,7 @@ struct iovec *configuration_MapMeTimescale(Configuration *config,
parcMemory_Deallocate((void **)&result);
parcBufferComposer_Release(&composer);
- struct iovec *response =
- utils_CreateAck(header, control, sizeof(mapme_timing_command));
-
- return response;
+ return utils_CreateAck(header, control, sizeof(mapme_timing_command));
}
struct iovec *configuration_MapMeRetx(Configuration *config,
@@ -1164,12 +1155,44 @@ struct iovec *configuration_MapMeRetx(Configuration *config,
parcMemory_Deallocate((void **)&result);
parcBufferComposer_Release(&composer);
- struct iovec *response =
- utils_CreateAck(header, control, sizeof(mapme_timing_command));
+ return utils_CreateAck(header, control, sizeof(mapme_timing_command));
+}
- return response;
+struct iovec * configuration_MapMeSendUpdate(Configuration *config,
+ struct iovec *request, unsigned ingressId) {
+ header_control_message *header = request[0].iov_base;
+ mapme_send_update_command *control = request[1].iov_base;
+
+ FIB * fib = forwarder_getFib(config->forwarder);
+ if (!fib)
+ goto ERR;
+ Name *prefix = name_CreateFromAddress(control->addressType, control->address,
+ control->len);
+ if (!prefix)
+ goto ERR;
+ FibEntry *entry = fib_Contains(fib, prefix);
+ name_Release(&prefix);
+ if (!entry)
+ goto ERR;
+
+ const NumberSet * nexthops = fibEntry_GetNexthops(entry);
+ unsigned size = (unsigned) numberSet_Length(nexthops);
+
+ /* The command is accepted iif triggered by (one of) the producer of this prefix */
+ for (unsigned i = 0; i < size; i++) {
+ unsigned nhop = numberSet_GetItem(nexthops, i);
+ if (nhop == ingressId) {
+ MapMe * mapme = forwarder_getMapmeInstance(config->forwarder);
+ mapme_send_updates(mapme, entry, nexthops);
+ return utils_CreateAck(header, control, sizeof(mapme_timing_command));
+ }
+ }
+
+ERR:
+ return utils_CreateNack(header, control, sizeof(connection_set_admin_state_command));
}
+
struct iovec *configuration_ConnectionSetAdminState(Configuration *config,
struct iovec *request) {
header_control_message *header = request[0].iov_base;
@@ -1418,6 +1441,10 @@ struct iovec *configuration_DispatchCommand(Configuration *config,
response = configuration_MapMeRetx(config, control);
break;
+ case MAPME_SEND_UPDATE:
+ response = configuration_MapMeSendUpdate(config, control, ingressId);
+ break;
+
case CONNECTION_SET_ADMIN_STATE:
response = configuration_ConnectionSetAdminState(config, control);
break;
diff --git a/hicn-light/src/hicn/core/mapme.c b/hicn-light/src/hicn/core/mapme.c
index 93a01bb0d..a22d01ae7 100644
--- a/hicn-light/src/hicn/core/mapme.c
+++ b/hicn-light/src/hicn/core/mapme.c
@@ -482,14 +482,6 @@ static bool mapme_hasLocalNextHops(const MapMe *mapme,
void
mapme_send_updates(const MapMe * mapme, FibEntry * fibEntry, const NumberSet * nexthops)
{
- /* Detect change */
- NumberSet * previous_nexthops = fibEntry_GetPreviousNextHops(fibEntry);
- if (numberSet_Equals(nexthops, previous_nexthops)) {
- INFO(mapme, "[MAP-Me] No change in nexthops");
- return;
- }
- fibEntry_SetPreviousNextHops(fibEntry, nexthops);
-
if (!TFIB(fibEntry)) /* Create TFIB associated to FIB entry */
mapme_CreateTFIB(fibEntry);
TFIB(fibEntry)->seq++;
@@ -507,6 +499,21 @@ mapme_send_updates(const MapMe * mapme, FibEntry * fibEntry, const NumberSet * n
free(name_str);
}
+
+void
+mapme_maybe_send_updates(const MapMe * mapme, FibEntry * fibEntry, const NumberSet * nexthops)
+{
+ /* Detect change */
+ NumberSet * previous_nexthops = fibEntry_GetPreviousNextHops(fibEntry);
+ if (numberSet_Equals(nexthops, previous_nexthops)) {
+ INFO(mapme, "[MAP-Me] No change in nexthops");
+ return;
+ }
+ fibEntry_SetPreviousNextHops(fibEntry, nexthops);
+
+ mapme_send_updates(mapme, fibEntry, nexthops);
+}
+
void
mapme_reconsiderFibEntry(const MapMe *mapme, FibEntry * fibEntry)
{
diff --git a/hicn-light/src/hicn/core/mapme.h b/hicn-light/src/hicn/core/mapme.h
index 503b22568..72f8d536a 100644
--- a/hicn-light/src/hicn/core/mapme.h
+++ b/hicn-light/src/hicn/core/mapme.h
@@ -70,7 +70,7 @@ void mapme_Process(const MapMe *mapme, const uint8_t *msgBuffer,
/**
* @function mapme_send_updates
- * @abstract Trigger the update for specified FIB entry and nexthops
+ * @abstract Trigger (if needed) the update for specified FIB entry and nexthops
* @param [in] mapme - Pointer to the MAP-Me data structure.
* @param [in] fibEntry - The FIB entry to consider
* @param [in] nexthops - NumberSet holding the next hops on which to send the
@@ -79,6 +79,16 @@ void mapme_Process(const MapMe *mapme, const uint8_t *msgBuffer,
void mapme_send_updates(const MapMe * mapme, FibEntry * fibEntry, const NumberSet * nexthops);
/**
+ * @function mapme_send_updates
+ * @abstract Trigger the update for specified FIB entry and nexthops, only if needed
+ * @param [in] mapme - Pointer to the MAP-Me data structure.
+ * @param [in] fibEntry - The FIB entry to consider
+ * @param [in] nexthops - NumberSet holding the next hops on which to send the
+ * update.
+ */
+void mapme_maybe_send_updates(const MapMe * mapme, FibEntry * fibEntry, const NumberSet * nexthops);
+
+/**
* @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.
diff --git a/hicn-light/src/hicn/strategies/lowLatency.c b/hicn-light/src/hicn/strategies/lowLatency.c
index 47de73538..61bffe243 100644
--- a/hicn-light/src/hicn/strategies/lowLatency.c
+++ b/hicn-light/src/hicn/strategies/lowLatency.c
@@ -192,7 +192,7 @@ static void strategyLowLatency_SendMapmeUpdate(StrategyLowLatency *ll,
for(unsigned i = 0; i < ll->related_prefixes_len; i++){
FibEntry *fibEntry = fib_MatchName(fib, ll->related_prefixes[i]);
if(fibEntry != NULL){
- mapme_send_updates(mapme, fibEntry, nexthops);
+ mapme_maybe_send_updates(mapme, fibEntry, nexthops);
}
}
}
diff --git a/hicn-light/src/hicn/utils/commands.h b/hicn-light/src/hicn/utils/commands.h
index 1cce8edd3..d8e5329b3 100644
--- a/hicn-light/src/hicn/utils/commands.h
+++ b/hicn-light/src/hicn/utils/commands.h
@@ -70,6 +70,7 @@ typedef enum {
MAPME_DISCOVERY,
MAPME_TIMESCALE,
MAPME_RETX,
+ MAPME_SEND_UPDATE,
CONNECTION_SET_ADMIN_STATE,
#ifdef WITH_POLICY
ADD_POLICY,
@@ -308,6 +309,12 @@ typedef struct {
uint32_t timePeriod;
} mapme_timing_command;
+typedef struct {
+ ip_address_t address;
+ uint8_t addressType;
+ uint8_t len;
+} mapme_send_update_command;
+
// SIZE=1
typedef struct {
@@ -400,6 +407,8 @@ static inline int payloadLengthDaemon(command_id id) {
return sizeof(mapme_timing_command);
case MAPME_RETX:
return sizeof(mapme_timing_command);
+ case MAPME_SEND_UPDATE:
+ return sizeof(mapme_send_update_command);
case CONNECTION_SET_ADMIN_STATE:
return sizeof(connection_set_admin_state_command);
#ifdef WITH_POLICY