]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
client: don't display management interface index if unknown
authorVincent Bernat <vincent@bernat.ch>
Sat, 27 Jul 2019 15:36:35 +0000 (17:36 +0200)
committerVincent Bernat <vincent@bernat.ch>
Sat, 27 Jul 2019 15:36:35 +0000 (17:36 +0200)
src/client/display.c
tests/integration/test_basic.py

index dc130703f61a250c268f20ff5843d273f2f57b7c..d416e5d4d69078ef295668ec0b7127b608dd5a3f 100644 (file)
@@ -258,8 +258,9 @@ display_chassis(struct writer* w, lldpctl_atom_t* chassis, int details)
        lldpctl_atom_foreach(mgmts, mgmt) {
                tag_datatag(w, "mgmt-ip", "MgmtIP",
                    lldpctl_atom_get_str(mgmt, lldpctl_k_mgmt_ip));
-               tag_datatag(w, "mgmt-iface", "MgmtIface",
-                   lldpctl_atom_get_str(mgmt, lldpctl_k_mgmt_iface_index));
+               if (lldpctl_atom_get_int(mgmt, lldpctl_k_mgmt_iface_index))
+                       tag_datatag(w, "mgmt-iface", "MgmtIface",
+                           lldpctl_atom_get_str(mgmt, lldpctl_k_mgmt_iface_index));
        }
        lldpctl_atom_dec_ref(mgmts);
 
index f2cea6ba1565ff54e4e004c0412c8c720713e44d..3e31d5327bc6f545af2b4a237e366a89166cce34 100644 (file)
@@ -152,7 +152,7 @@ def test_forced_unknown_management_address(lldpd1, lldpd, lldpcli, namespaces):
     with namespaces(1):
         out = lldpcli("-f", "keyvalue", "show", "neighbors")
         assert out["lldp.eth0.chassis.mgmt-ip"] == "2001:db8::47"
-        assert out["lldp.eth0.chassis.mgmt-iface"] == "0"
+        assert "lldp.eth0.chassis.mgmt-iface" not in out
 
 
 def test_forced_known_management_address(lldpd1, lldpd, lldpcli, namespaces):