773311
From 7aa75981dfc17eb7f0ac9ee7300e346f3b6a0c8e Mon Sep 17 00:00:00 2001
773311
From: Numan Siddique <numans@ovn.org>
773311
Date: Tue, 7 Jul 2020 18:30:20 +0530
773311
Subject: [PATCH 1/5] ovn-northd: Fix the missing lflow issue in LS_OUT_PRE_LB.
773311
773311
When load balancer(s) configured with VIPs are associated to a logical switch,
773311
then ovn-northd adds the below logical flow so that the packets in the egress
773311
switch pipeline enter the conntrack.
773311
773311
table=0 (ls_out_pre_lb      ), priority=100  , match=(ip), action=(reg0[[0]] = 1; next;)
773311
773311
ovn-northd maintains a local boolean variable 'vip_configured' in
773311
build_pre_lb() and adds the above lflow if this is true at the end.
773311
But this variable is overriden as -> vip_configured = !!lb->n_vips;
773311
when it loops through every load balancer associated with the logical switch.
773311
773311
This is wrong and this patch fixes this issue.
773311
773311
A test case is addd to test this scenario and the test case fails without the
773311
fix in this patch.
773311
773311
Fixes: bb9f2b9ce56c("ovn-northd: Consider load balancer active backends in router pipeline")
773311
773311
Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1849162
773311
Reported-by: Tim Rozet <trozet@redhat.com>
773311
Acked-by: Dumitru Ceara <dceara@redhat.com>
773311
Signed-off-by: Numan Siddique <numans@ovn.org>
773311
773311
(cherry-picked from master commit 59af6f9048946e16813ad7ad4e453b85989670e4)
773311
---
773311
 northd/ovn-northd.c |  2 +-
773311
 tests/ovn-northd.at | 73 +++++++++++++++++++++++++++++++++++++++++++++
773311
 2 files changed, 74 insertions(+), 1 deletion(-)
773311
773311
diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c
773311
index 8a809d020..2b891c68f 100644
773311
--- a/northd/ovn-northd.c
773311
+++ b/northd/ovn-northd.c
773311
@@ -4932,7 +4932,7 @@ build_pre_lb(struct ovn_datapath *od, struct hmap *lflows,
773311
              * table, we will eventually look at L4 information. */
773311
         }
773311
 
773311
-        vip_configured = !!lb->n_vips;
773311
+        vip_configured = (vip_configured || lb->n_vips);
773311
     }
773311
 
773311
     /* 'REGBIT_CONNTRACK_DEFRAG' is set to let the pre-stateful table send
773311
diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at
773311
index 37805d3d8..842800b90 100644
773311
--- a/tests/ovn-northd.at
773311
+++ b/tests/ovn-northd.at
773311
@@ -1485,3 +1485,76 @@ lsp2
773311
 ])
773311
 
773311
 AT_CLEANUP
773311
+
773311
+# This test case tests that when a logical switch has load balancers associated
773311
+# (with VIPs configured), the below logical flow is added by ovn-northd.
773311
+# table=0 (ls_out_pre_lb      ), priority=100  , match=(ip), action=(reg0[[0]] = 1; next;)
773311
+# This test case is added for the BZ -
773311
+# https://bugzilla.redhat.com/show_bug.cgi?id=1849162
773311
+#
773311
+# ovn-northd was not adding the above lflow if the last load balancer associated
773311
+# to the logical switch doesn't have the VIP configured even if other load
773311
+# balancers before the last one in the last have VIPs configured.
773311
+# So make sure that the above lflow is added even if one load balancer has VIP
773311
+# associated.
773311
+
773311
+AT_SETUP([ovn -- Load balancer - missing ls_out_pre_lb flows])
773311
+ovn_start
773311
+
773311
+ovn-nbctl ls-add sw0
773311
+ovn-nbctl lsp-add sw0 sw0-p1
773311
+
773311
+ovn-nbctl lb-add lb1 "10.0.0.10" "10.0.0.3"
773311
+ovn-nbctl lb-add lb2 "10.0.0.11" "10.0.0.4"
773311
+
773311
+ovn-nbctl --wait=sb sync
773311
+AT_CHECK([ovn-sbctl lflow-list | grep "ls_out_pre_lb.*priority=100" | grep reg0 | sort], [0], [dnl
773311
+])
773311
+
773311
+ovn-nbctl ls-lb-add sw0 lb1
773311
+ovn-nbctl --wait=sb sync
773311
+AT_CHECK([ovn-sbctl lflow-list | grep "ls_out_pre_lb.*priority=100" | grep reg0 | sort], [0], [dnl
773311
+  table=0 (ls_out_pre_lb      ), priority=100  , match=(ip), action=(reg0[[0]] = 1; next;)
773311
+])
773311
+
773311
+ovn-nbctl ls-lb-add sw0 lb2
773311
+ovn-nbctl --wait=sb sync
773311
+AT_CHECK([ovn-sbctl lflow-list | grep "ls_out_pre_lb.*priority=100" | grep reg0 | sort], [0], [dnl
773311
+  table=0 (ls_out_pre_lb      ), priority=100  , match=(ip), action=(reg0[[0]] = 1; next;)
773311
+])
773311
+
773311
+lb1_uuid=$(ovn-nbctl --bare --columns _uuid find load_balancer name=lb1)
773311
+lb2_uuid=$(ovn-nbctl --bare --columns _uuid find load_balancer name=lb2)
773311
+
773311
+ovn-nbctl clear load_balancer $lb1_uuid vips
773311
+ovn-nbctl --wait=sb sync
773311
+AT_CHECK([ovn-sbctl lflow-list | grep "ls_out_pre_lb.*priority=100" | grep reg0 | sort], [0], [dnl
773311
+  table=0 (ls_out_pre_lb      ), priority=100  , match=(ip), action=(reg0[[0]] = 1; next;)
773311
+])
773311
+
773311
+ovn-nbctl clear load_balancer $lb2_uuid vips
773311
+ovn-nbctl --wait=sb sync
773311
+AT_CHECK([ovn-sbctl lflow-list | grep "ls_out_pre_lb.*priority=100" | grep reg0 | sort], [0], [dnl
773311
+])
773311
+
773311
+ovn-nbctl set load_balancer $lb1_uuid vips:"10.0.0.10"="10.0.0.3"
773311
+ovn-nbctl set load_balancer $lb2_uuid vips:"10.0.0.11"="10.0.0.4"
773311
+
773311
+ovn-nbctl --wait=sb sync
773311
+AT_CHECK([ovn-sbctl lflow-list | grep "ls_out_pre_lb.*priority=100" | grep reg0 | sort], [0], [dnl
773311
+  table=0 (ls_out_pre_lb      ), priority=100  , match=(ip), action=(reg0[[0]] = 1; next;)
773311
+])
773311
+
773311
+# Now reverse the order of clearing the vip.
773311
+ovn-nbctl clear load_balancer $lb2_uuid vips
773311
+ovn-nbctl --wait=sb sync
773311
+AT_CHECK([ovn-sbctl lflow-list | grep "ls_out_pre_lb.*priority=100" | grep reg0 | sort], [0], [dnl
773311
+  table=0 (ls_out_pre_lb      ), priority=100  , match=(ip), action=(reg0[[0]] = 1; next;)
773311
+])
773311
+
773311
+ovn-nbctl clear load_balancer $lb1_uuid vips
773311
+ovn-nbctl --wait=sb sync
773311
+AT_CHECK([ovn-sbctl lflow-list | grep "ls_out_pre_lb.*priority=100" | grep reg0 | sort], [0], [dnl
773311
+])
773311
+
773311
+AT_CLEANUP
773311
-- 
773311
2.26.2
773311