cfm: Expose remote CFM opstate in the database.
[sliver-openvswitch.git] / ofproto / ofproto.c
index 8c10f19..5c9ab9d 100644 (file)
@@ -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