struct timer tx_timer; /* Send CCM when expired. */
struct timer fault_timer; /* Check for faults when expired. */
+
+ struct hmap remote_mps; /* Expected remote MPs. */
+};
+
+/* Remote MPs represent foreign network entities that are configured to have
+ * the same MAID as this CFM instance. */
+struct remote_mp {
+ uint16_t mpid; /* The Maintenance Point ID of this 'remote_mp'. */
+ struct hmap_node node; /* Node in 'remote_mps' map. */
+
+ bool recv; /* CCM was received since last fault check. */
+ bool fault; /* Indicates a connectivity fault. */
};
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20);
cfmi = xzalloc(sizeof *cfmi);
cfm = &cfmi->cfm;
- hmap_init(&cfm->remote_mps);
+ hmap_init(&cfmi->remote_mps);
cfm_generate_maid(cfmi);
list_push_back(&all_cfms, &cfmi->list_node);
return cfm;
return;
}
- HMAP_FOR_EACH_SAFE (rmp, rmp_next, node, &cfm->remote_mps) {
- hmap_remove(&cfm->remote_mps, &rmp->node);
+ HMAP_FOR_EACH_SAFE (rmp, rmp_next, node, &cfmi->remote_mps) {
+ hmap_remove(&cfmi->remote_mps, &rmp->node);
free(rmp);
}
- hmap_destroy(&cfm->remote_mps);
+ hmap_destroy(&cfmi->remote_mps);
list_remove(&cfmi->list_node);
free(cfmi);
}
struct remote_mp *rmp;
cfm->fault = false;
- HMAP_FOR_EACH (rmp, node, &cfm->remote_mps) {
+ HMAP_FOR_EACH (rmp, node, &cfmi->remote_mps) {
rmp->fault = !rmp->recv;
rmp->recv = false;
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;
continue;
}
- if ((rmp = lookup_remote_mp(&cfm->remote_mps, mpid))) {
- hmap_remove(&cfm->remote_mps, &rmp->node);
+ if ((rmp = lookup_remote_mp(&cfmi->remote_mps, mpid))) {
+ hmap_remove(&cfmi->remote_mps, &rmp->node);
} else {
rmp = xzalloc(sizeof *rmp);
rmp->mpid = mpid;
hmap_insert(&new_rmps, &rmp->node, hash_mpid(mpid));
}
- hmap_swap(&new_rmps, &cfm->remote_mps);
+ hmap_swap(&new_rmps, &cfmi->remote_mps);
HMAP_FOR_EACH_SAFE (rmp, rmp_next, node, &new_rmps) {
hmap_remove(&new_rmps, &rmp->node);
hmap_destroy(&new_rmps);
}
-/* Finds a 'remote_mp' with 'mpid' in 'cfm'. If no such 'remote_mp' exists
- * returns NULL. */
-const struct remote_mp *
-cfm_get_remote_mp(const struct cfm *cfm, uint16_t mpid)
-{
- return lookup_remote_mp(&cfm->remote_mps, mpid);
-}
-
/* Returns true if the CFM library should process packets from 'flow'. */
bool
cfm_should_process_flow(const struct flow *flow)
ccm_mpid = ntohs(ccm->mpid);
ccm_interval = ccm->flags & 0x7;
- rmp = lookup_remote_mp(&cfm->remote_mps, ccm_mpid);
+ rmp = lookup_remote_mp(&cfmi->remote_mps, ccm_mpid);
if (rmp) {
rmp->recv = true;
timer_msecs_until_expired(&cfmi->fault_timer));
ds_put_cstr(&ds, "\n");
- HMAP_FOR_EACH (rmp, node, &cfmi->cfm.remote_mps) {
+ HMAP_FOR_EACH (rmp, node, &cfmi->remote_mps) {
ds_put_format(&ds, "Remote MPID %"PRIu16": %s\n", rmp->mpid,
rmp->fault ? "fault" : "");
ds_put_format(&ds, "\trecv since check: %s",