From: Vincent Bernat Date: Sun, 7 Aug 2016 06:14:43 +0000 (+0200) Subject: lldp: update RFC3636 to RFC4836 X-Git-Tag: 0.9.5~22 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a97e3dfe2cdfb70c8a2afaf2a581f640ebf74a20;p=thirdparty%2Flldpd.git lldp: update RFC3636 to RFC4836 Unfortunately, RFC4836 still lags behind. For example, no more than 10G for speeds, no 10GBASE-T. For advertised modes, we try to be more future-proof by using "other" for any unknown mode. Moreover, document the fact that we advertise 10GBASE_T as 10GBASE-R and on Linux, we have to guess when the port is fiber (and we guesss 10GBASE-X). --- diff --git a/src/daemon/interfaces-bsd.c b/src/daemon/interfaces-bsd.c index 8b658e3c..a2c3c501 100644 --- a/src/daemon/interfaces-bsd.c +++ b/src/daemon/interfaces-bsd.c @@ -541,6 +541,8 @@ ifbsd_macphy(struct lldpd *cfg, LLDP_DOT3_MAU_10GIGBASESR, LLDP_DOT3_MAU_10GIGBASESR}, {IFM_10G_CX4, LLDP_DOT3_MAU_10GIGBASELX4, LLDP_DOT3_MAU_10GIGBASELX4}, + {IFM_10G_T, + LLDP_DOT3_MAU_10GIGBASER, LLDP_DOT3_MAU_10GIGBASER}, // no better, same as for Linux {0, 0, 0} }; @@ -583,13 +585,17 @@ ifbsd_macphy(struct lldpd *cfg, continue; } + int found = 0; for (int j = 0; advertised_ifmedia_to_rfc3636[j][0]; j++) { if (advertised_ifmedia_to_rfc3636[j][0] == media) { port->p_macphy.autoneg_advertised |= advertised_ifmedia_to_rfc3636[j][1 + duplex]; + found = 1; break; } } + if (!found) port->p_macphy.autoneg_advertised |= \ + LLDP_DOT3_LINK_AUTONEG_OTHER; } port->p_macphy.mau_type = 0; diff --git a/src/daemon/interfaces-linux.c b/src/daemon/interfaces-linux.c index c2d4e613..663cd0ac 100644 --- a/src/daemon/interfaces-linux.c +++ b/src/daemon/interfaces-linux.c @@ -333,10 +333,9 @@ iflinux_macphy(struct lldpd_hardware *hardware) {ADVERTISED_100baseT_Full, LLDP_DOT3_LINK_AUTONEG_100BASE_TXFD}, {ADVERTISED_1000baseT_Half, LLDP_DOT3_LINK_AUTONEG_1000BASE_T}, {ADVERTISED_1000baseT_Full, LLDP_DOT3_LINK_AUTONEG_1000BASE_TFD}, - {ADVERTISED_10000baseT_Full, LLDP_DOT3_LINK_AUTONEG_OTHER}, + {ADVERTISED_1000baseKX_Full, LLDP_DOT3_LINK_AUTONEG_1000BASE_XFD}, {ADVERTISED_Pause, LLDP_DOT3_LINK_AUTONEG_FDX_PAUSE}, {ADVERTISED_Asym_Pause, LLDP_DOT3_LINK_AUTONEG_FDX_APAUSE}, - {ADVERTISED_2500baseX_Full, LLDP_DOT3_LINK_AUTONEG_OTHER}, {0,0}}; log_debug("interfaces", "ask ethtool for the appropriate MAC/PHY for %s", @@ -345,10 +344,14 @@ iflinux_macphy(struct lldpd_hardware *hardware) port->p_macphy.autoneg_support = (ethc.supported & SUPPORTED_Autoneg) ? 1 : 0; port->p_macphy.autoneg_enabled = (ethc.autoneg == AUTONEG_DISABLE) ? 0 : 1; for (j=0; advertised_ethtool_to_rfc3636[j][0]; j++) { - if (ethc.advertising & advertised_ethtool_to_rfc3636[j][0]) - port->p_macphy.autoneg_advertised |= + if (ethc.advertising & advertised_ethtool_to_rfc3636[j][0]) { + port->p_macphy.autoneg_advertised |= advertised_ethtool_to_rfc3636[j][1]; + ethc.advertising &= ~advertised_ethtool_to_rfc3636[j][0]; + } } + if (ethc.advertising) + port->p_macphy.autoneg_advertised |= LLDP_DOT3_LINK_AUTONEG_OTHER; switch (ethc.speed) { case SPEED_10: port->p_macphy.mau_type = (ethc.duplex == DUPLEX_FULL) ? \ @@ -376,6 +379,10 @@ iflinux_macphy(struct lldpd_hardware *hardware) LLDP_DOT3_MAU_1000BASEXFD : LLDP_DOT3_MAU_1000BASEXHD; break; case SPEED_10000: + // For fiber, we tell 10GIGBASEX and for others, + // 10GIGBASER. It's not unusual to have 10GIGBASER on + // fiber either but we don't have 10GIGBASET for + // copper. No good solution. port->p_macphy.mau_type = (ethc.port == PORT_FIBRE) ? \ LLDP_DOT3_MAU_10GIGBASEX : LLDP_DOT3_MAU_10GIGBASER; break; diff --git a/src/lldp-const.h b/src/lldp-const.h index 6e0a60e0..1e69e4bc 100644 --- a/src/lldp-const.h +++ b/src/lldp-const.h @@ -47,7 +47,7 @@ #define LLDP_PORTID_SUBTYPE_LOCAL 7 #define LLDP_PORTID_SUBTYPE_MAX LLDP_PORTID_SUBTYPE_LOCAL -/* Operational MAU Type field, from RFC 3636 */ +/* Operational MAU Type field, from RFC 3636 (see IANAifMauTypeListBits) */ #define LLDP_DOT3_MAU_AUI 1 #define LLDP_DOT3_MAU_10BASE5 2 #define LLDP_DOT3_MAU_FOIRL 3 @@ -88,6 +88,19 @@ #define LLDP_DOT3_MAU_10GIGBASEEW 38 #define LLDP_DOT3_MAU_10GIGBASELW 39 #define LLDP_DOT3_MAU_10GIGBASESW 40 +#define LLDP_DOT3_MAU_10GIGBASECX4 41 +#define LLDP_DOT3_MAU_2BASETL 42 +#define LLDP_DOT3_MAU_10PASSTS 43 +#define LLDP_DOT3_MAU_100BASEBX10D 44 +#define LLDP_DOT3_MAU_100BASEBX10U 45 +#define LLDP_DOT3_MAU_100BASELX10 46 +#define LLDP_DOT3_MAU_1000BASEBX10D 47 +#define LLDP_DOT3_MAU_1000BASEBX10U 48 +#define LLDP_DOT3_MAU_1000BASELX10 49 +#define LLDP_DOT3_MAU_1000BASEPX10D 50 +#define LLDP_DOT3_MAU_1000BASEPX10U 51 +#define LLDP_DOT3_MAU_1000BASEPX20D 52 +#define LLDP_DOT3_MAU_1000BASEPX20U 53 /* Dot3 Power Devicetype */ #define LLDP_DOT3_POWER_PSE 1 @@ -116,7 +129,7 @@ #define LLDP_DOT3_POWER_PRIO_HIGH 2 #define LLDP_DOT3_POWER_PRIO_LOW 3 -/* PMD Auto-Negotiation Advertised Capability field, from RFC 3636 */ +/* PMD Auto-Negotiation Advertised Capability field, from RFC 3636 (see IANAifMauAutoNegCapBits) */ #define LLDP_DOT3_LINK_AUTONEG_OTHER 0x8000 #define LLDP_DOT3_LINK_AUTONEG_10BASE_T 0x4000 #define LLDP_DOT3_LINK_AUTONEG_10BASET_FD 0x2000