[openib-general] [PATCH] OpenSM/osm_trap_rcv.c: Reduce repeated trap messages so log doesn't fill so quickly

Yevgeny Kliteynik kliteyn at dev.mellanox.co.il
Wed Nov 22 23:45:41 PST 2006


Looks good, thanks.

-- Yevgeny

Hal Rosenstock wrote:
> OpenSM/osm_trap_rcv.c: Reduce repeated trap messages so log doesn't fill
> so quickly
> 
> Signed-off-by: Hal Rosenstock <halr at voltaire.com>
> 
> Index: opensm/osm_trap_rcv.c
> ===================================================================
> --- opensm/osm_trap_rcv.c	(revision 10137)
> +++ opensm/osm_trap_rcv.c	(working copy)
> @@ -34,7 +34,6 @@
>   * $Id$
>   */
>  
> -
>  /*
>   * Abstract:
>   *    Implementation of osm_trap_rcv_t.
> @@ -299,6 +298,27 @@ __osm_trap_get_key(
>  
>  /**********************************************************************
>   **********************************************************************/
> +static int
> +__print_num_received(
> +  IN uint32_t num_received )
> +{
> +  uint32_t i;
> +
> +  /* Series is 10, 20, 50, 100, 200, 500, ... */
> +  i = num_received;
> +  while (i >= 10) {
> +    if (i % 10)
> +      break;
> +    i = i / 10;
> +  }
> +  if (i == 1 || i == 2 || i == 5)
> +    return 1;
> +  else
> +    return 0;
> +}
> +
> +/**********************************************************************
> + **********************************************************************/
>  static void
>  __osm_trap_rcv_process_request(
>    IN osm_trap_rcv_t* const p_rcv,
> @@ -494,10 +514,11 @@ __osm_trap_rcv_process_request(
>      /* Now we know how many times it provided this trap */
>      if (num_received > 10)
>      {
> -      osm_log( p_rcv->p_log, OSM_LOG_ERROR,
> -               "__osm_trap_rcv_process_request: ERR 3804: "
> -               "Received trap %u times consecutively\n",
> -               num_received);
> +      if (__print_num_received(num_received))
> +        osm_log( p_rcv->p_log, OSM_LOG_ERROR,
> +                 "__osm_trap_rcv_process_request: ERR 3804: "
> +                 "Received trap %u times consecutively\n",
> +                 num_received);
>        /*
>         * If the trap provides info about a bad port
>         * we mark it as unhealthy.
> @@ -569,10 +590,11 @@ __osm_trap_rcv_process_request(
>      /* If was already registered do nothing more */
>      if ( num_received > 10 && run_heavy_sweep == FALSE )
>      {
> -      osm_log( p_rcv->p_log, OSM_LOG_VERBOSE,
> -               "__osm_trap_rcv_process_request: "
> -               "Continuously received this trap %u times. Ignoring it\n",
> -               num_received);
> +      if (__print_num_received(num_received))
> +        osm_log( p_rcv->p_log, OSM_LOG_VERBOSE,
> +                 "__osm_trap_rcv_process_request: "
> +                 "Continuously received this trap %u times. Ignoring it\n",
> +                 num_received);
>        goto Exit;
>      }
>    }
> 
> 
> 
> 
> _______________________________________________
> openib-general mailing list
> openib-general at openib.org
> http://openib.org/mailman/listinfo/openib-general
> 
> To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general
> 




More information about the general mailing list