[ovs-dev] [PATCH] ovn-controller:improve the ofctrl_run, pinctrl_run
nickcooper-zhangtonghao
nickcooper-zhangtonghao at opencloud.tech
Thu Aug 4 11:50:03 UTC 2016
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 at opencloud.tech>
---
ovn/controller/ofctrl.c | 15 +++++----------
ovn/controller/pinctrl.c | 16 +++++-----------
2 files changed, 10 insertions(+), 21 deletions(-)
diff --git a/ovn/controller/ofctrl.c b/ovn/controller/ofctrl.c
index 79d840d..9742e34 100644
--- a/ovn/controller/ofctrl.c
+++ b/ovn/controller/ofctrl.c
@@ -432,17 +432,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);
diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c
index 416dad6..0377ef3 100644
--- a/ovn/controller/pinctrl.c
+++ b/ovn/controller/pinctrl.c
@@ -454,18 +454,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);
--
1.8.3.1
More information about the dev
mailing list