bundles: Clean up bundle commit.
authorJarno Rajahalme <jrajahalme@nicira.com>
Mon, 22 Dec 2014 19:31:18 +0000 (11:31 -0800)
committerJarno Rajahalme <jrajahalme@nicira.com>
Mon, 22 Dec 2014 20:56:02 +0000 (12:56 -0800)
This fixes ofp_bundle_commit() in two ways:

- Always remove the bundle regardless of the error condition.
- A commit of an empty bundle must be successful.

The actual commit is still not supported.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
lib/ofp-parse.c
ofproto/bundles.c

index 2ae1edb..9acf6a4 100644 (file)
@@ -22,7 +22,6 @@
 #include <errno.h>
 #include <stdlib.h>
 
-#include "bundle.h"
 #include "byte-order.h"
 #include "dynamic-string.h"
 #include "learn.h"
index 5244a26..4d9deac 100644 (file)
@@ -187,6 +187,8 @@ ofp_bundle_commit(struct ofconn *ofconn, uint32_t id, uint16_t flags)
 {
     struct hmap *bundles;
     struct ofp_bundle *bundle;
+    enum ofperr error = 0;
+    struct bundle_message *msg;
 
     bundles = ofconn_get_bundles(ofconn);
     bundle = ofp_bundle_find(bundles, id);
@@ -195,13 +197,16 @@ ofp_bundle_commit(struct ofconn *ofconn, uint32_t id, uint16_t flags)
         return OFPERR_OFPBFC_BAD_ID;
     }
     if (bundle->flags != flags) {
-        ofp_bundle_remove(ofconn, bundle);
-        return OFPERR_OFPBFC_BAD_FLAGS;
+        error = OFPERR_OFPBFC_BAD_FLAGS;
+    } else {
+        LIST_FOR_EACH (msg, node, &bundle->msg_list) {
+            /* XXX: actual commit */
+            error = OFPERR_OFPBFC_MSG_FAILED;
+        }
     }
 
-    /* XXX: actual commit */
-
-    return OFPERR_OFPBFC_MSG_UNSUP;
+    ofp_bundle_remove(ofconn, bundle);
+    return error;
 }
 
 enum ofperr