From bea0d76429a214c7d2db31b464e0c71f2e989c91 Mon Sep 17 00:00:00 2001 From: Roopa Prabhu Date: Sat, 8 Jun 2013 10:30:43 +0200 Subject: [PATCH] Fixed some boundary conditions in code that cleans remote ports on ttl expiry. Problem: - ttl expires, cleanup check fails to detect that ttl has elapsed and skips cleanup - After that, The ttl timer set routine again ends up setting the timer to ttl resulting in 2 * ttl time for the expired rport to get released (The test I did was with 1 port) --- src/daemon/event.c | 2 +- src/lldpd-structs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/daemon/event.c b/src/daemon/event.c index 1871b3b2..17213c86 100644 --- a/src/daemon/event.c +++ b/src/daemon/event.c @@ -695,7 +695,7 @@ levent_schedule_cleanup(struct lldpd *cfg) TAILQ_FOREACH(hardware, &cfg->g_hardware, h_entries) { TAILQ_FOREACH(port, &hardware->h_rports, p_entries) { next = port->p_chassis->c_ttl - (now - port->p_lastupdate); - if (next > 0 && next < tv.tv_sec) + if (next >= 0 && next < tv.tv_sec) tv.tv_sec = next; } } diff --git a/src/lldpd-structs.c b/src/lldpd-structs.c index 758be94f..a14fe5da 100644 --- a/src/lldpd-structs.c +++ b/src/lldpd-structs.c @@ -122,7 +122,7 @@ lldpd_remote_cleanup(struct lldpd_hardware *hardware, port_next = TAILQ_NEXT(port, p_entries); del = (expire == NULL); if (expire && - (now - port->p_lastupdate > port->p_chassis->c_ttl)) { + (now - port->p_lastupdate >= port->p_chassis->c_ttl)) { hardware->h_ageout_cnt++; hardware->h_delete_cnt++; expire(hardware, port); -- 2.39.5