]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lldp: update RFC3636 to RFC4836
authorVincent Bernat <vincent@bernat.im>
Sun, 7 Aug 2016 06:14:43 +0000 (08:14 +0200)
committerVincent Bernat <vincent@bernat.im>
Sun, 7 Aug 2016 06:14:43 +0000 (08:14 +0200)
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).

src/daemon/interfaces-bsd.c
src/daemon/interfaces-linux.c
src/lldp-const.h

index 8b658e3c5a8ee073258584aebc91e4410b40859b..a2c3c501d30ec554d70ca55c8fb8a645f58859e5 100644 (file)
@@ -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;
index c2d4e61384b271fea0ed810558b17bb078bab0b3..663cd0ac1c651250e00341edf6e2ec0010b46afd 100644 (file)
@@ -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;
index 6e0a60e0071144b094f99c63e6c551e595e2f86a..1e69e4bcb9c2edd541b7625252d8f2ce7783b8be 100644 (file)
@@ -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
 #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
 #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