]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lldpd: fix how LLDP can be disabled
authorVincent Bernat <vincent@bernat.im>
Sun, 15 Jun 2014 08:07:30 +0000 (10:07 +0200)
committerVincent Bernat <vincent@bernat.im>
Sun, 15 Jun 2014 08:07:30 +0000 (10:07 +0200)
Commit 46baf62775eaca47075e1d9966a2103fd466e4b3 broke the ability to
disable LLDP. Instead of trying to be smart, just enumerate all the
possible cases.

src/daemon/lldpd.c

index 116c02cf6c5699f4f0d9ee0cfeba8cd989f33a82..4c32f277d96058dbd97833e0cc6bf0b4b4dde2a2 100644 (file)
@@ -1398,11 +1398,8 @@ lldpd_main(int argc, char *argv[], char *envp[])
                        found = 0;
                        for (i=0; protos[i].mode != 0; i++) {
                                if (ch == protos[i].arg) {
-                                       if (protos[i].enabled < 3) {
-                                               found = 1;
-                                               if (protos[i].enabled++ == 1)
-                                                       break;
-                                       }
+                                       found = 1;
+                                       protos[i].enabled++;
                                }
                        }
                        if (!found)
@@ -1577,13 +1574,27 @@ lldpd_main(int argc, char *argv[], char *envp[])
 
        log_debug("main", "initialize protocols");
        cfg->g_protocols = protos;
-       for (i=0; protos[i].mode != 0; i++)
+       for (i=0; protos[i].mode != 0; i++) {
+
+               /* With -ll, disable LLDP */
+               if (protos[i].mode == LLDPD_MODE_LLDP)
+                       protos[i].enabled %= 3;
+               /* With -ccc force CDPV2, enable CDPV1 */
+               if (protos[i].mode == LLDPD_MODE_CDPV1 && protos[i].enabled == 3) {
+                       protos[i].enabled = 1;
+               }
+               /* With -cc force CDPV1, enable CDPV2 */
+               if (protos[i].mode == LLDPD_MODE_CDPV2 && protos[i].enabled == 2) {
+                       protos[i].enabled = 1;
+               }
+
                if (protos[i].enabled > 1)
                        log_info("main", "protocol %s enabled and forced", protos[i].name);
                else if (protos[i].enabled)
                        log_info("main", "protocol %s enabled", protos[i].name);
                else
                        log_info("main", "protocol %s disabled", protos[i].name);
+           }
 
        TAILQ_INIT(&cfg->g_hardware);
        TAILQ_INIT(&cfg->g_chassis);