diff options
author | Ethan Jackson <ethan@nicira.com> | 2011-08-26 14:54:34 -0700 |
---|---|---|
committer | Ethan Jackson <ethan@nicira.com> | 2011-09-09 14:11:14 -0700 |
commit | 1de11730e612b09e28892880c2845185497a3741 (patch) | |
tree | 87e8cb6122e52d7c6b709faefce670ae638d9c68 /lib/cfm.c | |
parent | 348f01e3e36b67f86ac2f9f90c7574d9e1b85d73 (diff) | |
download | openvswitch-1de11730e612b09e28892880c2845185497a3741.tar.gz |
cfm: Write remote MPIDs to the database.
A controller may want to know which MPIDs are reachable from an
interface configured with CFM. This patch regularly writes this
information to the database.
Bug #7014.
Diffstat (limited to 'lib/cfm.c')
-rw-r--r-- | lib/cfm.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -88,6 +88,11 @@ struct cfm { struct timer fault_timer; /* Check for faults when expired. */ struct hmap remote_mps; /* Remote MPs. */ + + /* Result of cfm_get_remote_mpids(). Updated only during fault check to + * avoid flapping. */ + uint64_t *rmps_array; /* Cache of remote_mps. */ + size_t rmps_array_len; /* Number of rmps in 'rmps_array'. */ }; /* Remote MPs represent foreign network entities that are configured to have @@ -249,6 +254,7 @@ cfm_destroy(struct cfm *cfm) hmap_destroy(&cfm->remote_mps); hmap_remove(&all_cfms, &cfm->hmap_node); + free(cfm->rmps_array); free(cfm->name); free(cfm); } @@ -264,6 +270,11 @@ cfm_run(struct cfm *cfm) cfm->fault = cfm->unexpected_recv; cfm->unexpected_recv = false; + cfm->rmps_array_len = 0; + free(cfm->rmps_array); + cfm->rmps_array = xmalloc(hmap_count(&cfm->remote_mps) * + sizeof *cfm->rmps_array); + HMAP_FOR_EACH_SAFE (rmp, rmp_next, node, &cfm->remote_mps) { if (!rmp->recv) { @@ -285,6 +296,8 @@ cfm_run(struct cfm *cfm) rmp->mpid); cfm->fault = true; } + + cfm->rmps_array[cfm->rmps_array_len++] = rmp->mpid; } } @@ -480,6 +493,17 @@ cfm_get_fault(const struct cfm *cfm) return cfm->fault; } +/* Populates 'rmps' with an array of remote maintenance points reachable by + * 'cfm'. The number of remote maintenance points is written to 'n_rmps'. + * 'cfm' retains ownership of the array written to 'rmps' */ +void +cfm_get_remote_mpids(const struct cfm *cfm, const uint64_t **rmps, + size_t *n_rmps) +{ + *rmps = cfm->rmps_array; + *n_rmps = cfm->rmps_array_len; +} + static struct cfm * cfm_find(const char *name) { |