hardware_next = TAILQ_NEXT(hardware, h_entries);
if (!hardware->h_flags) {
TAILQ_REMOVE(&cfg->g_hardware, hardware, h_entries);
- lldpd_remote_cleanup(hardware, NULL);
+ lldpd_remote_cleanup(hardware, notify_clients_deletion, 1);
lldpd_hardware_cleanup(cfg, hardware);
} else
- lldpd_remote_cleanup(hardware, notify_clients_deletion);
+ lldpd_remote_cleanup(hardware, notify_clients_deletion, 0);
}
log_debug("localchassis", "cleanup all chassis");
hardware = hardware_next) {
hardware_next = TAILQ_NEXT(hardware, h_entries);
log_debug("main", "cleanup interface %s", hardware->h_ifname);
- lldpd_remote_cleanup(hardware, NULL);
+ lldpd_remote_cleanup(hardware, NULL, 1);
lldpd_hardware_cleanup(cfg, hardware);
}
}
add_chassis(&chassis_list, one_port->p_chassis);
/* Free hardware port */
- lldpd_remote_cleanup(hardware, NULL);
+ lldpd_remote_cleanup(hardware, NULL, 1);
lldpd_port_cleanup(port->port, 1);
free(port->hardware);
}
#endif
-/* Cleanup a remote port. The last argument, `expire` is a function that should
- * be called when expiration happens. If it is NULL, all remote ports are
- * removed. */
+/* Cleanup a remote port. The before last argument, `expire` is a function that
+ * should be called when a remote port is removed. If the last argument is 1,
+ * all remote ports are removed.
+ */
void
lldpd_remote_cleanup(struct lldpd_hardware *hardware,
- void(*expire)(struct lldpd_hardware *, struct lldpd_port *))
+ void(*expire)(struct lldpd_hardware *, struct lldpd_port *),
+ int all)
{
struct lldpd_port *port, *port_next;
int del;
port != NULL;
port = port_next) {
port_next = TAILQ_NEXT(port, p_entries);
- del = (expire == NULL);
+ del = all;
if (expire &&
(now - port->p_lastupdate >= port->p_chassis->c_ttl)) {
hardware->h_ageout_cnt++;
hardware->h_delete_cnt++;
- expire(hardware, port);
del = 1;
}
if (del) {
- if (expire)
- TAILQ_REMOVE(&hardware->h_rports, port, p_entries);
+ expire(hardware, port);
+ TAILQ_REMOVE(&hardware->h_rports, port, p_entries);
lldpd_port_cleanup(port, 1);
free(port);
}
}
- if (!expire) TAILQ_INIT(&hardware->h_rports);
+ if (all) TAILQ_INIT(&hardware->h_rports);
}
/* If `all' is true, clear all information, including information that
void lldpd_chassis_mgmt_cleanup(struct lldpd_chassis *);
void lldpd_chassis_cleanup(struct lldpd_chassis *, int);
void lldpd_remote_cleanup(struct lldpd_hardware *,
- void(*expire)(struct lldpd_hardware *, struct lldpd_port *));
+ void(*expire)(struct lldpd_hardware *, struct lldpd_port *),
+ int);
void lldpd_port_cleanup(struct lldpd_port *, int);
void lldpd_config_cleanup(struct lldpd_config *);
#ifdef ENABLE_DOT1