From 878441b274a73f6c67aeca1761bdf29a2a526c2f Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Thu, 1 Mar 2018 08:02:12 +0100 Subject: [PATCH] netlink: fix non-updated management address --- NEWS | 1 + src/daemon/netlink.c | 2 +- tests/integration/test_basic.py | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 48db878d..f40ba0f3 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ lldpd (1.0.0) chassisid". * Fix: + Ensure chassis-related changes are propagated immediately. + + Ensure management address change is correctly detected. lldpd (0.9.9) * Changes: diff --git a/src/daemon/netlink.c b/src/daemon/netlink.c index 36696139..fdb01001 100644 --- a/src/daemon/netlink.c +++ b/src/daemon/netlink.c @@ -606,7 +606,7 @@ retry: TAILQ_FOREACH(ifaold, ifas, next) { if ((ifaold->index == ifanew->index) && !memcmp(&ifaold->address, &ifanew->address, - sizeof(ifaold->address))) continue; + sizeof(ifaold->address))) break; } if (getnameinfo((struct sockaddr *)&ifanew->address, sizeof(ifanew->address), diff --git a/tests/integration/test_basic.py b/tests/integration/test_basic.py index 1ff7f4b7..d26f8c88 100644 --- a/tests/integration/test_basic.py +++ b/tests/integration/test_basic.py @@ -164,6 +164,27 @@ def test_management_address(lldpd1, lldpd, lldpcli, links, namespaces): assert out["lldp.eth0.chassis.mgmt-ip"] == "172.25.21.47" +def test_change_management_address(lldpd1, lldpd, lldpcli, links, namespaces): + with namespaces(2): + ipr = pyroute2.IPRoute() + idx = ipr.link_lookup(ifname="eth1")[0] + ipr.addr('add', index=idx, address="192.168.14.2", mask=24) + lldpd("-m", "192.168.*") + # We need a short TX interval as updating the IP address + # doesn't trigger a resend. + lldpcli("configure", "lldp", "tx-interval", "2") + with namespaces(1): + out = lldpcli("-f", "keyvalue", "show", "neighbors") + assert out["lldp.eth0.chassis.mgmt-ip"] == "192.168.14.2" + with namespaces(2): + ipr.addr('del', index=idx, address="192.168.14.2", mask=24) + ipr.addr('add', index=idx, address="192.168.14.5", mask=24) + time.sleep(5) + with namespaces(1): + out = lldpcli("-f", "keyvalue", "show", "neighbors") + assert out["lldp.eth0.chassis.mgmt-ip"] == "192.168.14.5" + + def test_portid_subtype_ifname(lldpd1, lldpd, lldpcli, namespaces): with namespaces(2): lldpd() -- 2.39.2