summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_dump.c
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/bgp_dump.c')
-rw-r--r--bgpd/bgp_dump.c64
1 files changed, 30 insertions, 34 deletions
diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c
index edb725a9..d76b5699 100644
--- a/bgpd/bgp_dump.c
+++ b/bgpd/bgp_dump.c
@@ -33,7 +33,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "bgpd/bgp_route.h"
#include "bgpd/bgp_attr.h"
#include "bgpd/bgp_dump.h"
-
+
enum bgp_dump_type
{
BGP_DUMP_ALL,
@@ -89,28 +89,28 @@ struct bgp_dump bgp_dump_routes;
/* Dump whole BGP table is very heavy process. */
struct thread *t_bgp_dump_routes;
-
+
/* Some define for BGP packet dump. */
static FILE *
bgp_dump_open_file (struct bgp_dump *bgp_dump)
{
int ret;
time_t clock;
- struct tm *tm;
+ struct tm tm;
char fullpath[MAXPATHLEN];
char realpath[MAXPATHLEN];
mode_t oldumask;
time (&clock);
- tm = localtime (&clock);
+ localtime_r(&clock, &tm);
if (bgp_dump->filename[0] != DIRECTORY_SEP)
{
sprintf (fullpath, "%s/%s", vty_get_cwd (), bgp_dump->filename);
- ret = strftime (realpath, MAXPATHLEN, fullpath, tm);
+ ret = strftime (realpath, MAXPATHLEN, fullpath, &tm);
}
else
- ret = strftime (realpath, MAXPATHLEN, bgp_dump->filename, tm);
+ ret = strftime (realpath, MAXPATHLEN, bgp_dump->filename, &tm);
if (ret == 0)
{
@@ -127,11 +127,11 @@ bgp_dump_open_file (struct bgp_dump *bgp_dump)
if (bgp_dump->fp == NULL)
{
- zlog_warn ("bgp_dump_open_file: %s: %s", realpath, strerror (errno));
+ zlog_warn("bgp_dump_open_file: %s: %s", realpath, errtoa(errno, 0).str);
umask(oldumask);
return NULL;
}
- umask(oldumask);
+ umask(oldumask);
return bgp_dump->fp;
}
@@ -141,7 +141,7 @@ bgp_dump_interval_add (struct bgp_dump *bgp_dump, int interval)
{
int secs_into_day;
time_t t;
- struct tm *tm;
+ struct tm tm;
if (interval > 0)
{
@@ -152,11 +152,11 @@ bgp_dump_interval_add (struct bgp_dump *bgp_dump, int interval)
* intervals, dump every interval seconds starting from midnight
*/
(void) time(&t);
- tm = localtime(&t);
- secs_into_day = tm->tm_sec + 60*tm->tm_min + 60*60*tm->tm_hour;
+ localtime_r(&t, &tm);
+ secs_into_day = tm.tm_sec + 60*tm.tm_min + 60*60*tm.tm_hour;
interval = interval - secs_into_day % interval; /* always > 0 */
}
- bgp_dump->t_interval = thread_add_timer (master, bgp_dump_interval_func,
+ bgp_dump->t_interval = thread_add_timer (master, bgp_dump_interval_func,
bgp_dump, interval);
}
else
@@ -179,7 +179,7 @@ bgp_dump_header (struct stream *obuf, int type, int subtype)
time (&now);
/* Put dump packet header. */
- stream_putl (obuf, now);
+ stream_putl (obuf, now);
stream_putw (obuf, type);
stream_putw (obuf, subtype);
@@ -348,7 +348,7 @@ bgp_dump_routes_func (int afi, int first_run, unsigned int seq)
/* Entry count, note that this is overwritten later */
stream_putw(obuf, 0);
- for (info = rn->info; info; info = info->next)
+ for (info = rn->info; info; info = info->info_next)
{
entry_count++;
@@ -356,11 +356,7 @@ bgp_dump_routes_func (int afi, int first_run, unsigned int seq)
stream_putw(obuf, info->peer->table_dump_index);
/* Originated */
-#ifdef HAVE_CLOCK_MONOTONIC
- stream_putl (obuf, time(NULL) - (bgp_clock() - info->uptime));
-#else
- stream_putl (obuf, info->uptime);
-#endif /* HAVE_CLOCK_MONOTONIC */
+ stream_putl (obuf, bgp_wall_clock(info->uptime));
/* Dump attribute. */
/* Skip prefix & AFI/SAFI for MP_NLRI */
@@ -504,7 +500,7 @@ bgp_dump_packet_func (struct bgp_dump *bgp_dump, struct peer *peer,
/* Dump header and common part. */
if (CHECK_FLAG (peer->cap, PEER_CAP_AS4_RCV) )
- {
+ {
bgp_dump_header (obuf, MSG_PROTOCOL_BGP4MP, BGP4MP_MESSAGE_AS4);
}
else
@@ -515,7 +511,7 @@ bgp_dump_packet_func (struct bgp_dump *bgp_dump, struct peer *peer,
/* Packet contents. */
stream_put (obuf, STREAM_DATA (packet), stream_get_endp (packet));
-
+
/* Set length. */
bgp_dump_set_size (obuf, MSG_PROTOCOL_BGP4MP);
@@ -535,7 +531,7 @@ bgp_dump_packet (struct peer *peer, int type, struct stream *packet)
if (type == BGP_MSG_UPDATE)
bgp_dump_packet_func (&bgp_dump_updates, peer, packet);
}
-
+
static unsigned int
bgp_dump_parse_time (const char *str)
{
@@ -589,10 +585,10 @@ bgp_dump_set (struct vty *vty, struct bgp_dump *bgp_dump,
const char *interval_str)
{
unsigned int interval;
-
+
if (interval_str)
{
-
+
/* Check interval string. */
interval = bgp_dump_parse_time (interval_str);
if (interval == 0)
@@ -614,13 +610,13 @@ bgp_dump_set (struct vty *vty, struct bgp_dump *bgp_dump,
if (bgp_dump->interval_str)
free (bgp_dump->interval_str);
bgp_dump->interval_str = strdup (interval_str);
-
+
}
else
{
interval = 0;
}
-
+
/* Create interval thread. */
bgp_dump_interval_add (bgp_dump, interval);
@@ -669,7 +665,7 @@ bgp_dump_unset (struct vty *vty, struct bgp_dump *bgp_dump)
free (bgp_dump->interval_str);
bgp_dump->interval_str = NULL;
}
-
+
return CMD_SUCCESS;
}
@@ -816,36 +812,36 @@ config_write_bgp_dump (struct vty *vty)
if (bgp_dump_all.filename)
{
if (bgp_dump_all.interval_str)
- vty_out (vty, "dump bgp all %s %s%s",
+ vty_out (vty, "dump bgp all %s %s%s",
bgp_dump_all.filename, bgp_dump_all.interval_str,
VTY_NEWLINE);
else
- vty_out (vty, "dump bgp all %s%s",
+ vty_out (vty, "dump bgp all %s%s",
bgp_dump_all.filename, VTY_NEWLINE);
}
if (bgp_dump_updates.filename)
{
if (bgp_dump_updates.interval_str)
- vty_out (vty, "dump bgp updates %s %s%s",
+ vty_out (vty, "dump bgp updates %s %s%s",
bgp_dump_updates.filename, bgp_dump_updates.interval_str,
VTY_NEWLINE);
else
- vty_out (vty, "dump bgp updates %s%s",
+ vty_out (vty, "dump bgp updates %s%s",
bgp_dump_updates.filename, VTY_NEWLINE);
}
if (bgp_dump_routes.filename)
{
if (bgp_dump_routes.interval_str)
- vty_out (vty, "dump bgp routes-mrt %s %s%s",
+ vty_out (vty, "dump bgp routes-mrt %s %s%s",
bgp_dump_routes.filename, bgp_dump_routes.interval_str,
VTY_NEWLINE);
else
- vty_out (vty, "dump bgp routes-mrt %s%s",
+ vty_out (vty, "dump bgp routes-mrt %s%s",
bgp_dump_routes.filename, VTY_NEWLINE);
}
return 0;
}
-
+
/* Initialize BGP packet dump functionality. */
void
bgp_dump_init (void)