OpenFlow errors
In OpenFaucet, OpenFlow OFPT_ERROR error messages are represented
as exceptions of type OpenflowError. In a
message handler, sending an error message to the peer is done by
raising an OpenflowError exception, with
the appropriate error type, error code, and data to describe the
error. For instance, in an OpenFlow controller’s
handle_port_status()
callback:
from openfaucet import oferror
class MyController(object):
def handle_port_status(self, reason, desc):
# ...
raise oferror.OpenflowError(oferror.OFPET_BAD_REQUEST,
oferror.OFPBRC_EPERM, ())
The exception object is transparently catched and serialized by an
OpenFaucet IOpenflowControllerStub
protocol object into an OFPT_ERROR OpenFlow message.
-
class openfaucet.oferror.OpenflowError
-
__init__(error_type, error_code, data)
Create an OpenflowError.
Parameters: |
- error_type – The error type, as one of the OFPET_*
constants.
- error_code – The error code, as one of the OFP* error
code constants.
- data – The data attached in the error message, as a sequence
of binary strings.
|
A standard set of valid error types is defined in the OpenFlow
standard, as well as a set of valid error codes for every error
type. Most error types and codes can only be sent by a datapath to a
controller.
-
openfaucet.oferror.OFPET_HELLO_FAILED
The hello protocol failed. This error can be raised only when
handling an OFPT_HELLO message during the initial handshake.
-
openfaucet.oferror.OFPHFC_INCOMPATIBLE
- The peers use incompatible versions of the protocol.
-
openfaucet.oferror.OFPHFC_EPERM
- Permissions error.
-
openfaucet.oferror.OFPET_BAD_REQUEST
The request was not understood.
-
openfaucet.oferror.OFPBRC_BAD_VERSION
- The protocol version in the received message is not supported.
-
openfaucet.oferror.OFPBRC_BAD_TYPE
- The message type is not supported.
-
openfaucet.oferror.OFPBRC_BAD_STAT
- The stats type is not supported.
-
openfaucet.oferror.OFPBRC_BAD_VENDOR
- The received vendor ID is not supported.
-
openfaucet.oferror.OFPBRC_BAD_SUBTYPE
- The received vendor-specific subtype is not supported.
-
openfaucet.oferror.OFPBRC_EPERM
- Permissions error.
-
openfaucet.oferror.OFPBRC_BAD_LEN
- The message has an invalid length.
-
openfaucet.oferror.OFPBRC_BUFFER_EMPTY
- The specified buffer has already been used.
-
openfaucet.oferror.OFPBRC_BUFFER_UNKNOWN
- The specified buffer does not exist.
-
openfaucet.oferror.OFPET_BAD_ACTION
Error in an action description.
-
openfaucet.oferror.OFPBAC_BAD_TYPE
- Unknown action type.
-
openfaucet.oferror.OFPBAC_BAD_LEN
- An action has an invalid length.
-
openfaucet.oferror.OFPBAC_BAD_VENDOR
- A vendor action has a vendor ID that is unsupported.
-
openfaucet.oferror.OFPBAC_BAD_VENDOR_TYPE
- A vendor action has a vendor-specific subtype that is not
supported.
-
openfaucet.oferror.OFPBAC_BAD_OUT_PORT
- An output action has an invalid port number.
-
openfaucet.oferror.OFPBAC_BAD_ARGUMENT
- An action has an invalid argument.
-
openfaucet.oferror.OFPBAC_EPERM
- Permissions error.
-
openfaucet.oferror.OFPBAC_TOO_MANY
- Can’t handle this many actions.
-
openfaucet.oferror.OFPBAC_BAD_QUEUE
- An action has an invalid queue number argument.
-
openfaucet.oferror.OFPET_FLOW_MOD_FAILED
Problem when modifying a flow entry.
-
openfaucet.oferror.OFPFMFC_ALL_TABLES_FULL
- The flow cannot be added because of full tables.
-
openfaucet.oferror.OFPFMFC_OVERLAP
- Attempted to add an overlapping flow with check_overlap set to
True.
-
openfaucet.oferror.OFPFMFC_EPERM
- Permissions error.
-
openfaucet.oferror.OFPFMFC_BAD_EMERG_TIMEOUT
- The flow cannot added because emerg was set to True and
the idle and hard timeouts were set to non-zero.
-
openfaucet.oferror.OFPFMFC_BAD_COMMAND
- An OFPT_FLOW_MOD message was sent with an invalid command.
-
openfaucet.oferror.OFPFMFC_UNSUPPORTED
- The specified list of actions cannot be processed in this order.
-
openfaucet.oferror.OFPET_PORT_MOD_FAILED
A port modification request failed.
-
openfaucet.oferror.OFPPMFC_BAD_PORT
- The specified port number does not exist.
-
openfaucet.oferror.OFPPMFC_BAD_HW_ADDR
- The specified port hardware address is wrong.
-
openfaucet.oferror.OFPET_QUEUE_OP_FAILED
A queue operation failed.
-
openfaucet.oferror.OFPQOFC_BAD_PORT
- The specified port number does not exist or is invalid.
-
openfaucet.oferror.OFPQOFC_BAD_QUEUE
- The specified queue number does not exist.
-
openfaucet.oferror.OFPQOFC_EPERM
- Permissions error.
The semantics of data in an
OpenflowError depends on the error
type. For OFPET_HELLO_FAILED errors,
data is an ASCII text string that adds detail on why the error
occurred:
from openfaucet import oferror
raise oferror.OpenflowError(oferror.OFPET_HELLO_FAILED,
oferror.OFPHFC_INCOMPATIBLE,
('only v1.0.0 supported',))
For all other error types, data contains at least 64 bytes of the
failed
request. raise_error_with_request()
is a helper method of protocol objects that can be used to raise
exceptions with such data, for instance in a controller callback:
from openfaucet import oferror
class MyController(object):
def connection_made(self):
# ...
self.protocol().raise_error_with_request(oferror.OFPET_HELLO_FAILED,
oferror.OFPHFC_EPERM)