summaryrefslogtreecommitdiff
path: root/bgpd
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@vyatta.com>2013-01-04 22:29:23 +0000
committerDavid Lamparter <equinox@opensourcerouting.org>2013-01-15 17:49:48 +0100
commitd61c1bbd4bf6ddf717dda88350668a9f1e2da0ac (patch)
treec6a056bdfb24031339eb5781c0f57748059dbea4 /bgpd
parent47f6aef02b85c604bbd556574e2c724b7304e9e8 (diff)
bgpd: use recent monotonic time for readtime
The readtime value is for diagnostic, and doesn't have to be highly accurate. This also fixes a problem where the readtime was being measured with system clock, but the peer_uptime() was comparing with bgp_clock. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_packet.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index 968c8e4d..02863d75 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -2385,6 +2385,15 @@ bgp_marker_all_one (struct stream *s, int length)
return 1;
}
+/* Recent thread time.
+ On same clock base as bgp_clock (MONOTONIC)
+ but can be time of last context switch to bgp_read thread. */
+static time_t
+bgp_recent_clock (void)
+{
+ return recent_relative_time().tv_sec;
+}
+
/* Starting point of packet process function. */
int
bgp_read (struct thread *thread)
@@ -2513,14 +2522,14 @@ bgp_read (struct thread *thread)
bgp_open_receive (peer, size); /* XXX return value ignored! */
break;
case BGP_MSG_UPDATE:
- peer->readtime = time(NULL); /* Last read timer reset */
+ peer->readtime = bgp_recent_clock ();
bgp_update_receive (peer, size);
break;
case BGP_MSG_NOTIFY:
bgp_notify_receive (peer, size);
break;
case BGP_MSG_KEEPALIVE:
- peer->readtime = time(NULL); /* Last read timer reset */
+ peer->readtime = bgp_recent_clock ();
bgp_keepalive_receive (peer, size);
break;
case BGP_MSG_ROUTE_REFRESH_NEW: