]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lldpd: add possibility to disable LLDP
authorVincent Bernat <vincent.bernat@dailymotion.com>
Mon, 12 Nov 2012 15:36:55 +0000 (16:36 +0100)
committerVincent Bernat <vincent.bernat@dailymotion.com>
Mon, 12 Nov 2012 15:36:55 +0000 (16:36 +0100)
LLDP was mandatory. It is now possible to disable it entirely with
`-ll`. In this case, when no neighbor is detected, the first enabled
protocol will be used. For example, with `-ll -c`, lldpd will act as a
pure CDP daemon.

NEWS
src/daemon/lldpd.8
src/daemon/lldpd.c

diff --git a/NEWS b/NEWS
index e572b2c51b7960181645f67582e8604e73f97991..9453aa97fbfbff2d27899e71c9402f6e0b9bee94 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,8 @@
+lldpd (0.6.2)
+  * Features:
+    + Allow to disable LLDP protocol (with `-ll`). In this case, the
+      first enabled protocol will be used when no neighbor is detected.
+
 lldpd (0.6.1)
   * Features:
     + Provide liblldpctl.so, a library to interface with lldpd. The
index 49f1449484c3b3bae97a86650f623821c210e0fb..ef97de634c7486f501d044565e30d5f56276f03d 100644 (file)
@@ -111,7 +111,7 @@ even when there is no EDP peer detected.
 Force to send LLDP packets even when there is no LLDP peer detected
 but there is a peer speaking another protocol detected. By default,
 LLDP packets are sent when there is a peer speaking LLDP detected or
-when there is no peer at all.
+when there is no peer at all. If repeated, LLDP is disabled.
 .It Fl r
 Receive-only mode. With this switch,
 .Nm
index b078cd4079269b87f4033e85fd66de1c0f4a3823..49a8b103b436cccce9feaf63ac1eb69204fba9d3 100644 (file)
@@ -711,10 +711,18 @@ lldpd_send_all(struct lldpd *cfg)
                        }
                }
 
-               if (!sent)
-                       /* Nothing was sent for this port, let's speak LLDP */
-                       cfg->g_protocols[0].send(cfg,
-                           hardware);
+               if (!sent) {
+                       /* Nothing was sent for this port, let's speak the first
+                        * available protocol. */
+                       for (i = 0; cfg->g_protocols[i].mode != 0; i++) {
+                               if (!cfg->g_protocols[i].enabled) continue;
+                               cfg->g_protocols[i].send(cfg,
+                                   hardware);
+                               break;
+                       }
+                       if (cfg->g_protocols[i].mode == 0)
+                               LLOG_WARNX("no protocol enabled, dunno what to send");
+               }
        }
 }
 
@@ -1027,6 +1035,7 @@ lldpd_main(int argc, char *argv[])
                        for (i=0; protos[i].mode != 0; i++) {
                                if (ch == protos[i].arg) {
                                        protos[i].enabled++;
+                                       protos[i].enabled %= 3;
                                        /* When an argument enable
                                           several protocols, only the
                                           first one can be forced. */