Currently, when Ryu failed to negotiate the OpenFlow version with a
switch, Ryu will send the OFPT_ERROR message with an error reason on its
data field.
But on Python 3, error reason string is a str type value and required to
be encoded into a bytes type value, otherwise causes an exception when
sending the message.
This patch fixes to encode the given str value into a bytes type value
in OFPErrorMsg.__init__() and solves this problem.
Signed-off-by: William Fisher <william.w.fisher@gmail.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
With this patch, when failed to negotiate the OpenFlow version with a
switch, Ryu will close the socket connecting to the switch after sending
a OFPT_ERROR message.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
If a sender closes a socket immediately after sending some data, a
receiver can fail to receive full data from the sender.
This patch fixes to shutdown a socket with "SHUT_WR" (disallows further
sends only) and enables "Datapath" to wait for a switch to disconnect
the connection.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Currently, Ryu does not provide the way to close a socket connecting to
a switch after sending all enqueued messages, but provides only the way
to close the socket immediately regardless of enqueued messages.
This patch adds a new option "close_socket" into "Datapath.send_msg()"
method and this option enables to close the socket after sending the
given message. This patch is convenient to close the socket after
sending OFPT_ERROR message to the switch.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This patch adds the example to explain how to register dpset.DPSet
service and how to get DPSet instance from user application in order to
call the API of DPSet.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
As a default, netaddr.valid_ipv4() uses the "aton" rule for its validation,
so valid_ipv4('2') and valid_ipv4('1.2.3') returns True.
It may cause unexpected behaviors.
This commit replaces netaddr.valid_ipv4() to ryu.lib.ip.valid_ipv4(),
which is wrapper of netaddr.valid_ipv4(), and use "pton" rule in the method.
So, address representation like '2' or '1.2.3' will be rejected.
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
This patch enables to initiate OpenFlow connection from controller side
by using "--ofp-switch-address-list" and "--ofp-switch-connect-interval"
options.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This patch introduces "timestamp" attribute for OpenFlow event classes
which shows when that event was generated by Datapath instance and nearly
equivalent to when Ryu finished receiving the message contained in that
event instance.
Suggested-by: Matthew Hayes <matthew_john_hayes@hotmail.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Currently, OFPErrorExperimenterMsg is not registered into OpenFlow
message events dict as "EventOFPErrorExperimenterMsg", and could not be
converted to events by ofp_event module.
This patch obsolete OFPErrorExperimenterMsg class and fixes to use
EventOFPErrorMsg to handle the experimenter error messages.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
With netaddr.valid_ipv4/6, empty host is not allowed and will fail
to validate.
This patch changes to the default openflow listen host to "0.0.0.0"
and enable to validate it by using netaddr.
Note: The default behavior is NOT changed.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
OFPErrorMsg.data usually contains the offending OpenFlow message,
but is an ASCII text string if its type is OFPET_HELLO_FAILED.
Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
When disconnecting switches, dpset will fail to unregister ports,
because size of values in the port state dictionary might be
changed when doing the iteration.
This patch fixes to copy the values list and fixes this problem.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
When the controller receive loop currently accepts an OpenFlow
message, it does not validate the message length. As a result, a
malicious or malfunctioning switch could cause send a message that
would result in the receive loop making no forward progress.
This patch ensures that the message length passed in the OpenFlow
message is validated against the specified minimum, and forced to that
value if it is smaller.
Thanks to Samuel Jero (at Purdue's Dependable and Secure Distributed
Systems Lab) for discovering this issue.
Signed-off-by: Victor J. Orlikowski <vjo@duke.edu>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Navigates back the stack to locate the module instead of relying on
inspect to locate the module based on the file name.
This patch is suggested by papostolescu as Pull Request(*1)
on GitHub.
(*1) https://github.com/osrg/ryu/pull/26
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
When a Datapath disconnects, an application may not know about it
until it attempts to send a message to that Datapath.
Ryu's core will detect the failure to send, and will close the
Datapath object - but has no way of letting the application know that
it did so.
With this patch, send_msg() returns True or False, depending on
whether the message that the application was trying to send was able
to be enqueued to send via a given Datapath object.
If the Datapath.send_msg() returns False, the calling application can
thereby determine that the Datapath is no longer valid, and should
clean up any references it has to it.
Existing applications may choose to ignore the return value, and
nothing breaks.
I have patched one utility method that uses send_msg(), since it was
not marked as deprecated. All utility methods marked as deprecated, I
have not altered.
Signed-off-by: Victor J. Orlikowski <vjo@duke.edu>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
IANA has registered TCP port 6653 for OpenFlow, but 6633 was the
de facto standard for a long while.
So some applications might be using 6633 as the default.
But now, Mininet has adopted port 6653 as the default, we migrate
to port 6653 too.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
To improve maintainability, this patch moves the descriptions of
"Ryu application API" into each source code.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Because ryu/app/rest_nw_id.py has been deleted, the reference for
NW_ID_UNKNOWN can not be resolved now.
This patch fixes this problem.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
To notify ofp_port state change, this patch implements
ofp_event.EventOFPPortStateChange.
This event performs like EventOFPPortStatus, but ofp_handler will
send this event after updating "ports" dict of datapath instances.
And, this patch suppresses the warning when user app accessing
to datapath.ports for backward compatibility.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Victor J. Orlikowski <vjo@duke.edu>
Tested-by: Andy Hill <hillad@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
A set of minor cleanups.
1) Remove the unused import of MAIN_DISPATCHER from ryu.controller.handler.
2) Remove the extraneous "close_requested" variable.
3) Ensure use of equality instead of identity for testing against DEAD_DISPATCHER.
4) Alter the exit condition for the _send_loop.
Signed-off-by: Victor J. Orlikowski <vjo@duke.edu>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Add a new feature: an echo request loop, which implements a liveness
check for connected Datapaths. This feature is off by default, but can
be enabled by setting the config file option
maximum_unreplied_echo_requests to a positive integer value.
Signed-off-by: Victor J. Orlikowski <vjo@duke.edu>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Change socket-timeout from being a CLI option to being a config file
option, since this should not *normally* need to be set on the command
line.
Signed-off-by: Victor J. Orlikowski <vjo@duke.edu>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Also, temporarily work around a bug in eventlet's Queue.put() by
wrapping the send_q with a semaphore.
Signed-off-by: Victor J. Orlikowski <vjo@duke.edu>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
OpenFlow Spec defines that the data field should contain at least
64 bytes of the failed request that caused the error message to be
generated, unless otherwise specified.
But, the data field can be empty in some switch implementation,
this patch checks the data field length and skips parsing it if the
field does not contain enough bytes to parse.
Reported-by: Yury Yurochko <y.yurochko@brain4net.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This patch adds ports to the EventDPReconnected in dpset, and adds an EventSwitchReconnected to the topology module.
Signed-off-by: Victor J. Orlikowski <vjo@duke.edu>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Just cleaning up where the patch you previously applied for me is the original version, and not the corrected version.
Thanks for applying the original!
Signed-off-by: Victor J. Orlikowski <vjo@duke.edu>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
If a switch connects multiple times, there are a number of potential
causes. A potential cause is that the OF agent on the switch crashed,
and was re-launched - but, because of the crash, Ryu believes that the
switch is still connected.
Should this occur, the newly re-launched OF agent on the switch often
clears the flow tables on the switch, before connecting to the
controller. When the switch agent re-connects to Ryu, the state of
the flow tables on the switch may not match what Ryu expects.
As a result, I suggest generating a new event: EventDPReconnected
Extending the existing EventDP would change semantics, and would break
apps others have written that rely on those semantics.
Applications registering a handler for EventDPReconnected would then
be able to choose whether to wipe the flow tables on the switch and
re-send flow rules, or whether to probe the switch with a flow-stats
message, and re-send rules more carefully.
Adding EventDPReconnected is the best solution to not break existing
apps, and to implement the following portion of section 6.3.3
(“Connection Interruption”) of the OpenFlow 1.3.4 specification, for
switches that have connected multiple times:
" When the OpenFlow channel is reestablished, the flow entries present
in the flow tables at that time are preserved and normal OpenFlow
operation resumes. If desired, the controller has then the option of
reading all flow entries with a flow-stats request (see 7.3.5.2), to
re-synchronise its state with the switch state. Alternatively, the
controller then has the option of deleting all flow entries with a
flow-mod request (see 6.4), to start from a clean state on the switch.
"
Signed-off-by: Victor J. Orlikowski <vjo@duke.edu>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
We have found, in production usage, a race condition in the transition to config mode.
If a sufficient number of events is being received, the reply to the FeaturesRequest may be received before the datapath is able to move into CONFIG_DISPATCHER state. As a result, the EventOFPSwitchFeatures handler may never fire (because the reply is received before the datapath has changed state).
This patch also includes a minor typo fix.
Signed-off-by: Victor J. Orlikowski <vjo@duke.edu>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
While continuing to run our application with the stability patch I submitted earlier, I discovered additional failure modes for some of our hardware switches were causing unexpected exceptions.
This revision better handles these situations.
Signed-off-by: Victor J. Orlikowski <vjo@duke.edu>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Because Ryu always sends SET_CONFIG message when a datapath connecting,
the switch configurations of user applications will be overwritten by
the default values of Ryu when the datapath re-connecting.
This patch removes sending SET_CONFIG message from ofp_handler and
avoids this problem.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
When Ryu getting multiple OpenFlow messages in a single packet,
_recv_loop() can pass the messages data including the subsequent
OpenFlow message binary data to ofproto_parser.msg().
If the received OpenFlow message containing a binary data field
(e.g. Echo-Reply, Packet-In), the parser may compose messages
class with the subsequent messages data into the data field.
This patch splits the received message buffer by the recieved
OpenFlow message lenght and passes it to the parser.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
If a switch gets disconnected via a network interruption on the control plane (or a similar event),
the datapath associated with that switch might not be properly cleaned up.
At the same time, the socket associated with that datapath can get leaked.
This ultimately results in file descriptor resource exhaustion for Ryu,
as a socket had the potential to be leaked on each reconnect.
Also, a small typo was corrected in a method name in DPSet.
Currently, the error message event log which is output by ofp_handler.py
is difficult to understand what is wrong in the previous OpenFlow request
message.
This patch improves the readability of this output to find out errors.
*** Output Example ***
EventOFPErrorMsg received.
version=0x4, msg_type=0x1, msg_len=0x4c, xid=0xecc7f07b
`-- msg_type: OFPT_ERROR(1)
OFPErrorMsg(type=0x4, code=0x9, data=b'\x04\x0e\x00\x58\xec\xc7\xf0\x7b\x00\x0
0\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
x00\x2b\x67\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x0
0\x01\x00\x0c\x80\x00\x18\x04\xc0\xa8\x00\x01\x00\x00\x00\x00')
|-- type: OFPET_BAD_MATCH(4)
|-- code: OFPBMC_BAD_PREREQ(9)
`-- data: version=0x4, msg_type=0xe, msg_len=0x58, xid=0xecc7f07b
`-- msg_type: OFPT_FLOW_MOD(14)
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This patch is generated by "2to3 -f dict" and irrevant parts were
hand-removed.
Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
UserWarning is always shown when ryu.controller.dpset.DPset is loaded. It is noisy.
Signed-off-by: Satoshi Kobayashi <satoshi-k@stratosphere.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Datapath#ports is kept for compatibility with the previous openflow versions (< 1.3). Datapath#ports is not updated when received EventOFPPortStatus. This behavior may confuse users. Wherefore, showing warning message when the user accesses to Datapath#ports with the currently openflow versions (>= 1.3) is friendly.
Signed-off-by: Satoshi Kobayashi <satoshi-k@stratosphere.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
We use syntaxes which can be used only in Python2 at many locations. But we should reduce the use of the syntaxes. This patch serves syntax level compatibility with Python3. However, for full compatibility is required still a lot of work because many API changes are made between 2 to 3.
Signed-off-by: Satoshi Kobayashi <satoshi-k@stratosphere.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
port from wiki.
dummy quantumclient is necessary to import ryu.app.quantum_adapter by
sphinx.ext.autodoc.
Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>