kytos / flow_manager

MIT License
1 stars 16 forks source link

Disabled EVC leaves its flows in flow_manager #114

Closed italovalcy closed 3 years ago

italovalcy commented 3 years ago

Hi,

When you create an EVC and disable it, after some time the flows are recreated at the flow table of the switches.

Steps to reproduce:

  1. Run Kytos with mef_eline and a simple mininet topology (mn --topo linear,3 --controller=remote,ip=127.0.0.1)
  2. Create an EVC:
    $ curl -s -X POST -H 'Content-type: application/json' http://localhost:8181/api/kytos/mef_eline/v2/evc -d '{"uni_z": {"tag": {"value": 300, "tag_type": 1}, "interface_id": "00:00:00:00:00:00:00:02:1"}, "uni_a": {"tag": {"value": 300, "tag_type": 1}, "interface_id": "00:00:00:00:00:00:00:01:1"}, "enabled": true, "name": "Vlan300_Test_evc1", "dynamic_backup_path": true}'
    {"circuit_id":"81ff614dc44c4dc9"}
  3. Disable the EVC
    $ curl -s -X PATCH -H 'Content-type: application/json' http://localhost:8181/api/kytos/mef_eline/v2/evc/81ff614dc44c4dc9 -d '{"enable" : false}'
  4. wait a couple of minutes (at least the time for consistency check interval - see CONSISTENCY_INTERVAL in /var/lib/kytos/napps/kytos/flow_manager/settings.py)
  5. check the flow table of the switches:
    mininet> sh for s in s1 s2 s3; do echo ====== $s; ovs-ofctl dump-flows $s; done

Expected behavior: you should see only the OF LLDP flows

Actual behavior: the flows of the disabled EVC will be recreated:

mininet> sh for s in s1 s2 s3; do echo ====== $s; ovs-ofctl dump-flows $s; done
====== s1
 cookie=0x81ff614dc44c4dc9, duration=248.085s, table=0, n_packets=0, n_bytes=0, in_port="s1-eth1",dl_vlan=300 actions=mod_vlan_vid:300,mod_vlan_vid:4026,output:"s1-eth3"
 cookie=0x81ff614dc44c4dc9, duration=248.080s, table=0, n_packets=0, n_bytes=0, in_port="s1-eth3",dl_vlan=4026 actions=strip_vlan,output:"s1-eth1"
 cookie=0x0, duration=668.320s, table=0, n_packets=476, n_bytes=19992, priority=1000,dl_vlan=3799,dl_type=0x88cc actions=CONTROLLER:65535
====== s2
 cookie=0x81ff614dc44c4dc9, duration=248.125s, table=0, n_packets=0, n_bytes=0, in_port="s2-eth1",dl_vlan=300 actions=mod_vlan_vid:300,mod_vlan_vid:4026,output:"s2-eth2"
 cookie=0x81ff614dc44c4dc9, duration=248.119s, table=0, n_packets=0, n_bytes=0, in_port="s2-eth2",dl_vlan=4026 actions=strip_vlan,output:"s2-eth1"
 cookie=0x0, duration=668.401s, table=0, n_packets=476, n_bytes=19992, priority=1000,dl_vlan=3799,dl_type=0x88cc actions=CONTROLLER:65535
====== s3
 cookie=0x0, duration=668.315s, table=0, n_packets=476, n_bytes=19992, priority=1000,dl_vlan=3799,dl_type=0x88cc actions=CONTROLLER:65535
ajoaoff commented 3 years ago

Hi, @italovalcy. I was able to reproduce the error, but since the flows were actually removed from the switches when the EVC was disabled and they were reinstalled by the consistecy check, this is an issue in flow_manager, not here.

cmagnobarbosa commented 3 years ago

This problem occurs because the request sent to remove stored flows contains only the cookie field. Currently, consistency checking requires the flow used to remove a flow to be the same as the flow used in the installation (except by the REST request). The process to remove flows using a range the cookie are not supported by the consistency.

When the consistency check receives a flow dictionary that contain only the cookie field the default value the table_id, match are used to generate "Flow" object. Therefore, when the stored Flow of the installation the EVC are compared to the removal request using__eq__ they are not identified as the same, resulting in a problem in the consistency check.

The figure below details the problem:

bug_consistencia_english

Additional information:

Currently, two flows are compared using __eq__ https://github.com/kytos/of_core/blob/master/flow.py#L214

cmagnobarbosa commented 3 years ago

@italovalcy suggested changing the way to check if two flows are the same, he suggested use dictionary instead of __eq__ (this method comparing several fields of the Flow # L214). In addition, @ajoaoff suggested using the matching code available at https://github.com/amlight/flow_stats/blob/master/main.py, to replicate switch matching on the controller.

This change will make the consistency check supports that the deleted occurs sending only the cookie field or other field instead the requirement to send the complete flow. In additional some changes must be made to that the consistency check support restricted and not restricted exclusion,  as specified in the OpenFlow documentation.