[ovs-dev] [PATCH v2 40/47] ofp-util: Support decoding of EXT-187 requests

Simon Horman horms at verge.net.au
Tue Jun 10 10:27:44 UTC 2014


Support decoding of EXT-187: flow entry notification extension
(ONF flow monitor) requests.

Signed-off-by: Simon Horman <horms at verge.net.au>

---
v2
* First post
---
 lib/ofp-util.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 4090ed2..91e4b39 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -5271,6 +5271,62 @@ ofputil_decode_nx_flow_monitor_request(struct ofputil_flow_monitor_request *rq,
     return nx_pull_match(msg, ntohs(nfmr->match_len), &rq->match, NULL, NULL);
 }
 
+/* Converts an ONFMP_FLOW_MONITOR request in 'msg' into an abstract
+ * ofputil_flow_monitor_request in 'rq'.
+ *
+ * Multiple ONFMP_FLOW_MONITOR requests can be packed into a single OpenFlow
+ * message.  Calling this function multiple times for a single 'msg' iterates
+ * through the requests.  The caller must initially leave 'msg''s layer
+ * pointers null and not modify them between calls.
+ *
+ * Returns 0 if successful, EOF if no requests were left in this 'msg',
+ * otherwise an OFPERR_* value. */
+static int
+ofputil_decode_onf13_flow_monitor_request(struct ofputil_flow_monitor_request *rq,
+                                          struct ofpbuf *msg)
+{
+    struct onf13_flow_monitor_request *onffmr;
+    enum nx_flow_monitor_flags flags;
+
+    onffmr = ofpbuf_try_pull(msg, sizeof *onffmr);
+    if (!onffmr) {
+        VLOG_WARN_RL(&bad_ofmsg_rl,
+                     "ONFMP_FLOW_MONITOR request has %"PRIu32" "
+                     "leftover bytes at end", ofpbuf_size(msg));
+        return OFPERR_OFPBRC_BAD_LEN;
+    }
+
+    flags = ntohs(onffmr->flags);
+    if (!(flags & (NXFMF_ADD | NXFMF_DELETE | NXFMF_MODIFY))
+        || flags & ~(NXFMF_INITIAL | NXFMF_ADD | NXFMF_DELETE
+                     | NXFMF_MODIFY | NXFMF_ACTIONS | NXFMF_OWN)) {
+        VLOG_WARN_RL(&bad_ofmsg_rl,
+                     "ONFMP_FLOW_MONITOR has bad flags %#"PRIx16,
+                     flags);
+        return OFPERR_OFPMOFC_BAD_FLAGS;
+    }
+
+    if (!is_all_zeros(onffmr->zeros, sizeof onffmr->zeros)) {
+        return OFPERR_NXBRC_MUST_BE_ZERO;
+    }
+
+    rq->id = ntohl(onffmr->id);
+    rq->flags = nx_to_ofp14_flow_monitor_flags(flags);
+    if (ofputil_port_from_ofp11(onffmr->out_port, &rq->out_port)) {
+        VLOG_WARN_RL(&bad_ofmsg_rl,
+                     "OFPMP_FLOW_MONITOR has bad out_port %#"PRIx32,
+                     ntohl(onffmr->out_port));
+        return OFPERR_OFPMOFC_BAD_OUT;
+    }
+    rq->out_group = OFPG_ANY;
+    rq->table_id = onffmr->table_id;
+    rq->command = OFPFMC14_ADD;
+
+    /* nx_pull_match() is use to put an OXM match without an
+     * ofp_match_header */
+    return nx_pull_match(msg, ntohs(onffmr->match_len), &rq->match, NULL, NULL);
+}
+
 /* Converts an OFPMP_FLOW_MONITOR request in 'msg' into an abstract
  * ofputil_flow_monitor_request in 'rq'.
  *
@@ -5351,6 +5407,8 @@ ofputil_decode_flow_monitor_request(struct ofputil_flow_monitor_request *rq,
 
     if (raw == OFPRAW_OFPST14_FLOW_MONITOR_REQUEST) {
         error = ofputil_decode_of14_flow_monitor_request(rq, msg);
+    } else if (raw == OFPRAW_ONFST13_FLOW_MONITOR_REQUEST) {
+        error = ofputil_decode_onf13_flow_monitor_request(rq, msg);
     } else if (raw == OFPRAW_NXST_FLOW_MONITOR_REQUEST) {
         error = ofputil_decode_nx_flow_monitor_request(rq, msg);
     } else {
-- 
2.0.0.rc2




More information about the dev mailing list