Skip to content
This repository was archived by the owner on Apr 22, 2024. It is now read-only.

Commit 4a5a862

Browse files
gleybersonandradeberaldoleal
authored andcommitted
Fix _validate_in_port method of PacketOut class
There was an error in _validate_in_port method of openflow 1.3 PacketOut class
1 parent decbcac commit 4a5a862

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

pyof/v0x04/controller2switch/packet_out.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from pyof.foundation.exceptions import PackException, ValidationError
88
from pyof.v0x04.common.action import ListOfActions
99
from pyof.v0x04.common.header import Header, Type
10-
from pyof.v0x04.common.port import Port, PortNo
10+
from pyof.v0x04.common.port import PortNo
1111

1212
__all__ = ('PacketOut',)
1313

@@ -122,17 +122,8 @@ def _update_actions_len(self):
122122
self.actions_len = ListOfActions(self.actions).get_size()
123123

124124
def _validate_in_port(self):
125-
port = self.in_port
126-
127-
if isinstance(port, PortNo):
128-
valid = port in _VIRT_IN_PORTS
129-
elif isinstance(port, int):
130-
# Must use "else" because PortNo is an IntEnum and (int instance)
131-
valid = port >= 1 and port < PortNo.OFPP_MAX.value
132-
elif isinstance(port, Port):
133-
valid = port.is_valid()
134-
else: # unknown value
135-
valid = False
136-
137-
if not valid:
138-
raise ValidationError('{} is not a valid input port.'.format(port))
125+
is_valid_range = self.in_port > 0 and self.in_port <= PortNo.OFPP_MAX
126+
is_valid_virtual_in_ports = self.in_port in _VIRT_IN_PORTS
127+
128+
if (is_valid_range or is_valid_virtual_in_ports) is False:
129+
raise ValidationError(f'{self.in_port} is not a valid input port.')

0 commit comments

Comments
 (0)