]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
protocol/lldp: accept unknown TLVs on known orgs feature/unknown-tlvs-on-known-orgs 536/head
authorVincent Bernat <vincent@bernat.ch>
Tue, 16 Aug 2022 16:31:06 +0000 (18:31 +0200)
committerVincent Bernat <vincent@bernat.ch>
Tue, 16 Aug 2022 16:52:12 +0000 (18:52 +0200)
Fix #532

NEWS
src/daemon/protocols/lldp.c
tests/integration/test_custom.py

diff --git a/NEWS b/NEWS
index c36aa2921971fa11ec2b7d24f2c28c75c621ed6c..ee9c8851bb6d8b4d91f20268d47ce1ecf6ade579 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ lldpd (1.0.15)
  * Changes
    + Add configure command to override system capabilities. Contributed by
      Ignacio Sanchez Navarro. (#526)
+   + An unrecognized ORG TLV is now considered as a custom one. (#536)
  * Fix:
    + Really don't send VLANs when there are too many (#520)
    + Ignore temporary IPv6 addresses (#521)
index 81397aaf35f09b0c5538ec99bbe806f79440edf6..032f28e7bf813943e710a73b8c79318dc56d45f8 100644 (file)
@@ -669,6 +669,7 @@ lldp_decode(struct lldpd *cfg, char *frame, int s,
        u_int8_t addr_str_length, addr_str_buffer[32];
        u_int8_t addr_family, addr_length, *addr_ptr, iface_subtype;
        u_int32_t iface_number, iface;
+       int unrecognized;
 #ifdef ENABLE_CUSTOM
        struct lldpd_custom *custom = NULL;
 #endif
@@ -897,10 +898,11 @@ lldp_decode(struct lldpd *cfg, char *frame, int s,
                case LLDP_TLV_ORG:
                        CHECK_TLV_SIZE(1 + (int)sizeof(orgid), "Organisational");
                        PEEK_BYTES(orgid, sizeof(orgid));
+                       unrecognized = 0;
                        tlv_subtype = PEEK_UINT8;
                        if (memcmp(dot1, orgid, sizeof(orgid)) == 0) {
 #ifndef ENABLE_DOT1
-                               hardware->h_rx_unrecognized_cnt++;
+                               unrecognized = 1;
 #else
                                /* Dot1 */
                                switch (tlv_subtype) {
@@ -986,12 +988,12 @@ lldp_decode(struct lldpd *cfg, char *frame, int s,
                                        break;
                                default:
                                        /* Unknown Dot1 TLV, ignore it */
-                                       hardware->h_rx_unrecognized_cnt++;
+                                       unrecognized = 1;
                                }
 #endif
                        } else if (memcmp(dot3, orgid, sizeof(orgid)) == 0) {
 #ifndef ENABLE_DOT3
-                               hardware->h_rx_unrecognized_cnt++;
+                               unrecognized = 1;
 #else
                                /* Dot3 */
                                switch (tlv_subtype) {
@@ -1077,13 +1079,13 @@ lldp_decode(struct lldpd *cfg, char *frame, int s,
                                        break;
                                default:
                                        /* Unknown Dot3 TLV, ignore it */
-                                       hardware->h_rx_unrecognized_cnt++;
+                                       unrecognized = 1;
                                }
 #endif
                        } else if (memcmp(med, orgid, sizeof(orgid)) == 0) {
                                /* LLDP-MED */
 #ifndef ENABLE_LLDPMED
-                               hardware->h_rx_unrecognized_cnt++;
+                               unrecognized = 1;
 #else
                                u_int32_t policy;
                                unsigned loctype;
@@ -1277,11 +1279,14 @@ lldp_decode(struct lldpd *cfg, char *frame, int s,
                        } else if (memcmp(dcbx, orgid, sizeof(orgid)) == 0) {
                                log_debug("lldp", "unsupported DCBX tlv received on %s - ignore",
                                    hardware->h_ifname);
-                               hardware->h_rx_unrecognized_cnt++;
+                               unrecognized = 1;
                        } else {
                                log_debug("lldp", "unknown org tlv [%02x:%02x:%02x] received on %s",
                                    orgid[0], orgid[1], orgid[2],
                                    hardware->h_ifname);
+                               unrecognized = 1;
+                       }
+                       if (unrecognized) {
                                hardware->h_rx_unrecognized_cnt++;
 #ifdef ENABLE_CUSTOM
                                custom = (struct lldpd_custom*)calloc(1, sizeof(struct lldpd_custom));
index a2d6dc79b7e61abbe180c3cd355520aa236cee0c..f01f0ea1bbe68064ac5a9542a24a6e2a002edcac 100644 (file)
@@ -49,7 +49,12 @@ import time
     (["oui 33,44,55 subtype 44 oui-info 45,45,45,45,45",
       "add oui 33,44,55 subtype 55 oui-info 65,65,65,65,65",
       "-"],
-     {})])
+     {}),
+    (["oui 00,80,c2 subtype 18 oui-info 45,45,45,45,45"],
+     {'unknown-tlv.oui': '00,80,C2',
+      'unknown-tlv.subtype': '18',
+      'unknown-tlv.len': '5',
+      'unknown-tlv': '45,45,45,45,45'})])
 def test_custom_tlv(lldpd1, lldpd, lldpcli, namespaces,
                     commands, expected):
     with namespaces(2):