Lines Matching refs:damp
39 struct bgp_damp_config *damp = &bgp_damp_cfg;
54 i = (int)(((double) penalty / damp->reuse_limit - 1.0) * damp->scale_factor);
56 if ( i >= damp->reuse_index_size )
57 i = damp->reuse_index_size - 1;
59 index = damp->reuse_index[i] - damp->reuse_index[0];
61 return (damp->reuse_offset + index) % damp->reuse_list_size;
73 bdi->next = damp->reuse_list[index];
74 if (damp->reuse_list[index])
75 damp->reuse_list[index]->prev = bdi;
76 damp->reuse_list[index] = bdi;
88 damp->reuse_list[bdi->index] = bdi->next;
103 if (i >= damp->decay_array_size)
106 return (int) (penalty * damp->decay_array[i]);
120 damp->t_reuse = NULL;
121 damp->t_reuse =
132 bdi = damp->reuse_list[damp->reuse_offset];
133 damp->reuse_list[damp->reuse_offset] = NULL;
137 damp->reuse_offset = (damp->reuse_offset + 1) % damp->reuse_list_size;
154 if (bdi->penalty < damp->reuse_limit)
168 if (bdi->penalty <= damp->reuse_limit / 2.0)
171 BGP_DAMP_LIST_ADD (damp, bdi);
215 BGP_DAMP_LIST_ADD (damp, bdi);
226 if (bdi->penalty > damp->ceiling)
227 bdi->penalty = damp->ceiling;
252 if (bdi->penalty >= damp->suppress_value)
256 BGP_DAMP_LIST_DEL (damp, bdi);
282 && (bdi->penalty < damp->suppress_value))
285 && (bdi->penalty < damp->reuse_limit) )
289 BGP_DAMP_LIST_ADD (damp, bdi);
296 if (bdi->penalty > damp->reuse_limit / 2.0)
318 if (t_diff >= damp->max_suppress_time)
322 BGP_DAMP_LIST_ADD (damp, bdi);
323 bdi->penalty = damp->reuse_limit;
339 if (bdi->penalty <= damp->reuse_limit / 2.0)
367 BGP_DAMP_LIST_DEL (damp, bdi);
388 damp->suppress_value = sup;
389 damp->half_life = hlife;
390 damp->reuse_limit = reuse;
391 damp->max_suppress_time = maxsup;
394 damp->reuse_index_size = REUSE_ARRAY_SIZE;
396 damp->ceiling = (int)(damp->reuse_limit * (pow(2, (double)damp->max_suppress_time/damp->half_life)));
399 damp->decay_array_size = ceil ((double) damp->max_suppress_time / DELTA_T);
400 damp->decay_array = XMALLOC (MTYPE_BGP_DAMP_ARRAY,
401 sizeof(double) * (damp->decay_array_size));
402 damp->decay_array[0] = 1.0;
403 damp->decay_array[1] = exp ((1.0/((double)damp->half_life/DELTA_T)) * log(0.5));
406 for (i = 2; i < damp->decay_array_size; i++)
407 damp->decay_array[i] = damp->decay_array[i-1] * damp->decay_array[1];
410 i = ceil ((double)damp->max_suppress_time / DELTA_REUSE) + 1;
413 damp->reuse_list_size = i;
415 damp->reuse_list = XCALLOC (MTYPE_BGP_DAMP_ARRAY,
416 damp->reuse_list_size
418 memset (damp->reuse_list, 0x00,
419 damp->reuse_list_size * sizeof (struct bgp_reuse_node *));
422 damp->reuse_index = XMALLOC (MTYPE_BGP_DAMP_ARRAY,
423 sizeof(int) * damp->reuse_index_size);
424 memset (damp->reuse_index, 0x00,
425 damp->reuse_list_size * sizeof (int));
427 reuse_max_ratio = (double)damp->ceiling/damp->reuse_limit;
428 j = (exp((double)damp->max_suppress_time/damp->half_life) * log10(2.0));
432 damp->scale_factor = (double)damp->reuse_index_size/(reuse_max_ratio - 1);
434 for (i = 0; i < damp->reuse_index_size; i++)
436 damp->reuse_index[i] =
437 (int)(((double)damp->half_life / DELTA_REUSE)
438 * log10 (1.0 / (damp->reuse_limit * ( 1.0 + ((double)i/damp->scale_factor)))) / log10(0.5));
448 if (damp->half_life == half
449 && damp->reuse_limit == reuse
450 && damp->suppress_value == suppress
451 && damp->max_suppress_time == max)
460 if (! damp->t_reuse)
461 damp->t_reuse =
468 bgp_damp_config_clean (struct bgp_damp_config *damp)
471 XFREE (MTYPE_BGP_DAMP_ARRAY, damp->decay_array);
474 XFREE (MTYPE_BGP_DAMP_ARRAY, damp->reuse_index);
477 XFREE (MTYPE_BGP_DAMP_ARRAY, damp->reuse_list);
487 damp->reuse_offset = 0;
489 for (i = 0; i < damp->reuse_list_size; i++)
491 if (! damp->reuse_list[i])
494 for (bdi = damp->reuse_list[i]; bdi; bdi = next)
499 damp->reuse_list[i] = NULL;
502 for (bdi = damp->no_reuse_list; bdi; bdi = next)
507 damp->no_reuse_list = NULL;
514 if (damp->t_reuse )
515 thread_cancel (damp->t_reuse);
516 damp->t_reuse = NULL;
565 if (penalty > damp->reuse_limit)
567 reuse_time = (int) (DELTA_T * ((log((double)damp->reuse_limit/penalty))/(log(damp->decay_array[1]))));
569 if (reuse_time > damp->max_suppress_time)
570 reuse_time = damp->max_suppress_time;
608 if (! damp || ! bdi)
641 if (! damp || ! bdi)