kytos-ng / of_core

Kytos Main OpenFlow Network Application (NApp)
MIT License
0 stars 5 forks source link

Flow04 from_dict with an empty list of actions can result in an inconsistent `id` #64

Closed viniarck closed 2 years ago

viniarck commented 2 years ago

I've just realized this issue since flow_manager now has been optimized to rely more on the id when finding and comparing flows, since this can result in an inconsistent id, for example, these two flow dicts are semantically the same considering the default values:

flow1_dict = {"match": {"in_port": 1, "dl_vlan": 105}, "actions": []}
flow2_dict = {"match": {"in_port": 1, "dl_vlan": 105}}

But, the as_dict method would return respectively:

{'switch': '00:00:00:00:00:00:00:01', 'table_id': 0, 'match': {'in_port': 1, 'dl_vlan': 105}, 'priority': 32768, 'idle_timeout': 0, 'hard_timeout': 0, 'cookie': 0, 'cookie_mask': 0, 'instructions': [{'instruction_type': 'apply_actions', 'actions': []}]}
{'switch': '00:00:00:00:00:00:00:01', 'table_id': 0, 'match': {'in_port': 1, 'dl_vlan': 105}, 'priority': 32768, 'idle_timeout': 0, 'hard_timeout': 0, 'cookie': 0, 'cookie_mask': 0, 'instructions': []}

diff:

13,18c13
<   "instructions": [
<     {
<       "instruction_type": "apply_actions",
<       "actions": []
<     }
<   ]
---
>   "instructions": []