kytos-ng / of_core

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

OF negotiation failed isn't much informative #84

Closed viniarck closed 1 year ago

viniarck commented 1 year ago

Currently, when OF negotiation fails there isn't information logged about the version from the connection that fails, it would be great to include the version of the OF header from that device to easily spot if it's an unexpected or unsupported version to facilitate for operators:

2022-09-21 13:54:06,594 - INFO [kytos.core.atcp_server] [atcp_server.py:131:connection_made] (MainThread) New connection from 127.0.0.1:45310
2022-09-21 13:54:06,595 - INFO [kytos.core.atcp_server] [atcp_server.py:131:connection_made] (MainThread) New connection from 127.0.0.1:45312
2022-09-21 13:54:06,596 - INFO [kytos.core.atcp_server] [atcp_server.py:131:connection_made] (MainThread) New connection from 127.0.0.1:45318
2022-09-21 13:54:06,601 - WARNING [kytos.napps.kytos/of_core] [main.py:435:fail_negotiation] (MainThread) connection ('127.0.0.1', 45310): version negotiation failed
2022-09-21 13:54:06,604 - ERROR [kytos.napps.kytos/of_core] [main.py:323:process_new_connection] (MainThread) Connection ('127.0.0.1', 45310): Negotiation Failed
2022-09-21 13:54:06,605 - WARNING [kytos.napps.kytos/of_core] [main.py:435:fail_negotiation] (MainThread) connection ('127.0.0.1', 45312): version negotiation failed
2022-09-21 13:54:06,605 - ERROR [kytos.napps.kytos/of_core] [main.py:323:process_new_connection] (MainThread) Connection ('127.0.0.1', 45312): Negotiation Failed
2022-09-21 13:54:06,605 - WARNING [kytos.napps.kytos/of_core] [main.py:435:fail_negotiation] (MainThread) connection ('127.0.0.1', 45318): version negotiation failed
2022-09-21 13:54:06,606 - ERROR [kytos.napps.kytos/of_core] [main.py:323:process_new_connection] (MainThread) Connection ('127.0.0.1', 45318): Negotiation Failed

Patching this log statement with would be more informative:

diff --git a/main.py b/main.py
index 6cfd62d..c6ac270 100644
--- a/main.py
+++ b/main.py
@@ -432,13 +432,13 @@ class Main(KytosNApp):

     async def fail_negotiation(self, connection, hello_message):
         """Send Error message and emit event upon negotiation failure."""
-        log.warning('connection %s: version negotiation failed',
-                    connection.id)
+        log.warning('connection %s: version %d negotiation failed',
+                    connection.id, hello_message.header.version)
kytos $> 2022-09-21 13:58:16,953 - INFO [kytos.core.atcp_server] [atcp_server.py:131:connection_made] (MainThread) New connection from 127.0.0.1:46642
2022-09-21 13:58:16,953 - INFO [kytos.core.atcp_server] [atcp_server.py:131:connection_made] (MainThread) New connection from 127.0.0.1:46644
2022-09-21 13:58:16,953 - INFO [kytos.core.atcp_server] [atcp_server.py:131:connection_made] (MainThread) New connection from 127.0.0.1:46656
2022-09-21 13:58:16,956 - WARNING [kytos.napps.kytos/of_core] [main.py:436:fail_negotiation] (MainThread) connection ('127.0.0.1', 46642): version 1 negotiation failed
2022-09-21 13:58:16,956 - ERROR [kytos.napps.kytos/of_core] [main.py:323:process_new_connection] (MainThread) Connection ('127.0.0.1', 46642): Negotiation Failed
2022-09-21 13:58:16,957 - WARNING [kytos.napps.kytos/of_core] [main.py:436:fail_negotiation] (MainThread) connection ('127.0.0.1', 46644): version 1 negotiation failed
2022-09-21 13:58:16,958 - ERROR [kytos.napps.kytos/of_core] [main.py:323:process_new_connection] (MainThread) Connection ('127.0.0.1', 46644): Negotiation Failed
2022-09-21 13:58:16,959 - WARNING [kytos.napps.kytos/of_core] [main.py:436:fail_negotiation] (MainThread) connection ('127.0.0.1', 46656): version 1 negotiation failed
2022-09-21 13:58:16,959 - ERROR [kytos.napps.kytos/of_core] [main.py:323:process_new_connection] (MainThread) Connection ('127.0.0.1', 46656): Negotiation Failed
viniarck commented 1 year ago

@Alopalao, if you could also include this minor enhancement on PR #82 that'd be great since we'll have to test/exercise OF negotiation failures there, thanks.

viniarck commented 1 year ago

Landed on https://github.com/kytos-ng/of_core/pull/82