]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lldpd: make fast start work only when receiving LLDP-MED LLDPDU
authorVincent Bernat <bernat@luffy.cx>
Wed, 8 May 2013 10:23:27 +0000 (12:23 +0200)
committerVincent Bernat <bernat@luffy.cx>
Wed, 8 May 2013 10:23:27 +0000 (12:23 +0200)
src/daemon/event.c
src/daemon/lldpd.c
src/lldpd-structs.h

index 91aef84d0fe74eaa5c7763375f999e447199099b..2e7dced3b925787fd428cf6204ac5929bae9cd24 100644 (file)
@@ -709,19 +709,20 @@ static void
 levent_send_pdu(evutil_socket_t fd, short what, void *arg)
 {
        struct lldpd_hardware *hardware = arg;
-       int tx_interval;
+       int tx_interval = hardware->h_cfg->g_config.c_tx_interval;
 
        log_debug("event", "trigger sending PDU for port %s",
            hardware->h_ifname);
        lldpd_send(hardware);
 
+#ifdef ENABLE_LLDPMED
        if (hardware->h_tx_fast > 0)
                hardware->h_tx_fast--;
 
        if (hardware->h_tx_fast > 0)
                tx_interval = hardware->h_cfg->g_config.c_tx_fast_interval;
-       else
-               tx_interval = hardware->h_cfg->g_config.c_tx_interval;
+#endif
+
        struct timeval tv = { tx_interval, 0 };
        if (event_add(hardware->h_timer, &tv) == -1) {
                log_warnx("event", "unable to re-register timer event for port %s",
index e1ac868f0bd11911bfd6df61e66886eea7beea20..49a0e51f2abbb2a11a30bba4179f410249ab3111 100644 (file)
@@ -529,17 +529,19 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s,
        agent_notify(hardware, i, port);
 #endif
 
-       if (!oport) {
+#ifdef ENABLE_LLDPMED
+       if (!oport && port->p_chassis->c_med_type) {
                /* New neighbor, fast start */
                if (hardware->h_cfg->g_config.c_enable_fast_start &&
-                               !hardware->h_tx_fast) {
-                       log_debug("decode", "%s: Entering fast start due to "
-                                 "new neighbor\n", hardware->h_ifname);
+                   !hardware->h_tx_fast) {
+                       log_debug("decode", "%s: entering fast start due to "
+                           "new neighbor", hardware->h_ifname);
                        hardware->h_tx_fast = hardware->h_cfg->g_config.c_tx_fast_init;
                }
 
                levent_schedule_pdu(hardware);
        }
+#endif
 
        return;
 }
@@ -1195,6 +1197,7 @@ lldpd_main(int argc, char *argv[])
        int i, found, advertise_version = 1;
 #ifdef ENABLE_LLDPMED
        int lldpmed = 0, noinventory = 0;
+       int enable_fast_start = 0;
 #endif
        char *descr_override = NULL;
        char *platform_override = NULL;
@@ -1203,7 +1206,6 @@ lldpd_main(int argc, char *argv[])
        int smart = 15;
        int receiveonly = 0;
        int ctl;
-       int enable_fast_start = 0;
 
        /* Non privileged user */
        struct passwd *user;
@@ -1427,8 +1429,10 @@ lldpd_main(int argc, char *argv[])
        cfg->g_config.c_tx_interval = LLDPD_TX_INTERVAL;
        cfg->g_config.c_max_neighbors = LLDPD_MAX_NEIGHBORS;
        cfg->g_config.c_enable_fast_start = enable_fast_start;
+#ifdef ENABLE_LLDPMED
        cfg->g_config.c_tx_fast_init = LLDPD_FAST_INIT;
        cfg->g_config.c_tx_fast_interval = LLDPD_FAST_TX_INTERVAL;
+#endif
 #ifdef USE_SNMP
        cfg->g_snmp = snmp;
        cfg->g_snmp_agentx = agentx;
index 0c7b8786a40356f3862b8852cdaf86990f72b530..1c47919d417c30e297960214660859ce409c18ec 100644 (file)
@@ -327,10 +327,10 @@ struct lldpd_config {
 
 #ifdef ENABLE_LLDPMED
        int c_noinventory;      /* Don't send inventory with LLDP-MED */
-#endif
        int c_enable_fast_start; /* enable fast start */
        int c_tx_fast_init;     /* Num of lldpd lldppdu's for fast start */
        int c_tx_fast_interval; /* Time intr between sends during fast start */
+#endif
 };
 MARSHAL_BEGIN(lldpd_config)
 MARSHAL_STR(lldpd_config, c_mgmt_pattern)
@@ -393,7 +393,9 @@ struct lldpd_hardware {
        struct lldpd_port        h_lport;  /* Port attached to this hardware port */
        TAILQ_HEAD(, lldpd_port) h_rports; /* Remote ports */
 
+#ifdef ENABLE_LLDPMED
        int                     h_tx_fast; /* current tx fast start count */
+#endif
 };
 MARSHAL_BEGIN(lldpd_hardware)
 MARSHAL_IGNORE(lldpd_hardware, h_entries.tqe_next)