From bac1b1f721e6b23da2063340827576fd9c59d0f4 Mon Sep 17 00:00:00 2001 From: LIU Yulong Date: Tue, 9 Apr 2024 09:11:03 +0800 Subject: [PATCH] More precise flow table cleaning OVS-agent wants to clean flows table by table during restart, but actually it does not. If one table has same cookie with other tables, all related flows will be clean at once. This patch adds the table_id param to the related call to limit the flow clean on one table at once. Closes-Bug: #2060587 Change-Id: I266eb0f5115af718b91f930d759581616310999d --- .../drivers/openvswitch/agent/openflow/native/ofswitch.py | 3 ++- .../ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/ofswitch.py b/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/ofswitch.py index f4021a648b9..8f6b69904a2 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/ofswitch.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/ofswitch.py @@ -183,7 +183,8 @@ class OpenFlowSwitchMixin(object): for c in cookies: LOG.warning("Deleting flow with cookie 0x%(cookie)x", {'cookie': c}) - self.uninstall_flows(cookie=c, cookie_mask=ovs_lib.UINT64_BITMASK) + self.uninstall_flows(table_id=table_id, + cookie=c, cookie_mask=ovs_lib.UINT64_BITMASK) def cleanup_flows(self): LOG.info("Reserved cookies for %s: %s", self.br_name, diff --git a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py index c63ebfaf706..f15b3efc73d 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py +++ b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py @@ -3045,9 +3045,11 @@ class TestOvsNeutronAgentOSKen(TestOvsNeutronAgent, mock.call(tid) for tid in ovs_constants.INT_BR_ALL_TABLES] dump_flows.assert_has_calls(dump_flows_expected) - expected = [mock.call(cookie=17185, + expected = [mock.call(table_id=2, + cookie=17185, cookie_mask=uint64_max), - mock.call(cookie=9029, + mock.call(table_id=2, + cookie=9029, cookie_mask=uint64_max)] uninstall_flows.assert_has_calls(expected, any_order=True) self.assertEqual(