]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_damp.h
bgpd: partially revert e23b9ef6d271223d29c7f91a10d98aa6dcd252b3
[mirror_frr.git] / bgpd / bgp_damp.h
index 6853696378163a87a5f38d754e6d393e9faf2e11..18bf561c477c83114a9db5a73a4645916d96c28f 100644 (file)
 /* BGP flap dampening
-   Copyright (C) 2001 IP Infusion Inc.
+ * Copyright (C) 2001 IP Infusion Inc.
+ *
+ * This file is part of GNU Zebra.
+ *
+ * GNU Zebra is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * GNU Zebra is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
 
-This file is part of GNU Zebra.
+#ifndef _QUAGGA_BGP_DAMP_H
+#define _QUAGGA_BGP_DAMP_H
 
-GNU Zebra is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
+/* Structure maintained on a per-route basis. */
+struct bgp_damp_info {
+       /* Doubly linked list.  This information must be linked to
+          reuse_list or no_reuse_list.  */
+       struct bgp_damp_info *next;
+       struct bgp_damp_info *prev;
 
-GNU Zebra is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
+       /* Figure-of-merit.  */
+       unsigned int penalty;
 
-You should have received a copy of the GNU General Public License
-along with GNU Zebra; see the file COPYING.  If not, write to the Free
-Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.  */
+       /* Number of flapping.  */
+       unsigned int flap;
 
-#ifndef _QUAGGA_BGP_DAMP_H
-#define _QUAGGA_BGP_DAMP_H
+       /* First flap time  */
+       time_t start_time;
 
-/* Structure maintained on a per-route basis. */
-struct bgp_damp_info
-{
-  /* Doubly linked list.  This information must be linked to
-     reuse_list or no_reuse_list.  */
-  struct bgp_damp_info *next;
-  struct bgp_damp_info *prev;
-
-  /* Figure-of-merit.  */
-  unsigned int penalty;
-
-  /* Number of flapping.  */
-  unsigned int flap;
-       
-  /* First flap time  */
-  time_t start_time;
-  /* Last time penalty was updated.  */
-  time_t t_updated;
-
-  /* Time of route start to be suppressed.  */
-  time_t suppress_time;
-
-  /* Back reference to bgp_info. */
-  struct bgp_info *binfo;
-
-  /* Back reference to bgp_node. */
-  struct bgp_node *rn;
-
-  /* Current index in the reuse_list. */
-  int index;
-
-  /* Last time message type. */
-  u_char lastrecord;
+       /* Last time penalty was updated.  */
+       time_t t_updated;
+
+       /* Time of route start to be suppressed.  */
+       time_t suppress_time;
+
+       /* Back reference to bgp_path_info. */
+       struct bgp_path_info *path;
+
+       /* Back reference to bgp_node. */
+       struct bgp_node *rn;
+
+       /* Current index in the reuse_list. */
+       int index;
+
+       /* Last time message type. */
+       uint8_t lastrecord;
 #define BGP_RECORD_UPDATE      1U
 #define BGP_RECORD_WITHDRAW    2U
 
-  afi_t afi;
-  safi_t safi;
+       afi_t afi;
+       safi_t safi;
 };
 
 /* Specified parameter set configuration. */
-struct bgp_damp_config
-{
-  /* Value over which routes suppressed.  */
-  unsigned int suppress_value;
-
-  /* Value below which suppressed routes reused.  */
-  unsigned int reuse_limit;
-
-  /* Max time a route can be suppressed.  */
-  time_t max_suppress_time;      
-
-  /* Time during which accumulated penalty reduces by half.  */
-  time_t half_life;
-
-  /* Non-configurable parameters but fixed at implementation time.
-   * To change this values, init_bgp_damp() should be modified.
-   */
-  time_t tmax;                  /* Max time previous instability retained */
-  unsigned int reuse_list_size;         /* Number of reuse lists */
-  unsigned int reuse_index_size; /* Size of reuse index array */
-
-  /* Non-configurable parameters.  Most of these are calculated from
-   * the configurable parameters above.
-   */
-  unsigned int ceiling;                        /* Max value a penalty can attain */
-  unsigned int decay_rate_per_tick;    /* Calculated from half-life */
-  unsigned int decay_array_size; /* Calculated using config parameters */
-  double scale_factor;
-  unsigned int reuse_scale_factor; 
-         
-  /* Decay array per-set based. */ 
-  double *decay_array; 
-
-  /* Reuse index array per-set based. */ 
-  int *reuse_index;
-
-  /* Reuse list array per-set based. */  
-  struct bgp_damp_info **reuse_list;
-  int reuse_offset;
-        
-  /* All dampening information which is not on reuse list.  */
-  struct bgp_damp_info *no_reuse_list;
-
-  /* Reuse timer thread per-set base. */
-  struct thread* t_reuse;
+struct bgp_damp_config {
+       /* Value over which routes suppressed.  */
+       unsigned int suppress_value;
+
+       /* Value below which suppressed routes reused.  */
+       unsigned int reuse_limit;
+
+       /* Max time a route can be suppressed.  */
+       time_t max_suppress_time;
+
+       /* Time during which accumulated penalty reduces by half.  */
+       time_t half_life;
+
+       /* Non-configurable parameters but fixed at implementation time.
+        * To change this values, init_bgp_damp() should be modified.
+        */
+       time_t tmax; /* Max time previous instability retained */
+       unsigned int reuse_list_size;  /* Number of reuse lists */
+       unsigned int reuse_index_size; /* Size of reuse index array */
+
+       /* Non-configurable parameters.  Most of these are calculated from
+        * the configurable parameters above.
+        */
+       unsigned int ceiling;             /* Max value a penalty can attain */
+       unsigned int decay_rate_per_tick; /* Calculated from half-life */
+       unsigned int decay_array_size; /* Calculated using config parameters */
+       double scale_factor;
+       unsigned int reuse_scale_factor;
+
+       /* Decay array per-set based. */
+       double *decay_array;
+
+       /* Reuse index array per-set based. */
+       int *reuse_index;
+
+       /* Reuse list array per-set based. */
+       struct bgp_damp_info **reuse_list;
+       int reuse_offset;
+
+       /* All dampening information which is not on reuse list.  */
+       struct bgp_damp_info *no_reuse_list;
+
+       /* Reuse timer thread per-set base. */
+       struct thread *t_reuse;
 };
 
 #define BGP_DAMP_NONE           0
@@ -129,19 +127,24 @@ struct bgp_damp_config
 #define REUSE_LIST_SIZE          256
 #define REUSE_ARRAY_SIZE        1024
 
-extern int bgp_damp_enable (struct bgp *, afi_t, safi_t, time_t, unsigned int, 
-                     unsigned int, time_t);
-extern int bgp_damp_disable (struct bgp *, afi_t, safi_t);
-extern int bgp_damp_withdraw (struct bgp_info *, struct bgp_node *,
-                      afi_t, safi_t, int);
-extern int bgp_damp_update (struct bgp_info *, struct bgp_node *, afi_t, safi_t);
-extern int bgp_damp_scan (struct bgp_info *, afi_t, safi_t);
-extern void bgp_damp_info_free (struct bgp_damp_info *, int);
-extern void bgp_damp_info_clean (void);
-extern int bgp_damp_decay (time_t, int);
-extern void bgp_config_write_damp (struct vty *);
-extern void bgp_damp_info_vty (struct vty *, struct bgp_info *, json_object *json_path);
-extern const char * bgp_damp_reuse_time_vty (struct vty *, struct bgp_info *,
-                                             char *, size_t, u_char, json_object *);
+extern int bgp_damp_enable(struct bgp *, afi_t, safi_t, time_t, unsigned int,
+                          unsigned int, time_t);
+extern int bgp_damp_disable(struct bgp *, afi_t, safi_t);
+extern int bgp_damp_withdraw(struct bgp_path_info *path, struct bgp_node *rn,
+                            afi_t afi, safi_t safi, int attr_change);
+extern int bgp_damp_update(struct bgp_path_info *path, struct bgp_node *rn,
+                          afi_t afi, safi_t saff);
+extern int bgp_damp_scan(struct bgp_path_info *path, afi_t afi, safi_t safi);
+extern void bgp_damp_info_free(struct bgp_damp_info *path, int withdraw);
+extern void bgp_damp_info_clean(void);
+extern int bgp_damp_decay(time_t, int);
+extern void bgp_config_write_damp(struct vty *);
+extern void bgp_damp_info_vty(struct vty *vty, struct bgp_path_info *path,
+                             json_object *json_path);
+extern const char *bgp_damp_reuse_time_vty(struct vty *vty,
+                                          struct bgp_path_info *path,
+                                          char *timebuf, size_t len,
+                                          bool use_json, json_object *json);
+extern int bgp_show_dampening_parameters(struct vty *vty, afi_t, safi_t);
 
 #endif /* _QUAGGA_BGP_DAMP_H */