Skip to content

Commit

Permalink
Merge pull request #137 from kytos-ng/fix/match_id_cookie
Browse files Browse the repository at this point in the history
fix: `cookie` is no longer a factor of a Flow `match_id`
  • Loading branch information
viniarck authored Jul 17, 2024
2 parents a41245a + 14e76dd commit 3545b1c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
***********************
Expand Down
1 change: 0 additions & 1 deletion flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 9 additions & 1 deletion tests/unit/test_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit 3545b1c

Please sign in to comment.