[ovs-dev] [cleanups 12/13] classifier: Add functions and macros for iteration, and use them in ofproto.

Ethan Jackson ethan at nicira.com
Mon Nov 15 22:54:47 UTC 2010


 /* Implements OFPFC_MODIFY.  Returns 0 on success or an OpenFlow error code as
  * encoded by ofp_mkerr() on failure.
@@ -3987,19 +3956,24 @@ static void modify_flows_cb(struct cls_rule *,
void *cbdata_);
 static int
 modify_flows_loose(struct ofconn *ofconn, struct flow_mod *fm)
 {
-    struct modify_flows_cbdata cbdata;
+    struct ofproto *p = ofconn->ofproto;
+    struct rule *match = NULL;
+    struct cls_cursor cursor;
+    struct rule *rule;

-    cbdata.ofproto = ofconn->ofproto;
-    cbdata.fm = fm;
-    cbdata.match = NULL;
+    cls_cursor_init(&cursor, &p->cls, &fm->cr);
+    CLS_CURSOR_FOR_EACH (rule, cr, &cursor) {
+        if (!rule_is_hidden(rule)) {
+            match = rule;
+            modify_flow(p, fm, rule);
+        }
+    }

-    classifier_for_each_match(&ofconn->ofproto->cls, &fm->cr,
-                              modify_flows_cb, &cbdata);
-    if (cbdata.match) {
+    if (match) {
         /* This credits the packet to whichever flow happened to happened to

happened to happened to.  Not part of the diff but may as well fix it.

Looks Good




More information about the dev mailing list