kytos-ng / of_core

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

When handling `OFPMP_PORT_DESC` it's always creating active interfaces #89

Closed viniarck closed 1 year ago

viniarck commented 1 year ago

Currently, the handle_port_desc function, it's not considering whichever the port state of the event is, it's assuming it's active, so if you have an interface that's admin disabled it'll end up as active even though it's not in practice, so this will lead to issues since NApps might will incorrectly try to use an active interface that's in practice is down.

How to reproduce the issue

If you start a switch with a disabled interface in the real switch you should see the issue, here's an example of s1 with interface s1-eth2 disabled on OvS:

20221130_141001

kytos $> controller.switches['00:00:00:00:00:00:00:01'].interfaces[2].as_dict()
Out[7]:
{'id': '00:00:00:00:00:00:00:01:2',
 'name': 's1-eth2',
 'port_number': 2,
 'mac': '72:de:c9:71:1d:39',
 'switch': '00:00:00:00:00:00:00:01',
 'type': 'interface',
 'nni': True,
 'uni': False,
 'speed': 1250000000.0,
 'metadata': {},
 'lldp': True,
 'active': True,
 'enabled': True,
 'link': 'cf0f4071be426b3f745027f5d22bc61f8312ae86293c9b28e7e66015607a9260'}

Here's an EVC that got provisioned over s1-eth2 since the topology has an incorrect state for it:

{
    "active": true,
    "archived": false,
    "backup_links": [],
    "backup_path": [],
    "bandwidth": 0,
    "circuit_scheduler": [],
    "creation_time": "2022-11-30T17:21:53",
    "current_path": [
        {
            "active": true,
            "enabled": true,
            "endpoint_a": {
                "active": true,
                "enabled": true,
                "id": "00:00:00:00:00:00:00:01:2",
                "link": "cf0f4071be426b3f745027f5d22bc61f8312ae86293c9b28e7e66015607a9260",
                "lldp": true,
                "mac": "72:de:c9:71:1d:39",
                "metadata": {},
                "name": "s1-eth2",
                "nni": true,
                "port_number": 2,
                "speed": 1250000000.0,
                "switch": "00:00:00:00:00:00:00:01",
                "type": "interface",
                "uni": false
            },

Workaround

As an workaround, since port status are being upated correctly, if you perform a shut/no-shut it should update the state of the interface accordingly