[ovs-dev] [PATCH 2/2] cfm: Expose remote CFM opstate in the database.
Ethan Jackson
ethan at nicira.com
Sat Aug 11 01:27:19 UTC 2012
A controller may want to know the remote CFM opstate of a given CFM
enabled interface. This patch makes this data available in the
database.
Signed-off-by: Ethan Jackson <ethan at nicira.com>
---
ofproto/ofproto-dpif.c | 9 +++++++++
ofproto/ofproto-provider.h | 9 +++++++++
ofproto/ofproto.c | 15 ++++++++++++++-
ofproto/ofproto.h | 1 +
vswitchd/bridge.c | 10 +++++++++-
vswitchd/vswitch.ovsschema | 9 +++++++--
vswitchd/vswitch.xml | 7 +++++++
7 files changed, 56 insertions(+), 4 deletions(-)
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 5851dcd..cf34e92 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -1316,6 +1316,14 @@ get_cfm_fault(const struct ofport *ofport_)
}
static int
+get_cfm_opup(const struct ofport *ofport_)
+{
+ struct ofport_dpif *ofport = ofport_dpif_cast(ofport_);
+
+ return ofport->cfm ? cfm_get_opup(ofport->cfm) : -1;
+}
+
+static int
get_cfm_remote_mpids(const struct ofport *ofport_, const uint64_t **rmps,
size_t *n_rmps)
{
@@ -7173,6 +7181,7 @@ const struct ofproto_class ofproto_dpif_class = {
set_sflow,
set_cfm,
get_cfm_fault,
+ get_cfm_opup,
get_cfm_remote_mpids,
get_cfm_health,
set_stp,
diff --git a/ofproto/ofproto-provider.h b/ofproto/ofproto-provider.h
index f0d57ee..15dc347 100644
--- a/ofproto/ofproto-provider.h
+++ b/ofproto/ofproto-provider.h
@@ -1015,6 +1015,15 @@ struct ofproto_class {
* not support CFM. */
int (*get_cfm_fault)(const struct ofport *ofport);
+ /* Check the operational status reported by the remote CFM endpoint of
+ * 'ofp_port' Returns 1 if operationally up, 0 if operationally down, and
+ * -1 if CFM is not enabled on 'ofp_port' or does not support operational
+ * status.
+ *
+ * This function may be a null pointer if the ofproto implementation does
+ * not support CFM. */
+ int (*get_cfm_opup)(const struct ofport *ofport);
+
/* Gets the MPIDs of the remote maintenance points broadcasting to
* 'ofport'. Populates 'rmps' with a provider owned array of MPIDs, and
* 'n_rmps' with the number of MPIDs in 'rmps'. Returns a number less than
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 8c10f19..5c9ab9d 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -2594,7 +2594,7 @@ ofproto_get_netflow_ids(const struct ofproto *ofproto,
/* Checks the fault status of CFM for 'ofp_port' within 'ofproto'. Returns a
* bitmask of 'cfm_fault_reason's to indicate a CFM fault (generally
* indicating a connectivity problem). Returns zero if CFM is not faulted,
- * and -1 if CFM is not enabled on 'port'. */
+ * and -1 if CFM is not enabled on 'ofp_port'. */
int
ofproto_port_get_cfm_fault(const struct ofproto *ofproto, uint16_t ofp_port)
{
@@ -2604,6 +2604,19 @@ ofproto_port_get_cfm_fault(const struct ofproto *ofproto, uint16_t ofp_port)
: -1);
}
+/* Checks the operational status reported by the remote CFM endpoint of
+ * 'ofp_port' Returns 1 if operationally up, 0 if operationally down, and -1
+ * if CFM is not enabled on 'ofp_port' or does not support operational status.
+ */
+int
+ofproto_port_get_cfm_opup(const struct ofproto *ofproto, uint16_t ofp_port)
+{
+ struct ofport *ofport = ofproto_get_port(ofproto, ofp_port);
+ return (ofport && ofproto->ofproto_class->get_cfm_opup
+ ? ofproto->ofproto_class->get_cfm_opup(ofport)
+ : -1);
+}
+
/* Gets the MPIDs of the remote maintenance points broadcasting to 'ofp_port'
* within 'ofproto'. Populates 'rmps' with an array of MPIDs owned by
* 'ofproto', and 'n_rmps' with the number of MPIDs in 'rmps'. Returns a
diff --git a/ofproto/ofproto.h b/ofproto/ofproto.h
index 0919d81..32a00f2 100644
--- a/ofproto/ofproto.h
+++ b/ofproto/ofproto.h
@@ -349,6 +349,7 @@ void ofproto_get_all_flows(struct ofproto *p, struct ds *);
void ofproto_get_netflow_ids(const struct ofproto *,
uint8_t *engine_type, uint8_t *engine_id);
int ofproto_port_get_cfm_fault(const struct ofproto *, uint16_t ofp_port);
+int ofproto_port_get_cfm_opup(const struct ofproto *, uint16_t ofp_port);
int ofproto_port_get_cfm_remote_mpids(const struct ofproto *,
uint16_t ofp_port, const uint64_t **rmps,
size_t *n_rmps);
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 2c1142b..9bafa66 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -1696,7 +1696,7 @@ static void
iface_refresh_cfm_stats(struct iface *iface)
{
const struct ovsrec_interface *cfg = iface->cfg;
- int fault, error;
+ int fault, opup, error;
const uint64_t *rmps;
size_t n_rmps;
int health;
@@ -1727,6 +1727,14 @@ iface_refresh_cfm_stats(struct iface *iface)
ovsrec_interface_set_cfm_fault_status(cfg, NULL, 0);
}
+ opup = ofproto_port_get_cfm_opup(iface->port->bridge->ofproto,
+ iface->ofp_port);
+ if (opup >= 0) {
+ ovsrec_interface_set_cfm_remote_opstate(cfg, opup ? "up" : "down");
+ } else {
+ ovsrec_interface_set_cfm_remote_opstate(cfg, NULL);
+ }
+
error = ofproto_port_get_cfm_remote_mpids(iface->port->bridge->ofproto,
iface->ofp_port, &rmps, &n_rmps);
if (error >= 0) {
diff --git a/vswitchd/vswitch.ovsschema b/vswitchd/vswitch.ovsschema
index 9712003..bbfb01f 100644
--- a/vswitchd/vswitch.ovsschema
+++ b/vswitchd/vswitch.ovsschema
@@ -1,6 +1,6 @@
{"name": "Open_vSwitch",
- "version": "6.9.3",
- "cksum": "2110020336 16754",
+ "version": "6.10.0",
+ "cksum": "3699312094 16958",
"tables": {
"Open_vSwitch": {
"columns": {
@@ -199,6 +199,11 @@
"type": {
"key": "string", "min": 0, "max": "unlimited"},
"ephemeral": true},
+ "cfm_remote_opstate": {
+ "type": {"key": {"type": "string",
+ "enum": ["set", ["up", "down"]]},
+ "min": 0, "max": 1},
+ "ephemeral": true},
"cfm_health": {
"type": {"key": {"type": "integer",
"minInteger": 0,
diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml
index 13d24b6..ed1279c 100644
--- a/vswitchd/vswitch.xml
+++ b/vswitchd/vswitch.xml
@@ -1764,6 +1764,13 @@
frame having an invalid interval.
</column>
+ <column name="cfm_remote_opstate">
+ <p> When in extended mode, indicates the operational state of the
+ remote endpoint as either <code>up</code> or <code>down</code>. See
+ <ref column="other_config" key="cfm_opstate"/>.
+ </p>
+ </column>
+
<column name="cfm_health">
<p>
Indicates the health of the interface as a percentage of CCM frames
--
1.7.11.4
More information about the dev
mailing list