aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-light/src
diff options
context:
space:
mode:
authormichele papalini <micpapal@cisco.com>2019-10-10 13:44:10 +0200
committermichele papalini <micpapal@cisco.com>2019-10-10 13:44:10 +0200
commitd0c23b111015ed645272678bc229e1059337408f (patch)
treea60e55099d750c0dd92bef209299fec4215eef47 /hicn-light/src
parente3d49850d80d6f603180cd5bd5ca0bfc0730f54a (diff)
[HICN-315] memory leaks in hicn-light
Signed-off-by: michele papalini <micpapal@cisco.com> Change-Id: I43f64d616fbbbc2b10b4a181529d087fb0afc56c
Diffstat (limited to 'hicn-light/src')
-rw-r--r--hicn-light/src/hicn/processor/fib.c2
-rw-r--r--hicn-light/src/hicn/processor/fibEntry.c13
-rw-r--r--hicn-light/src/hicn/processor/messageProcessor.c3
-rw-r--r--hicn-light/src/hicn/strategies/loadBalancer.c11
4 files changed, 23 insertions, 6 deletions
diff --git a/hicn-light/src/hicn/processor/fib.c b/hicn-light/src/hicn/processor/fib.c
index 6489e59e2..6bb29c404 100644
--- a/hicn-light/src/hicn/processor/fib.c
+++ b/hicn-light/src/hicn/processor/fib.c
@@ -452,6 +452,8 @@ void fib_RemoveConnectionId(FIB *fib, unsigned connectionId) {
for (int i = 0; i < fibEntryList_Length(list); i++) {
_removeNode(fib, fibEntry_GetPrefix(fibEntryList_Get(list, i)));
}
+
+ fibEntryList_Destroy(&list);
}
size_t fib_Length(const FIB *fib) {
diff --git a/hicn-light/src/hicn/processor/fibEntry.c b/hicn-light/src/hicn/processor/fibEntry.c
index 04e453ab9..f12dd506b 100644
--- a/hicn-light/src/hicn/processor/fibEntry.c
+++ b/hicn-light/src/hicn/processor/fibEntry.c
@@ -201,6 +201,7 @@ NumberSet *
fibEntry_GetAvailableNextHops(const FibEntry *fibEntry, unsigned in_connection) {
ConnectionTable * table = forwarder_GetConnectionTable(fibEntry->forwarder);
NumberSet * nexthops;
+ bool dealloc_nexthops = false;
policy_t policy = fibEntry_GetPolicy(fibEntry);
/* Reset available next hops and start filtering */
@@ -214,6 +215,7 @@ fibEntry_GetAvailableNextHops(const FibEntry *fibEntry, unsigned in_connection)
if (in_connection == ~0) {
/* We might advertise among all available up connections */
nexthops = numberSet_Create();
+ dealloc_nexthops = true;
ConnectionList * list = connectionTable_GetEntries(table);
for (size_t i = 0; i < connectionList_Length(list); i++) {
@@ -226,7 +228,7 @@ fibEntry_GetAvailableNextHops(const FibEntry *fibEntry, unsigned in_connection)
continue;
numberSet_Add(nexthops, connection_GetConnectionId(conn));
}
-
+ connectionList_Destroy(&list);
} else {
nexthops = (NumberSet*)fibEntry_GetNexthops(fibEntry);
for (size_t k = 0; k < numberSet_Length(nexthops); k++) {
@@ -247,8 +249,12 @@ fibEntry_GetAvailableNextHops(const FibEntry *fibEntry, unsigned in_connection)
numberSet_Add(available_nexthops, conn_id);
}
- if (numberSet_Length(available_nexthops) > 0)
+ if (numberSet_Length(available_nexthops) > 0){
+ if(dealloc_nexthops){
+ numberSet_Release(&nexthops);
+ }
return available_nexthops;
+ }
}
for (size_t k = 0; k < numberSet_Length(nexthops); k++) {
@@ -297,6 +303,9 @@ fibEntry_GetAvailableNextHops(const FibEntry *fibEntry, unsigned in_connection)
numberSet_Add(available_nexthops, conn_id);
}
+ if(dealloc_nexthops)
+ numberSet_Release(&nexthops);
+
if (numberSet_Length(available_nexthops) == 0)
return available_nexthops;
diff --git a/hicn-light/src/hicn/processor/messageProcessor.c b/hicn-light/src/hicn/processor/messageProcessor.c
index 456618269..3ca9264b8 100644
--- a/hicn-light/src/hicn/processor/messageProcessor.c
+++ b/hicn-light/src/hicn/processor/messageProcessor.c
@@ -298,7 +298,7 @@ bool messageProcessor_AddOrUpdateRoute(MessageProcessor *processor,
unsigned ifidx) {
Configuration *config = forwarder_GetConfiguration(processor->forwarder);
- const char *prefixStr = utils_PrefixLenToString(
+ char *prefixStr = (char *) utils_PrefixLenToString(
control->addressType, &control->address, &control->len);
strategy_type fwdStrategy =
configuration_GetForwardingStrategy(config, prefixStr);
@@ -323,6 +323,7 @@ bool messageProcessor_AddOrUpdateRoute(MessageProcessor *processor,
fib_Add(processor->fib, entry);
}
+ free(prefixStr);
name_Release(&prefix);
/* For policy implementation, we need access to the ConnectionTable in all
diff --git a/hicn-light/src/hicn/strategies/loadBalancer.c b/hicn-light/src/hicn/strategies/loadBalancer.c
index b66de217e..ca9d34289 100644
--- a/hicn-light/src/hicn/strategies/loadBalancer.c
+++ b/hicn-light/src/hicn/strategies/loadBalancer.c
@@ -201,6 +201,7 @@ static NumberSet *_strategyLoadBalancer_LookupNexthop(
PARCUnsigned *cid = parcUnsigned_Create(numberSet_GetItem(nexthops, i));
const StrategyNexthopState *elem =
parcHashMap_Get(lb->strategy_state, cid);
+ parcUnsigned_Release(&cid);
if (!elem)
continue;
sum += strategyNexthopState_GetWeight(elem);
@@ -213,12 +214,15 @@ static NumberSet *_strategyLoadBalancer_LookupNexthop(
PARCUnsigned *cid = parcUnsigned_Create(numberSet_GetItem(nexthops, i));
const StrategyNexthopState *state =
parcHashMap_Get(lb->strategy_state, cid);
- if (!state)
- continue;
+ if (!state){
+ parcUnsigned_Release(&cid);
+ continue;
+ }
distance -= strategyNexthopState_GetWeight(state);
if (distance < 0) {
numberSet_Add(outList, parcUnsigned_GetUnsigned(cid));
_update_Stats(lb, (StrategyNexthopState *)state, true);
+ parcUnsigned_Release(&cid);
break;
}
}
@@ -296,19 +300,20 @@ static void _strategyLoadBalancer_resetState(StrategyImpl *strategy) {
static void _strategyLoadBalancer_AddNexthop(StrategyImpl *strategy,
unsigned connectionId) {
- StrategyNexthopState *state = strategyNexthopState_Create();
PARCUnsigned *cid = parcUnsigned_Create(connectionId);
StrategyLoadBalancer *lb = (StrategyLoadBalancer *)strategy->context;
if (!parcHashMap_Contains(lb->strategy_state, cid)) {
+ StrategyNexthopState *state = strategyNexthopState_Create();
parcHashMap_Put(lb->strategy_state, cid, state);
#ifndef WITH_POLICY
numberSet_Add(lb->nexthops, connectionId);
#endif /* WITH_POLICY */
_strategyLoadBalancer_resetState(strategy);
}
+ parcUnsigned_Release(&cid);
}
static void _strategyLoadBalancer_RemoveNexthop(StrategyImpl *strategy,