summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorEsben Norby <norby@cvs.openbsd.org>2006-06-28 10:53:40 +0000
committerEsben Norby <norby@cvs.openbsd.org>2006-06-28 10:53:40 +0000
commitc8a16f45926300991328908f6b6f4f6f5113023d (patch)
treef701928b2983f6728ebd9bf5160f33b8fcacdb1a /usr.sbin
parentf48e7b1fb09ad3b1d0849e70bb2162b4c5d6747e (diff)
Track the uptime of the ospfd daemon itself.
It is possible to read the uptime of the daemon with the "ospfctl show" command. ok claudio@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ospfctl/ospfctl.c4
-rw-r--r--usr.sbin/ospfd/ospfd.h4
-rw-r--r--usr.sbin/ospfd/rde.c13
3 files changed, 18 insertions, 3 deletions
diff --git a/usr.sbin/ospfctl/ospfctl.c b/usr.sbin/ospfctl/ospfctl.c
index e6b00dbe16b..0bac85fb98e 100644
--- a/usr.sbin/ospfctl/ospfctl.c
+++ b/usr.sbin/ospfctl/ospfctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfctl.c,v 1.33 2006/04/21 16:36:39 claudio Exp $ */
+/* $OpenBSD: ospfctl.c,v 1.34 2006/06/28 10:53:39 norby Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -293,6 +293,8 @@ show_summary_msg(struct imsg *imsg)
case IMSG_CTL_SHOW_SUM:
sum = imsg->data;
printf("Router ID: %s\n", inet_ntoa(sum->rtr_id));
+ printf("Uptime: %s\n", sum->uptime == 0 ? "00:00:00" :
+ fmt_timeframe_core(sum->uptime));
printf("RFC1583 compatibility flag is ");
if (sum->rfc1583compat)
printf("enabled\n");
diff --git a/usr.sbin/ospfd/ospfd.h b/usr.sbin/ospfd/ospfd.h
index 408d842ecdd..b8039d357d3 100644
--- a/usr.sbin/ospfd/ospfd.h
+++ b/usr.sbin/ospfd/ospfd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfd.h,v 1.59 2006/05/31 03:24:06 claudio Exp $ */
+/* $OpenBSD: ospfd.h,v 1.60 2006/06/28 10:53:39 norby Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -388,6 +388,7 @@ struct ospfd_conf {
#define OSPFD_OPT_NOACTION 0x00000004
u_int32_t spf_delay;
u_int32_t spf_hold_time;
+ time_t uptime;
int spf_state;
int ospf_socket;
int flags;
@@ -491,6 +492,7 @@ struct ctl_sum {
u_int32_t spf_hold_time;
u_int32_t num_ext_lsa;
u_int32_t num_area;
+ time_t uptime;
u_int8_t rfc1583compat;
};
diff --git a/usr.sbin/ospfd/rde.c b/usr.sbin/ospfd/rde.c
index 9ef7fc6e195..06d8a1bebb5 100644
--- a/usr.sbin/ospfd/rde.c
+++ b/usr.sbin/ospfd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.46 2006/05/30 22:06:14 claudio Exp $ */
+/* $OpenBSD: rde.c,v 1.47 2006/06/28 10:53:39 norby Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -91,6 +91,7 @@ pid_t
rde(struct ospfd_conf *xconf, int pipe_parent2rde[2], int pipe_ospfe2rde[2],
int pipe_parent2ospfe[2])
{
+ struct timeval now;
struct passwd *pw;
struct redistribute *r;
struct event ev_sigint, ev_sigterm;
@@ -166,6 +167,9 @@ rde(struct ospfd_conf *xconf, int pipe_parent2rde[2], int pipe_ospfe2rde[2],
free(r);
}
+ gettimeofday(&now, NULL);
+ rdeconf->uptime = now.tv_sec;
+
event_dispatch();
rde_shutdown();
@@ -695,6 +699,7 @@ void
rde_send_summary(pid_t pid)
{
static struct ctl_sum sumctl;
+ struct timeval now;
struct area *area;
struct vertex *v;
@@ -710,6 +715,12 @@ rde_send_summary(pid_t pid)
RB_FOREACH(v, lsa_tree, &asext_tree)
sumctl.num_ext_lsa++;
+ gettimeofday(&now, NULL);
+ if (rdeconf->uptime < now.tv_sec)
+ sumctl.uptime = now.tv_sec - rdeconf->uptime;
+ else
+ sumctl.uptime = 0;
+
sumctl.rfc1583compat = rdeconf->rfc1583compat;
rde_imsg_compose_ospfe(IMSG_CTL_SHOW_SUM, 0, pid, &sumctl,