2840 Commits

Author SHA1 Message Date
Victor Orlikowski
09644f186c Validate OpenFlow message length in header, to prevent controller receive loop DoS
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>
2016-08-25 15:04:25 +09:00
Iwase Yusuke
ba1fb5cf06 PyInstaller: Enable to build stand-alone executables
Usage: After installing Ryu (on virtualenv is better), build a
ryu-manager executable as following:
   $ pip install PyInstaller==3.1.1
   $ cd tools/
   $ pyinstaller ryu-manager.spec
   $ ./dist/ryu-manager

Note: PyInstaller==3.2 may have a bug of str encoding, please use
Pyinstaller==3.1.1 instead.
   https://github.com/pyinstaller/pyinstaller/issues/1976

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-25 14:25:57 +09:00
Iwase Yusuke
db0f6c1165 handler: Fix for frozen builds
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>
2016-08-25 14:25:40 +09:00
IWASE Yusuke
37df91f7f4 BGPSpeaker: Suppress RD in EVPN VRF on SSH console
Because the NLRI_CLASS of the VRF EVPN Table is the same as the
NLRI_CLASS of the Global EVPN Table, the str representation can not
be distinguished with 'formatted_nlri_str' format.
So, 'show vrf' commands on the SSH console returns the str outputs
with Route Distinguisher (RD) even if the route on the VRF Table
can be identified without RD value.

This patch implements the str representation properties to output
BGP routes on SSH console.

Current: RD '65001:100' is duplicated
  bgpd> show vrf all
  VPN: ('65001:100', 'evpn')
   *>  65001💯multicast_etag(ethernet_tag_id:300,ip_addr:10.10.1.0) None     0.0.0.0              Only Path                     ?

With this patch:
  bgpd> show vrf all
  VPN: ('65001:100', 'evpn')
   *>  multicast_etag(ethernet_tag_id:300,ip_addr:10.10.1.0) None     0.0.0.0              Only Path                     ?

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-25 13:34:19 +09:00
IWASE Yusuke
c2c421bddd doc: Update the API Reference for BGPSpeaker
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-25 13:34:12 +09:00
IWASE Yusuke
aa136b26cf test_validation: Add unit tests for validation utilities
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-25 13:34:07 +09:00
IWASE Yusuke
d5ed7c27b7 BGPSpeaker: Enable validation for optional arguments
Currently, RegisterWithArgChecks validates only required arguments,
so invalid arguments might be passed through if the arguments are
registered as optionals.
This patch fixes to enable validation for optional arguments.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-25 13:33:59 +09:00
IWASE Yusuke
c8b8a34f3d BGPSpeaker: Raise exception when validation fails
In the validator for the API arguments should raise exception
when the validator detects invalid arguments, otherwise the
decorator for registering API functions, RegisterWithArgChecks,
can pass through the invalid arguments.

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>
2016-08-25 13:33:55 +09:00
IWASE Yusuke
ba150be4b1 BGPSpeaker: Improve validation utility methods
This patch fixes to reduce Pylint warnings, to use 'netaddr' utilities
and to reduce redundant if statements.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-25 13:33:49 +09:00
IWASE Yusuke
d8b0ea97cc BGPSpeaker: Resolve unused argumet 'multi_exit_disc'
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-25 13:33:44 +09:00
IWASE Yusuke
6d5a3022a1 BGPSpeaker: Reduce Pylint warnings
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-25 13:33:40 +09:00
IWASE Yusuke
55e517eec6 test_table_manager: Add UTs for the Global Table API
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-25 13:33:35 +09:00
IWASE Yusuke
83324ef9d7 table_manager: Rename internal API for consistency
This patch remames the internal (not for users) API for the consistency,
and add missing docstring.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-25 13:33:30 +09:00
IWASE Yusuke
8ea4e674a9 test_table_manager: Add UTs for the VRF Table API
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-25 13:33:26 +09:00
IWASE Yusuke
b8e75e7e7b BGPSpeaker: Support VRF Table for Ethernet VPN
This patch enables BGPSpeaker to store EVPN routes into the VRF
tables and to provide the API for advertising routes.

Usage example:

  speaker = BGPSpeaker(as_number=65001,
                       router_id='172.17.0.1')

  speaker.neighbor_add(address='172.17.0.2', remote_as=65002,
                       enable_evpn=True)

  speaker.vrf_add(route_dist='65001:100',
                  import_rts=['65001:100'],
                  export_rts=['65001:100'],
                  route_family=RF_L2_EVPN)

  speaker.evpn_prefix_add(route_type=EVPN_MAC_IP_ADV_ROUTE,
                          route_dist='65001:100',
                          esi=0,
                          ethernet_tag_id=200,
                          mac_addr='aa:bb:cc:dd:ee:ff',
                          ip_addr='10.0.0.1',
                          next_hop='172.19.0.1')

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-25 13:33:20 +09:00
IWASE Yusuke
59a3049e13 test_bgpspeaker: Add unit test for the API of EVPN
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-25 13:33:15 +09:00
IWASE Yusuke
985e2557b2 BGPSpeaker: Support Ethernet VPN update messages
This patch enables BGPSpeaker to advertise BGP EVPN routes and
store the advertised BGP EVPN routes from the neighbors.

