[Olsr-dev] [PATCH v1 1/1] gateway: properly cleanup gateways on shutdown

Ferry Huberts (spam-protected)
Thu Oct 18 10:25:38 CEST 2012


Ignore this patch please, working on a new rev

On 17-10-12 15:57, Ferry Huberts wrote:
> From: Ferry Huberts <(spam-protected)>
>
> Signed-off-by: Ferry Huberts <(spam-protected)>
> ---
>   src/gateway.c | 18 +++++++++++++++---
>   src/gateway.h |  2 +-
>   src/hna_set.c |  2 +-
>   src/tc_set.c  |  2 +-
>   4 files changed, 18 insertions(+), 6 deletions(-)
>
> diff --git a/src/gateway.c b/src/gateway.c
> index 99c191f..8347f70 100644
> --- a/src/gateway.c
> +++ b/src/gateway.c
> @@ -181,6 +181,8 @@ int olsr_init_gateways(void) {
>    * Cleanup gateway tunnel system
>    */
>   void olsr_cleanup_gateways(void) {
> +  struct avl_node * avlnode = NULL;
> +
>     if (current_ipv4_gw) {
>       olsr_os_del_ipip_tunnel(v4gw_tunnel);
>     }
> @@ -190,6 +192,10 @@ void olsr_cleanup_gateways(void) {
>
>     olsr_remove_ifchange_handler(smartgw_tunnel_monitor);
>
> +  while ((avlnode = avl_walk_first(&gateway_tree))) {
> +    olsr_delete_gateway_entry(&(node2gateway(avlnode)->originator), FORCE_DELETE_GW_ENTRY, true);
> +  }
> +
>     assert(gw_handler);
>     gw_handler->cleanup();
>     gw_handler = NULL;
> @@ -384,8 +390,10 @@ void olsr_update_gateway_entry(union olsr_ip_addr *originator, union olsr_ip_add
>    *
>    * @param originator
>    * @param prefixlen
> + * @param immediate when set to true then the gateway is removed from the
> + * gateway tree immediately, else it is removed on a delayed schedule.
>    */
> -void olsr_delete_gateway_entry(union olsr_ip_addr *originator, uint8_t prefixlen) {
> +void olsr_delete_gateway_entry(union olsr_ip_addr *originator, uint8_t prefixlen, bool immediate) {
>     struct gateway_entry *gw = node2gateway(avl_find(&gateway_tree, originator));
>     bool change = false;
>
> @@ -431,8 +439,12 @@ void olsr_delete_gateway_entry(union olsr_ip_addr *originator, uint8_t prefixlen
>           v6gw_tunnel = NULL;
>         }
>
> -      /* remove gateway entry on a delayed schedule */
> -      olsr_set_timer(&gw->cleanup_timer, GW_CLEANUP_INTERVAL, 0, false, cleanup_gateway_handler, gw, NULL);
> +      if (!immediate) {
> +        /* remove gateway entry on a delayed schedule */
> +        olsr_set_timer(&gw->cleanup_timer, GW_CLEANUP_INTERVAL, 0, false, cleanup_gateway_handler, gw, NULL);
> +      } else {
> +        cleanup_gateway_handler(gw);
> +      }
>       } else if (change) {
>         assert(gw_handler);
>         gw_handler->update(gw);
> diff --git a/src/gateway.h b/src/gateway.h
> index 0ddaa6f..91e9170 100644
> --- a/src/gateway.h
> +++ b/src/gateway.h
> @@ -152,7 +152,7 @@ void refresh_smartgw_netmask(void);
>
>   bool olsr_is_smart_gateway(struct olsr_ip_prefix *prefix, union olsr_ip_addr *net);
>   void olsr_update_gateway_entry(union olsr_ip_addr *originator, union olsr_ip_addr *mask, int prefixlen, uint16_t seqno);
> -void olsr_delete_gateway_entry(union olsr_ip_addr *originator, uint8_t prefixlen);
> +void olsr_delete_gateway_entry(union olsr_ip_addr *originator, uint8_t prefixlen, bool immediate);
>   void olsr_trigger_gatewayloss_check(void);
>
>   /*
> diff --git a/src/hna_set.c b/src/hna_set.c
> index 33280fe..2ce3c7d 100644
> --- a/src/hna_set.c
> +++ b/src/hna_set.c
> @@ -216,7 +216,7 @@ olsr_delete_hna_net_entry(struct hna_net *net_to_delete) {
>   #ifdef __linux__
>     if (is_prefix_inetgw(&net_to_delete->hna_prefix)) {
>       /* modify smart gateway entry if necessary */
> -    olsr_delete_gateway_entry(&net_to_delete->hna_gw->A_gateway_addr, net_to_delete->hna_prefix.prefix_len);
> +    olsr_delete_gateway_entry(&net_to_delete->hna_gw->A_gateway_addr, net_to_delete->hna_prefix.prefix_len, false);
>     }
>   #endif /* __linux__ */
>
> diff --git a/src/tc_set.c b/src/tc_set.c
> index 1f9da04..d32ec39 100644
> --- a/src/tc_set.c
> +++ b/src/tc_set.c
> @@ -283,7 +283,7 @@ olsr_delete_tc_entry(struct tc_entry *tc)
>
>     /* delete gateway if available */
>   #ifdef __linux__
> -  olsr_delete_gateway_entry(&tc->addr, FORCE_DELETE_GW_ENTRY);
> +  olsr_delete_gateway_entry(&tc->addr, FORCE_DELETE_GW_ENTRY, false);
>   #endif /* __linux__ */
>     /*
>      * Delete the rt_path for ourselves.
>

-- 
Ferry Huberts




More information about the Olsr-dev mailing list