Signed-off-by: Ben Pfaff <[email protected]>
---
lib/lldp/lldp.c | 4 ++--
lib/lldp/lldpd-structs.c | 17 ++++++++---------
lib/lldp/lldpd-structs.h | 6 +++---
lib/lldp/lldpd.c | 10 +++++-----
4 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/lib/lldp/lldp.c b/lib/lldp/lldp.c
index f620d73..b3c8346 100644
--- a/lib/lldp/lldp.c
+++ b/lib/lldp/lldp.c
@@ -597,8 +597,8 @@ lldp_decode(struct lldpd *cfg OVS_UNUSED, char *frame, int
s,
return 1;
malformed:
- lldpd_chassis_cleanup(chassis, 1);
- lldpd_port_cleanup(port, 1);
+ lldpd_chassis_cleanup(chassis, true);
+ lldpd_port_cleanup(port, true);
free(port);
return -1;
}
diff --git a/lib/lldp/lldpd-structs.c b/lib/lldp/lldpd-structs.c
index bd77c28..abd251a 100644
--- a/lib/lldp/lldpd-structs.c
+++ b/lib/lldp/lldpd-structs.c
@@ -44,7 +44,7 @@ lldpd_chassis_mgmt_cleanup(struct lldpd_chassis *chassis)
}
void
-lldpd_chassis_cleanup(struct lldpd_chassis *chassis, int all)
+lldpd_chassis_cleanup(struct lldpd_chassis *chassis, bool all)
{
lldpd_chassis_mgmt_cleanup(chassis);
VLOG_DBG("cleanup chassis %s",
@@ -58,27 +58,26 @@ lldpd_chassis_cleanup(struct lldpd_chassis *chassis, int
all)
}
/* 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.
+ * should be called when a remote port is removed. If the last argument is
+ * true, all remote ports are removed.
*/
void
lldpd_remote_cleanup(struct lldpd_hardware *hw,
void(*expire)(struct lldpd_hardware *,
struct lldpd_port *),
- int all)
+ bool all)
{
struct lldpd_port *port, *port_next;
- int del;
time_t now = time_now();
VLOG_DBG("cleanup remote port on %s", hw->h_ifname);
LIST_FOR_EACH_SAFE (port, port_next, p_entries, &hw->h_rports.p_entries) {
- del = all;
+ bool del = all;
if (!all && expire &&
(now >= port->p_lastupdate + port->p_chassis->c_ttl)) {
hw->h_ageout_cnt++;
hw->h_delete_cnt++;
- del = 1;
+ del = true;
}
if (del) {
if (expire) {
@@ -88,7 +87,7 @@ lldpd_remote_cleanup(struct lldpd_hardware *hw,
if (!all) {
list_remove(&port->p_entries);
}
- lldpd_port_cleanup(port, 1);
+ lldpd_port_cleanup(port, true);
free(port);
}
}
@@ -100,7 +99,7 @@ lldpd_remote_cleanup(struct lldpd_hardware *hw,
/* If `all' is true, clear all information, including information that
are not refreshed periodically. Port should be freed manually. */
void
-lldpd_port_cleanup(struct lldpd_port *port, int all)
+lldpd_port_cleanup(struct lldpd_port *port, bool all)
{
/* We set these to NULL so we don't free wrong memory */
diff --git a/lib/lldp/lldpd-structs.h b/lib/lldp/lldpd-structs.h
index 727dc72..c926c29 100644
--- a/lib/lldp/lldpd-structs.h
+++ b/lib/lldp/lldpd-structs.h
@@ -219,10 +219,10 @@ struct lldpd_neighbor_change {
/* Cleanup functions */
void lldpd_chassis_mgmt_cleanup(struct lldpd_chassis *);
-void lldpd_chassis_cleanup(struct lldpd_chassis *, int);
+void lldpd_chassis_cleanup(struct lldpd_chassis *, bool all);
void lldpd_remote_cleanup(struct lldpd_hardware *,
- void (*expire)(struct lldpd_hardware *, struct lldpd_port *), int);
-void lldpd_port_cleanup(struct lldpd_port *, int);
+ void (*expire)(struct lldpd_hardware *, struct lldpd_port *), bool all);
+void lldpd_port_cleanup(struct lldpd_port *, bool all);
void lldpd_config_cleanup(struct lldpd_config *);
#endif
diff --git a/lib/lldp/lldpd.c b/lib/lldp/lldpd.c
index 88cebe0..ff77afd 100644
--- a/lib/lldp/lldpd.c
+++ b/lib/lldp/lldpd.c
@@ -123,7 +123,7 @@ lldpd_hardware_cleanup(struct lldpd *cfg, struct
lldpd_hardware *hardware)
{
VLOG_DBG("cleanup hardware port %s", hardware->h_ifname);
- lldpd_port_cleanup(&hardware->h_lport, 1);
+ lldpd_port_cleanup(&hardware->h_lport, true);
if (hardware->h_ops && hardware->h_ops->cleanup) {
hardware->h_ops->cleanup(cfg, hardware);
}
@@ -141,10 +141,10 @@ lldpd_cleanup(struct lldpd *cfg)
LIST_FOR_EACH_SAFE (hw, hw_next, h_entries, &cfg->g_hardware.h_entries) {
if (!hw->h_flags) {
list_remove(&hw->h_entries);
- lldpd_remote_cleanup(hw, NULL, 1);
+ lldpd_remote_cleanup(hw, NULL, true);
lldpd_hardware_cleanup(cfg, hw);
} else {
- lldpd_remote_cleanup(hw, NULL, 0);
+ lldpd_remote_cleanup(hw, NULL, false);
}
}
@@ -335,8 +335,8 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s,
} else if (count > cfg->g_config.c_max_neighbors - 1) {
VLOG_DBG("too many neighbors for port %s, drop this new one",
hw->h_ifname);
- lldpd_port_cleanup(port, 1);
- lldpd_chassis_cleanup(chassis, 1);
+ lldpd_port_cleanup(port, true);
+ lldpd_chassis_cleanup(chassis, true);
free(port);
return;
}
--
2.1.3
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev