[ovs-dev] [PATCH 2/2] ovn: fix lrouter flows building issue when easy SNAT configured

Dongjun dongj at dtdream.com
Thu Jul 28 06:30:38 UTC 2016


The lrouter drop the traffic to it's own port IPs unless the IPs are
configured for SNAT. Now these flows are still built.

Signed-off-by: Dongjun <dongj at dtdream.com>
---
 ovn/northd/ovn-northd.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
 mode change 100644 => 100755 ovn/northd/ovn-northd.c

diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
old mode 100644
new mode 100755
index 716f123..90394d1
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -2490,6 +2490,15 @@ op_put_networks(struct ds *ds, const struct ovn_port *op, bool add_bcast)
     ds_put_cstr(ds, "}");
 }
 
+static bool has_ip(ovs_be32 *ips, size_t size, ovs_be32 ip){
+    for (int i = 0; i < size; i++) {
+        if (ip == ips[i]) {
+            return true;
+        }
+    }
+    return false;
+}
+
 static void
 build_lrouter_flows(struct hmap *datapaths, struct hmap *ports,
                     struct hmap *lflows)
@@ -2689,11 +2698,8 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports,
         ds_put_cstr(&match, "ip4.dst == {");
         bool has_drop_ips = false;
         for (int i = 0; i < op->lrp_networks.n_ipv4_addrs; i++) {
-            for (int j = 0; j < n_snat_ips; j++) {
-                /* Packets to SNAT IPs should not be dropped. */
-                if (op->lrp_networks.ipv4_addrs[i].addr == snat_ips[j]) {
-                    continue;
-                }
+            if(has_ip(snat_ips, n_snat_ips, op->lrp_networks.ipv4_addrs[i].addr)){
+                continue;
             }
             ds_put_format(&match, "%s, ",
                           op->lrp_networks.ipv4_addrs[i].addr_s);
-- 
1.8.3.1




More information about the dev mailing list