kytos-ng / flow_manager

Kytos NApp that manages OpenFlow 1.3 entries
https://kytos-ng.github.io/api/flow_manager.html
MIT License
0 stars 6 forks source link

`OFPET_HELLO_FAILED` on this method `on_handle_errors` shouldn't try to process the event #110

Closed viniarck closed 1 year ago

viniarck commented 1 year ago

As highlighted on OF spec, an OFPT_ERROR with type OFPET_HELLO_FAILED will be sent if the negotiation fails, flow_manager shouldn't try to process it otherwise it can crash since the connection will be missing and it's not responsible for handling it:

"If the negotiated version is supported by the recipient, then the connection proceeds. Otherwise, the
recipient must reply with an OFPT_ERROR message with a type field of OFPET_HELLO_FAILED, a code field of
OFPHFC_COMPATIBLE, and optionally an ASCII string explaining the situation in data, and then terminate
the connection."
kytos $> 2022-09-21 14:29:31,519 - INFO [kytos.core.atcp_server] [atcp_server.py:131:connection_made] (MainThread) New connection from 127.0.0.1:38434
2022-09-21 14:29:31,520 - INFO [kytos.core.atcp_server] [atcp_server.py:131:connection_made] (MainThread) New connection from 127.0.0.1:38450
2022-09-21 14:29:31,521 - INFO [kytos.core.atcp_server] [atcp_server.py:131:connection_made] (MainThread) New connection from 127.0.0.1:38452
2022-09-21 14:29:31,530 - WARNING [kytos.napps.kytos/of_core] [main.py:435:fail_negotiation] (MainThread) connection ('127.0.0.1', 38434): version 1 negotiation failed
2022-09-21 14:29:31,533 - ERROR [kytos.napps.kytos/of_core] [main.py:323:process_new_connection] (MainThread) Connection ('127.0.0.1', 38434): Negotiation Failed
2022-09-21 14:29:31,536 - WARNING [kytos.napps.kytos/of_core] [main.py:435:fail_negotiation] (MainThread) connection ('127.0.0.1', 38450): version 1 negotiation failed
2022-09-21 14:29:31,539 - ERROR [kytos.napps.kytos/of_core] [main.py:323:process_new_connection] (MainThread) Connection ('127.0.0.1', 38450): Negotiation Failed
2022-09-21 14:29:31,543 - ERROR [kytos.core.helpers] [helpers.py:151:handler_context_apm] (thread_pool_sb_0) listen_to handler: <function Main.on_handle_errors at 0x7ff22c4c3670>, args:
 (<Main(flow_manager, stopped 140675471369920)>, KytosEvent('kytos/of_core.v0x04.messages.out.ofpt_error', {'message': ErrorMsg(xid=874), 'destination': Connection('127.0.0.1', 38434, N
one, None, <ConnectionState.FAILED: 3>)}, -1050)) traceback: Traceback (most recent call last):,   File "/home/viniarck/repos/kytos/kytos/core/helpers.py", line 146, in handler_context_
apm,     result = handler(*args),   File "/home/viniarck/repos/napps/napps/kytos/flow_manager/main.py", line 767, in on_handle_errors,     self.handle_errors(event),   File "/home/vinia
rck/repos/napps/napps/kytos/flow_manager/main.py", line 774, in handle_errors,     switch = connection.switch, AttributeError: 'NoneType' object has no attribute 'switch',

I encountered this when exploring PR https://github.com/kytos-ng/of_core/pull/82 that's dropping OF 1.0 support

Alopalao commented 1 year ago

How can I replicate this scenario? I run mininet with OF 1.0 and my result is:

kytos $> 2022-09-21 14:41:56,561 - INFO [kytos.core.atcp_server] (MainThread) New connection from 127.0.0.1:54530                                                                                          
2022-09-21 14:41:56,564 - WARNING [kytos.napps.kytos/of_core] (MainThread) connection ('127.0.0.1', 54530): version 1 negotiation failed
2022-09-21 14:41:56,564 - ERROR [kytos.napps.kytos/of_core] (MainThread) Connection ('127.0.0.1', 54530): Negotiation Failed
2022-09-21 14:41:57,062 - INFO [kytos.core.atcp_server] (MainThread) New connection from 127.0.0.1:35104
2022-09-21 14:41:57,062 - INFO [kytos.core.atcp_server] (MainThread) New connection from 127.0.0.1:35112
2022-09-21 14:41:57,064 - WARNING [kytos.napps.kytos/of_core] (MainThread) connection ('127.0.0.1', 35112): version 1 negotiation failed
2022-09-21 14:41:57,065 - ERROR [kytos.napps.kytos/of_core] (MainThread) Connection ('127.0.0.1', 35112): Negotiation Failed

Without ERROR from kytos.core.helper

viniarck commented 1 year ago

How can I replicate this scenario? I run mininet with OF 1.0 and my result is:

kytos $> 2022-09-21 14:41:56,561 - INFO [kytos.core.atcp_server] (MainThread) New connection from 127.0.0.1:54530                                                                                          
2022-09-21 14:41:56,564 - WARNING [kytos.napps.kytos/of_core] (MainThread) connection ('127.0.0.1', 54530): version 1 negotiation failed
2022-09-21 14:41:56,564 - ERROR [kytos.napps.kytos/of_core] (MainThread) Connection ('127.0.0.1', 54530): Negotiation Failed
2022-09-21 14:41:57,062 - INFO [kytos.core.atcp_server] (MainThread) New connection from 127.0.0.1:35104
2022-09-21 14:41:57,062 - INFO [kytos.core.atcp_server] (MainThread) New connection from 127.0.0.1:35112
2022-09-21 14:41:57,064 - WARNING [kytos.napps.kytos/of_core] (MainThread) connection ('127.0.0.1', 35112): version 1 negotiation failed
2022-09-21 14:41:57,065 - ERROR [kytos.napps.kytos/of_core] (MainThread) Connection ('127.0.0.1', 35112): Negotiation Failed

Without ERROR from kytos.core.helper

Hi, @Alopalao. Double check if you have kytos/flow_manager:2022.2.0 installed and enabled. If you do, when you run mininet with any topology on OF1.0 when the negotiatoin fails you should hit this issue since this method will be called, and it'll crash with an unhanded exception.