2003-10-18 Lorenzo Colitti <lorenzo@ripe.net>

* bgpd/bgp_dump.{c,h}: (bgp_dump_interval_add) Dump at discrete
          fixed intervals rather than fixed intervals from startup time.
          (bgp_dump_interval_func) Dont return immediately if file cant be
          openeded, but reschedule interval dumps, even - admin might
          fix problem in meantime. Close the dump file in between intervals.
          (bgp_dump_init) account for MSG header when initialising stream
	  size.
This commit is contained in:
paul 2003-10-18 01:01:19 +00:00
parent cc1131ab01
commit 9834cd0f43
2 changed files with 37 additions and 13 deletions

View File

@ -129,13 +129,32 @@ int
bgp_dump_interval_add (struct bgp_dump *bgp_dump, int interval)
{
int bgp_dump_interval_func (struct thread *);
int interval2, secs_into_day;
time_t t;
struct tm *tm;
if (interval > 0 )
bgp_dump->t_interval = thread_add_timer (master, bgp_dump_interval_func,
bgp_dump, interval);
{
if ((interval < 86400) && ((86400 % interval) == 0))
{
(void) time(&t);
tm = localtime(&t);
secs_into_day = tm->tm_sec + 60*tm->tm_min + 60*60*tm->tm_hour;
interval2 = interval - secs_into_day % interval;
if(interval2 == 0) interval2 = interval;
}
else
{
interval2 = interval;
}
bgp_dump->t_interval = thread_add_timer (master, bgp_dump_interval_func,
bgp_dump, interval2);
}
else
{
bgp_dump->t_interval = thread_add_event (master, bgp_dump_interval_func,
bgp_dump, 0);
}
return 0;
}
@ -304,21 +323,24 @@ bgp_dump_interval_func (struct thread *t)
bgp_dump = THREAD_ARG (t);
bgp_dump->t_interval = NULL;
if (bgp_dump_open_file (bgp_dump) == NULL)
return 0;
/* Reschedule dump even if file couldn't be opened this time... */
if (bgp_dump_open_file (bgp_dump) != NULL)
{
/* In case of bgp_dump_routes, we need special route dump function. */
if (bgp_dump->type == BGP_DUMP_ROUTES)
{
bgp_dump_routes_func (AFI_IP);
bgp_dump_routes_func (AFI_IP6);
/* Close the file now. For a RIB dump there's no point in leaving
* it open until the next scheduled dump starts. */
fclose(bgp_dump->fp); bgp_dump->fp = NULL;
}
}
/* if interval is set reschedule */
if (bgp_dump->interval > 0)
bgp_dump_interval_add (bgp_dump, bgp_dump->interval);
return 0;
}
@ -738,7 +760,8 @@ bgp_dump_init ()
memset (&bgp_dump_updates, 0, sizeof (struct bgp_dump));
memset (&bgp_dump_routes, 0, sizeof (struct bgp_dump));
bgp_dump_obuf = stream_new (BGP_MAX_PACKET_SIZE + BGP_DUMP_HEADER_SIZE);
bgp_dump_obuf = stream_new (BGP_MAX_PACKET_SIZE + BGP_DUMP_MSG_HEADER
+ BGP_DUMP_HEADER_SIZE);
install_node (&bgp_dump_node, config_write_bgp_dump);

View File

@ -28,6 +28,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#define BGP4MP_SNAPSHOT 3
#define BGP_DUMP_HEADER_SIZE 12
#define BGP_DUMP_MSG_HEADER 40
void bgp_dump_init ();
void bgp_dump_state (struct peer *, int, int);