lldpd (1.0.6)
* Fix:
+ Do not loose chassis local information when interface status changes.
+ + Fix SNMP walk on lldpRemTable when missing remote system
+ name or description.
* Changes:
+ Deprecate use of lldpctl_watch_callback(). Use
lldpctl_watch_callback2() instead.
agent_h_local_chassis(struct variable *vp, oid *name, size_t *length,
int exact, size_t *var_len, WriteMethod **write_method)
{
+ u_char *a;
+
if (header_generic(vp, name, length, exact, var_len, write_method))
return NULL;
- return agent_v_chassis(vp, var_len, LOCAL_CHASSIS(scfg));
+ if ((a = agent_v_chassis(vp, var_len, LOCAL_CHASSIS(scfg))) != NULL)
+ return a;
+ TRYNEXT(agent_h_local_chassis);
}
static u_char*
agent_h_remote_chassis(struct variable *vp, oid*name, size_t *length,
int exact, size_t *var_len, WriteMethod **write_method)
{
struct lldpd_port *port;
+ u_char *a;
if ((port = header_tprindexed_table(vp, name, length,
exact, var_len, write_method, 0)) == NULL)
return NULL;
- return agent_v_chassis(vp, var_len, port->p_chassis);
+ if ((a = agent_v_chassis(vp, var_len, port->p_chassis)) != NULL)
+ return a;
+ TRYNEXT(agent_h_remote_chassis);
}
static u_char*
long_ret = hardware->h_ageout_cnt;
return (u_char *)&long_ret;
default:
- break;
+ return NULL;
}
- return NULL;
}
#ifdef ENABLE_DOT1
*var_len = strlen(vlan->v_name);
return (u_char *)vlan->v_name;
default:
- break;
+ return NULL;
}
- return NULL;
}
static u_char*
agent_h_local_vlan(struct variable *vp, oid *name, size_t *length,
long_ret = (ppvid->p_cap_status & LLDP_PPVID_CAP_ENABLED)?1:2;
return (u_char *)&long_ret;
default:
- break;
+ return NULL;
}
- return NULL;
}
static u_char*
agent_h_local_ppvid(struct variable *vp, oid *name, size_t *length,
*var_len = pi->p_pi_len;
return (u_char *)pi->p_pi;
default:
- break;
+ return NULL;
}
- return NULL;
}
static u_char*
agent_h_local_pi(struct variable *vp, oid *name, size_t *length,
int exact, size_t *var_len, WriteMethod **write_method)
-{
+{
struct lldpd_pi *pi;
if ((pi = header_ppiindexed_table(vp, name, length,
*var_len = sizeof(zeroDotZero);
return (u_char*)zeroDotZero;
default:
- break;
+ return NULL;
}
- return NULL;
}
static u_char*
agent_h_local_management(struct variable *vp, oid *name, size_t *length,
*var_len = custom->oui_info_len;
return (u_char *)custom->oui_info;
default:
- break;
+ return NULL;
}
- return NULL;
}
static u_char*
agent_h_remote_custom(struct variable *vp, oid *name, size_t *length,
+pytest_plugins = ['helpers_namespace']
+
import pytest
+import scapy.all
+
from fixtures.programs import *
from fixtures.namespaces import *
from fixtures.network import *
# _lldpd. Just do a plain namespace.
with Namespace('pid', 'net', 'mnt', 'ipc', 'uts'):
yield
+
+
+@pytest.helpers.register
+def send_pcap(location, interface):
+ packets = scapy.all.rdpcap(location)
+ print(packets)
+ scapy.all.sendp(packets, iface=interface)
pyroute2==0.5.2
pytest==3.10.1
+pytest-helpers-namespace==2019.1.8
pytest-xdist==1.26.1
scapy==2.4.3
import pytest
-import scapy.all
-
-
-def send_pcap(location, interface):
- packets = scapy.all.rdpcap(location)
- print(packets)
- scapy.all.sendp(packets, iface=interface)
def test_cisco_sg200(request, lldpd1, lldpcli, namespaces):
with namespaces(2):
- send_pcap('data/sg200.pcap', 'eth1')
+ pytest.helpers.send_pcap('data/sg200.pcap', 'eth1')
with namespaces(1):
out = lldpcli("-f", "keyvalue", "show", "neighbors", "details")
assert out['lldp.eth0.age'].startswith('0 day, 00:00:')
readon="Dot3 not supported")
def test_8023bt(lldpd1, lldpcli, namespaces):
with namespaces(2):
- send_pcap('data/8023bt.pcap', 'eth1')
+ pytest.helpers.send_pcap('data/8023bt.pcap', 'eth1')
with namespaces(1):
out = lldpcli("-f", "keyvalue", "show", "neighbors", "details")
for k in list(out.keys()):
import pytest
-import time
pytestmark = pytest.mark.skipif("not config.lldpd.snmp",
reason="no SNMP support")
assert out['.1.0.8802.1.1.2.1.3.3.0'] == 'STRING: "ns-1.example.com"'
assert out['.1.0.8802.1.1.2.1.3.4.0'].startswith(
'STRING: "Spectacular GNU/Linux 2016 Linux')
+
+
+def test_snmp_empty_sysname(snmpd, snmpwalk, lldpd, links, namespaces):
+ # See https://github.com/vincentbernat/lldpd/issues/392
+ links(namespaces(1), namespaces(2))
+ links(namespaces(1), namespaces(3))
+ links(namespaces(1), namespaces(4))
+ with namespaces(1):
+ snmpd()
+ lldpd("-x")
+ with namespaces(2):
+ lldpd()
+ with namespaces(3):
+ # Packet without sysName
+ lldpd("-r")
+ pytest.helpers.send_pcap('data/connectx.pcap', 'eth3')
+ with namespaces(4):
+ lldpd()
+ with namespaces(1):
+ out = snmpwalk(".1.0.8802.1.1.2.1.4.1.1.9") # lldpRemSysName
+ # We should get something like:
+ # .1.0.8802.1.1.2.1.4.1.1.9.400.3.1 STRING: "ns-2.example.com"
+ # .1.0.8802.1.1.2.1.4.1.1.9.700.5.2 (not present)
+ # .1.0.8802.1.1.2.1.4.1.1.9.1000.7.3 STRING: "ns-4.example.com"
+ print(out)
+ assert list(out.values()) == ['STRING: "ns-2.example.com"',
+ 'STRING: "ns-4.example.com"']
+ oids = list(out.keys())
+ assert oids[0].endswith(".3.1")
+ assert oids[1].endswith(".7.3")