lldpd (0.9.7)
* Changes:
+ + Attach remote TTL to port instead of chassis.
+ JSON support is now built-in and unconditionally enabled. Use
--enable-json0 to keep the pre-0.9.2 json-c format.
+ When logging to syslog and daemonizing, don't log to stderr.
}
tag_datatag(w, "descr", "SysDescr",
lldpctl_atom_get_str(chassis, lldpctl_k_chassis_descr));
- if (details)
+ if (details && lldpctl_atom_get_int(chassis, lldpctl_k_chassis_ttl) > 0)
tag_datatag(w, "ttl", "TTL",
lldpctl_atom_get_str(chassis, lldpctl_k_chassis_ttl));
tag_datatag(w, "descr", "PortDescr",
lldpctl_atom_get_str(port, lldpctl_k_port_descr));
+ if (details)
+ tag_datatag(w, "ttl", "TTL",
+ lldpctl_atom_get_str(port, lldpctl_k_port_ttl));
/* Dot3 */
if (details == DISPLAY_DETAILS) {
struct lldpd_port *port;
TAILQ_FOREACH(hardware, &cfg->g_hardware, h_entries) {
TAILQ_FOREACH(port, &hardware->h_rports, p_entries) {
- if (now >= port->p_lastupdate + port->p_chassis->c_ttl) {
+ if (now >= port->p_lastupdate + port->p_ttl) {
tv.tv_sec = 0;
log_debug("event", "immediate cleanup on port %s (%lld, %d, %lld)",
hardware->h_ifname,
(long long)now,
- port->p_chassis->c_ttl,
+ port->p_ttl,
(long long)port->p_lastupdate);
break;
}
- next = port->p_chassis->c_ttl - (now - port->p_lastupdate);
+ next = port->p_ttl - (now - port->p_lastupdate);
if (next < tv.tv_sec)
tv.tv_sec = next;
}
version, hardware->h_ifname);
goto malformed;
}
- chassis->c_ttl = PEEK_UINT8; /* TTL */
+ port->p_ttl = PEEK_UINT8; /* TTL */
PEEK_DISCARD_UINT16; /* Checksum, already checked */
while (length) {
(chassis->c_name == NULL) ||
(chassis->c_descr == NULL) ||
(port->p_descr == NULL) ||
- (chassis->c_ttl == 0) ||
+ (port->p_ttl == 0) ||
(chassis->c_cap_enabled == 0)) {
log_warnx("cdp", "some mandatory CDP/FDP tlv are missing for frame received on %s",
hardware->h_ifname);
hardware->h_ifname);
goto malformed;
}
- chassis->c_ttl = cfg?cfg->g_config.c_tx_interval * cfg->g_config.c_tx_hold:0;
+ port->p_ttl = cfg?cfg->g_config.c_tx_interval * cfg->g_config.c_tx_hold:0;
chassis->c_id_subtype = LLDP_CHASSISID_SUBTYPE_LLADDR;
chassis->c_id_len = ETHER_ADDR_LEN;
if ((chassis->c_id = (char *)malloc(ETHER_ADDR_LEN)) == NULL) {
break;
case LLDP_TLV_TTL:
CHECK_TLV_SIZE(2, "TTL");
- chassis->c_ttl = PEEK_UINT16;
+ port->p_ttl = PEEK_UINT16;
ttl_received = 1;
break;
case LLDP_TLV_PORT_DESCR:
goto malformed;
}
TAILQ_INSERT_TAIL(&chassis->c_mgmt, mgmt, m_entries);
- chassis->c_ttl = cfg?(cfg->g_config.c_tx_interval * cfg->g_config.c_tx_hold):
+ port->p_ttl = cfg?(cfg->g_config.c_tx_interval * cfg->g_config.c_tx_hold):
LLDPD_TTL;
port->p_id_subtype = LLDP_PORTID_SUBTYPE_LOCAL;
return port->p_protocol;
case lldpctl_k_port_age:
return port->p_lastchange;
+ case lldpctl_k_port_ttl:
+ return port->p_ttl;
case lldpctl_k_port_id_subtype:
return port->p_id_subtype;
case lldpctl_k_port_hidden:
lldpctl_k_port_hidden, /**< `(I)` Is this port hidden (or should it be displayed?)? */
lldpctl_k_port_status, /**< `(IS,WO)` Operational status of this (local) port */
lldpctl_k_port_chassis, /**< `(A)` Chassis associated to the port */
+ lldpctl_k_port_ttl, /**< `(I)` TTL for port, 0 if info is attached to chassis */
lldpctl_k_port_dot3_mfs = 1300, /**< `(I)` MFS */
lldpctl_k_port_dot3_aggregid, /**< `(I)` Port aggregation ID */
port_next = TAILQ_NEXT(port, p_entries);
del = all;
if (!all && expire &&
- (now >= port->p_lastupdate + port->p_chassis->c_ttl)) {
+ (now >= port->p_lastupdate + port->p_ttl)) {
hardware->h_ageout_cnt++;
hardware->h_delete_cnt++;
del = 1;
u_int16_t c_cap_available;
u_int16_t c_cap_enabled;
- u_int16_t c_ttl;
+ u_int16_t c_ttl; /* TTL for local chassis */
TAILQ_HEAD(, lldpd_mgmt) c_mgmt;
char *p_descr;
int p_descr_force; /* Description has been forced by user */
u_int16_t p_mfs;
+ u_int16_t p_ttl; /* TTL for remote port */
#ifdef ENABLE_DOT3
/* Dot3 stuff */
LLDP_PORTID_SUBTYPE_LLADDR);
ck_assert_int_eq(nport->p_id_len, ETHER_ADDR_LEN);
fail_unless(memcmp(mac2, nport->p_id, ETHER_ADDR_LEN) == 0);
- ck_assert_int_eq(nchassis->c_ttl, 120);
ck_assert_ptr_eq(nchassis->c_name, NULL);
ck_assert_ptr_eq(nchassis->c_descr, NULL);
ck_assert_ptr_eq(nport->p_descr, NULL);
+ ck_assert_int_eq(nport->p_ttl, 120);
}
END_TEST
LLDP_PORTID_SUBTYPE_LLADDR);
ck_assert_int_eq(nport->p_id_len, ETHER_ADDR_LEN);
fail_unless(memcmp(mac1, nport->p_id, ETHER_ADDR_LEN) == 0);
- ck_assert_int_eq(nchassis->c_ttl, 120);
+ ck_assert_int_eq(nport->p_ttl, 120);
ck_assert_str_eq(nchassis->c_name, "naruto.XXXXXXXXXXXXXXXXXXX");
ck_assert_str_eq(nchassis->c_descr,
"Linux 2.6.29-2-amd64 #1 SMP Sun May 17 17:15:47 UTC 2009 x86_64");
printf(" ID: %s\n", tohex(nport->p_id, nport->p_id_len));
printf(" Description: %s\n", nport->p_descr?nport->p_descr:"(null)");
printf(" MFS: %" PRIu16 "\n", nport->p_mfs);
+ printf(" TTL: %" PRIu16 "\n", nport->p_ttl);
#ifdef ENABLE_DOT3
printf(" Dot3 aggrID: %" PRIu32 "\n", nport->p_aggregid);
printf(" Dot3 MAC/phy autoneg supported: %" PRIu8 "\n", nport->p_macphy.autoneg_support);
"lldp.eth0.rid": "1",
"lldp.eth0.chassis.mac": "00:00:00:00:00:02",
"lldp.eth0.chassis.name": "ns-2.example.com",
- "lldp.eth0.chassis.ttl": "120",
"lldp.eth0.chassis.mgmt-ip": "fe80::200:ff:fe00:2",
"lldp.eth0.chassis.Bridge.enabled": "off",
"lldp.eth0.chassis.Wlan.enabled": "off",
"lldp.eth0.port.mac": "00:00:00:00:00:02",
- "lldp.eth0.port.descr": "eth1"}
+ "lldp.eth0.port.descr": "eth1",
+ "lldp.eth0.port.ttl": "120"}
@pytest.mark.parametrize("neighbors", (5, 10, 20))
ChassisID: mac 00:00:00:00:00:02
SysName: ns-2.example.com
SysDescr: Spectacular GNU/Linux 2016 {uname}
- TTL: 120
MgmtIP: fe80::200:ff:fe00:2
Capability: Bridge, off
Capability: Router, {router}
Capability: Station, {station}
Port:
PortID: mac 00:00:00:00:00:02
- PortDescr: eth1{dot3}
+ PortDescr: eth1
+ TTL: 120{dot3}
-------------------------------------------------------------------------------
"""
out = result.stdout.decode('ascii')
"value": "00:00:00:00:00:02"
},
"descr": "Spectacular GNU/Linux 2016 {}".format(uname),
- "ttl": "120",
"mgmt-ip": "fe80::200:ff:fe00:2",
"capability": [
{"type": "Bridge", "enabled": False},
"type": "mac",
"value": "00:00:00:00:00:02"
},
- "descr": "eth1"
+ "descr": "eth1",
+ "ttl": "120"
}
}}
}}
<id label="ChassisID" type="mac">00:00:00:00:00:02</id>
<name label="SysName">ns-2.example.com</name>
<descr label="SysDescr">Spectacular GNU/Linux 2016 {uname}</descr>
- <ttl label="TTL">120</ttl>
<mgmt-ip label="MgmtIP">fe80::200:ff:fe00:2</mgmt-ip>
<capability label="Capability" type="Bridge" enabled="off"/>
<capability label="Capability" type="Router" enabled="{router}"/>
</chassis>
<port label="Port">
<id label="PortID" type="mac">00:00:00:00:00:02</id>
- <descr label="PortDescr">eth1</descr>{dot3}
+ <descr label="PortDescr">eth1</descr>
+ <ttl label="TTL">120</ttl>{dot3}
</port>
</interface>
</lldp>
"lldp.eth0.via": "LLDP",
"lldp.eth0.rid": "1",
"lldp.eth0.chassis.mac": "00:35:35:35:35:35",
- "lldp.eth0.chassis.ttl": "120",
+ "lldp.eth0.port.ttl": "120",
"lldp.eth0.port.ifname": "g1",
}
if 'Dot3' in pytest.config.lldpd.features: