[ovs-dev] [PATCH v4 10/10] I-P: Handle sbrec_chassis changes

numans at ovn.org numans at ovn.org
Thu Apr 30 17:00:42 UTC 2020


From: Numan Siddique <numans at ovn.org>

When ovn-controller updates the nb_cfg column of its chassis,
this results in full recomputation on all the nodes. This results
in wastage of CPU cycles. To address this, this patch handles
sbrec_chassis changes incrementally.

We don't need to handle any sbrec_chassis changes during runtime_data
stage, because before engine_run() is called, encaps_run() is called
which will handle any chassis/encap changes.

For new chassis addition and deletion, we need to add/delete flows for
the tunnel ports created/deleted. So physical_run() is called for this.

For any chassis updates, we can ignore this for flow computation.

This patch handles all these.

Signed-off-by: Numan Siddique <numans at ovn.org>
---
 controller/ovn-controller.c | 53 ++++++++++++++++++++++++++++++-------
 tests/ovn.at                | 21 +++++++++++++--
 2 files changed, 62 insertions(+), 12 deletions(-)

diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c
index 58ede3a54..8c5ac2d8e 100644
--- a/controller/ovn-controller.c
+++ b/controller/ovn-controller.c
@@ -1379,7 +1379,8 @@ static void init_physical_ctx(struct engine_node *node,
 
     struct sbrec_chassis_table *chassis_table =
         (struct sbrec_chassis_table *)EN_OVSDB_GET(
-            engine_get_input("SB_chassis", node));
+            engine_get_input("SB_chassis",
+                engine_get_input("physical_flow_changes", node)));
 
     struct ed_type_mff_ovn_geneve *ed_mff_ovn_geneve =
         engine_get_input_data("mff_ovn_geneve", node);
@@ -1395,7 +1396,8 @@ static void init_physical_ctx(struct engine_node *node,
     const struct sbrec_chassis *chassis = NULL;
     struct ovsdb_idl_index *sbrec_chassis_by_name =
         engine_ovsdb_node_get_index(
-                engine_get_input("SB_chassis", node),
+                engine_get_input("SB_chassis",
+                    engine_get_input("physical_flow_changes", node)),
                 "name");
     if (chassis_id) {
         chassis = chassis_lookup_by_name(sbrec_chassis_by_name, chassis_id);
@@ -1472,7 +1474,8 @@ static void init_lflow_ctx(struct engine_node *node,
     const struct sbrec_chassis *chassis = NULL;
     struct ovsdb_idl_index *sbrec_chassis_by_name =
         engine_ovsdb_node_get_index(
-                engine_get_input("SB_chassis", node),
+            engine_get_input("SB_chassis",
+                engine_get_input("physical_flow_changes", node)),
                 "name");
     if (chassis_id) {
         chassis = chassis_lookup_by_name(sbrec_chassis_by_name, chassis_id);
@@ -1553,8 +1556,9 @@ en_flow_output_run(struct engine_node *node, void *data)
 
     struct ovsdb_idl_index *sbrec_chassis_by_name =
         engine_ovsdb_node_get_index(
-                engine_get_input("SB_chassis", node),
-                "name");
+            engine_get_input("SB_chassis",
+                engine_get_input("physical_flow_changes", node)),
+            "name");
 
     const struct sbrec_chassis *chassis = NULL;
     if (chassis_id) {
@@ -1719,8 +1723,9 @@ _flow_output_resource_ref_handler(struct engine_node *node, void *data,
 
     struct ovsdb_idl_index *sbrec_chassis_by_name =
         engine_ovsdb_node_get_index(
-                engine_get_input("SB_chassis", node),
-                "name");
+            engine_get_input("SB_chassis",
+                engine_get_input("physical_flow_changes", node)),
+            "name");
     const struct sbrec_chassis *chassis = NULL;
     if (chassis_id) {
         chassis = chassis_lookup_by_name(sbrec_chassis_by_name, chassis_id);
@@ -1871,6 +1876,31 @@ physical_flow_changes_ovs_iface_handler(struct engine_node *node OVS_UNUSED,
     return true;
 }
 
+/* Handles sbrec_chassis changes.
+ * If a new chassis is added or removed return false, so that
+ * physical flows are programmed.
+ * For any updates, there is no need for any flow computation.
+ * Encap changes will also result in sbrec_chassis changes,
+ * but we handle encap changes separately.
+ */
+static bool
+physical_flow_changes_sb_chassis_handler(struct engine_node *node OVS_UNUSED,
+                                         void *data OVS_UNUSED)
+{
+    struct sbrec_chassis_table *chassis_table =
+        (struct sbrec_chassis_table *)EN_OVSDB_GET(
+            engine_get_input("SB_chassis", node));
+
+    const struct sbrec_chassis *ch;
+    SBREC_CHASSIS_TABLE_FOR_EACH_TRACKED (ch, chassis_table) {
+        if (sbrec_chassis_is_deleted(ch) || sbrec_chassis_is_new(ch)) {
+            return false;
+        }
+    }
+
+    return true;
+}
+
 static bool
 flow_output_runtime_data_handler(struct engine_node *node,
                                  void *data OVS_UNUSED)
@@ -2079,6 +2109,10 @@ main(int argc, char *argv[])
                      NULL);
     engine_add_input(&en_physical_flow_changes, &en_ovs_interface,
                      physical_flow_changes_ovs_iface_handler);
+    engine_add_input(&en_physical_flow_changes, &en_sb_chassis,
+                     physical_flow_changes_sb_chassis_handler);
+    engine_add_input(&en_physical_flow_changes, &en_sb_encap,
+                     NULL);
 
     engine_add_input(&en_flow_output, &en_addr_sets,
                      flow_output_addr_sets_handler);
@@ -2093,8 +2127,6 @@ main(int argc, char *argv[])
     engine_add_input(&en_flow_output, &en_ovs_open_vswitch, NULL);
     engine_add_input(&en_flow_output, &en_ovs_bridge, NULL);
 
-    engine_add_input(&en_flow_output, &en_sb_chassis, NULL);
-    engine_add_input(&en_flow_output, &en_sb_encap, NULL);
     engine_add_input(&en_flow_output, &en_sb_multicast_group,
                      flow_output_sb_multicast_group_handler);
     engine_add_input(&en_flow_output, &en_sb_port_binding,
@@ -2121,7 +2153,8 @@ main(int argc, char *argv[])
                      runtime_data_ovs_interface_handler);
     engine_add_input(&en_runtime_data, &en_ovs_qos, NULL);
 
-    engine_add_input(&en_runtime_data, &en_sb_chassis, NULL);
+    engine_add_input(&en_runtime_data, &en_sb_chassis,
+                     runtime_data_noop_handler);
     engine_add_input(&en_runtime_data, &en_sb_datapath_binding,
                      runtime_data_sb_datapath_binding_handler);
     engine_add_input(&en_runtime_data, &en_sb_port_binding,
diff --git a/tests/ovn.at b/tests/ovn.at
index c04cd06d2..08ba219fd 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -11081,6 +11081,12 @@ only_broadcast_from_lrp1() {
 garp="fffffffffffff0000000000108060001080006040001f00000000001c0a80064000000000000c0a80064"
 echo $garp > expout
 
+OVS_WAIT_UNTIL(
+    [$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap > rcv_text
+     exp_rcvd=$(cat rcv_text | grep $garp | wc -l)
+     echo "expected received = $exp_rcvd"
+     test $exp_rcvd -ge 1])
+
 $PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv1_snoop_tx
 echo "packets on hv1-snoopvif:"
 cat hv1_snoop_tx
@@ -11109,12 +11115,17 @@ as hv1 reset_pcap_file snoopvif hv1/snoopvif
 as hv2 reset_pcap_file br-phys_n1 hv2/br-phys_n1
 as hv3 reset_pcap_file br-phys_n1 hv3/br-phys_n1
 
-# Wait for packets to be received.
-OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 100])
 trim_zeros() {
     sed 's/\(00\)\{1,\}$//'
 }
 
+# Wait for packets to be received.
+OVS_WAIT_UNTIL(
+    [$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap > rcv_text
+     exp_rcvd=$(cat rcv_text | grep $garp | wc -l)
+     echo "expected received = $exp_rcvd"
+     test $exp_rcvd -ge 1])
+
 $PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq >  hv1_snoopvif_tx
 AT_CHECK([sort hv1_snoopvif_tx], [0], [expout])
 $PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv3/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv3_br_phys_tx
@@ -11160,6 +11171,12 @@ trim_zeros() {
 garp="fffffffffffff00000000001810007de08060001080006040001f00000000001c0a80064000000000000c0a80064"
 echo $garp > expout
 
+OVS_WAIT_UNTIL(
+    [$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap > rcv_text
+     exp_rcvd=$(cat rcv_text | grep $garp | wc -l)
+     echo "expected received = $exp_rcvd"
+     test $exp_rcvd -ge 1])
+
 $PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq >  hv1_snoopvif_tx
 AT_CHECK([sort hv1_snoopvif_tx], [0], [expout])
 $PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv3/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv3_br_phys_tx
-- 
2.25.4



More information about the dev mailing list