secchan: In ofproto_set_controller(), only reconnect if controller really changed.
authorBen Pfaff <blp@nicira.com>
Tue, 10 Mar 2009 23:54:00 +0000 (16:54 -0700)
committerBen Pfaff <blp@nicira.com>
Tue, 10 Mar 2009 23:54:21 +0000 (16:54 -0700)
The vswitchd bridge code tries not to call this function if it doesn't
have to, but it's not doing a good job.  We should fix it in vswitchd, but
it's also a good idea to do it here.

secchan/ofproto.c

index 9711515ef1503a1554129478c1df031bf6472511..9a49a11138342446dd6cbe9cd6a9466ff07efae9 100644 (file)
@@ -398,7 +398,11 @@ ofproto_set_controller(struct ofproto *ofproto, const char *controller)
     if (ofproto->discovery) {
         return EINVAL;
     } else if (controller) {
-        return rconn_connect(ofproto->controller->rconn, controller);
+        if (strcmp(rconn_get_name(ofproto->controller->rconn), controller)) {
+            return rconn_connect(ofproto->controller->rconn, controller);
+        } else {
+            return 0;
+        }
     } else {
         rconn_disconnect(ofproto->controller->rconn);
         return 0;