TODO:
 - To support the VRF table for BGP EVPN routes.
   This patch supports the global table only.
 - To implement Multihoming Functions.
   Currently, ONLY Single-Homing is supported.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-25 13:33:10 +09:00
IWASE Yusuke
55e0097545 packet/bgp: Fix to serialize BGPNotification on Python3
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-25 13:33:03 +09:00
IWASE Yusuke
b999b8a14f BGPSpeaker/info_base: Add comparison methods for Python3
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-25 13:32:58 +09:00
IWASE Yusuke
aeda7ae4c5 BGPSpeaker: Support Python3 on SSH console
Currently, SSH console of BGPSpeaker fails to recieve commands from
user when it is running on Python3 due to the binary conversion.
This patch fixes this problem and enables to use SSH console on
Python3.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-25 13:32:52 +09:00
IWASE Yusuke
c51c46b584 test_bgp: Add unit tests for Ethernet VPN
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-25 13:32:48 +09:00
IWASE Yusuke
c4dac34bad packet/bgp: Support MPLS-Based Ethernet VPN (RFC7432)
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-25 13:32:42 +09:00
IWASE Yusuke
0255390a76 packet/bgp: Enable to parse the entire packet data
This patch fixes the TCP packet parser to return the BGP packet
parser class if the TCP src or dst port is the reserved BGP port
and enable to parse the entire packet data.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-25 13:31:22 +09:00
Shinpei Muraoka
d4b8bd609f tests: Add tests for specifying Packet library for OFPPacketOut.data
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-25 13:30:57 +09:00
Shinpei Muraoka
7735137e9d lib/packet: Support the Json format data
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-25 13:30:49 +09:00
Shinpei Muraoka
cb4c0b87db ofproto: Enable to specify packet library for OFPPacketOut.data
So far if you set the packet library to OFPPacketOut.data, error occurred.
This patch will be able to set the packet library in OFPPacketOut.data.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-25 13:30:45 +09:00
IWASE Yusuke
59ea6a5231 lib: Reduce Pylint warnings
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-19 17:49:01 +09:00
IWASE Yusuke
6154450494 stringify: Fix to utilise six.moves.builtins
To improve Pylint results, this patch fixes to utilise six.moves.builtins
instead of using __builtin__ on Python2 or builtins on Python3.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-19 17:49:00 +09:00
IWASE Yusuke
016ec1c644 ofctl_nicira_ext: Fix not enough arguments for format string
Currently, the assignment for 'table_id' is missing in the arguments
of str representation.
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>
2016-08-19 17:48:53 +09:00
IWASE Yusuke
8c5071e2db ofctl_nicira_ext: Resolve not initialized values
Currently, 'dst_start_end' and 'src_start_end' in NXActionLearn
are not initialized before assignment to convert into string
representation.
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>
2016-08-19 17:48:46 +09:00
FUJITA Tomonori
fbafa4b950 Ryu 4.5
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
v4.5
2016-08-02 11:07:47 +09:00
Victor Orlikowski
12d6584bee Ensure that send() and send_msg() in controller return status to calling applications
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>
2016-08-02 11:02:31 +09:00
Victor Orlikowski
9ee265ab45 Clean up stale Datapath objects in the ofctl_service application
A quick patch to clean up stale Datapath objects in the ofctl_service application.

Signed-off-by: Victor J. Orlikowski <vjo@duke.edu>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-08-02 11:01:52 +09:00
Shinpei Muraoka
d0992e24ae packet lib: Add packet library of GRE
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-29 05:55:32 +09:00
Shinpei Muraoka
4ca81f9624 ofproto/nx_actions: Update argument of NXActionCT
Since zone_src in NXActionCT was not possible to specify string,
update zone_src of NXActionCT for the uniformity.
Therefore, you will be able to specify string of OXM/NXM fields for zone_src.

If you want to set the immediate value for zone,
zone_src set the None or empty character string.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-27 19:46:04 +09:00
Shinpei Muraoka
64ba9f1cdc ofproto/nx_actions: Revert API of NXAction
This patch will revert the API of NXAction for the following report.
https://bugs.launchpad.net/dragonflow/+bug/1599367
revert commit id: 3c3896fd77f274ce953dcb78795aa5cc4fde6c65

This patch reverts recently introduced start and end arguments.
Add the utility method for ofs_nbits.
NXActionRegLoad now takes ofs_nbits argument instead of ofs
and nbits even with this revert.

