5f9769
From 34c2afc7d49f735e825e0d01bf1b2b64bb277f76 Mon Sep 17 00:00:00 2001
5f9769
Message-Id: <34c2afc7d49f735e825e0d01bf1b2b64bb277f76.1610458802.git.lorenzo.bianconi@redhat.com>
5f9769
In-Reply-To: <f21c1b7a467a691847b5552d4570af706fcc5bb0.1610458802.git.lorenzo.bianconi@redhat.com>
5f9769
References: <f21c1b7a467a691847b5552d4570af706fcc5bb0.1610458802.git.lorenzo.bianconi@redhat.com>
5f9769
From: Anton Ivanov <anton.ivanov@cambridgegreys.com>
5f9769
Date: Tue, 5 Jan 2021 17:49:36 +0000
5f9769
Subject: [PATCH 09/16] ovn-northd: Move lrouter arp and nd datapath processing
5f9769
 to a function.
5f9769
5f9769
Signed-off-by: Anton Ivanov <anton.ivanov@cambridgegreys.com>
5f9769
Signed-off-by: Numan Siddique <numans@ovn.org>
5f9769
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
5f9769
---
5f9769
 northd/ovn-northd.c | 96 +++++++++++++++++++++++----------------------
5f9769
 1 file changed, 50 insertions(+), 46 deletions(-)
5f9769
5f9769
diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c
5f9769
index 92300e017..7f7bb07be 100644
5f9769
--- a/northd/ovn-northd.c
5f9769
+++ b/northd/ovn-northd.c
5f9769
@@ -8937,52 +8937,6 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports,
5f9769
     struct ovn_datapath *od;
5f9769
     struct ovn_port *op;
5f9769
 
5f9769
-    HMAP_FOR_EACH (od, key_node, datapaths) {
5f9769
-        if (!od->nbr) {
5f9769
-            continue;
5f9769
-        }
5f9769
-
5f9769
-        /* Priority-90-92 flows handle ARP requests and ND packets. Most are
5f9769
-         * per logical port but DNAT addresses can be handled per datapath
5f9769
-         * for non gateway router ports.
5f9769
-         *
5f9769
-         * Priority 91 and 92 flows are added for each gateway router
5f9769
-         * port to handle the special cases. In case we get the packet
5f9769
-         * on a regular port, just reply with the port's ETH address.
5f9769
-         */
5f9769
-        for (int i = 0; i < od->nbr->n_nat; i++) {
5f9769
-            struct ovn_nat *nat_entry = &od->nat_entries[i];
5f9769
-
5f9769
-            /* Skip entries we failed to parse. */
5f9769
-            if (!nat_entry_is_valid(nat_entry)) {
5f9769
-                continue;
5f9769
-            }
5f9769
-
5f9769
-            /* Skip SNAT entries for now, we handle unique SNAT IPs separately
5f9769
-             * below.
5f9769
-             */
5f9769
-            if (!strcmp(nat_entry->nb->type, "snat")) {
5f9769
-                continue;
5f9769
-            }
5f9769
-            build_lrouter_nat_arp_nd_flow(od, nat_entry, lflows);
5f9769
-        }
5f9769
-
5f9769
-        /* Now handle SNAT entries too, one per unique SNAT IP. */
5f9769
-        struct shash_node *snat_snode;
5f9769
-        SHASH_FOR_EACH (snat_snode, &od->snat_ips) {
5f9769
-            struct ovn_snat_ip *snat_ip = snat_snode->data;
5f9769
-
5f9769
-            if (ovs_list_is_empty(&snat_ip->snat_entries)) {
5f9769
-                continue;
5f9769
-            }
5f9769
-
5f9769
-            struct ovn_nat *nat_entry =
5f9769
-                CONTAINER_OF(ovs_list_front(&snat_ip->snat_entries),
5f9769
-                             struct ovn_nat, ext_addr_list_node);
5f9769
-            build_lrouter_nat_arp_nd_flow(od, nat_entry, lflows);
5f9769
-        }
5f9769
-    }
5f9769
-
5f9769
     /* Logical router ingress table 3: IP Input for IPv4. */
5f9769
     HMAP_FOR_EACH (op, key_node, ports) {
5f9769
         if (!op->nbrp) {
5f9769
@@ -11308,6 +11262,55 @@ build_ipv6_input_flows_for_lrouter_port(
5f9769
 
5f9769
 }
5f9769
 
5f9769
+static void
5f9769
+build_lrouter_arp_nd_for_datapath(struct ovn_datapath *od,
5f9769
+                                  struct hmap *lflows)
5f9769
+{
5f9769
+    if (od->nbr) {
5f9769
+
5f9769
+        /* Priority-90-92 flows handle ARP requests and ND packets. Most are
5f9769
+         * per logical port but DNAT addresses can be handled per datapath
5f9769
+         * for non gateway router ports.
5f9769
+         *
5f9769
+         * Priority 91 and 92 flows are added for each gateway router
5f9769
+         * port to handle the special cases. In case we get the packet
5f9769
+         * on a regular port, just reply with the port's ETH address.
5f9769
+         */
5f9769
+        for (int i = 0; i < od->nbr->n_nat; i++) {
5f9769
+            struct ovn_nat *nat_entry = &od->nat_entries[i];
5f9769
+
5f9769
+            /* Skip entries we failed to parse. */
5f9769
+            if (!nat_entry_is_valid(nat_entry)) {
5f9769
+                continue;
5f9769
+            }
5f9769
+
5f9769
+            /* Skip SNAT entries for now, we handle unique SNAT IPs separately
5f9769
+             * below.
5f9769
+             */
5f9769
+            if (!strcmp(nat_entry->nb->type, "snat")) {
5f9769
+                continue;
5f9769
+            }
5f9769
+            build_lrouter_nat_arp_nd_flow(od, nat_entry, lflows);
5f9769
+        }
5f9769
+
5f9769
+        /* Now handle SNAT entries too, one per unique SNAT IP. */
5f9769
+        struct shash_node *snat_snode;
5f9769
+        SHASH_FOR_EACH (snat_snode, &od->snat_ips) {
5f9769
+            struct ovn_snat_ip *snat_ip = snat_snode->data;
5f9769
+
5f9769
+            if (ovs_list_is_empty(&snat_ip->snat_entries)) {
5f9769
+                continue;
5f9769
+            }
5f9769
+
5f9769
+            struct ovn_nat *nat_entry =
5f9769
+                CONTAINER_OF(ovs_list_front(&snat_ip->snat_entries),
5f9769
+                             struct ovn_nat, ext_addr_list_node);
5f9769
+            build_lrouter_nat_arp_nd_flow(od, nat_entry, lflows);
5f9769
+        }
5f9769
+    }
5f9769
+}
5f9769
+
5f9769
+
5f9769
 struct lswitch_flow_build_info {
5f9769
     struct hmap *datapaths;
5f9769
     struct hmap *ports;
5f9769
@@ -11360,6 +11363,7 @@ build_lswitch_and_lrouter_iterate_by_od(struct ovn_datapath *od,
5f9769
     build_arp_request_flows_for_lrouter(od, lsi->lflows, &lsi->match,
5f9769
                                         &lsi->actions);
5f9769
     build_misc_local_traffic_drop_flows_for_lrouter(od, lsi->lflows);
5f9769
+    build_lrouter_arp_nd_for_datapath(od, lsi->lflows);
5f9769
 }
5f9769
 
5f9769
 /* Helper function to combine all lflow generation which is iterated by port.
5f9769
-- 
5f9769
2.29.2
5f9769