[Olsr-dev] [olsrd] [PATCH v3 1/1] gateway: fix lazy gateway selection
Ferry Huberts
(spam-protected)
Tue Jul 17 14:23:15 CEST 2012
From: Ferry Huberts <(spam-protected)>
Only an increase in the number of gateway nodes was seen as a network
in flux. A decrease in the number of gateway nodes was not taken into
account.
Signed-off-by: Ferry Huberts <(spam-protected)>
---
src/gateway_default_handler.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/gateway_default_handler.c b/src/gateway_default_handler.c
index 9db8293..ef68935 100644
--- a/src/gateway_default_handler.c
+++ b/src/gateway_default_handler.c
@@ -90,21 +90,30 @@ static void gw_default_choose_gateway(void) {
}
}
-/* timer for lazy gateway selection */
+/**
+ * Timer callback for lazy gateway selection
+ *
+ * @param unused unused
+ */
static void gw_default_timer(void *unused __attribute__ ((unused))) {
- /* accept a 10% increase without trigger a stablecount reset */
- if (tc_tree.count * 10 <= gw_def_nodecount * 11) {
+ /* accept a 10% increase/decrease in the number of gateway nodes without triggering a stablecount reset */
+ if (((tc_tree.count * 10) <= (gw_def_nodecount * 11)) ||
+ ((tc_tree.count * 10) >= (gw_def_nodecount * 9))) {
gw_def_nodecount = tc_tree.count;
}
- if (tc_tree.count <= gw_def_nodecount) {
+
+ if (tc_tree.count == gw_def_nodecount) {
+ /* the number of gateway nodes is 'stable' */
gw_def_stablecount++;
}
else {
+ /* there was a significant change in the number of gateway nodes */
gw_def_nodecount = tc_tree.count;
gw_def_stablecount = 0;
}
if (gw_def_stablecount >= olsr_cnf->smart_gw_stablecount) {
+ /* the number of gateway nodes is stable enough, so we should select a new gateway now */
gw_default_choose_gateway();
}
}
--
1.7.10.4
More information about the Olsr-dev
mailing list