ofproto: Break out monitor deletion code
authorSimon Horman <horms@verge.net.au>
Mon, 16 Jun 2014 02:29:29 +0000 (11:29 +0900)
committerBen Pfaff <blp@nicira.com>
Tue, 24 Jun 2014 00:06:56 +0000 (17:06 -0700)
Break out monitor deletion code into a new function
flow_monitor_delete which is paramatised over the id of
the monitor to delete.

This is in preparation for supporting OpenFlow1.4 flow monitor requests
with delete and modify commands.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ofproto/ofproto.c

index 458703d..670b4ff 100644 (file)
@@ -4827,6 +4827,24 @@ ofmonitor_collect_resume_rules(struct ofmonitor *m,
     ofproto_collect_ofmonitor_refresh_rules(m, seqno, rules);
 }
 
+static enum ofperr
+flow_monitor_delete(struct ofconn *ofconn, uint32_t id)
+    OVS_REQUIRES(ofproto_mutex)
+{
+    struct ofmonitor *m;
+    enum ofperr error;
+
+    m = ofmonitor_lookup(ofconn, id);
+    if (m) {
+        ofmonitor_destroy(m);
+        error = 0;
+    } else {
+        error = OFPERR_OFPMOFC_UNKNOWN_MONITOR;
+    }
+
+    return error;
+}
+
 static enum ofperr
 handle_flow_monitor_request(struct ofconn *ofconn, const struct ofp_header *oh)
     OVS_EXCLUDED(ofproto_mutex)
@@ -4907,20 +4925,13 @@ static enum ofperr
 handle_flow_monitor_cancel(struct ofconn *ofconn, const struct ofp_header *oh)
     OVS_EXCLUDED(ofproto_mutex)
 {
-    struct ofmonitor *m;
     enum ofperr error;
     uint32_t id;
 
     id = ofputil_decode_flow_monitor_cancel(oh);
 
     ovs_mutex_lock(&ofproto_mutex);
-    m = ofmonitor_lookup(ofconn, id);
-    if (m) {
-        ofmonitor_destroy(m);
-        error = 0;
-    } else {
-        error = OFPERR_OFPMOFC_UNKNOWN_MONITOR;
-    }
+    error = flow_monitor_delete(ofconn, id);
     ovs_mutex_unlock(&ofproto_mutex);
 
     return error;