[ovs-dev] [PATCH 06/63] ovs-controller: Make sure vconn is connected before making messages
Simon Horman
horms at verge.net.au
Wed Jun 27 08:19:42 UTC 2012
This is a rather unpleasant hack but I am unsure of how to rework things
such that ovs-controller will work with a version of make_openflow() which
uses prevailing OpenFlow version in the header of OpenFlow messages.
Signed-off-by: Simon Horman <horms at verge.net.au>
---
v5
* No change
v4
* Initial post
---
utilities/ovs-controller.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/utilities/ovs-controller.c b/utilities/ovs-controller.c
index 04b16e8..35bd440 100644
--- a/utilities/ovs-controller.c
+++ b/utilities/ovs-controller.c
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
#include "command-line.h"
#include "compiler.h"
@@ -224,6 +225,25 @@ new_switch(struct switch_ *sw, struct vconn *vconn)
struct lswitch_config cfg;
sw->rconn = rconn_create(60, 0, DSCP_DEFAULT);
+
+ /* This is a hack (as evident by the presence of usleep()).
+ *
+ * vconn must be connected before the lswitch_create() makes any
+ * messages otherwise the correct version to place in the header
+ * is unknown.
+ */
+ while (1) {
+ int error = vconn_connect(vconn);
+ if (!error) {
+ break;
+ }
+ if (error != EAGAIN) {
+ VLOG_ERR("Failed to connect");
+ abort();
+ }
+ usleep(100000);
+ }
+
rconn_connect_unreliably(sw->rconn, vconn, NULL);
cfg.mode = (action_normal ? LSW_NORMAL
--
1.7.10.2.484.gcd07cc5
More information about the dev
mailing list