From: Roopa Prabhu Date: Sat, 8 Jun 2013 08:30:43 +0000 (+0200) Subject: Fixed some boundary conditions in code that cleans X-Git-Tag: 0.7.4~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bea0d76429a214c7d2db31b464e0c71f2e989c91;p=thirdparty%2Flldpd.git 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) --- 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);