From 23d9c6bf9c79f0e74a5f5371590b55bb56a80bab Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Thu, 21 May 2009 10:50:40 +0200 Subject: [PATCH] Fix the case where last change < start time. This case can happen if the master agent is restarted: lldpd last change will be before the start of the master agent. --- src/agent.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/agent.c b/src/agent.c index eba7edd1..9f9da8b0 100644 --- a/src/agent.c +++ b/src/agent.c @@ -122,7 +122,11 @@ header_tprindexed_table(struct variable *vp, oid *name, size_t *length, if ((variant == TPR_VARIANT_IP) && (hardware->h_rchassis->c_mgmt.s_addr == INADDR_ANY)) continue; - current[0] = (hardware->h_rlastchange - starttime.tv_sec)*100; + if (hardware->h_rlastchange > starttime.tv_sec) + current[0] = + (hardware->h_rlastchange - starttime.tv_sec)*100; + else + current[0] = 0; current[1] = if_nametoindex(hardware->h_ifname); current[2] = hardware->h_rid; k = j = 0; @@ -254,7 +258,11 @@ header_tprvindexed_table(struct variable *vp, oid *name, size_t *length, TAILQ_FOREACH(hardware, &scfg->g_hardware, h_entries) { if ((INTERFACE_OPENED(hardware)) && (hardware->h_rport != NULL)) { TAILQ_FOREACH(vlan, &hardware->h_rport->p_vlans, v_entries) { - current[0] = (hardware->h_rlastchange - starttime.tv_sec)*100; + if (hardware->h_rlastchange > starttime.tv_sec) + current[0] = + (hardware->h_rlastchange - starttime.tv_sec)*100; + else + current[0] = 0; current[1] = if_nametoindex(hardware->h_ifname); current[2] = hardware->h_rid; current[3] = vlan->v_vid; -- 2.39.5