Re: [ovs-dev] [PATCH] ovn: reduce logical flow applied to ovn-controller

2017-10-30 Thread Ben Pfaff
On Thu, Sep 21, 2017 at 07:45:23PM +0800, wang.qia...@zte.com.cn wrote:
> From 80260a2950f10544e307d6f20cb1cfe8c9bb885f Mon Sep 17 00:00:00 2001
> From: wang qianyu 
> Date: Thu, 21 Sep 2017 18:05:16 +0800
> Subject: [PATCH] ovn: reduce logical flow applied to ovn-controller
> 
> Add a logical_port column in Logical_Flow table. If logical flow generated 
> by
> logical_switch_port, set the logical_port of Logical_Flow with value of 
> port
> name. In ovn-controller, do not do expr_parse for non-local Logical_Flow.
> This can reduce the calculation and memory usage of ovn-controller.
> 
> Signed-off-by: wang qianyu 

Thank you for contributing to OVN!

This patch is wordwrapped and cannot be applied.  Can you send a version
that is not wordwrapped, or make this available as a Git branch?

Thanks,

Ben.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] ovn: reduce logical flow applied to ovn-controller

2017-09-21 Thread wang . qianyu
>From 80260a2950f10544e307d6f20cb1cfe8c9bb885f Mon Sep 17 00:00:00 2001
From: wang qianyu 
Date: Thu, 21 Sep 2017 18:05:16 +0800
Subject: [PATCH] ovn: reduce logical flow applied to ovn-controller

Add a logical_port column in Logical_Flow table. If logical flow generated 
by
logical_switch_port, set the logical_port of Logical_Flow with value of 
port
name. In ovn-controller, do not do expr_parse for non-local Logical_Flow.
This can reduce the calculation and memory usage of ovn-controller.

Signed-off-by: wang qianyu 
---
 ovn/controller/lflow.c  |  23 +++
 ovn/northd/ovn-northd.c | 165 
+---
 ovn/ovn-sb.ovsschema|   5 +-
 ovn/ovn-sb.xml  |   5 ++
 4 files changed, 130 insertions(+), 68 deletions(-)

diff --git a/ovn/controller/lflow.c b/ovn/controller/lflow.c
index 20a18c2..1798c60 100644
--- a/ovn/controller/lflow.c
+++ b/ovn/controller/lflow.c
@@ -137,6 +137,20 @@ is_gateway_router(const struct sbrec_datapath_binding 
*ldp,
 return ld ? ld->has_local_l3gateway : false;
 }
 
+static bool
+is_local_port(struct controller_ctx *ctx,
+  const char *logical_port_name,
+  const struct sbrec_chassis *chassis)
+{
+const struct sbrec_port_binding *binding_rec =lport_lookup_by_name(
+ctx->ovnsb_idl, logical_port_name);
+return binding_rec? (!strcmp(binding_rec->type, "patch")
+|| !strcmp(binding_rec->type, "localport")
+|| !strcmp(binding_rec->type, "vtep")
+|| !strcmp(binding_rec->type, "localnet")
+|| binding_rec->chassis == chassis) : false;
+}
+
 /* Adds the logical flows from the Logical_Flow table to flow tables. */
 static void
 add_logical_flows(struct controller_ctx *ctx,
@@ -168,6 +182,15 @@ add_logical_flows(struct controller_ctx *ctx,
 }
 
 SBREC_LOGICAL_FLOW_FOR_EACH (lflow, ctx->ovnsb_idl) {
+ if (lflow->logical_port
+&& lflow->logical_port[0]
+&& !is_local_port(ctx, lflow->logical_port, chassis)) {
+VLOG_INFO("flow: table=%"PRIu64", priority=%"PRIu64", %s, "
+"actions=%s not need to add in this chassis",
+lflow->table_id, lflow->priority,
+lflow->match, lflow->actions);
+continue;
+}
 consider_logical_flow(ctx, chassis_index,
   lflow, local_datapaths,
   group_table, chassis,
diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index 2db2380..e879c43 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -2236,6 +2236,7 @@ struct ovn_lflow {
 char *match;
 char *actions;
 char *stage_hint;
+struct ovn_port *op;
 const char *where;
 };
 
@@ -2262,7 +2263,7 @@ static void
 ovn_lflow_init(struct ovn_lflow *lflow, struct ovn_datapath *od,
enum ovn_stage stage, uint16_t priority,
char *match, char *actions, char *stage_hint,
-   const char *where)
+   struct ovn_port *op, const char *where)
 {
 lflow->od = od;
 lflow->stage = stage;
@@ -2270,6 +2271,7 @@ ovn_lflow_init(struct ovn_lflow *lflow, struct 
ovn_datapath *od,
 lflow->match = match;
 lflow->actions = actions;
 lflow->stage_hint = stage_hint;
+lflow->op = op;
 lflow->where = where;
 }
 
@@ -2278,14 +2280,15 @@ static void
 ovn_lflow_add_at(struct hmap *lflow_map, struct ovn_datapath *od,
  enum ovn_stage stage, uint16_t priority,
  const char *match, const char *actions,
- const char *stage_hint, const char *where)
+ const char *stage_hint, struct ovn_port *op,
+ const char *where)
 {
 ovs_assert(ovn_stage_to_datapath_type(stage) == 
ovn_datapath_get_type(od));
 
 struct ovn_lflow *lflow = xmalloc(sizeof *lflow);
 ovn_lflow_init(lflow, od, stage, priority,
xstrdup(match), xstrdup(actions),
-   nullable_xstrdup(stage_hint), where);
+   nullable_xstrdup(stage_hint), op, where);
 hmap_insert(lflow_map, >hmap_node, ovn_lflow_hash(lflow));
 }
 
@@ -2293,11 +2296,17 @@ ovn_lflow_add_at(struct hmap *lflow_map, struct 
ovn_datapath *od,
 #define ovn_lflow_add_with_hint(LFLOW_MAP, OD, STAGE, PRIORITY, MATCH, \
 ACTIONS, STAGE_HINT) \
 ovn_lflow_add_at(LFLOW_MAP, OD, STAGE, PRIORITY, MATCH, ACTIONS, \
- STAGE_HINT, OVS_SOURCE_LOCATOR)
+ STAGE_HINT, NULL, OVS_SOURCE_LOCATOR)
+
+/* Adds a row with the port to the Logical_Flow table. */
+#define ovn_lflow_add_with_port(LFLOW_MAP, OD, STAGE, PRIORITY, MATCH, \
+ACTIONS, STAGE_HINT, OP) \
+ovn_lflow_add_at(LFLOW_MAP, OD, STAGE, PRIORITY, MATCH, ACTIONS, \
+ STAGE_HINT, OP, OVS_SOURCE_LOCATOR)
 
 #define ovn_lflow_add(LFLOW_MAP, OD,