]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
Fixed some boundary conditions in code that cleans
authorRoopa Prabhu <roopa@cumulusnetworks.com>
Sat, 8 Jun 2013 08:30:43 +0000 (10:30 +0200)
committerVincent Bernat <bernat@luffy.cx>
Sat, 8 Jun 2013 08:30:43 +0000 (10:30 +0200)
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
src/lldpd-structs.c

index 1871b3b277909327d65fb9f31279d18a99df7f85..17213c86fd858b90c5afc6ca36c68dce388be376 100644 (file)
@@ -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;
                }
        }
index 758be94faba762d0393cff1a670f97eae6983949..a14fe5da3e6d72214933901c5d8dca4037bc8139 100644 (file)
@@ -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);