aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-light
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2019-08-23 07:05:36 +0000
committerGerrit Code Review <gerrit@fd.io>2019-08-23 07:05:36 +0000
commit3f709888ef31c008021f2e929a937a3d6b312c87 (patch)
treeb097dd27250417672022117a219560a8b984a32f /hicn-light
parent33eca8c68b581038f225fac7f75b398298341935 (diff)
parent707a14c46b1a5ba66e1abf7f7a9f0aed16f67501 (diff)
Merge "HICN-266 fix strategy creation with policies"
Diffstat (limited to 'hicn-light')
-rw-r--r--hicn-light/src/hicn/processor/fibEntry.c48
-rw-r--r--hicn-light/src/hicn/processor/messageProcessor.c8
-rw-r--r--hicn-light/src/hicn/strategies/loadBalancerWithPD.c4
-rw-r--r--hicn-light/src/hicn/strategies/loadBalancerWithPD.h4
4 files changed, 9 insertions, 55 deletions
diff --git a/hicn-light/src/hicn/processor/fibEntry.c b/hicn-light/src/hicn/processor/fibEntry.c
index 15d754168..9d82b086e 100644
--- a/hicn-light/src/hicn/processor/fibEntry.c
+++ b/hicn-light/src/hicn/processor/fibEntry.c
@@ -72,7 +72,6 @@ struct fib_entry {
#ifdef WITH_POLICY
FibEntry *fibEntry_Create(Name *name, strategy_type fwdStrategy, const Forwarder * forwarder) {
- ConnectionTable * table = forwarder_GetConnectionTable(forwarder);
#else
FibEntry *fibEntry_Create(Name *name, strategy_type fwdStrategy) {
#endif /* WITH_POLICY */
@@ -84,47 +83,31 @@ FibEntry *fibEntry_Create(Name *name, strategy_type fwdStrategy) {
if (fwdStrategy) {
switch (fwdStrategy) {
case SET_STRATEGY_LOADBALANCER:
-#ifdef WITH_POLICY
- fibEntry->fwdStrategy = strategyLoadBalancer_Create(table);
-#else
fibEntry->fwdStrategy = strategyLoadBalancer_Create();
-#endif /* WITH_POLICY */
+ break;
+
+ case SET_STRATEGY_RANDOM:
+ fibEntry->fwdStrategy = strategyRnd_Create();
break;
case SET_STRATEGY_RANDOM_PER_DASH_SEGMENT:
-#ifdef WITH_POLICY
- fibEntry->fwdStrategy = strategyRndSegment_Create(table);
-#else
fibEntry->fwdStrategy = strategyRndSegment_Create();
-#endif /* WITH_POLICY */
break;
case SET_STRATEGY_LOADBALANCER_WITH_DELAY:
-#ifdef WITH_POLICY
- fibEntry->fwdStrategy = strategyLoadBalancerWithPD_Create(table);
-#else
fibEntry->fwdStrategy = strategyLoadBalancerWithPD_Create();
-#endif /* WITH_POLICY */
break;
default:
// LB is the default strategy
-#ifdef WITH_POLICY
- fibEntry->fwdStrategy = strategyLoadBalancer_Create(table);
-#else
fibEntry->fwdStrategy = strategyLoadBalancer_Create();
-#endif /* WITH_POLICY */
// the LB strategy is the default one
// other strategies can be set using the appropiate function
break;
}
} else {
-#ifdef WITH_POLICY
- fibEntry->fwdStrategy = strategyLoadBalancer_Create(table);
-#else
fibEntry->fwdStrategy = strategyLoadBalancer_Create();
-#endif /* WITH_POLICY */
}
fibEntry->refcount = 1;
@@ -173,42 +156,27 @@ void fibEntry_Release(FibEntry **fibEntryPtr) {
void fibEntry_SetStrategy(FibEntry *fibEntry, strategy_type strategy) {
StrategyImpl *fwdStrategyImpl;
-#ifdef WITH_POLICY
- ConnectionTable * table = forwarder_GetConnectionTable(fibEntry->forwarder);
-#endif /* WITH_POLICY */
switch (strategy) {
case SET_STRATEGY_LOADBALANCER:
-#ifdef WITH_POLICY
- fwdStrategyImpl = strategyLoadBalancer_Create(table);
-#else
fwdStrategyImpl = strategyLoadBalancer_Create();
-#endif /* WITH_POLICY */
+ break;
+
+ case SET_STRATEGY_RANDOM:
+ fwdStrategyImpl = strategyRnd_Create();
break;
case SET_STRATEGY_RANDOM_PER_DASH_SEGMENT:
-#ifdef WITH_POLICY
- fwdStrategyImpl = strategyRndSegment_Create(table);
-#else
fwdStrategyImpl = strategyRndSegment_Create();
-#endif /* WITH_POLICY */
break;
case SET_STRATEGY_LOADBALANCER_WITH_DELAY:
-#ifdef WITH_POLICY
- fwdStrategyImpl = strategyLoadBalancerWithPD_Create(table);
-#else
fwdStrategyImpl = strategyLoadBalancerWithPD_Create();
-#endif /* WITH_POLICY */
break;
default:
// LB is the defualt strategy
-#ifdef WITH_POLICY
- fwdStrategyImpl = strategyLoadBalancer_Create(table);
-#else
fwdStrategyImpl = strategyLoadBalancer_Create();
-#endif /* WITH_POLICY */
// the LB strategy is the default one
// other strategies can be set using the appropiate function
break;
diff --git a/hicn-light/src/hicn/processor/messageProcessor.c b/hicn-light/src/hicn/processor/messageProcessor.c
index 7e0ece257..420863e26 100644
--- a/hicn-light/src/hicn/processor/messageProcessor.c
+++ b/hicn-light/src/hicn/processor/messageProcessor.c
@@ -34,9 +34,7 @@
#include <hicn/content_store/contentStoreLRU.h>
#include <hicn/strategies/loadBalancer.h>
-#ifndef WITH_POLICY
#include <hicn/strategies/loadBalancerWithPD.h>
-#endif /* ! WITH_POLICY */
#include <hicn/strategies/rnd.h>
#include <hicn/strategies/rndSegment.h>
#include <hicn/strategies/strategyImpl.h>
@@ -311,16 +309,14 @@ bool messageProcessor_AddOrUpdateRoute(MessageProcessor *processor,
Name *prefix = name_CreateFromAddress(control->addressType, control->address,
control->len);
FibEntry *entry = fib_Contains(processor->fib, prefix);
-#ifndef WITH_POLICY
bool newEntry = false;
-#endif /* ! WITH_POLICY */
if (entry != NULL) {
fibEntry_AddNexthop(entry, ifidx);
} else {
+ newEntry = true;
#ifdef WITH_POLICY
entry = fibEntry_Create(prefix, fwdStrategy, processor->forwarder);
#else
- newEntry = true;
entry = fibEntry_Create(prefix, fwdStrategy);
#endif /* WITH_POLICY */
fibEntry_AddNexthop(entry, ifidx);
@@ -329,7 +325,6 @@ bool messageProcessor_AddOrUpdateRoute(MessageProcessor *processor,
name_Release(&prefix);
-#ifndef WITH_POLICY
/* For policy implementation, we need access to the ConnectionTable in all
* Forwarding Strategies, so it is setup during FIB Entry creation */
if (newEntry && (fwdStrategy == SET_STRATEGY_LOADBALANCER_WITH_DELAY)) {
@@ -337,7 +332,6 @@ bool messageProcessor_AddOrUpdateRoute(MessageProcessor *processor,
fibEntry_GetFwdStrategy(entry),
forwarder_GetConnectionTable(processor->forwarder));
}
-#endif /* ! WITH_POLICY */
return true;
}
diff --git a/hicn-light/src/hicn/strategies/loadBalancerWithPD.c b/hicn-light/src/hicn/strategies/loadBalancerWithPD.c
index b0aae4cbb..dac759053 100644
--- a/hicn-light/src/hicn/strategies/loadBalancerWithPD.c
+++ b/hicn-light/src/hicn/strategies/loadBalancerWithPD.c
@@ -88,11 +88,7 @@ struct strategy_load_balancer_with_pd {
unsigned int fwdPackets;
};
-#ifdef WITH_POLICY
-StrategyImpl *strategyLoadBalancerWithPD_Create(const ConnectionTable *table) {
-#else
StrategyImpl *strategyLoadBalancerWithPD_Create() {
-#endif /* WITH_POLICY */
StrategyLoadBalancerWithPD *strategy =
parcMemory_AllocateAndClear(sizeof(StrategyLoadBalancerWithPD));
parcAssertNotNull(strategy, "parcMemory_AllocateAndClear(%zu) returned NULL",
diff --git a/hicn-light/src/hicn/strategies/loadBalancerWithPD.h b/hicn-light/src/hicn/strategies/loadBalancerWithPD.h
index e6c9f8271..a6ad94ab8 100644
--- a/hicn-light/src/hicn/strategies/loadBalancerWithPD.h
+++ b/hicn-light/src/hicn/strategies/loadBalancerWithPD.h
@@ -24,11 +24,7 @@
#include <hicn/strategies/strategyImpl.h>
#include <hicn/core/connectionTable.h>
-#ifdef WITH_POLICY
-StrategyImpl *strategyLoadBalancerWithPD_Create(const ConnectionTable * table);
-#else
StrategyImpl *strategyLoadBalancerWithPD_Create();
-#endif /* WITH_POLICY */
void strategyLoadBalancerWithPD_SetConnectionTable(StrategyImpl *strategy,
ConnectionTable *connTable);