From 80abbd9a339709c3308a40c35b72995bdd3c542b Mon Sep 17 00:00:00 2001 From: Vinicius Arcanjo Date: Tue, 9 Jul 2024 09:58:22 -0300 Subject: [PATCH 1/2] fix: removed cookie from match_id and covered with unit tests --- flow.py | 1 - tests/unit/test_flow.py | 10 +++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/flow.py b/flow.py index a851568..af65e45 100644 --- a/flow.py +++ b/flow.py @@ -115,7 +115,6 @@ def match_id(self): 'table_id': self.table_id, 'match': self.match.as_dict(), 'priority': self.priority, - 'cookie': self.cookie, } flow_str = json.dumps(flow_match_fields, sort_keys=True) md5sum = md5() diff --git a/tests/unit/test_flow.py b/tests/unit/test_flow.py index f1198e5..385577e 100644 --- a/tests/unit/test_flow.py +++ b/tests/unit/test_flow.py @@ -218,6 +218,10 @@ def test_match_id(): flow_one = {"match": Match04(**{"in_port": 1, "dl_vlan": 2})} flow_two = {"match": Match04(**{"in_port": 1, "dl_vlan": 2})} flow_three = {"match": Match04(**{"in_port": 1, "dl_vlan": 3})} + flow_four = {"match": Match04(**{"in_port": 1, "dl_vlan": 2}), + "cookie": 0x10} + flow_five = {"match": Match04(**{"in_port": 1, "dl_vlan": 2}), + "cookie": 0x20} assert Flow04(mock_switch, **flow_one).match_id == Flow04( mock_switch, **flow_two @@ -226,10 +230,14 @@ def test_match_id(): mock_switch, **flow_three ).match_id + # cookie shouldn't matter for match_id flow_two["cookie"] = 0x10 - assert Flow04(mock_switch, **flow_one).match_id != Flow04( + assert Flow04(mock_switch, **flow_one).match_id == Flow04( mock_switch, **flow_two ).match_id + assert Flow04(mock_switch, **flow_four).match_id == Flow04( + mock_switch, **flow_five + ).match_id class TestFlowBase: From 14e76dd83c18d417884d7aa61b879a95ba047a19 Mon Sep 17 00:00:00 2001 From: Vinicius Arcanjo Date: Tue, 9 Jul 2024 10:01:04 -0300 Subject: [PATCH 2/2] docs: updated CHANGELOG.rst --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 7c7ef98..1b4550b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -18,7 +18,7 @@ Fixed ===== - Multipart replies clean up now happens before connection gets established to be safer - Set ``interface.speed`` on ``PortStatus`` reason ``OFPPR_ADD`` and ``OFPPR_MODIFY`` - +- cookie is no longer a factor of a Flow match_id, just so equivalent matches but different cookies don't get different representations [2023.1.0] - 2023-06-05 ***********************