diff options
author | Michele Papalini <micpapal@cisco.com> | 2020-01-21 16:48:00 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@fd.io> | 2020-01-21 16:48:00 +0000 |
commit | bf366088b56e7f2e793e7026d9c655e26fe4a67a (patch) | |
tree | 8ffbec1e68088a2c6b0441f9f4db340be2f4f264 /hicn-light/src/hicn/core/mapme.c | |
parent | 50bedb707155de675121a556a8b129280440cdf5 (diff) | |
parent | 67c757c4d22a9983d4a87a4ce2476d00c464fc72 (diff) |
Merge "[HICN-481] Add APIs to trigger MAP-Me updates"
Diffstat (limited to 'hicn-light/src/hicn/core/mapme.c')
-rw-r--r-- | hicn-light/src/hicn/core/mapme.c | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/hicn-light/src/hicn/core/mapme.c b/hicn-light/src/hicn/core/mapme.c index e426e7575..93a01bb0d 100644 --- a/hicn-light/src/hicn/core/mapme.c +++ b/hicn-light/src/hicn/core/mapme.c @@ -480,29 +480,16 @@ static bool mapme_hasLocalNextHops(const MapMe *mapme, } void -mapme_reconsiderFibEntry(const MapMe *mapme, FibEntry * fibEntry) +mapme_send_updates(const MapMe * mapme, FibEntry * fibEntry, const NumberSet * nexthops) { - /* - * 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); + NumberSet * previous_nexthops = fibEntry_GetPreviousNextHops(fibEntry); + if (numberSet_Equals(nexthops, previous_nexthops)) { INFO(mapme, "[MAP-Me] No change in nexthops"); return; } - fibEntry_SetPreviousNextHops(fibEntry, available_nexthops); - + fibEntry_SetPreviousNextHops(fibEntry, nexthops); - /* Advertise prefix on all available next hops */ if (!TFIB(fibEntry)) /* Create TFIB associated to FIB entry */ mapme_CreateTFIB(fibEntry); TFIB(fibEntry)->seq++; @@ -510,14 +497,31 @@ mapme_reconsiderFibEntry(const MapMe *mapme, FibEntry * fibEntry) 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); + for (size_t j = 0; j < numberSet_Length(nexthops); j++) { + unsigned nexthop_id = numberSet_GetItem(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); +} + +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); + + /* Advertise prefix on all available next hops (if needed) */ + mapme_send_updates(mapme, fibEntry, available_nexthops); numberSet_Release(&available_nexthops); } |