[Olsr-dev] [olsrd] [PATCH v3 1/1] gateway: fix lazy gateway selection

Ferry Huberts (spam-protected)
Tue Jul 17 14:26:04 CEST 2012


sorry, that should be v1, not v3

On 17-07-12 14:23, Ferry Huberts wrote:
> 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();
>     }
>   }
>

-- 
Ferry Huberts






More information about the Olsr-dev mailing list