]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lldp: only enable LLDP-MED capibility TLV if we have that capability
authorVincent Bernat <vincent@bernat.im>
Mon, 12 Sep 2016 20:28:50 +0000 (22:28 +0200)
committerVincent Bernat <vincent@bernat.im>
Mon, 12 Sep 2016 20:33:59 +0000 (22:33 +0200)
In fact, we are not quite coherent. With LLDP-MED disabled (lldpd with
"-M" option), we can still set some TLV. We should either disallow that
or at least not send the capability TLV since we cannot build a complete
one (we miss the device type). We chose the later.

NEWS
src/daemon/protocols/lldp.c

diff --git a/NEWS b/NEWS
index e7066575c0b9fc1297dcff4563cb12338943d483..d104d7c39b9b584454d6b88bddbac23af2b907cc 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ lldpd (0.9.5)
       inaccuracies.
     + Directly get media information for an interface without using
       the privileged process.
+    + LLDP-MED capability TLV is not sent when LLDP-MED is not enabled,
+      even if other LLDP-MED TLV are present.
   * Fix:
     + Compilation fix with older versions of GCC.
     + Don't use ethtool at all to get real MAC address for enslaved
index 59b9f1c2161c19251ad7c7608fdd5109da8487a3..1f79fb9d2cb0fb54501130c3f9b5ba6918550d6c 100644 (file)
@@ -327,14 +327,16 @@ static int _lldp_send(struct lldpd *global,
 #ifdef ENABLE_LLDPMED
        if (port->p_med_cap_enabled) {
                /* LLDP-MED cap */
-               if (!(
-                     POKE_START_LLDP_TLV(LLDP_TLV_ORG) &&
-                     POKE_BYTES(med, sizeof(med)) &&
-                     POKE_UINT8(LLDP_TLV_MED_CAP) &&
-                     POKE_UINT16(chassis->c_med_cap_available) &&
-                     POKE_UINT8(chassis->c_med_type) &&
-                     POKE_END_LLDP_TLV))
-                       goto toobig;
+               if (port->p_med_cap_enabled & LLDP_MED_CAP_CAP) {
+                       if (!(
+                                   POKE_START_LLDP_TLV(LLDP_TLV_ORG) &&
+                                   POKE_BYTES(med, sizeof(med)) &&
+                                   POKE_UINT8(LLDP_TLV_MED_CAP) &&
+                                   POKE_UINT16(chassis->c_med_cap_available) &&
+                                   POKE_UINT8(chassis->c_med_type) &&
+                                   POKE_END_LLDP_TLV))
+                               goto toobig;
+               }
 
                /* LLDP-MED inventory */
 #define LLDP_INVENTORY(value, subtype)                                 \