Additionally, update test cases and documents.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-27 19:46:03 +09:00
IWASE Yusuke
882262d861 manager: Except KeyboardInterrupt to suppress traceback
Currently, ryu-manager emits traceback messages when killed via
KeyboardInterrupt.
This patch traps the KeyboardInterrupt, and outputs an appropriate
log message instead.

Signed-off-by: Victor J. Orlikowski <vjo@duke.edu>
Signed-off-by: Alan Fordyce <alan_fordyce@keysight.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-27 14:50:35 +09:00
IWASE Yusuke
3c0bd5b024 stplib: Handle the port state not changed events
According to OpenFlow Spec 1.3.5, OFPT_PORT_STATUS messages with
the reason value OFPPR_MODIFY should be sent the BOTH port state
and config have changed.
On the other hand, OVS does not send OFPT_PORT_STATUS messages
when the port config has changed and only sends when the port
state has changed.
But, other switch implementation, e.g. Lagopus, sends messages
when the both port state and config have changed.
Therefore, simple_switch_stp_13.py will overproduce the topology
recalculation events and will fail to recalculate the topology.

This patch checks the port state in OFPT_PORT_STATUS messages
and ignores the message if the port state is not changed.

Reported-by: Hong Panha <c011361065@edu.teu.ac.jp>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-27 14:31:27 +09:00
IWASE Yusuke
f52bb7007e stplib: Adopt to Python3
In Python3, cmp() method is no longer supported and numerical
operations evaluates value type more strictly.
So, stplib get some errors in its calculating process.

This patch fixes these problems and enable to use stplib on
Python3 interpreter.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-27 14:31:21 +09:00
IWASE Yusuke
a909fa3044 rest_qos: Fix to handle the case without QoS action
Currently, rest_qos.py might fail to parse the actions field in
the QoS rules when the actions field does not have any actions
for the QoS (SET_FIELD, METER, SET_QUEUE).

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>
2016-07-27 14:30:47 +09:00
Michael Haro
c631c46163 packet: support relayed DHCP packet
https://tools.ietf.org/html/draft-ietf-dhc-implementation-02#section-4.7.2

states that DHCP relays should use source port 67 and dest port 67.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-27 14:25:49 +09:00
Jonas Grunert
99d641c7d4 Fix: LLDP.OrganizationallySpecific not ignoring info field
LLDP.OrganizationallySpecificTLV did not set info field and produced
malformed LLDP packets

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-14 17:34:15 +09:00
Shinpei Muraoka
b09b39c11d test_parser: Add test data for some NXAction
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-12 13:21:47 +09:00
Shinpei Muraoka
0288ae2cfa ofproto/nx_actions: Support some NXAction
Actions to be added are as following.
 - NXActionSample2
 - NXActionOutputTrunc

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-12 13:21:41 +09:00
Shinpei Muraoka
eed14371b8 ofproto/nx_actions: Add comment for Ryu documents
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-12 13:21:36 +09:00
Shinpei Muraoka
8b8162ca1f test_parser: Add test data for missing NXAction
Note: The following actions are not implemented yet,
because ovs-ofctl command is not supported.
 - NXActionRegLoad2
 - NXActionOutputReg2

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-12 13:21:30 +09:00
Shinpei Muraoka
89f6945b7e ofproto/nx_actions: Support missing NXAction
Actions to be added are as following.
 - NXActionDecTtlCntIds
 - NXActionStackPush
 - NXActionStackPop
 - NXActionSample
 - NXActionOutputReg2
 - NXActionRegLoad2
 - NXActionController2

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-12 13:21:26 +09:00
Shinpei Muraoka
6daa1eedc5 ofproto/nx_actions: Update arguments to be compatible with ovs-ofctl
This patch, update the methods that are to be specified in the NXM or OXM.
Update the oxm_types specified in the bit format to the string.
Update the following NXAction.

 - NXActionOutputReg
 - NXActionMultipath
 - NXActionBundle
 - NXActionBundleLoad

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-12 13:21:20 +09:00
Shinpei Muraoka
8e30b1f444 test_parser: Add test data for NXAction used only in OpenFlow1.0
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-12 13:21:13 +09:00
Shinpei Muraoka
3b1a314bd0 ofproto/nx_actions: Add NXAction used only in OpenFlow1.0
There is NXAction to be used only in OpenFlow1.0.
These actions are supported by default in OpenFlow1.2 or later.
Therefore, it becomes unnecessary as the NXAction.
But, to add the NXAction in order to be able to use in OpenFlow1.0.
Actions to be added are as following.
 - NXActionSetQueue
 - NXActionDecTtl
 - NXActionPushMpls
 - NXActionPopMpls
 - NXActionSetMplsTtl
 - NXActionDecMplsTtl
 - NXActionSetMplsLabel
 - NXActionSetMplsTc

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-12 13:21:05 +09:00