]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
interfaces: don't modify chassis ID when overriden fix/chassisid-interface-flap 386/head
authorVincent Bernat <vincent@bernat.ch>
Sat, 11 Apr 2020 14:21:30 +0000 (16:21 +0200)
committerVincent Bernat <vincent@bernat.ch>
Sat, 11 Apr 2020 14:22:44 +0000 (16:22 +0200)
If the chassis ID has been overriden by the user, do not modify it.

Fix #385

NEWS
src/daemon/interfaces.c
tests/integration/test_basic.py

diff --git a/NEWS b/NEWS
index 2f2756b0e973f0d440a03999798b0cf63f4eb2fc..f98609172652daa889355f733c0b7827ff93ad91 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,7 @@
+lldpd (1.0.6)
+  * Fix:
+    + Do not loose chassis local information when interface status changes.
+
 lldpd (1.0.5)
   * Changes:
     + Interface names are also matched for management addresses.
index 5664b2d0a299056b2f0d797d50522690ff5a6fd2..b9521f6a4e7dba121cbe8a8217d07109c9ac8f51 100644 (file)
@@ -364,8 +364,12 @@ interfaces_helper_chassis(struct lldpd *cfg,
                (LOCAL_CHASSIS(cfg)->c_cap_enabled == 0))
            LOCAL_CHASSIS(cfg)->c_cap_enabled = LLDP_CAP_STATION;
 
-       if (LOCAL_CHASSIS(cfg)->c_id != NULL &&
-           LOCAL_CHASSIS(cfg)->c_id_subtype == LLDP_CHASSISID_SUBTYPE_LLADDR)
+       /* Do not modify the chassis if it's already set to a MAC address or if
+        * it's set to a local address equal to the user-provided
+        * configuration. */
+       if ((LOCAL_CHASSIS(cfg)->c_id != NULL &&
+           LOCAL_CHASSIS(cfg)->c_id_subtype == LLDP_CHASSISID_SUBTYPE_LLADDR) ||
+           cfg->g_config.c_cid_string != NULL)
                return;         /* We already have one */
 
        TAILQ_FOREACH(iface, interfaces, next) {
index cb4b91d6eb6cac9f5fbfbb42a59abb8e988a7da8..488b235c24e30e1c7bb771e86b2fe8b1810e6e1d 100644 (file)
@@ -133,6 +133,21 @@ def test_overrided_chassisid(lldpd1, lldpd, lldpcli, namespaces):
         assert out['lldp.eth0.chassis.local'] == "Modified chassis ID"
 
 
+def test_overrided_chassisid_kept(lldpd1, lldpd, lldpcli, namespaces, links):
+    with namespaces(2):
+        lldpd()
+        lldpcli("configure", "system", "chassisid", "Modified chassis ID")
+        links.down("eth1")
+        time.sleep(1)
+        links.up("eth1")
+        time.sleep(1)
+        lldpcli("update")
+        time.sleep(1)
+    with namespaces(1):
+        out = lldpcli("-f", "keyvalue", "show", "neighbors")
+        assert out['lldp.eth0.chassis.local'] == "Modified chassis ID"
+
+
 def test_overrided_chassisid_reverse(lldpd1, lldpd, lldpcli, namespaces):
     with namespaces(2):
         lldpd()