long long ccm_sent; /* The time we last sent a CCM. */
long long fault_check; /* The time we last checked for faults. */
+
+ struct hmap x_remote_mps; /* Unexpected remote MPs. */
+ struct hmap x_remote_maids; /* Unexpected remote MAIDs. */
};
static int
cfm = &cfmi->cfm;
hmap_init(&cfm->remote_mps);
- hmap_init(&cfm->x_remote_mps);
- hmap_init(&cfm->x_remote_maids);
+ hmap_init(&cfmi->x_remote_mps);
+ hmap_init(&cfmi->x_remote_maids);
return cfm;
}
void
cfm_destroy(struct cfm *cfm)
{
+ struct cfm_internal *cfmi = cfm_to_internal(cfm);
struct remote_mp *rmp, *rmp_next;
struct remote_maid *rmaid, *rmaid_next;
free(rmp);
}
- HMAP_FOR_EACH_SAFE (rmp, rmp_next, node, &cfm->x_remote_mps) {
- hmap_remove(&cfm->x_remote_mps, &rmp->node);
+ HMAP_FOR_EACH_SAFE (rmp, rmp_next, node, &cfmi->x_remote_mps) {
+ hmap_remove(&cfmi->x_remote_mps, &rmp->node);
free(rmp);
}
- HMAP_FOR_EACH_SAFE (rmaid, rmaid_next, node, &cfm->x_remote_maids) {
- hmap_remove(&cfm->x_remote_maids, &rmaid->node);
+ HMAP_FOR_EACH_SAFE (rmaid, rmaid_next, node, &cfmi->x_remote_maids) {
+ hmap_remove(&cfmi->x_remote_maids, &rmaid->node);
free(rmaid);
}
hmap_destroy(&cfm->remote_mps);
- hmap_destroy(&cfm->x_remote_mps);
- hmap_destroy(&cfm->x_remote_maids);
- free(cfm_to_internal(cfm));
+ hmap_destroy(&cfmi->x_remote_mps);
+ hmap_destroy(&cfmi->x_remote_maids);
+ free(cfmi);
}
/* Should be run periodically to update fault statistics messages. */
fault = rmp->fault || fault;
}
- HMAP_FOR_EACH_SAFE (rmp, rmp_next, node, &cfm->x_remote_mps) {
+ HMAP_FOR_EACH_SAFE (rmp, rmp_next, node, &cfmi->x_remote_mps) {
if (cfmi->fault_check > rmp->recv_time) {
- hmap_remove(&cfm->x_remote_mps, &rmp->node);
+ hmap_remove(&cfmi->x_remote_mps, &rmp->node);
free(rmp);
}
}
- HMAP_FOR_EACH_SAFE (rmaid, rmaid_next, node, &cfm->x_remote_maids) {
+ HMAP_FOR_EACH_SAFE (rmaid, rmaid_next, node, &cfmi->x_remote_maids) {
if (cfmi->fault_check > rmaid->recv_time) {
- hmap_remove(&cfm->x_remote_maids, &rmaid->node);
+ hmap_remove(&cfmi->x_remote_maids, &rmaid->node);
free(rmaid);
}
}
- fault = (fault || !hmap_is_empty(&cfm->x_remote_mps)
- || !hmap_is_empty(&cfm->x_remote_maids));
+ fault = (fault || !hmap_is_empty(&cfmi->x_remote_mps)
+ || !hmap_is_empty(&cfmi->x_remote_maids));
cfm->fault = fault;
cfmi->fault_check = now;
void
cfm_update_remote_mps(struct cfm *cfm, const uint16_t *mpids, size_t n_mpids)
{
+ struct cfm_internal *cfmi = cfm_to_internal(cfm);
size_t i;
struct hmap new_rmps;
struct remote_mp *rmp, *rmp_next;
if ((rmp = lookup_remote_mp(&cfm->remote_mps, mpid))) {
hmap_remove(&cfm->remote_mps, &rmp->node);
- } else if ((rmp = lookup_remote_mp(&cfm->x_remote_mps, mpid))) {
- hmap_remove(&cfm->x_remote_mps, &rmp->node);
+ } else if ((rmp = lookup_remote_mp(&cfmi->x_remote_mps, mpid))) {
+ hmap_remove(&cfmi->x_remote_mps, &rmp->node);
} else {
rmp = xzalloc(sizeof *rmp);
rmp->mpid = mpid;
if (memcmp(ccm->maid, cfm->maid, sizeof ccm->maid)) {
struct remote_maid *rmaid;
- rmaid = lookup_remote_maid(&cfm->x_remote_maids, ccm->maid);
+ rmaid = lookup_remote_maid(&cfmi->x_remote_maids, ccm->maid);
if (rmaid) {
rmaid->recv_time = time_msec();
} else {
rmaid = xzalloc(sizeof *rmaid);
rmaid->recv_time = time_msec();
memcpy(rmaid->maid, ccm->maid, sizeof rmaid->maid);
- hmap_insert(&cfm->x_remote_maids, &rmaid->node,
+ hmap_insert(&cfmi->x_remote_maids, &rmaid->node,
hash_bytes(ccm->maid, CCM_MAID_LEN, 0));
}
cfm->fault = true;
rmp = lookup_remote_mp(&cfm->remote_mps, ccm_mpid);
if (!rmp) {
- rmp = lookup_remote_mp(&cfm->x_remote_mps, ccm_mpid);
+ rmp = lookup_remote_mp(&cfmi->x_remote_mps, ccm_mpid);
}
if (!rmp) {
rmp = xzalloc(sizeof *rmp);
rmp->mpid = ccm_mpid;
- hmap_insert(&cfm->x_remote_mps, &rmp->node, hash_mpid(ccm_mpid));
+ hmap_insert(&cfmi->x_remote_mps, &rmp->node, hash_mpid(ccm_mpid));
rmp->fault = true;
}
ovsrec_maintenance_point_set_fault(mp, &rmp->fault, 1);
}
- if (hmap_is_empty(&cfm->x_remote_mps)) {
- ovsrec_monitor_set_unexpected_remote_mpids(mon, NULL, 0);
- } else {
- size_t length;
- struct remote_mp *rmp;
- int64_t *x_remote_mps;
-
- length = hmap_count(&cfm->x_remote_mps);
- x_remote_mps = xzalloc(length * sizeof *x_remote_mps);
-
- i = 0;
- HMAP_FOR_EACH (rmp, node, &cfm->x_remote_mps) {
- x_remote_mps[i++] = rmp->mpid;
- }
-
- ovsrec_monitor_set_unexpected_remote_mpids(mon, x_remote_mps, length);
- free(x_remote_mps);
- }
-
- if (hmap_is_empty(&cfm->x_remote_maids)) {
- ovsrec_monitor_set_unexpected_remote_maids(mon, NULL, 0);
- } else {
- size_t length;
- char **x_remote_maids;
- struct remote_maid *rmaid;
-
- length = hmap_count(&cfm->x_remote_maids);
- x_remote_maids = xzalloc(length * sizeof *x_remote_maids);
-
- i = 0;
- HMAP_FOR_EACH (rmaid, node, &cfm->x_remote_maids) {
- size_t j;
-
- x_remote_maids[i] = xzalloc(CCM_MAID_LEN * 2 + 1);
-
- for (j = 0; j < CCM_MAID_LEN; j++) {
- snprintf(&x_remote_maids[i][j * 2], 3, "%02hhx",
- rmaid->maid[j]);
- }
- i++;
- }
- ovsrec_monitor_set_unexpected_remote_maids(mon, x_remote_maids, length);
-
- for (i = 0; i < length; i++) {
- free(x_remote_maids[i]);
- }
- free(x_remote_maids);
- }
-
ovsrec_monitor_set_fault(mon, &cfm->fault, 1);
}