From: Vincent Bernat Date: Mon, 12 Nov 2012 15:36:55 +0000 (+0100) Subject: lldpd: add possibility to disable LLDP X-Git-Tag: 0.7.0~70 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=46baf62775eaca47075e1d9966a2103fd466e4b3;p=thirdparty%2Flldpd.git lldpd: add possibility to disable LLDP 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. --- diff --git a/NEWS b/NEWS index e572b2c5..9453aa97 100644 --- 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 diff --git a/src/daemon/lldpd.8 b/src/daemon/lldpd.8 index 49f14494..ef97de63 100644 --- a/src/daemon/lldpd.8 +++ b/src/daemon/lldpd.8 @@ -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 diff --git a/src/daemon/lldpd.c b/src/daemon/lldpd.c index b078cd40..49a8b103 100644 --- a/src/daemon/lldpd.c +++ b/src/daemon/lldpd.c @@ -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. */