From: Vincent Bernat Date: Mon, 12 Sep 2016 20:28:50 +0000 (+0200) Subject: lldp: only enable LLDP-MED capibility TLV if we have that capability X-Git-Tag: 0.9.5~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=03d178b6faf926b102efdadf9926754fbcc4a8cd;p=thirdparty%2Flldpd.git lldp: only enable LLDP-MED capibility TLV if we have that capability 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. --- diff --git a/NEWS b/NEWS index e7066575..d104d7c3 100644 --- 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 diff --git a/src/daemon/protocols/lldp.c b/src/daemon/protocols/lldp.c index 59b9f1c2..1f79fb9d 100644 --- a/src/daemon/protocols/lldp.c +++ b/src/daemon/protocols/lldp.c @@ -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) \