]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lldp: support for shutdown LLDPU
authorVincent Bernat <vincent@bernat.im>
Sat, 10 May 2014 15:57:08 +0000 (17:57 +0200)
committerVincent Bernat <vincent@bernat.im>
Sat, 10 May 2014 15:59:29 +0000 (17:59 +0200)
We just accept 0 as a valid TTL and let the expiration mechanism do its
work. We ensure that we can handle those 0 TTL and avoid underflow.

Closes #5.

NEWS
src/daemon/event.c
src/daemon/lldp.c
src/lldpd-structs.c

diff --git a/NEWS b/NEWS
index bfe394fc2c9a759d8fe2bb8aca9a6a8ce4d21352..1199f5a0955b657454ed071c15bdc5b1d7f000f5 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,8 @@ lldpd (0.7.9)
   * Fixes:
     + Fix `configure system bond-slave-src-mac-type local`. Also use
       it as default.
+  * Features:
+    + Add support for shutdown LLDPU
 
 lldpd (0.7.8)
   * Fixes:
index 8c5c3b4a524afff2630af6fe266ff9b06e26a728..45919371fcb2a2acdfcdd699e8a5e045cb3aed5d 100644 (file)
@@ -692,8 +692,12 @@ levent_schedule_cleanup(struct lldpd *cfg)
        struct lldpd_port *port;
        TAILQ_FOREACH(hardware, &cfg->g_hardware, h_entries) {
                TAILQ_FOREACH(port, &hardware->h_rports, p_entries) {
+                       if (now + port->p_chassis->c_ttl >= port->p_lastupdate) {
+                               tv.tv_sec = 0;
+                               break;
+                       }
                        next = port->p_chassis->c_ttl - (now - port->p_lastupdate);
-                       if (next >= 0 && next < tv.tv_sec)
+                       if (next < tv.tv_sec)
                                tv.tv_sec = next;
                }
        }
index 5727bd738d4fe004ff0fa6c01a45ee729dc8f997..d564c57f9c9e558fba5fbf13cff8df1c6d94ae0f 100644 (file)
@@ -483,7 +483,7 @@ lldp_decode(struct lldpd *cfg, char *frame, int s,
        const char dot3[] = LLDP_TLV_ORG_DOT3;
        const char med[] = LLDP_TLV_ORG_MED;
        char orgid[3];
-       int length, gotend = 0;
+       int length, gotend = 0, ttl_received = 0;
        int tlv_size, tlv_type, tlv_subtype;
        u_int8_t *pos, *tlv;
        char *b;
@@ -593,6 +593,7 @@ lldp_decode(struct lldpd *cfg, char *frame, int s,
                case LLDP_TLV_TTL:
                        CHECK_TLV_SIZE(2, "TTL");
                        chassis->c_ttl = PEEK_UINT16;
+                       ttl_received = 1;
                        break;
                case LLDP_TLV_PORT_DESCR:
                case LLDP_TLV_SYSTEM_NAME:
@@ -1008,7 +1009,7 @@ lldp_decode(struct lldpd *cfg, char *frame, int s,
        /* Some random check */
        if ((chassis->c_id == NULL) ||
            (port->p_id == NULL) ||
-           (chassis->c_ttl == 0) ||
+           (!ttl_received) ||
            (gotend == 0)) {
                log_warnx("lldp", "some mandatory tlv are missing for frame received on %s",
                    hardware->h_ifname);
index 71d28087bba2fa5fe82c0e5a25ca457505fba4c0..63a824bf5e5b928d4e5f4a1de3eeaa707aa6beb7 100644 (file)
@@ -124,7 +124,7 @@ lldpd_remote_cleanup(struct lldpd_hardware *hardware,
                port_next = TAILQ_NEXT(port, p_entries);
                del = all;
                if (!all && 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++;
                        del = 1;