paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * OSPF flap dampening by Manav Bhatia |
| 3 | * Copyright (C) 2002 |
| 4 | * |
| 5 | * This file is part of GNU Zebra. |
| 6 | * |
| 7 | * GNU Zebra is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the |
| 9 | * Free Software Foundation; either version 2, or (at your option) any |
| 10 | * later version. |
| 11 | * |
| 12 | * GNU Zebra is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with GNU Zebra; see the file COPYING. If not, write to the Free |
| 19 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 20 | * 02111-1307, USA. |
| 21 | */ |
| 22 | |
| 23 | /* |
| 24 | * Flap Damping (target e.g. link/route) |
| 25 | */ |
| 26 | |
| 27 | #define HAVE_OSPF6_DAMP |
| 28 | |
| 29 | typedef enum |
| 30 | { |
| 31 | OFF, |
| 32 | ON, |
| 33 | } onoff_t; |
| 34 | |
| 35 | typedef enum |
| 36 | { |
| 37 | event_none, |
| 38 | event_up, |
| 39 | event_down, |
| 40 | } damp_event_t; |
| 41 | |
| 42 | /* Structure maintained per target basis */ |
| 43 | struct ospf6_damp_info |
| 44 | { |
| 45 | /* identifier to decide which target */ |
| 46 | u_short type; |
| 47 | struct prefix name; |
| 48 | |
| 49 | /* do we damping this info */ |
| 50 | onoff_t damping; |
| 51 | |
| 52 | u_int penalty; |
| 53 | u_int flap; |
| 54 | time_t t_start; /* First flap (down event) time */ |
| 55 | time_t t_updated; /* Last time the penalty was updated */ |
| 56 | |
| 57 | /* index and double-link for reuse list */ |
| 58 | int index; |
| 59 | struct ospf6_damp_info *next; |
| 60 | struct ospf6_damp_info *prev; |
| 61 | |
| 62 | /* the last event that we are avoiding */ |
| 63 | int (*event) (void *target); |
| 64 | void *target; |
| 65 | damp_event_t event_type; |
| 66 | damp_event_t target_status; |
| 67 | }; |
| 68 | |
| 69 | #define OSPF6_DAMP_TYPE_ROUTE 0 |
| 70 | #define OSPF6_DAMP_TYPE_MAX 1 |
| 71 | |
| 72 | /* Global Configuration Parameters */ |
| 73 | struct ospf6_damp_config |
| 74 | { |
| 75 | /* is damping enabled ? */ |
| 76 | onoff_t enabled; |
| 77 | |
| 78 | /* configurable parameters */ |
| 79 | u_int half_life; |
| 80 | u_int suppress; |
| 81 | u_int reuse; |
| 82 | u_int t_hold; /* Maximum hold down time */ |
| 83 | |
| 84 | /* Non configurable parameters */ |
| 85 | u_int delta_t; |
| 86 | u_int delta_reuse; |
| 87 | u_int default_penalty; |
| 88 | u_int ceiling; /* Max value a penalty can attain */ |
| 89 | double scale_factor; |
| 90 | |
| 91 | int decay_array_size; /* Calculated using config parameters */ |
| 92 | double *decay_array; /* Storage for decay values */ |
| 93 | |
| 94 | int reuse_index_array_size; /* Size of reuse index array */ |
| 95 | int *reuse_index_array; |
| 96 | |
| 97 | int reuse_list_size; /* Number of reuse lists */ |
| 98 | struct ospf6_damp_info **reuse_list_array; |
| 99 | }; |
| 100 | |
| 101 | int ospf6_damp_reuse_timer (struct thread *); |
| 102 | void ospf6_damp_event_up (u_short type, struct prefix *name, |
| 103 | int (*exec_up) (void *), void *target); |
| 104 | void ospf6_damp_event_down (u_short type, struct prefix *name, |
| 105 | int (*exec_down) (void *), void *target); |
| 106 | |
| 107 | void ospf6_damp_config_write (struct vty *); |
| 108 | void ospf6_damp_init (); |
| 109 | |