summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Sardara <msardara@cisco.com>2020-02-13 20:47:19 +0000
committerGerrit Code Review <gerrit@fd.io>2020-02-13 20:47:19 +0000
commit2835305d247f23695bddf1a9068ee6f2f33bed70 (patch)
tree1ff9256acdaebdcb1d6d21993375accef18e7910
parent7ecd7bf20999042a13e88c2ac3c8b851d1db8da4 (diff)
parent1fb7b1be452111b9e26a100bc5dfdce266c30330 (diff)
Merge "[HICN-518] new API in hicn-light to allow a producer to force MAP-Me messages to be resent"
-rw-r--r--ctrl/libhicnctrl/includes/hicn/ctrl/commands.h16
-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
7 files changed, 94 insertions, 26 deletions
diff --git a/ctrl/libhicnctrl/includes/hicn/ctrl/commands.h b/ctrl/libhicnctrl/includes/hicn/ctrl/commands.h
index c55529894..d8e5329b3 100644
--- a/ctrl/libhicnctrl/includes/hicn/ctrl/commands.h
+++ b/ctrl/libhicnctrl/includes/hicn/ctrl/commands.h
@@ -37,6 +37,7 @@
#endif /* WITH_POLICY */
#define SYMBOLIC_NAME_LEN 16
+#define MAX_FWD_STRATEGY_RELATED_PREFIXES 10
typedef struct in6_addr ipv6_addr_t;
typedef uint32_t ipv4_addr_t;
@@ -69,6 +70,7 @@ typedef enum {
MAPME_DISCOVERY,
MAPME_TIMESCALE,
MAPME_RETX,
+ MAPME_SEND_UPDATE,
CONNECTION_SET_ADMIN_STATE,
#ifdef WITH_POLICY
ADD_POLICY,
@@ -251,9 +253,13 @@ typedef struct {
uint8_t strategyType;
uint8_t addressType;
uint8_t len;
+ uint8_t related_prefixes;
+ ip_address_t addresses[MAX_FWD_STRATEGY_RELATED_PREFIXES];
+ uint8_t lens[MAX_FWD_STRATEGY_RELATED_PREFIXES];
+ uint8_t addresses_type[MAX_FWD_STRATEGY_RELATED_PREFIXES];
} set_strategy_command;
-// SIZE=20
+// SIZE=208
//========== [11] SET WLDR ==========
@@ -303,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 {
@@ -395,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
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