kytos / python-openflow

Low level OpenFlow messages parser used by Kytos SDN Platform
https://kytos.io/
MIT License
46 stars 35 forks source link

`PackException` error running Kytos with OpenFlow 1.0 #630

Closed cmagnobarbosa closed 3 years ago

cmagnobarbosa commented 3 years ago

Running Kytos with OpenFlow 1.0 we get the PackException error with the message 'PortStatsRequest.port_no - Expected UBInt16, found value "None" of type NoneType, this error interrupted the normal execution of Kytos.

How to Reproduce:

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/carlosmagno/workspace/kytos/Teste_Coverage/python-openflow/pyof/foundation/base.py", line 695, in pack message += class_value.pack(instance_value) File "/home/carlosmagno/workspace/kytos/Teste_Coverage/python-openflow/pyof/foundation/base.py", line 193, in pack raise PackException(msg) pyof.foundation.exceptions.PackException: Expected UBInt16, found value "None" of type NoneType

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/carlosmagno/workspace/kytos/Teste_Coverage/kytos/kytos/core/controller.py", line 517, in msg_out_event_handler packet = message.pack() File "/home/carlosmagno/workspace/kytos/Teste_Coverage/python-openflow/pyof/v0x01/controller2switch/stats_request.py", line 52, in pack self.body = value.pack() File "/home/carlosmagno/workspace/kytos/Teste_Coverage/python-openflow/pyof/foundation/base.py", line 699, in pack raise PackException(msg) pyof.foundation.exceptions.PackException: PortStatsRequest.port_no - Expected UBInt16, found value "None" of type NoneType

2021-01-18 11:54:38,865 - INFO [kytos.core.atcp_server] (MainThread) Connection lost with client 127.0.0.1:59362. Reason: Request closed by client 2021-01-18 11:54:40,048 - INFO [kytos.core.atcp_server] (MainThread) New connection from 127.0.0.1:59366 2021-01-18 11:54:41,049 - INFO [kytos.core.atcp_server] (MainThread) Connection lost with client 127.0.0.1:59366. Reason: Request closed by client 2021-01-18 11:54:41,431 - INFO [kytos.core.atcp_server] (MainThread) Connection lost with client 127.0.0.1:59356. Reason: Request closed by client

My environment:

Platform

Release information

Distributor ID: Ubuntu Description: Ubuntu 20.10 Release: 20.10 Codename: groovy

System Information

Linux carlosmagno-Lenovo-ideapad-330S-15IKB 5.8.0-25-generic kytos/kytos#26-Ubuntu SMP Thu Oct 15 10:30:38 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Python

path=/home/carlosmagno/workspace/kytos/Teste_Coverage/env_task_retrieve_error/bin/python version=Python 3.6.12

Pip

path=/home/carlosmagno/workspace/kytos/Teste_Coverage/env_task_retrieve_error/bin/pip version=pip 20.3.3 from /home/carlosmagno/workspace/kytos/Teste_Coverage/env_task_retrieve_error/lib/python3.6/site-packages/pip (python 3.6)

Python Packages

kytos | github.com:cmagnobarbosa/kytos | f145a7f7
kytos_of_core | github.com:cmagnobarbosa/of_core | ccaa0d2c
kytos_utils | github.com:cmagnobarbosa/kytos-utils | a16a659e
python_openflow | github.com:cmagnobarbosa/python-openflow | 0537c626

Kytos environment

Kytosd

path=/home/carlosmagno/workspace/kytos/Teste_Coverage/env_task_retrieve_error/bin/kytosd version=kytosd 2020.2

Kytos

path=/home/carlosmagno/workspace/kytos/Teste_Coverage/env_task_retrieve_error/bin/kytos version=kytos command line, version 2020.2

Installed napps

Status | NApp ID | Description
=======+=====================+============================================================================= [ie] | kytos/of_core:1.5.1 | OpenFlow Core of Kytos Controller, responsible for main OpenFlow operations.

Status: (i)nstalled, (e)nabled

ajoaoff commented 3 years ago

The problem is here:

    body = PortStatsRequest()
    stats_request = StatsRequest(
        body_type=StatsType.OFPST_PORT,
        body=body)

PortStatsRequest has a default value of None for the port_no parameter, but None makes no sense here. There are two possible solutions, send port_no=Port.OFPP_NONE when creating the body, or change the default value to Port.OFPP_NONE, which in my opinion is best.