]> git.puffer.fish Git - mirror/frr.git/commitdiff
Fix "show ip bgp dampened-paths" garbage output.
authorChris Caputo <ccaputo@alt.net>
Tue, 23 Jun 2009 06:06:49 +0000 (06:06 +0000)
committerPaul Jakma <paul@quagga.net>
Tue, 23 Jun 2009 13:25:20 +0000 (14:25 +0100)
* bgpd/bgp_damp.c: Make bgp_damp_reuse_time_vty() accept a buffer and
  length, rather than returning a local var buffer whose contents can get
  trounced.  Remove duplicate BGP_UPTIME_LEN define.
* bgpd/bgp_damp.h: bgp_damp_reuse_time_vty() prototype change.
* bgpd/bgp_route.c: Provide bgp_damp_reuse_time_vty() with a buffer and
  length.  Remove duplicate BGP_UPTIME_LEN define.

This problem was noticed in 2005...

  http://hibernia.jakma.org/~paul/patches/quagga-test.diff

...but the fix didn't make it into the code.

Signed-off-by: Chris Caputo <ccaputo@alt.net>
bgpd/bgp_damp.c
bgpd/bgp_damp.h
bgpd/bgp_route.c

index 346ba52076f8814b61d307636eb2fe75fa6dd593..e21131ef92e8c483aee7c816c66b9414809d8051 100644 (file)
@@ -541,8 +541,6 @@ bgp_config_write_damp (struct vty *vty)
             VTY_NEWLINE);
 }
 
-#define BGP_UPTIME_LEN 25
-
 static const char *
 bgp_get_reuse_time (unsigned int penalty, char *buf, size_t len)
 {
@@ -616,11 +614,11 @@ bgp_damp_info_vty (struct vty *vty, struct bgp_info *binfo)
 }
 
 const char *
-bgp_damp_reuse_time_vty (struct vty *vty, struct bgp_info *binfo)
+bgp_damp_reuse_time_vty (struct vty *vty, struct bgp_info *binfo,
+                         char *timebuf, size_t len)
 {
   struct bgp_damp_info *bdi;
   time_t t_now, t_diff;
-  char timebuf[BGP_UPTIME_LEN];
   int penalty;
   
   if (!binfo->extra)
@@ -639,5 +637,5 @@ bgp_damp_reuse_time_vty (struct vty *vty, struct bgp_info *binfo)
   t_diff = t_now - bdi->t_updated;
   penalty = bgp_damp_decay (t_diff, bdi->penalty);
 
-  return  bgp_get_reuse_time (penalty, timebuf, BGP_UPTIME_LEN);
+  return  bgp_get_reuse_time (penalty, timebuf, len);
 }
index e0bef4a8f680634f86aba32a73a1314c7ef67009..e1d319b56658cce5682e3c88891f783c7155d177 100644 (file)
@@ -141,6 +141,7 @@ 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 *);
-extern const char * bgp_damp_reuse_time_vty (struct vty *, struct bgp_info *);
+extern const char * bgp_damp_reuse_time_vty (struct vty *, struct bgp_info *,
+                                             char *, size_t);
 
 #endif /* _QUAGGA_BGP_DAMP_H */
index a44d47abaadfd6cdd7a38758908390fbe25c99c8..4f3f85b329bf7cc50cf99c2cb54f199296169b41 100644 (file)
@@ -5810,6 +5810,7 @@ damp_route_vty_out (struct vty *vty, struct prefix *p,
 {
   struct attr *attr;
   int len;
+  char timebuf[BGP_UPTIME_LEN];
 
   /* short status lead text */ 
   route_vty_short_status_out (vty, binfo);
@@ -5827,7 +5828,7 @@ damp_route_vty_out (struct vty *vty, struct prefix *p,
   else
     vty_out (vty, "%*s", len, " ");
 
-  vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo));
+  vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN));
 
   /* Print attribute */
   attr = binfo->attr;
@@ -5843,8 +5844,6 @@ damp_route_vty_out (struct vty *vty, struct prefix *p,
   vty_out (vty, "%s", VTY_NEWLINE);
 }
 
-#define BGP_UPTIME_LEN 25
-
 /* flap route */
 static void
 flap_route_vty_out (struct vty *vty, struct prefix *p,
@@ -5888,7 +5887,7 @@ flap_route_vty_out (struct vty *vty, struct prefix *p,
 
   if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)
       && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
-    vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo));
+    vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN));
   else
     vty_out (vty, "%*s ", 8, " ");