diff mbox

[ovs-dev,12/13] ovs-ofctl: Fail if bundle errors are received.

Message ID 1468577959-98487-12-git-send-email-jarno@ovn.org
State Superseded
Headers show

Commit Message

Jarno Rajahalme July 15, 2016, 10:19 a.m. UTC
It is possible that a bundle add message fails, but the following
commit succeeds, since the message was not added to the bundle.  Make
ovs-ofctl fail also in these cases.

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
---
 utilities/ovs-ofctl.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index e373aa4..b04c063 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -660,9 +660,12 @@  transact_multiple_noreply(struct vconn *vconn, struct ovs_list *requests)
     ofpbuf_delete(reply);
 }
 
+static bool bundle_error = false;
+
 static void
 bundle_error_reporter(const struct ofp_header *oh)
 {
+    bundle_error = true;
     ofp_print(stderr, oh, ntohs(oh->length), verbosity + 1);
     fflush(stderr);
 }
@@ -670,8 +673,14 @@  bundle_error_reporter(const struct ofp_header *oh)
 static void
 bundle_transact(struct vconn *vconn, struct ovs_list *requests, uint16_t flags)
 {
-    run(vconn_bundle_transact(vconn, requests, flags, bundle_error_reporter),
-        "talking to %s", vconn_get_name(vconn));
+    int retval = vconn_bundle_transact(vconn, requests, flags,
+                                       bundle_error_reporter);
+    if (retval || bundle_error) {
+        if (!retval) {
+            retval = EPROTO;
+        }
+        ovs_fatal(retval, "talking to %s", vconn_get_name(vconn));
+    }
 }
 
 /* Sends 'request', which should be a request that only has a reply if an error