From: Vincent Bernat Date: Thu, 21 May 2009 08:50:40 +0000 (+0200) Subject: Fix the case where last change < start time. X-Git-Tag: 0.4.1~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=23d9c6bf9c79f0e74a5f5371590b55bb56a80bab;p=thirdparty%2Flldpd.git 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. --- 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;