[ovs-dev] [PATCH ovn RFC v2 02/12] Move out Table 1 operations to functions

anton.ivanov at cambridgegreys.com anton.ivanov at cambridgegreys.com
Wed Jul 15 16:50:08 UTC 2020


From: Anton Ivanov <anton.ivanov at cambridgegreys.com>

The functions are numbered in 10 step intervals to minimize
renumbering if new pipeline stages are added in the future.

Signed-off-by: Anton Ivanov <anton.ivanov at cambridgegreys.com>
---
 northd/ovn-northd.c | 75 +++++++++++++++++++++++++++------------------
 1 file changed, 46 insertions(+), 29 deletions(-)

diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c
index 4374b88a6..1ec530854 100644
--- a/northd/ovn-northd.c
+++ b/northd/ovn-northd.c
@@ -8160,7 +8160,7 @@ build_lrouter_nd_flow(struct ovn_datapath *od, struct ovn_port *op,
 }
 
 static void
-build_lrouter_flows_table_0_od(struct ovn_datapath *od, struct hmap *lflows)
+build_lrouter_flows_step_0_od(struct ovn_datapath *od, struct hmap *lflows)
 {
     /* Logical router ingress table 0: Admission control framework. */
     if (od->nbr) {
@@ -8172,7 +8172,7 @@ build_lrouter_flows_table_0_od(struct ovn_datapath *od, struct hmap *lflows)
 }
 
 static void
-build_lrouter_flows_table_0_op(struct ovn_port *op, struct hmap *lflows)
+build_lrouter_flows_step_0_op(struct ovn_port *op, struct hmap *lflows)
 {
     struct ds match = DS_EMPTY_INITIALIZER;
     struct ds actions = DS_EMPTY_INITIALIZER;
@@ -8216,32 +8216,12 @@ build_lrouter_flows_table_0_op(struct ovn_port *op, struct hmap *lflows)
 }
 
 static void
-build_lrouter_flows(struct hmap *datapaths, struct hmap *ports,
-                    struct hmap *lflows, struct shash *meter_groups,
-                    struct hmap *lbs)
+build_lrouter_flows_step_10_od(struct ovn_datapath *od, struct hmap *lflows)
 {
-    /* This flow table structure is documented in ovn-northd(8), so please
-     * update ovn-northd.8.xml if you change anything. */
-
-    struct ds match = DS_EMPTY_INITIALIZER;
-    struct ds actions = DS_EMPTY_INITIALIZER;
-
-    struct ovn_datapath *od;
-    HMAP_FOR_EACH (od, key_node, datapaths) {
-        build_lrouter_flows_table_0_od(od, lflows);
-    }
-
-    struct ovn_port *op;
-    HMAP_FOR_EACH (op, key_node, ports) {
-        build_lrouter_flows_table_0_op(op, lflows);
-    }
-
     /* Logical router ingress table 1: LOOKUP_NEIGHBOR and
      * table 2: LEARN_NEIGHBOR. */
-    HMAP_FOR_EACH (od, key_node, datapaths) {
-        if (!od->nbr) {
-            continue;
-        }
+
+    if (od->nbr) {
 
         /* Learn MAC bindings from ARP/IPv6 ND.
          *
@@ -8299,11 +8279,15 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports,
         ovn_lflow_add(lflows, od, S_ROUTER_IN_LEARN_NEIGHBOR, 90,
                       "nd_ns", "put_nd(inport, ip6.src, nd.sll); next;");
     }
+}
 
-    HMAP_FOR_EACH (op, key_node, ports) {
-        if (!op->nbrp) {
-            continue;
-        }
+static void
+build_lrouter_flows_step_10_op(struct ovn_port *op, struct hmap *lflows)
+{
+    struct ds match = DS_EMPTY_INITIALIZER;
+    struct ds actions = DS_EMPTY_INITIALIZER;
+
+    if (op->nbrp) {
 
         /* Check if we need to learn mac-binding from ARP requests. */
         for (int i = 0; i < op->lrp_networks.n_ipv4_addrs; i++) {
@@ -8327,6 +8311,39 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports,
         }
     }
 
+    ds_destroy(&match);
+    ds_destroy(&actions);
+}
+
+static void
+build_lrouter_flows(struct hmap *datapaths, struct hmap *ports,
+                    struct hmap *lflows, struct shash *meter_groups,
+                    struct hmap *lbs)
+{
+    /* This flow table structure is documented in ovn-northd(8), so please
+     * update ovn-northd.8.xml if you change anything. */
+
+    struct ds match = DS_EMPTY_INITIALIZER;
+    struct ds actions = DS_EMPTY_INITIALIZER;
+
+    struct ovn_datapath *od;
+    HMAP_FOR_EACH (od, key_node, datapaths) {
+        build_lrouter_flows_step_0_od(od, lflows);
+    }
+
+    struct ovn_port *op;
+    HMAP_FOR_EACH (op, key_node, ports) {
+        build_lrouter_flows_step_0_op(op, lflows);
+    }
+
+    HMAP_FOR_EACH (od, key_node, datapaths) {
+        build_lrouter_flows_step_10_od(od, lflows);
+    }
+
+    HMAP_FOR_EACH (op, key_node, ports) {
+        build_lrouter_flows_step_10_op(op, lflows);
+    }
+
     /* Logical router ingress table 3: IP Input. */
     HMAP_FOR_EACH (od, key_node, datapaths) {
         if (!od->nbr) {
-- 
2.20.1



More information about the dev mailing list