]> git.proxmox.com Git - ovs.git/commitdiff
ovn-controller: Simplify ofctrl_run(), pinctrl_run().
authornickcooper-zhangtonghao <nickcooper-zhangtonghao@opencloud.tech>
Thu, 4 Aug 2016 11:50:03 +0000 (04:50 -0700)
committerBen Pfaff <blp@ovn.org>
Sun, 14 Aug 2016 05:25:15 +0000 (22:25 -0700)
Before calling the function "ofctrl_run" and "pinctrl_run", the "br-int"
has been checked.  Remove the conditional statements in the function may
make the code clearer.

Signed-off-by: nickcooper-zhangtonghao <nickcooper-zhangtonghao@opencloud.tech>
Signed-off-by: Ben Pfaff <blp@ovn.org>
ovn/controller/ofctrl.c
ovn/controller/pinctrl.c

index 9388cb89b881e01ab5946b1f6a365966c5f7729a..e97115741cccca636c146916cd73cc6f611a82b7 100644 (file)
@@ -431,17 +431,12 @@ recv_S_UPDATE_FLOWS(const struct ofp_header *oh, enum ofptype type)
 enum mf_field_id
 ofctrl_run(const struct ovsrec_bridge *br_int)
 {
-    if (br_int) {
-        char *target;
-        target = xasprintf("unix:%s/%s.mgmt", ovs_rundir(), br_int->name);
-        if (strcmp(target, rconn_get_target(swconn))) {
-            VLOG_INFO("%s: connecting to switch", target);
-            rconn_connect(swconn, target, target);
-        }
-        free(target);
-    } else {
-        rconn_disconnect(swconn);
+    char *target = xasprintf("unix:%s/%s.mgmt", ovs_rundir(), br_int->name);
+    if (strcmp(target, rconn_get_target(swconn))) {
+        VLOG_INFO("%s: connecting to switch", target);
+        rconn_connect(swconn, target, target);
     }
+    free(target);
 
     rconn_run(swconn);
 
index bd685fe41e55905f31c4e0495aceda51c6c17fb8..ca49ca632c7fc8e544af376eb543490daebbd6c7 100644 (file)
@@ -461,18 +461,12 @@ pinctrl_run(struct controller_ctx *ctx, const struct lport_index *lports,
             const char *chassis_id,
             struct hmap *local_datapaths)
 {
-    if (br_int) {
-        char *target;
-
-        target = xasprintf("unix:%s/%s.mgmt", ovs_rundir(), br_int->name);
-        if (strcmp(target, rconn_get_target(swconn))) {
-            VLOG_INFO("%s: connecting to switch", target);
-            rconn_connect(swconn, target, target);
-        }
-        free(target);
-    } else {
-        rconn_disconnect(swconn);
+    char *target = xasprintf("unix:%s/%s.mgmt", ovs_rundir(), br_int->name);
+    if (strcmp(target, rconn_get_target(swconn))) {
+        VLOG_INFO("%s: connecting to switch", target);
+        rconn_connect(swconn, target, target);
     }
+    free(target);
 
     rconn_run(swconn);