int health_interval; /* Number of fault_intervals since health was
recomputed. */
long long int last_tx; /* Last CCM transmission time. */
+
+ int ref_cnt;
};
/* Remote MPs represent foreign network entities that are configured to have
cfm->fault_override = -1;
cfm->health = -1;
cfm->last_tx = 0;
+ cfm->ref_cnt = 1;
return cfm;
}
void
-cfm_destroy(struct cfm *cfm)
+cfm_unref(struct cfm *cfm)
{
struct remote_mp *rmp, *rmp_next;
return;
}
+ ovs_assert(cfm->ref_cnt);
+ if (--cfm->ref_cnt) {
+ return;
+ }
+
HMAP_FOR_EACH_SAFE (rmp, rmp_next, node, &cfm->remote_mps) {
hmap_remove(&cfm->remote_mps, &rmp->node);
free(rmp);
free(cfm);
}
+struct cfm *
+cfm_ref(const struct cfm *cfm_)
+{
+ struct cfm *cfm = CONST_CAST(struct cfm *, cfm_);
+ if (cfm) {
+ ovs_assert(cfm->ref_cnt > 0);
+ cfm->ref_cnt++;
+ }
+ return cfm;
+}
+
/* Should be run periodically to update fault statistics messages. */
void
cfm_run(struct cfm *cfm)
void cfm_init(void);
struct cfm *cfm_create(const struct netdev *);
-void cfm_destroy(struct cfm *);
+struct cfm *cfm_ref(const struct cfm *);
+void cfm_unref(struct cfm *);
void cfm_run(struct cfm *);
bool cfm_should_send_ccm(struct cfm *);
void cfm_compose_ccm(struct cfm *, struct ofpbuf *packet, uint8_t eth_src[6]);