Compare commits

...

647 Commits
v4.2 ... master

Author SHA1 Message Date
Josh Bailey
d6cda4f427
Merge pull request #170 from anarkiwi/readme
Add project status.
2022-06-09 16:09:40 -07:00
Josh Bailey
8499b4e59e Add project status. 2022-06-09 22:35:47 +00:00
Josh Bailey
537f35f4b2
Merge pull request #151 from crezov/master
fix NXActionRegLoad action_to_str
2021-09-10 10:17:24 +12:00
Josh Bailey
e67d259bba
Merge branch 'master' into master 2021-09-09 20:44:25 +12:00
Josh Bailey
ef58b40b4b
Merge pull request #152 from jbemmel/tunnel_endpoint_ip_and_mac_mobility_params
Patch to add 2 parameters for controlling specific EVPN route update fields
2021-09-09 20:44:12 +12:00
Josh Bailey
442d9f8197
Merge branch 'master' into tunnel_endpoint_ip_and_mac_mobility_params 2021-09-09 19:31:33 +12:00
Josh Bailey
0307a4e666
Merge pull request #153 from jbemmel/patch-1
Fix bug where path.source is set to VRF_TABLE (in vrf.py)
2021-09-09 19:31:20 +12:00
Josh Bailey
eead1ac358
Merge branch 'master' into patch-1 2021-09-09 18:25:59 +12:00
Josh Bailey
2e703468b0
Merge pull request #155 from jbemmel/patch-2
Fix major bug in child thread cleanup logic
2021-09-09 18:25:46 +12:00
J vanBemmel
ac849e3d4f
Fix major bug in child thread cleanup logic
Without this fix, one cannot restart BGP Speaker instances
2021-09-05 20:09:16 -05:00
J vanBemmel
df421911cb
Fix bug where path.source is set to VRF_TABLE (in vrf.py) 2021-09-04 16:41:26 -05:00
Jeroen van Bemmel
a09cae5a85 Use constants imported from API base 2021-09-03 22:56:15 -05:00
Jeroen van Bemmel
5722c7c856 Patch to add 2 parameters for controlling specific fields in EVPN route advertisements:
tunnel_endpoint_ip: To allow for VTEP IPs other than the implicit local router ID
mac_mobility: To insert an extended community with a sequence number for managing MAC Mobility
2021-09-03 22:48:01 -05:00
guojiaoniu
a44ace4987 fix NXActionRegLoad action_to_str 2021-08-31 22:50:33 +08:00
Josh Bailey
65663d4f9f
Merge pull request #97 from NvanAdrichem/point-to-multipoint
Enabled point-to-multipoint links in topology discovery.
2021-08-19 08:44:28 +12:00
Josh Bailey
f3d8c366db
Merge branch 'master' into point-to-multipoint 2021-08-18 12:53:50 +12:00
Josh Bailey
1a17208833
Merge pull request #150 from anarkiwi/ev
Eventlet 0.31.1
2021-08-03 14:52:58 +12:00
Josh Bailey
824ee13113 Eventlet 0.31.1 2021-07-26 10:55:04 +12:00
Josh Bailey
08efd69c0b
Merge pull request #144 from anarkiwi/pytype3
add ofproto 1.3 coverage, check key-error and attribute-error.
2021-06-10 12:12:35 +12:00
Josh Bailey
98d4913d32 add ofproto 1.3 coverage, check key-error and attribute-error. 2021-06-07 03:50:02 +00:00
Josh Bailey
34f33491ff
Merge pull request #142 from anarkiwi/pytype2
Enable bare minimum pytype + GHA (no ryu code changes).
2021-06-03 16:23:41 +12:00
Josh Bailey
8b41507c2c Enable bare minimum pytype + GHA (no ryu code changes). Exclusions/ignored errors can be incrementally removed, to manage diff size and risk. 2021-06-03 03:40:49 +00:00
Josh Bailey
f24e2b9bf1
Merge pull request #141 from anarkiwi/ev2
Upgrade eventlet.
2021-06-01 08:32:35 +12:00
Josh Bailey
dfe583bd83 Upgrade eventlet. 2021-06-01 08:02:07 +12:00
Josh Bailey
2eae52100b
Merge pull request #140 from anarkiwi/trpc
upgrade tinyrpc to 1.0.4.
2021-05-26 12:28:30 +12:00
Josh Bailey
bff06a2b05 upgrade tinyrpc to 1.0.4. 2021-05-26 00:02:52 +00:00
Josh Bailey
d1d1dc9427
Merge pull request #133 from anarkiwi/pippin
pin pip to 20.3.4.
2021-02-23 09:53:51 +13:00
Josh Bailey
a004f57c1f pin pip to 20.3.4. 2021-02-22 10:56:47 +13:00
Josh Bailey
1eaa77d334
Merge pull request #131 from anarkiwi/ev
eventlet 0.30.1
2021-02-10 14:19:46 +13:00
Josh Bailey
62e1ec6998 0.30.1 2021-02-10 10:33:28 +13:00
Josh Bailey
3c86fc00e4
Merge pull request #102 from SantiagoMunoz/master
doc: Consider null buffer_id in first example
2021-02-01 13:00:51 +13:00
Josh Bailey
42957ee824
Merge branch 'master' into master 2021-02-01 12:51:28 +13:00
Josh Bailey
91542b29b7
Merge pull request #86 from MrCocoaCat/patch-1
Update bridge.py
2021-02-01 10:33:04 +13:00
Josh Bailey
f26a60b1e1
Merge branch 'master' into patch-1 2021-02-01 10:24:09 +13:00
Josh Bailey
a5b4af99d4
Merge pull request #76 from ben51/master
Adding support for RFC8227 withdraw label
2021-02-01 10:13:31 +13:00
Josh Bailey
688fc4bf06
Merge branch 'master' into master 2021-02-01 10:04:47 +13:00
Josh Bailey
e69191a067
Merge pull request #83 from ben51/adj_rib_out_draft
Add support for Adj-RIB-Out (draft-ietf-grow-bmp-adj-rib-out-03)
2021-02-01 10:04:25 +13:00
Josh Bailey
fe1ca30fd4
Merge branch 'master' into adj_rib_out_draft 2021-02-01 09:54:35 +13:00
Josh Bailey
5b1343d7bc
Merge pull request #79 from DiegoRossiMafioletti/patch-1
Update nx_actions.py, fixing a typo on example
2021-02-01 09:47:47 +13:00
Josh Bailey
0e29dbe9ef
Merge branch 'master' into patch-1 2021-02-01 09:38:30 +13:00
Josh Bailey
1d9881145e
Merge pull request #72 from tahoe/patch-1
Just some English correction
2021-02-01 09:37:42 +13:00
Josh Bailey
58b287bc90
Merge branch 'master' into master 2021-02-01 09:14:32 +13:00
Josh Bailey
f3316fa85a
Merge branch 'master' into patch-1 2021-02-01 09:13:50 +13:00
Josh Bailey
bd1d5de383
Merge pull request #128 from cglewis/eventlet
revert #100, use latest eventlet
2021-01-21 09:16:07 +13:00
cglewis
045eca0592 Merge branch 'master' of https://github.com/faucetsdn/ryu into eventlet 2021-01-20 11:55:58 -08:00
Josh Bailey
dc7aa0abef
Merge pull request #122 from musicinmybrain/msgpack-1.0
Support msgpack 1.0.0 and later.
2021-01-21 08:52:24 +13:00
Josh Bailey
1310c2eda4
Merge pull request #121 from LKaemmerling/add-python-3.9-support
Add Support for Python 3.9
2021-01-21 08:51:27 +13:00
cglewis
ea4112f393 revert #100, use latest eventlet 2021-01-20 10:40:50 -08:00
Lukas Kämmerling
afa2f83559 Add Support for Python 3.9 2021-01-20 10:49:29 +01:00
Josh Bailey
d2f06b7f46
Merge pull request #127 from cglewis/renovate
add renovate
2021-01-20 15:21:17 +13:00
cglewis
8740dd97e4 add renovate 2021-01-19 17:59:31 -08:00
Benjamin Beasley
aa10cac1db Add msgpack 1.0 support; use version testing to preserve compatibility with older versions 2021-01-19 10:59:45 -05:00
Benjamin Beasley
8990ed47ed Enforce new msgpack format (use_bin_type=True) in ryu.services.protocols.bgp.net_ctrl.RpcSession; this option is already used in ryu.lib.rpc.MessageEncoder 2021-01-19 10:59:45 -05:00
Benjamin Beasley
0a1e1e81cf Bump minimum msgpack verson to 0.4.0, since ryu/lib/rpc.py uses the use_bin_type option to msgpack.Packer 2021-01-19 10:59:45 -05:00
Josh Bailey
476d12100a
Merge pull request #126 from cglewis/remove-travis
remove travis, move to github actions
2021-01-19 10:26:41 +13:00
cglewis
0e6ddebe75 remove travis, move to github actions 2021-01-18 13:06:05 -08:00
Josh Bailey
846e5ec026
Merge pull request #124 from cglewis/tests
fix docker tests and print output for python3
2021-01-19 08:43:30 +13:00
Josh Bailey
03d205c4dd
Merge pull request #125 from cglewis/gha-tests
add github actions for tox tests
2021-01-19 08:43:12 +13:00
cglewis
7fc22c00e1 add github actions for tox tests 2021-01-18 09:59:58 -08:00
cglewis
8533f7ef3f fix docker tests and print output for python3 2021-01-17 16:50:38 -08:00
Brad Cowie
a394673993
Merge pull request #106 from michaelharo/syntaxwarning
Resolve a syntax warning
2020-09-25 09:51:41 +12:00
Brad Cowie
27e5f64eda
Merge pull request #105 from michaelharo/nd_option_mtu
Add support for the MTU ND option.
2020-09-25 09:50:25 +12:00
Michael Haro
830b49798f Resolve a syntax warning 2020-07-20 07:43:35 -07:00
Michael Haro
ca597a5e09 Add support for the MTU ND option. 2020-07-20 07:20:34 -07:00
shinkasbe
0e0f66e119
doc: Fix typo on example 2020-06-16 10:14:42 +01:00
Santiago Rodriguez
20c0ececeb doc: Consider null buffer_id in first example
If the switch does not buffer the packet (like when using mininet), the example does not work.
For such cases, include the packet contents in  OFPPacketOut
2020-06-14 16:13:22 +01:00
Brad Cowie
861587c8ed
Merge pull request #100 from gizmoguy/py3.7-tls
Workaround eventlet Python3.7 SSLContext wrap issue
2020-06-12 16:27:57 +12:00
Brad Cowie
8a62f25371
Merge pull request #101 from gizmoguy/stickler
Add .stickler.yml.
2020-06-12 15:47:53 +12:00
Brad Cowie
f1b46fdebe Add .stickler.yml. 2020-06-12 15:18:59 +12:00
Brad Cowie
7559befd58 Allow user to set cipher list. 2020-06-12 14:53:37 +12:00
Brad Cowie
ddb32f678a Add workaround for Python3.7+ eventlet bug. 2020-06-12 13:58:25 +12:00
Artem Abramov
906b3a3ea5 Bugfix now multiple switches can connect with TLS
This fixes a bug in RYU StreamServer where SSLContext was modified for
each connection. Now the SSLContext of the server socket is modified
only once in __init__
2020-06-12 13:58:25 +12:00
Brad Cowie
32b6560bfb
Merge pull request #99 from gizmoguy/test-tidy
Tidy up travis test environment
2020-06-12 13:30:12 +12:00
Brad Cowie
15382e4972 Don't need to keep our requirements in sync with OpenStack. 2020-06-12 11:23:03 +12:00
Brad Cowie
dea688e5a6 Upgrade to ubuntu bionic. 2020-06-12 11:03:00 +12:00
Brad Cowie
9b002e0eec Update python versions for tox test environments. 2020-06-12 11:03:00 +12:00
Brad Cowie
7344c15b01 pylint 2020-06-12 11:03:00 +12:00
Brad Cowie
03affce4c9
Merge pull request #98 from gizmoguy/msgpack
We don't support msgpack 1.0.0 yet.
2020-06-12 11:01:55 +12:00
Brad Cowie
171bf3a6e1
Merge pull request #96 from gizmoguy/deprecate-py2
Deprecate older python versions
2020-06-12 11:01:21 +12:00
Brad Cowie
885db99eeb We don't support msgpack 1.0.0 yet. 2020-06-11 16:52:55 +12:00
Niels van Adrichem
f2d72cc34b Enabled point-to-multipoint links in topology discovery. 2020-06-09 16:51:32 +02:00
Brad Cowie
b6bf01a5c9 Remove workaround for issue with older python versions. 2020-06-08 14:34:42 +12:00
Brad Cowie
3395daccfe Deprecate using Ryu with older python versions. 2020-06-08 14:34:31 +12:00
Brad Cowie
f4bed28fa0
Merge pull request #92 from gizmoguy/fix-api-docs
Add .readthedocs.yml.
2020-05-23 11:16:58 +12:00
Brad Cowie
814c8a757a Add .readthedocs.yml. 2020-05-23 11:12:24 +12:00
Brad Cowie
73de59b27b
Merge pull request #88 from gizmoguy/update-urls
Update URLs.
2020-05-12 16:35:41 +12:00
Brad Cowie
7dad6e1e4b
Merge pull request #90 from gizmoguy/contributing
Update how to contribute to Ryu.
2020-05-12 16:35:21 +12:00
Brad Cowie
10a9f79c6a Update how to contribute to Ryu. 2020-05-12 16:32:54 +12:00
Brad Cowie
5fd42fff66 Update URLs. 2020-05-12 14:04:33 +12:00
Scott
c343376849 updated jsonrpc.Session call to have correct arguments for latest version of ovs
Signed-off-by: Scott <sdyear@gmail.com>
2020-04-22 15:49:06 +09:00
Grant Curell
be289978c7 Fix two bugs in simple switch 13 examples
- dpid with leading 0s would be truncated to less than 16 characters
- Response object incorrectly used body type when it should use text
2020-04-01 10:13:07 -05:00
MrCocoaCat
c565ec6f77
Update bridge.py
Sometimes you don't know 'datapath_id', you need to initialize the class with 'br_name'
2020-03-20 18:34:30 +08:00
Adrian Freund
e3ebed7943 Restrict tinyrpc to version 0.9.4 as newer versions break python2 support 2019-11-27 13:18:39 +01:00
FUJITA Tomonori
c776e4cb68 Ryu 4.34
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
2019-10-01 19:42:10 +09:00
Benjamin Villain via Ryu-devel
0866cb7d48 Add support for revised RFC8227 withdraw labels
This commit fixes a parsing error when a BGP update contains a "withdraw label"
equal to 0x000000 instead of 0x8000000 as stated in RFC 3107. This commits
treats both labels as "withdraw label"

Signed-off-by: Benjamin Villain <villainb@amazon.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2019-09-25 15:59:38 +09:00
Benjamin Villain via Ryu-devel
4e0fc9e72d Add support for Adj-RIB-Out (draft-ietf-grow-bmp-adj-rib-out-03)
Signed-off-by: Benjamin Villain <villainb@amazon.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2019-09-25 15:59:31 +09:00
Benjamin Villain
d1b1b471e7 Add support for Adj-RIB-Out (draft-ietf-grow-bmp-adj-rib-out-03) 2019-09-20 14:30:09 +10:00
FUJITA Tomonori
29b8d7d28b drop Python 3.4 CI test
Python 3.4 is officially dead.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
2019-08-01 16:27:36 +09:00
FUJITA Tomonori
bc111ac10d Ryu 4.33
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
2019-08-01 16:09:20 +09:00
FUJITA Tomonori
a295810f77 fix style errors
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2019-07-18 20:59:43 +09:00
Ozgur Yurekten
550e890671 nx_action_encap and nx_action_decap classes are defined
Signed-off-by: Ozgur Yurekten <ozgur.yurekten@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2019-07-18 20:43:09 +09:00
FUJITA Tomonori
6456711a34 Ryu 4.32
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
2019-05-02 18:55:39 +09:00
Diego Rossi Mafioletti
faffcb80d4
Update nx_actions.py, fixing a typo on example
Change parser.NXActionResubmit to parser.NXActionResubmitTable, according to right OpenFlow action.
2019-04-11 07:09:42 -03:00
Atzm Watanabe
6f906e72c9 app/ofctl: fix possible deadlock
When datapath reconnects/disconnects, waiting requests on old
datapath should be canceled.  Otherwise, threads that sent
requests may fall into deadlock because replies possibly never
come.

Signed-off-by: Atzm Watanabe <atzm@iij.ad.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
2019-04-09 20:27:31 +09:00
FUJITA Tomonori
050bfbc711 Ryu 4.31
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
2019-04-01 21:41:06 +09:00
IWAMOTO Toshihiro
01a09a0e02 Choose the highest TLS version
Please note that this is a stop-gap measure.  Also add a basic SSL
server test.

Co-authored-by: alex <atoptsoglou@suse.com>
Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
2019-03-28 11:41:01 +09:00
FUJITA Tomonori
56e8fb3f57 Ryu 4.30
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-11-03 19:37:16 +09:00
Bill Allen
1b38505909 Grammatical improvements to some of the documentation.
Signed-off-by: Bill Allen <photo.allen@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-10-20 07:24:35 +09:00
FUJITA Tomonori
d074e15a48 Ryu 4.29
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-10-03 14:21:56 +09:00
Benjamin Villain
62b4c07464 Adding support for RFC8227 withdraw label
According to RFC8227, many vendors don't properly implement RFC3107
related to withdraw label. Indeed, it happens that a speaker sends
a label of 0x000000 in place of 0x800000 to signal a route withdrawal.
As a result, the parser fails to parse the message since it doesn't stop
at the withdraw label and tries to parse more label than there is.

This commit fixes this by considering both 0x800000 and 0x000000 as withdraw
labels.
2018-09-28 14:25:00 +10:00
Atzm Watanabe
e3aa55872b app/ofctl: fix possible deadlock when the datapath disconnects
Signed-off-by: Atzm Watanabe <atzm@iij.ad.jp>
Reviewed-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
2018-09-26 15:34:16 +09:00
FUJITA Tomonori
0031cff9a3 Ryu 4.28
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-09-01 21:54:08 +09:00
Slawek Kaplonski
d7d526ad21 Fix convertion of ipv4 to string on i386 and arch
On architectures like i386 or arm convertion of IPv4 to string
was failing in some cases.
It was like that because some integer values were converted to
long which is not the case on x86_64.
It was like that for example with value "2871386400" which is
used in ryu.tests.unit.ofproto.test_parser_v10:TestOFPMatch unit
test.
Because of that this test was failing when running on architectures
where integer range was too small to handle this value.

Signed-off-by: Slawek Kaplonski <skaplons@redhat.com>
Reviewed-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-08-14 06:17:01 -07:00
IWASE Yusuke
8312ab23b3 mrtlib: Define JSON representation types
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-08-11 20:05:04 +09:00
IWASE Yusuke
bc5bf0dbb6 test_mrtlib: Test cases for ADD_PATH
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-08-11 20:04:57 +09:00
IWASE Yusuke
807185470e mrtlib: Support RFC8050
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-08-11 20:04:50 +09:00
IWASE Yusuke
ccedf4cfb3 mrtlib: Missing subclass for SUBTYPE_RIB_*_MULTICAST
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-08-11 20:04:30 +09:00
FUJITA Tomonori
a2bcf0a7e6 Ryu 4.27
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-08-02 20:04:48 +09:00
IWAMOTO Toshihiro
840a348845 Declare support of recent python3 versions
Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-08-01 16:00:12 +09:00
IWAMOTO Toshihiro
19662c5688 Test more python versions on travis CI
It seems tests weren't correctly run because of interactions between
travis CI env and tox venv.  Also, run the scenario test on more
recent python3, as python3.4 is going away.
The test uses a lot of memory and fails with pypy, so it's disabled for now.

Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-08-01 16:00:11 +09:00
IWAMOTO Toshihiro
6e9fbad22e Bump oslo.config to 2.5.0
Ryu is using item_type since commit f77529036, so oslo.config minimum
version needs to be updated.

Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-08-01 16:00:10 +09:00
Slawek Kaplonski
49b5e5c30a Fix UT when running in python 3.7 env
Due to change [1] in python 3.7 one of ryu's unit tests
was failing with this version of interpreter. It was like that
because of missing __qualname__ attribute in functools.partial
object.
This patch fixes it by adding such attribute if it's not
set already.

[1] https://github.com/python/cpython/pull/4496

Signed-off-by: Slawek Kaplonski <skaplons@redhat.com>
Acked-By: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-07-31 07:19:53 +09:00
IWAMOTO Toshihiro
b39ff68f82 lib/ovs/bridge: Return multiple controllers
OVSBridge may have more than one controller. Let get_controller()
return a list of controllers in such cases.

NOTE: this introduces incompatibility if multiple controllers are
configured for a bridge.

Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-07-21 14:50:44 +09:00
IWASE Yusuke
e848eaa57e BGPSpeaker: Enable to specify remote port for neighbor
Currently, the remote port of neighbor is the hard-coded value 179.

This patch enables to specify the remote port of neighbor in
"BGPSpeaker.neighbor_add()" API.

Suggested-by: Suresh Kumar <knetsolutions2@gmail.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2018-07-15 16:23:47 +09:00
IWAMOTO Toshihiro
d96e6a60ab switch.tester: Fix name shadowing
tester.py imported all the classes from the packet library at the top level
namespace. This commit adds CLSNAME_ALIASES dict so that those classes
with the same names can be imported as different names.
This fixes an issue reported by ted.nozaki in ryu-devel:
https://sourceforge.net/p/ryu/mailman/message/36312622/

Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-07-15 15:55:24 +09:00
IWAMOTO Toshihiro
2c6a053f8d gui_topology: Avoid wildcard URL matching
GUIServerController eats up the entire URL space and sometimes causes
problems. See the following thread in ryu-devel for example:

https://sourceforge.net/p/ryu/mailman/message/36312411/

Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-07-15 15:53:40 +09:00
FUJITA Tomonori
b9909d0686 Ryu 4.26
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-07-01 20:10:13 +09:00
IWAMOTO Toshihiro
704dcc786a nx_actions: Fix NXActionSetTunnel docstring
set_tunnel and set_field:xxx->tun_id are different actions.

Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-06-20 12:05:11 +09:00
IWAMOTO Toshihiro
4bc29b2c5f Fix pycodestyle W605 warnings
W605 invalid escape sequence, which was recently added in pycodestyle,
would be a syntax error in future python3 versions.

Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-06-20 12:05:08 +09:00
IWASE Yusuke
b1ec9ed457 BGPSpeaker: Fix BGP state string conversion
The constants BGP_FSM_* are str type values and not callable.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-06-20 12:04:53 +09:00
IWASE Yusuke
56aff9adf3 pycodestyle: Ignore W504
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-06-20 12:04:46 +09:00
IWASE Yusuke
db7338b8db BGPSpeaker: Advertise local routes to RR clients
The current implementation misses the mandatory attributes when sending
locally generated routes to its Route Reflector (RR) clients, then the
clients will reject the received routes.

This patch fixes to add or update attributes to for sending locally
generated routes its RR clients.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-06-20 12:04:30 +09:00
IWAMOTO Toshihiro
a6bda030d3 pip: Blacklist eventlet 0.23.0
This is to sync with OpenStack requirements.

Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-06-20 11:10:25 +09:00
IWAMOTO Toshihiro
482aabcb1e lldp: Remove remaining SystemCapabilities.subtype from tests
Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-06-20 10:42:59 +09:00
Marcin Chron
99fc573a9c lldp: fixed SystemCapabilities TLV
This patch removes 'Subtype' byte from SystemCapabilities TLV.
There was an inconsistency in offical IEEE document which was corrected
in 802.1AB-2009/Cor 1-2013.

Signed-off-by: Marcin Chron <marcin_miko1@o2.pl>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-06-20 10:42:26 +09:00
FUJITA Tomonori
c29c9019ac Ryu 4.25
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-06-01 20:43:17 +09:00
Joe Mader
cda5bc7825 allow versions of eventlet > 0.21.0 2018-05-13 09:40:00 -06:00
FUJITA Tomonori
1c008060fa Ryu 4.24
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-04-01 15:15:49 +09:00
IWAMOTO Toshihiro
b8ebdbe961 ofproto: add Nicira extension ct_clear action
Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-03-28 18:02:06 +09:00
IWASE Yusuke
4e10ba4438 ofproto: Encode data field on OFPErrorMsg
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>
2018-03-26 22:11:39 +09:00
IWASE Yusuke
3003d475d2 ofp_handler: Close socket when HELLO failed
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>
2018-03-26 22:11:38 +09:00
IWASE Yusuke
afbc80352c controller: Wait for switch to disconnect connection
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>
2018-03-26 22:11:32 +09:00
IWASE Yusuke
7a40d5c2f3 controller: Option to close socket after sending Message
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>
2018-03-26 22:11:25 +09:00
IWASE Yusuke
976914f5e6 controller: Improve pylint result
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-03-26 22:11:19 +09:00
IWASE Yusuke
fe06d87f65 test_requirements: Avoid using pip as library
Because importing "pip" in Python scripts is not supported usage of
"pip", this patch fixes to use "pkg_resources" + "urllib" instead.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-03-26 15:55:20 +09:00
IWASE Yusuke
a27c56a054 utils: Remove "parse_requirements" function
This patch removes unused function "parse_requirements" in order to
avoid using "pip" as a Python library.

Note: Officially "from pip import req as pip_req" is not supported usage
of "pip".

Reported-by: Katsaounis Molyvas Stamatios <mokats@intracom-telecom.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-03-26 15:55:18 +09:00
Thomas Bechtold
e6773539b5 Switch to msgpack in pip-requires
msgpack-python got renamed to msgpack[1] so use the new name.

[1] https://pypi.python.org/pypi/msgpack/0.5.1

Signed-off-by: Thomas Bechtold <tbechtold@suse.com>
Acked-By: Iwase Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-03-20 22:36:04 +09:00
IWASE Yusuke
a0f90115cc nicira_ext: Support DEC_NSH_TTL action
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-03-20 22:32:51 +09:00
IWASE Yusuke
684b665290 nicira_ext: Support Network Service Header match
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-03-20 22:32:50 +09:00
IWASE Yusuke
0841f3f253 doc: Fix unexpected indent in ofctl.api doc
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-03-05 20:28:17 +09:00
FUJITA Tomonori
8a48b62c90 Ryu 4.23
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-03-02 10:29:20 +09:00
IWASE Yusuke
09d2811569 doc: Document for ryu.lib.ovs
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-02-10 18:45:58 +09:00
IWASE Yusuke
bd384997ac lib/ovs: Fix a typo of "--may-exist" option
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-02-10 18:45:58 +09:00
FUJITA Tomonori
fb224e23b9 Ryu 4.22
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-02-01 20:56:39 +09:00
IWASE Yusuke
fa172559c5 bgp/application: Add note for BGPSpeaker API reference
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-01-23 17:16:47 +09:00
IWASE Yusuke
7d0b080e73 BGPSpeaker: Move docstring from __init__ to class
By the default, Sphinx does not include __init__() method for the
"autoclass" directive, and currently the description for the arguments
of BGPSpeaker is not generated.

This patch moves the docstring of __init__() to the class's docstring
and enables to generate the docs for the arguments of __init__().

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-01-23 17:16:45 +09:00
IWASE Yusuke
80312a4d64 BGPSpeaker: Enable to notify adj-RIB-in changed
This patch introduces a new argument "adj_rib_in_change_handler" into
BGPSpeaker and enables to notify adj-RIB-in changed to watchers.

Also this patch enables to "bgp.application.RyuBGPSpeaker" to notify a
new event EventAdjRibInChanged to other Ryu applications.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-01-23 17:16:41 +09:00
Dennis
d0cd93c1a0
Just some English correction
Just some clarification in a sentence.
2018-01-18 10:33:22 -08:00
IWASE Yusuke
e81ec3fb01 ofctl: Enable to get all datapath objects
Also, updates the API document of ryu.app.ofctl.api.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-01-17 08:46:53 +09:00
IWASE Yusuke
37c73db7b1 confroller/dpset: Add usage example of instantiation
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>
2018-01-17 08:46:52 +09:00
IWASE Yusuke
81cdd4f0d7 test_rpc: Adopt to msgpack-python>=0.50
msgpack-python version 0.50 or later supports bytearray objects, this
patch fixes to adopt to this change.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-01-17 08:46:14 +09:00
IWASE Yusuke
c3b484c787 doc: Usage for ryu/services/protocols/bgp/application.py
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-01-17 08:46:13 +09:00
FUJITA Tomonori
8287e3513a Ryu 4.21
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-01-02 13:49:50 +09:00
IWASE Yusuke
6e3eccb453 *: Apply autopep8
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-12-17 19:27:47 +09:00
IWASE Yusuke
83650576e4 travis: Introduce autopep8 test
This patch add a new test using "autopep8" to keep codes reformatted
easily by using Python tool.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-12-17 19:27:46 +09:00
IWASE Yusuke
d64db265b3 *: Adopt to pycodestyle's checks
This patch adopts to the following pycodestyle's checks;
  E275: missing whitespace after keyword
  E305: expected 2 blank lines after end of function or class

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-12-17 19:27:42 +09:00
IWASE Yusuke
bdf3549563 pycodestyle: Replace pep8
pep8 has been renamed to pycodestyle and will be removed in a future
release.

This patch replaces pep8 by pycodestyle and adding some settings for
pycodestyle.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-12-17 19:27:41 +09:00
IWASE Yusuke
870dcab678 ofproto_v1_5_parser: oxm_ids with name str in OFPActionCopyField
Currently, oxm_ids argument of OFPActionCopyField should be a list of
OFPOxmId instances, but this patch enables to specify with the OXM field
name as the str type value which is corresponding to the keywords of
OFPMatch.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-12-17 19:27:33 +09:00
IWASE Yusuke
4602651b2c ofproto_v1_5_parser: Missing trailing pads of OFPActionCopyField
OpenFlow Spec 1.5 says OFPActionCopyField has the trailing paddings to
make the action a whole multiple of 8 bytes in length.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-12-17 19:27:33 +09:00
IWASE Yusuke
aa9f3f483c ofproto_v1_5_parser: Fix length calculation of OFPOxmId
Currently, the oxm_length field is always composed with zero value
because OpenFlow Spec does not still clarify whether its value should be
doubled if the hasmask bit is set.

This patch fixes to compose the oxm_length value with the payload length
because Open vSwitch strictly checks the oxm_length which contained in
the OFPAT_COPY_FIELD action (introduced at OpenFlow 1.5), and this
causes the OFPT_ERROR messages then flows will not be installed.

Note: This patch does not backport this fix to ofproto_v1_3_parser.py
and ofproto_v1_4_parser.py because those modules are tested based on the
implementation of "linc/of_protocol" which supposes the oxm_length is
always zero. Also OFPOxmId should be rarely serialized at the controller
side when using OpenFlow 1.3 or 1.4.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-12-17 19:27:31 +09:00
Felician Nemeth
385b628d70 ovsdb: Fix small bug
Signed-off-by: Felicián Németh <nemethf@tmit.bme.hu>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-12-11 23:42:31 +09:00
IWAMOTO Toshihiro
1493f51daa packet_data_generator3: Generate OF13 Ext-230 bundle packets
Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-12-11 22:35:10 +09:00
IWAMOTO Toshihiro
381216075f packet_data_generator3: Support ovs-2.8
From ovs 2.8, ovs-ofctl tries to collect port descriptions, which
isn't handled by the fake server in gen.py.  Pass the --no-names
option to work around this.

Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-12-11 22:35:09 +09:00
IWAMOTO Toshihiro
9fa0b58199 ofproto_v1_3: Add bundle extension
Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-12-11 22:35:05 +09:00
IWAMOTO Toshihiro
98ea9024ed ofproto: Correct OFPBundle{Ctrl, Add}Msg docstrings
Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-12-11 22:34:16 +09:00
IWASE Yusuke
bf83292364 rest_vtep: Add some descriptions for troubleshooting
This patch adds some notes about the settings when using the Mininet
VMs for the environment on which rest_vtep.py running.

Reported-by: Varun Amrutiya <h20170244@pilani.bits-pilani.ac.in>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-12-11 22:34:00 +09:00
IWASE Yusuke
7e6f3f00ed topology: Enable to detect migrations of hosts
Currently, the topology library does not update the position of a host
which was detected before even if the host migrated to another port.

This patch enables to detect the migrations of the hosts when the host
is detected on another port.

Reported-by: Mahmoud Elzoghbi <mahmoud.said.elzoghbi@gmail.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-12-11 22:33:41 +09:00
FUJITA Tomonori
63f81837fd Ryu 4.20
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-12-02 09:50:31 +09:00
morland
7f6d8730ab fix bug in the example of flow_stats_reply
Signed-off-by: morland <mqy_bs@hotmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-11-28 11:30:13 +09:00
Thomas Boros
9aa56ef3bd app: added simple switch with openflow 1.5 support
Signed-off-by: Thomas Boros <tomas.boros92@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-11-28 10:48:26 +09:00
IWASE Yusuke
4d26387910 ofproto_v1_5_parser: Change default of command_bucket_id
Currently, Ryu will send the OFPGroupMod message with
"command_bucket_id=0" by the default if using the OpenFlow version 1.5.
OTOH, Open vSwitch expects "command_bucket_id=OFPG_BUCKET_ALL" if
"command" is other than OFPGC_INSERT_BUCKET or OFPGC_REMOVE_BUCKET,
otherwise OVS will rejects the OFPGroupMod message.

This patch changes the default value of "command_bucket_id" to
OFPG_BUCKET_ALL as OVS expects.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-11-28 10:33:23 +09:00
Jerico Moeyersons
3b946c0192 app: Fix simple_switch for multi switch env
Currently, the matches of flows in the learning switch examples are based
on the destination and the in_port. In a multi-OF-switch environment this
could cause issues when doing calls from a host on a first switch to
multiple hosts on another switch, namely that new destinations aren't
added as a flow because the source is already known on the second switch
(when doing multiple calls to different hosts on another switch).
This patch fixes this issue by adding the eth_src to the match field.

Reported-by: Jerico Moeyersons <jerico09@hotmail.com>
2017-11-28 10:28:12 +09:00
Charlie Lewis
ed2c6eca22 doc: fix typo 2017-11-18 12:26:49 +09:00
IWASE Yusuke
6ec8802a00 test_icmpv6: Catch proper Exception
In some test cases in test_icmpv6.py, @raises() decorator does not catch
the correct Exception, because "pack" function cannot be resolved and it
need to be specified as "struct.pack".

This patch fixes to this unresolved references and make it more strictly
matching of Exception class (e.g., AssertionError).

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2017-11-16 09:15:47 +09:00
IWASE Yusuke
f3d752178c packet/icmp: Avoid TypeError when calculating length
Currently, ICMPv4 packet instance without its payload, it will raise
TypeError when calculating packet length, because the default value of
"data" field (payload data) is None and len() can not be applied against
None type object.

This patch changes the default value of "data" to the empty binary
value and confirms the value type of "data" field before serialization.
Also, this patch applies the same improvements to ICMPv6 packet library.

Reported-by: William Fisher <william.w.fisher@gmail.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
2017-11-16 09:15:28 +09:00
Satoshi Fujimoto
2599aef3bf *: Reject Binary Represented IP Addresses
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>
2017-11-16 09:15:12 +09:00
Satoshi Fujimoto
8185637767 serivice/bgp: Fix ssh connection problem in Python 2.7
Currently, 'is_connected' attribute in SshServer is refered
before it is created, in Python 2.7.
This raises an Exception and the SSH operation won't work
anymore after this happens.
This commit ensures that 'is_connected' is created before
it is refered.

Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-11-05 21:10:03 +09:00
IWASE Yusuke
5bde6ae440 flags: Inject __class__ attribute to LooseVersion
Currently, ryu-manager uses distutils.version.LooseVersion for
"--zapi-frr-version" to parse the given version sting.
With custom type class for oslo_config.cfg.Opt, oslo_config might access
__class__ attribute for equal comparison.
But in case on Python 2, LooseVersion does not have __class__ attribute
and it causes AttributeError. (This error is not always reproduced)

This patch injects required attribute into LooseVersion and avoids this
problem.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-11-02 11:18:03 +09:00
IWASE Yusuke
eda4940eb8 library_ovsdb_manager: Descriptions for OVS configs
To connect OVSDB Manager library to OVS, some additional configurations
on OVS is required, but currently no description about these
configurations.

This patch adds descriptions for OVS configurations and includes some
improvements of sample application.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-11-02 09:20:55 +09:00
Satoshi Fujimoto
92730dc7e9 app/ofctl: Enable to send single BarrierRequest
Currently, with ryu.app.ofctl.api.send_msg(),
a BarrierRequest will send with every messages.
So, using send_msg() with a BarrierRequest will
cause duplex transmission of BarrierRequests.

This commit enables to send a single BarrierRequest
if send_msg() is used with a BarrierRequest
by avoiding sending an additional BarrierRequest.

Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-11-01 23:22:37 +09:00
IWASE Yusuke
66bdeaa7b5 packet/zebra: Support FRRouting version 3.0
This patch enables to support Zebra messages of FRRouting version 3.0
and introduces a flag to switch FRRouting version.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-11-01 23:22:09 +09:00
IWAMOTO Toshihiro
6e51b2a41d of14: Implement OFPBundleCtrlMsg parser
Copied from of15 implementation.

Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-11-01 23:21:44 +09:00
IWASE Yusuke
98d97b992e rest_qos: Avoid None when deleting OVSDB addr
Currently, rest_qos.py will raise AttributeError when deleting OVSDB
server address because rest_qos.py will try to split the given address
string but the address is None when deleting.

This patch checks if the given address is None or not before the string
manipulation and fixes this problem.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-11-01 23:21:11 +09:00
IWASE Yusuke
253ce73b7f lib/ovs/vsctl: Function for validate OVSDB address
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-11-01 23:21:09 +09:00
FUJITA Tomonori
51a1130f6c Ryu 4.19
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-11-01 21:48:39 +09:00
IWASE Yusuke
e1e85052f5 BGPSpeaker: Enable to specify local listen addresses
Currently, BGPSpeaker will listen the incoming connection with the
unspecified IP addresses ('0.0.0.0' and '::').

This patch enables to specify the local listen address list for starting
BGPSpeaker instance.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-10-15 13:21:23 +09:00
IWASE Yusuke
6329444165 bgp/application: Enhance arguments handling for BGPSpeaker
Currently, when new arguments are introduced into BGPSpeaker,
ryu.application.RyuBGPSpeaker need modifications to support the
introduced arguments.

This patch enables to pass arguments to BGPSpeaker without some
modifications on RyuBGPSpeaker.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-10-15 13:21:21 +09:00
IWASE Yusuke
7ef14a83a2 test_controller: Test cases for _split_addr()
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-10-15 13:04:41 +09:00
IWASE Yusuke
09d5b2533c controller: APIs to register switch address dynamically
This patch introduces APIs to register/unregister switch address after
Ryu (ofp_handler) starting.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-10-15 13:04:39 +09:00
IWASE Yusuke
f775290360 controller: Support proactive connection
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>
2017-10-15 13:04:38 +09:00
FUJITA Tomonori
6e69e9b8a6 Ryu 4.18
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-10-03 13:38:51 +09:00
IWASE Yusuke
3c22bf4144 zclient/zserver: Support FRRouting messages format
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-09-17 13:37:32 +09:00
IWASE Yusuke
bf9b8ac588 test_zebra: Enhance test cases
Note: The binary representation is not extracted from the real packets
and based on the implemetation, so might be required to be fixup with
the real packets.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-09-17 13:37:31 +09:00
IWASE Yusuke
aedd3920b3 packet/zebra: Support MPLS Labels messages
This patch implements the following messages on FRRouting:
 - FRR_ZEBRA_MPLS_LABELS_ADD
 - FRR_ZEBRA_MPLS_LABELS_DELETE

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-09-17 13:37:29 +09:00
IWASE Yusuke
e423a1f0bc packet/zebra: Support Interface Router Advertisement messages
This patch implements the following messages on FRRouting:
 - FRR_ZEBRA_INTERFACE_ENABLE_RADV
 - FRR_ZEBRA_INTERFACE_DISABLE_RADV

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-09-17 13:37:22 +09:00
IWASE Yusuke
6b48da6729 packet/zebra: Support VRF related messages
This patch implements the following messages on FRRouting:
 - FRR_ZEBRA_VRF_ADD
 - FRR_ZEBRA_VRF_DELETE
 - FRR_ZEBRA_INTERFACE_VRF_UPDATE

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-09-17 13:37:16 +09:00
IWASE Yusuke
7baed0a100 packet/zebra: Support BFD Destination messages
This patch implements the following messages on FRRouting:
 - ZEBRA_INTERFACE_BFD_DEST_UPDATE
 - ZEBRA_BFD_DEST_REGISTER
 - ZEBRA_BFD_DEST_DEREGISTER
 - ZEBRA_BFD_DEST_UPDATE
 - ZEBRA_BFD_DEST_REPLAY

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-09-17 13:37:13 +09:00
IWASE Yusuke
7804cbb6f4 packet/zebra: Support Neighbor Connected Address messages
This patch implements the following messages on FRRouting:
 - ZEBRA_INTERFACE_NBR_ADDRESS_ADD
 - ZEBRA_INTERFACE_NBR_ADDRESS_DELETE

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-09-17 13:37:07 +09:00
IWASE Yusuke
7091523f8f test_zebra: Add pcap for API version 4 on FRR v2.0
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-09-17 13:37:00 +09:00
IWASE Yusuke
90f0434c18 packet/zebra: Support some FRRouting messages format
Note: This patch does not support all messages defined in FRRouting,
and some of message are left on TODO.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-09-17 13:36:53 +09:00
IWASE Yusuke
0716d2cba1 packet/zebra: Constants for supporting FRRouting format
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-09-17 13:36:45 +09:00
IWASE Yusuke
a5f24fe3e3 packet/zebra: Support asymmetric structure of ZEBRA_*_IMPORT_LOOKUP
The ZEBRA_IPV4_IMPORT_LOOKUP/ZEBRA_IPV6_IMPORT_LOOKUP has asymmetric
structures at when sent to Zebra daemon and when sent from Zebra daemon.
Especially, "prefix_len" field is inserted before "prefix" filed when
sent to Zebra daemon.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-09-17 13:36:40 +09:00
IWASE Yusuke
b66c597fb6 packet/zebra: Parse messages based on Zebra API version
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-09-17 13:36:32 +09:00
IWASE Yusuke
c860675a5f packet/zebra: Missing bw_cls_num in InterfaceLinkParams
This patch fixes to parse the missing field of the number of unreserved
bandwidth classes in Interface Link Parameters structure.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-09-17 13:36:26 +09:00
IWASE Yusuke
8e851711a7 packet/zebra: Constants for Link Parameters Status
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-09-17 13:36:14 +09:00
IWASE Yusuke
18fa853352 packet/zebra: Constants for Interface Address Flags
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-09-17 13:36:12 +09:00
IWASE Yusuke
a104e11c0d packet/zebra: Return "ZebraMessage" for message from Zebra
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-09-17 13:36:10 +09:00
IWASE Yusuke
96891addf5 packet/zebra: Fix unresolved reference for _serialize_nexthops
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-09-17 13:36:02 +09:00
Thomas Bechtold
0673a8868e Only import pip if needed
In some systems pip is not installed and the parse_requirements() function
is not needed. So only import pip if needed. Otherwise this fails with:

  from ryu.base import app_manager
  File "/usr/lib/python2.7/site-packages/ryu/base/app_manager.py", line 34, in <module>
  from ryu import utils
  File "/usr/lib/python2.7/site-packages/ryu/utils.py", line 23, in <module>
  from pip import req as pip_req
  ImportError: No module named pip

Signed-off-by: Thomas Bechtold <tbechtold@suse.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-09-05 15:54:07 +09:00
FUJITA Tomonori
1782f54f3c Ryu 4.17
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-09-04 21:52:10 +09:00
mgrex97
0c0656f95a topology/switches: Fix delete port can't immediately remove link.
If remove port data from self.port_state first,
self.get_port method can't get the port data,
this problem will cause link can't immediately be removed.
This patch remove port data after get_port and link delete.

Signed-off-by: Yu Ren <j6y4u4xup6@gmail.com>
Signed-off-by: mgrex97 <j6y4u4xup6@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-08-29 22:51:15 +09:00
IWASE Yusuke
80fedbfeaf BGPSpeaker/net_ctrl: Close activity for each session
Currently, a thread for processing outgoing message will be remained in
"RpcSession" activity even if RPC session is closed by the remote peer,
and garbages on memory will grow.

This patch fixes to close "RpcSession" activity when RPC session
closing.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-08-29 22:50:36 +09:00
Satoshi Fujimoto
98a838e487 packet/bmp: Correctly parse peer address with IPv4
Currently, Ryu expects that the IPv4 peer address format is
"4 bytes with IPv4 address, followed by 12 bytes padding".
However RFC 7854 says the format is
"12 bytes padding, followed by 4 bytes with IPv4 address".

This patch fixes it to correctly parse/serialize peer address.

Reported-by: Henk Smit <hhwsmit@xs4all.nl>
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-08-29 22:49:53 +09:00
IWASE Yusuke
f85ae78465 rest_qos: Avoid discarding Queues info for each request
Currently, rest_qos discards the Queues info stored on its dictionary
for each "Set queue" request.
So rest_qos always reply only last Queue setting.

This patch fixes to avoid discarding the Queues info and enable to reply
all configured Queues settings.

Note: In order to store all Queues settings, "port name" field for each
Queue will be inserted on the reply of "Get queue configuration" API.
 - Before:
    [
      {
        "command_result": {
          "result": "success",
          "details": {
            "0": {
              "config": {
                "max-rate": "500000"
              }
            },
            "1": {
              "config": {
                "min-rate": "800000"
              }
            }
          }
        },
        "switch_id": "0000000000000001"
      }
    ]
 - After:
    [
      {
        "command_result": {
          "result": "success",
          "details": {
            "s1-eth1": {    # <-- Inserted
              "0": {
                "config": {
                  "max-rate": "500000"
                }
              },
              "1": {
                "config": {
                  "min-rate": "800000"
                }
              }
            }
          }
        },
        "switch_id": "0000000000000001"
      }
    ]

Reported-by: Fahmy Sherif Alaa Salaheldin <sherif.fahmy@epfl.ch>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-08-29 22:49:36 +09:00
Dingyuan Hu
bc7451dc7c services/ovsdb: Listen on IPv6 Address
This patch enables Ryu to listen ovsdb connections on IPv6 Address.
Note that you need to make a config file like belows:
    [ovsdb]
    address=::

Signed-off-by: Dingyuan Hu <hdyvip@gmail.com>
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-08-29 22:49:12 +09:00
Satoshi Fujimoto
7f537c4185 packet/icmpv6: Assert length in options are valid
About the 'length' field in ICMPv6 options,
RFC4861 says that "The value 0 is invalid".
This patch adds assertions to raise a exception
for such invalid ICMPv6 packets.

Reported-by: William Fisher <william.w.fisher@gmail.com>
Reported-by: Shivaram Mysore <shivaram.mysore@gmail.com>
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-08-04 21:11:49 +09:00
Satoshi Fujimoto
ee9a197dd6 packet/icmpv6: Fix parsing undefined nd_option fails
The length of nd_option is units of 8 octets.
Currently, for nd_options which is undefined in the ICMPv6 packet library,
the parser assumes that the length is [8 * length - 2].
It causes fails while parsing these options.

This patch fixes it to parse such options correctly.

Reported-by: William Fisher <william.w.fisher@gmail.com>
Reported-by: Shivaram Mysore <shivaram.mysore@gmail.com>
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-08-04 21:11:09 +09:00
IWASE Yusuke
44cd14ac81 ofp_event: Timestamp when OpenFlow event was generated
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>
2017-08-04 21:07:28 +09:00
FUJITA Tomonori
6d950481f6 Ryu 4.16
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-08-02 10:39:13 +09:00
IWASE Yusuke
800c136a9b doc: Fix unexpected indent in ryu/lib/packet/bgp.py
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-07-30 22:07:08 +09:00
IWASE Yusuke
cb40f779d1 doc: Deprecated option html_use_smartypants
"html_use_smartypants" in conf.py is deprecated in Sphinx 1.6.
This patch fixes to use "smart_quotes" in docutils.conf instead.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-07-30 22:07:06 +09:00
IWAMOTO Toshihiro
ec04ff9f46 ofproto: Avoid emitting illegal instruction sets
The OpenFlow spec forbids multiple occurences of a same instruction
type within a mod_flow message, so make sure
ofp_instruction_from_jsondict doesn't emit such an instruction set.

Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-07-21 21:54:25 +09:00
Travis Gockel
5e176f9e7c doc: Minor grammar changes in ryu_app_api 2017-07-21 21:47:47 +09:00
IWASE Yusuke
214cd8c305 unit/ofproto: Adopt to rename of OFPErrorExperimenterMsg
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-07-21 21:38:42 +09:00
IWASE Yusuke
5099034d0c ofproto: Handle OFPErrorExperimenterMsg
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>
2017-07-21 21:38:42 +09:00
IWASE Yusuke
b964275b53 bgp_sample_conf: absolute_import to suppress warnings
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-07-21 21:38:42 +09:00
Satoshi Fujimoto
60651d8a1c service/ovsdb: get socket from RemoteOvsdb
This patch adds "socket" field to RemoteOvsdb
to get sockets which connects to switches.

e.g.)
    @set_ev_cls(ovsdb_event.EventNewOVSDBConnection)
    def handle_new_ovsdb_connection(self, ev):
        print(ev.client.socket.getsockname()[0])

Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-07-02 20:21:14 +09:00
FUJITA Tomonori
cd67c52471 Ryu 4.15
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-07-02 20:08:32 +09:00
FUJITA Tomonori
a991fed7e4 Revert "tests: Separate test files from Ryu module"
This reverts commit a67ed2858417b9d795460f05126c01fb0cd344f9.

The commit breaks OpenStack neutron dynamic routing.
2017-06-30 14:23:03 +09:00
IWASE Yusuke
a67ed28584 tests: Separate test files from Ryu module
To prevent redundant files (e.g., pcap files, json files for tests,
packet data generator) to be installed, this patch separates test
directory from Ryu module.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-06-26 15:17:44 +09:00
Satoshi Fujimoto
d8ae9491da service/ovsdb: Use dict.items() instead of six.iteritems()
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-06-23 12:08:18 +09:00
Satoshi Fujimoto
ea23ebdadf doc/ovsdb_manager: Update Sample Code
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-06-23 12:08:18 +09:00
Satoshi Fujimoto
10b9273928 service/ovsdb: Use Python 2/3 compatible code
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-06-23 12:08:18 +09:00
Satoshi Fujimoto
27b8d44bb1 service/ovsdb: Avoid to use dict as default argument
Using mutable values as default arguments will cause unexpected behavior.

Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-06-23 12:08:18 +09:00
Satoshi Fujimoto
cf667e4097 service/ovsdb: Add properties to EventNewOVSDBConnection
Currently, EventNewOVSDBConnection only has system_id.
This patch let the class has RemoteOvsdb to get more
informations through it.

e.g.)
    @set_ev_cls(ovsdb_event.EventNewOVSDBConnection)
    def handle_new_ovsdb_connection(self, ev):
        system_id = ev.system_id
        remote_addr = ev.client.address

Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-06-23 12:08:18 +09:00
IWASE Yusuke
2edfb20884 test_vsctl: Strip unexpected double quote
This patch removes unexpected double quote around IP address in
OVSDB_SWITCH_ADDR.
e.g.)
 NG: tcp:"172.17.0.2":6640
 OK: tcp:172.17.0.2:6640

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-06-23 11:36:18 +09:00
IWASE Yusuke
d9d0588689 pip: OpenStack updated requirements of eventlet again
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-06-22 16:08:35 +09:00
IWASE Yusuke
388a97ef6d manager: Introduce user flags option
This patch introduces "--user-flags" option which enable to add user
original CLI or config file options for their own Ryu applications.

Usage Example)
  $ cat user_flags.py
  from ryu import cfg

  CONF = cfg.CONF
  CONF.register_cli_opts([
      cfg.StrOpt(
          'user-cli-opt', default=None,
          help='user original CLI option'),
  ])

  $ ryu-manager --user-flags user_flags.py user_app.py

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-06-22 16:08:33 +09:00
IWASE Yusuke
0f1430edfd CONTRIBUTING: Update info of Python ver/lib and links
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-06-22 16:07:57 +09:00
IWASE Yusuke
b4786a3fe3 CONTRIBUTING: Update procedure for running tests
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-06-22 16:07:54 +09:00
IWASE Yusuke
ef212fe87e CONTRIBUTING: Update procedure for submitting patches
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-06-22 16:07:49 +09:00
IWASE Yusuke
cec1254a35 README: Dependencies for installing optional requirements
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-06-22 16:07:41 +09:00
IWASE Yusuke
03c67d368d service/ovsdb: Default of controller_info in set_controller
Currently, api.set_controller in OVSDB service raises AttributeError if
controller_info is None and controller is not found in current table.

This patch sets the empty dict as the default value and fixes this
problem.

Reported-by: 胡鼎原 <hdyvip@gmail.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-06-04 13:56:28 +09:00
FUJITA Tomonori
574e417d9d Ryu 4.14
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-06-02 13:58:40 +09:00
胡鼎原
8fa14c87ec doc: fix error in ovsdb_manager.rst code
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-30 22:11:02 +09:00
胡鼎原
51a86c4d56 fix dhcp6.py bug using python3
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-30 22:10:46 +09:00
IWASE Yusuke
bfcd65744c pip: OpenStack avoids newer eventlet
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-30 17:00:45 +09:00
IWAMOTO Toshihiro
430bc97638 ofctl: Add some tests for ofp_instruction_from_str
Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-30 16:13:19 +09:00
IWAMOTO Toshihiro
a52c62a120 ofctl: Add ovs-ofctl style action string parser
This commit adds a new method called ofp_instruction_from_str,
which takes an ovs-ofctl style action string and returns a list of
JSON dictionaries. Currently only a few action strings are understood.

Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-30 16:13:18 +09:00
IWAMOTO Toshihiro
a5dca1a1e3 nicira_ext: Define some CT constants
Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-30 16:13:17 +09:00
Satoshi Fujimoto
7794ff714c BGPSpeaker/SSH: Support to show L2VPN Flow Spec routes
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-12 09:48:19 +09:00
Satoshi Fujimoto
0168c28935 BGPSpeaker: Support IPv6 Flow Spec update messages
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-12 09:48:14 +09:00
Satoshi Fujimoto
0b9bc03e6c BGPSpeaker/info_base: Add tables for L2VPN Flow Spec
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-12 09:48:09 +09:00
Satoshi Fujimoto
12b809f5f7 utils/test_bgp: Add unit tests for L2VPN Flow Spec
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-12 09:48:05 +09:00
Satoshi Fujimoto
e82d26b1b5 test_table_manager: Add unit tests for L2VPN Flow Spec
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-12 09:48:01 +09:00
Satoshi Fujimoto
2bcb040dcb test_bgpspeaker: Add unit tests for L2VPN Flow Spec
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-12 09:47:57 +09:00
Satoshi Fujimoto
d37a311829 packet/bgp: Support L2VPN Flow Spec
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-12 09:47:52 +09:00
Satoshi Fujimoto
b327981534 packet/bgp: Properly calculate length for FlowSpec
RFC 5575 says the 'len' field in numeric or bitmask operators
represents that the length of the value field is [1 << 'len'].
But, in serializing FlowSpec messages, the packet library uses
the `len` field as the length of the value field itself.
This patch fixes it to serialize FlowSpec messages properly.

Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-12 09:47:48 +09:00
Satoshi Fujimoto
9a4e8968ed test_bgp: Add test cases for L2VPN Flow Spec
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-12 09:47:42 +09:00
Satoshi Fujimoto
434b2adacd BGPSpeaker/SSH: Support to show IPv6 Flow Spec routes
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-12 09:47:36 +09:00
Satoshi Fujimoto
7e6c648ba1 BGPSpeaker: Support IPv6 Flow Spec update messages
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-12 09:47:07 +09:00
Satoshi Fujimoto
4d9d444df1 BGPSpeaker/info_base: Add tables for IPv6 Flow Spec
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-12 09:46:59 +09:00
Satoshi Fujimoto
8597ef851b utils/test_bgp: Add unit tests for IPv6 Flow Spec
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-12 09:46:54 +09:00
Satoshi Fujimoto
f8654b67c7 test_table_manager: Add unit tests for IPv6 Flow Spec
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-12 09:46:48 +09:00
Satoshi Fujimoto
c53605385e test_bgpspeaker: Add unit tests for IPv6 Flow Spec
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-12 09:46:42 +09:00
Satoshi Fujimoto
bb38fb2f30 packet/bgp: Support IPv6 Flow Spec
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-12 09:46:37 +09:00
Satoshi Fujimoto
64b9dfcdd6 test_bgp: Add test cases for IPv6 Flow Spec
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-12 09:46:31 +09:00
IWAMOTO Toshihiro
607f4d8276 ofproto: Allow CIDR notation for ipv[46]_{src, dst}
This hack allows CIDR notations for OFPMatch. For example:
    ofpp.OFPMatch(ipv4_src="198.51.100.0/24")

Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-11 12:32:18 +09:00
Brad Cowie
a197d87375 utils.import_module: Prefer filepath than Python module
Currently, ryu.utils.import_module() prefers the Python module path
than the user specified file path, and if the user app name is the
same with the Python module, this function returns the Python module
instead of the user app.

This patch fixes to try to load "file" before finding the loaded
Python module, and fixes this problem.

Note: With this patch, import_module() will reload (override) a module
if the specified module file name is the same.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: Brad Cowie <brad@gizmoguy.net.nz>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-09 10:48:18 +09:00
Shinpei Muraoka
077eef801e library_packet_ref: Separate ref into each protocol
To keep readablity if include all class into library reference, this
patch separates library_packet_ref.rst into each protocol.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-09 10:20:16 +09:00
Shinpei Muraoka
99e7cc4074 lib/packet: Use literal block for diagram in pydoc
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-09 10:20:16 +09:00
IWASE Yusuke
5969a89ee4 packet/bgp: Omit description of default value
Omit description of default value The default value is described in the
aut generated API doc of class.
So the default value should not be hardcoded in pydoc.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-09 10:20:16 +09:00
IWASE Yusuke
c6d9bfc384 packet/lldp: Add description for each class
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-09 10:20:16 +09:00
IWASE Yusuke
4c7d523e22 packet/arp: Update description for arguments
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-09 10:20:16 +09:00
Shinpei Muraoka
352c007535 BGPSpeaker/info_base/base: Unify documentation format
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-09 10:20:16 +09:00
Shinpei Muraoka
74c6f5b21c BGPSpeaker: Unify documentation format
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-09 10:20:16 +09:00
IWASE Yusuke
3c0dd6ee7a BGPSpeaker: Improve EVPN Redundancy Mode validation
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-09 10:20:16 +09:00
Satoshi Fujimoto
09fa78182f bgp: Enable to configure default local preference
This patch enables to configure the default local preference.
If not specified, the value will be 100 as a default.

Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-09 10:20:16 +09:00
IWASE Yusuke
2354bd7df3 packet/zebra: Support IP_ROUTE message from Zebra
Zebra IPv4/IPv6 route message have asymmetric structure, in other words,
the message structure from Zebra to the protocol daemons and that from
the protocol daemons to Zebra have the different structures.

This patch introduces _ZebraMessageFromZebra in order to distinguish
which daemon sent the message and fixes _ZebraIPRoute to decode IPv4/IPv6
route message from Zebra.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-09 10:20:16 +09:00
IWASE Yusuke
6d35bb8d01 lib/hub: Workaround for issue of eventlet
This patch adopts the workaround which is discussing on the eventlet
team at the following:
 https://github.com/eventlet/eventlet/issues/401
This workaround is suggested by Raymond Burkholder.

Suggested-by: Raymond Burkholder <ray@oneunified.net>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-05-09 10:17:08 +09:00
FUJITA Tomonori
5a1da545bf Ryu 4.13
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-04-04 18:01:09 +09:00
surlyjake
468f471f87 nicira_ext: Constants for IP fragment matching
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-03-28 13:03:02 +09:00
Satoshi Fujimoto
e1741b7d77 bgp/info_base: Refactor has_nexthop() method
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-03-28 11:01:12 +09:00
Satoshi Fujimoto
399a03feb1 bgp/peer: Fix invalid NEXT_HOP in UPDATE message
Currently, when BGPSpeaker advertises IPv4/6 unicast routes
via an iBGP connection, if the Nexthop in the route is omitted,
BGP Speaker advertises the Nexthop with the unspecified address.
This route can be evaluated as invalid by the receiving router.
This patch fixes it by making BGPSpeaker to advertising
the Nexthop with the host's own ip address if the local route
in the RIB has the Nexthop with the unspecified address.

Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-03-28 11:01:11 +09:00
Satoshi Fujimoto
b7dcd40837 ofctl_v1_5: Fix lack of arguments for modify role API
ofctl_v1_5 can't send role request messages,
because of lack of arguments.
This patch fixes it by adding the argument for short_id.
ofctl_v1_5 sets None to short_id.
It means ofctl_v1_5 uses the default value of short_id.

Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-03-28 11:00:44 +09:00
Satoshi Fujimoto
6dfda4a227 ofctl_rest: Add get role API
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-03-28 11:00:43 +09:00
Satoshi Fujimoto
d0f25d639b ofctl: Fix type of fields of DescStat
With Python3 and OpenFlow v1.0/v1.2/v1.3, Ryu can't dump
the description statistics reply message into JSON,
because the message has byte type values.
This patch fixes it by using to_jsondict().

Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-03-28 11:00:17 +09:00
Shinpei Muraoka
ab902d2b5e utils/test_bgp: Add unit tests for Flow Specification
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-03-28 10:00:55 +09:00
Shinpei Muraoka
9fa4e6b42d core_managers/test_table_manager: Add unit tests for Flow Specification
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-03-28 10:00:45 +09:00
Shinpei Muraoka
4230897783 test_bgpspeaker: Add unit tests for Flow Specification
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-03-28 10:00:37 +09:00
Shinpei Muraoka
06a61123be library_packet_ref: Add description of action for Flow Specification
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-03-28 10:00:28 +09:00
Shinpei Muraoka
b3a83ef185 BGPSpeaker: Support Flow Specification update messages
This patch enables BGPSpeaker to store FlowSpec routes into
the global table and VRF tables and to provide the API
for advertising routes.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-03-28 10:00:21 +09:00
Shinpei Muraoka
a486539400 BGPSpeaker/SSH: Supports display of Flow Specification RIB
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-03-28 10:00:16 +09:00
Shinpei Muraoka
880bd4ab85 BGPSpeaker/info_base: Add tables for Flow Specification
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-03-28 10:00:10 +09:00
Shinpei Muraoka
765a723fe6 packet/bgp: Implement the utility of Flow Specification for BGPSpeaker
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-03-28 10:00:03 +09:00
Shinpei Muraoka
f12485e6de packet/bgp: Fix subtype for Traffic Filtering Actions of Flow Specification
This patch sets the constant value
so that you can omit argument "subtype" for
Traffic Filtering Action of Flow Specification.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-03-28 09:55:58 +09:00
Shinpei Muraoka
fd16c43a31 packet/bgp: Unify variable names for Flow Specification
Currently, FLOW_SPEC and FLOWSPEC constants are mixed,
so this patch will unify to FLOWSPEC.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-03-28 09:55:57 +09:00
Shinpei Muraoka
271961ecb1 packet/bgp: Add the address converter for Flow Specification
Argument "addr" of "_FlowSpecPrefixBase" must be
specified in the network address.
If argument "addr" specified in the host address,
this patch converts the given address into the network address.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-03-28 09:55:52 +09:00
Shinpei Muraoka
66a5bddaf0 packet/bgp: Fix data structure for VPNv4 Flow Specification
The Route Distinguisher did not include in data structure
for VPNv4 Flow Specification.
This patch adds the Route Distinguisher to data structure
for VPNv4 Flow Specification.
For details, refer to Chapter 8 of RFC 5575.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-03-28 09:55:48 +09:00
Shinpei Muraoka
16c3640673 library_packet_ref:Add bgp reference for Flow Specification
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-03-28 09:55:42 +09:00
Shinpei Muraoka
4cbdbb767b test_bgp: Add test cases for user interface of Flow Specification
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-03-28 09:55:34 +09:00
Shinpei Muraoka
4838463ab3 packet/bgp: Implement user interface of Flow Specification
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-03-28 09:55:29 +09:00
FUJITA Tomonori
35e12d858c Ryu 4.12
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-03-02 15:38:47 +09:00
IWASE Yusuke
9420884db4 hub.StreamServer: Ommit validation for IPv4 address
To support the case that user specifies the host address like
'localhost', this patch removes the validation of the given address
as IPv4 address family and fixes to try listening as IPv4 by default.
Then, the validation will be handled in "eventlet.listen()".
This behavior is the same as that of before supporting the unix domain
socket.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-02-28 22:37:40 +09:00
IWASE Yusuke
a134362526 wsgi: Change default wsgi listen host to "0.0.0.0"
With netaddr.valid_ipv4/6, empty host is not allowed and will fail
to validate.
This patch changes to the default wsgi 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>
2017-02-24 22:20:54 +09:00
IWASE Yusuke
7baa456696 zebra: Add sample application for Zebra server service
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-02-22 12:23:33 +09:00
IWASE Yusuke
8914385148 zebra: Implement Server APIs for Zebra protocol service
This patch implements APIs for performing as Zebra daemon of Quagga
and enables to integrate with other Quagga daemons.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-02-22 12:23:24 +09:00
IWASE Yusuke
1b486a0634 zebra: Implement database for Zebra protocol service
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-02-22 12:23:19 +09:00
IWASE Yusuke
dc57ff5b47 tools/optional-requires: SQLAlchemy for Zebra service
This patch adds a new optional requirements, SQLAlchemy, for Zebra
protocol service database.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-02-22 12:22:51 +09:00
IWASE Yusuke
d90589c2cc lib/netdevice: Constants defined in netdevice(7)
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-02-22 12:22:48 +09:00
IWASE Yusuke
793dc13e01 controller: Change default OPF listen host to "0.0.0.0"
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>
2017-02-22 12:22:46 +09:00
IWASE Yusuke
9efde1d2f5 hub: Enable StreamServer to listen Unix domain socket
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-02-22 12:22:38 +09:00
IWASE Yusuke
fd3bfb55de zebra: Add sample application for Zebra client service
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-02-22 12:22:30 +09:00
IWASE Yusuke
e5a0974508 Implement Zebra protocol client service
This patch implements APIs for performing as a protocol daemon of Quagga
such as "ripd", "ospfd", "bgpd", for example.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-02-22 12:22:29 +09:00
IWASE Yusuke
c1f810b9b1 bgp/utils/bgp: Use lib/ip for Python 3 compatibility
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-02-22 11:38:01 +09:00
IWASE Yusuke
fd96d24314 BGPSpeaker: Use isinstance(*, bool) for boolean check
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-02-22 11:37:57 +09:00
IWASE Yusuke
ef3eefb2ad BGPSpeaker: Support Route Reflector features [RFC4456]
This patch implements the features for acting as a Route Reflector
which defined in RFC4456.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-02-22 11:37:52 +09:00
IWASE Yusuke
e06ec47232 packet/zebra: Enable to specify "prefix" arg in str
Currently, "prefix" argument should be an instance of IPv4Prefix or
IPv6Prefix in some Zebra message body classes.
But for the convenience, this patch enables to specify "prefix" in
the str type representation.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-02-17 20:14:02 +09:00
IWASE Yusuke
88aaba68bb lib/ip: Add wrapper for netaddr.valid_ipv4/6
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-02-17 20:14:00 +09:00
Albert Siersema
15a12a7a6a allow_local_as_in_count : allow local ASN in AS patch, e.g. "rd auto/route-target both auto"
Cisco/Juniper/Cumulus and undoubtedly more vendors offer a
simplification of the EVPN configuration by not having to
specify individual RD/RT's, e.g. in Cisco NX-OS syntax:

evpn
    vni 10311 l2
      rd auto
      route-target import auto
      route-target export auto

This simplifies/unifies the configuration.
All leaf switches/ryu instances share the same ASN (e.g. 65511).
Spine switches in the same layer can share an ASN as well (e.g. 65510).

To facilitate the above, the local ASN has to be accepted in the AS path.
To this end, Cisco includes an 'allowas-in' configuration statement.
See:
http://www.cisco.com/c/en/us/products/collateral/switches/nexus-9000-series-switches/guide-c07-734107.html
search for "MP-eBGP Design with VTEP Leaf Nodes in the Same BGP
Autonomous System"

This patch offers the possibility to specify the number of accepted
occurrences
of the local ASN in incoming AS paths. The default value is 0, which basically
is the same as the code before this patch: local ASN in the path
indicates a loop.
Non-zero values allow the local ASN to appear the specified number of times in
the AS path. A maximum value of 3 should satisfy most deployments.

Signed-off-by: Albert Siersema <albert@mediacaster.nl>
2017-02-11 14:59:51 +09:00
IWASE Yusuke
e13f46b256 BGPSpeaker: Advertise VNI on EVPN Multicast Ethernet-Tag
For the interoperability with other MP BGP EVPN VXLAN implementations
(e.g., Cisco NX-OS), this patch enables to advertise the VNI with the
PMSI Tunnel attribute on the Inclusive Multicast Ethernet Tag Route
messages.

Suggested-by: Albert Siersema <albert@mediacaster.nl>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-02-11 14:41:08 +09:00
IWASE Yusuke
6e78aa3b94 BGPSpeaker: Allow empty IP Address in EVPN advertisement
For the EVPN MAC/IP Advertisement Route, IP Address field might be
omitted in case of the L2VPN MAC advertisement (e.g., Cisco NX-OS).
This patch allows to specify the empty IP Address to advertise.

This patch is suggested by Albert Siersema for the interoperability
with other MP BGP EVPN VXLAN implementations.

Suggested-by: Albert Siersema <albert@mediacaster.nl>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-02-11 14:41:07 +09:00
IWASE Yusuke
b0c9da18a0 RyuBGPSpeaker: Enable to notify BGP events
This patch enables RyuBGPSpeaker, which is a base Ryu application for
creating user BGP applications, to notify the BGP events corresponding
to 'best_path_change_handler', 'peer_down_handler' and 'peer_up_handler'
of bgpspeaker.BGPSpeaker.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-02-11 14:21:04 +09:00
IWASE Yusuke
d2a97b16aa ofctl_v1_*: Use utility functions of ofctl_utils
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-02-11 14:21:04 +09:00
IWASE Yusuke
dffb3d3cf6 ofctl_v1_*: Use str_to_int instead of builtin int
This patch fixes lib/ofctl_v1_* to use the utility function str_to_int()
instead of the builtin function int().
With this change, lib/ofctl_v1_* can convert the user input values into
integer even if non-decimal string values (e.g. hexadecimal "0x80").

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-02-11 14:21:04 +09:00
Shinpei Muraoka
83bf7fae1d test_bgp: Add test cases for Flow Specification
This patch adds the test cases for
Flow Specification NLRI in MP_REAACH NLRI and
Traffic Filtering Actions in EXTENDED_COMMUNITIES.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-02-11 14:21:04 +09:00
Shinpei Muraoka
79741fdc88 packet/bgp: Support Flow Specification
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-02-11 14:21:04 +09:00
Shinpei Muraoka
838708a32a pakcket/bgp: pylint
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-02-11 14:21:04 +09:00
IWASE Yusuke
c4218ccde3 BGPSpeaker: Support to advertise Type 1, 2 Route Target
Currently, BGPSpeaker supports only type 0 (Two-Octet AS-Specific) Route
Target (or Route Distinguisher).
This patch enables to advertise Type 1 (IPv4-Address-Specific) and Type
2 (Four-Octet AS-Specific) Route Targets.

Reported-by: Albert Siersema <albert@mediacaster.nl>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-02-11 14:21:04 +09:00
FUJITA Tomonori
6c92a75aa8 Ryu 4.11
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-02-04 15:00:43 +09:00
IWASE Yusuke
37391bb5bd utils: Re-implement parse_requirements
This patch re-implements utils.parse_requirements() without retrieving
code from OpenStack.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-01-23 22:26:29 +09:00
fumihiko kakuma
e9099345d2 docker_base.py: fix an ip option of "docker network connect"
ip address with subnet is ignored in ip option of "docker network connect"
This patch specifies a correct ip format for option.

Signed-off-by: Fumihiko Kakuma <kakuma@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-01-23 22:24:15 +09:00
IWASE Yusuke
17e2e51924 library_packet_ref: Add doc for Zebra packet library
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-01-23 22:23:24 +09:00
IWASE Yusuke
8ed4e24fb1 test_zebra: Unit tests for Zebra packet library
The pcap files for Zebra protocol were generated by:
  v2: Quagga 0.99.24.1 (Ubuntu 14.04 LST packaged version)
  v3: Quagga 1.1.0 (from Git source)

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-01-23 22:23:23 +09:00
IWASE Yusuke
0662e9024d packet/zebra: Add Zebra protocol parser
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-01-23 22:23:22 +09:00
IWASE Yusuke
1513ac9f95 bgp_scenario_test: Clean previous builds before installing
On Python3 Docker image, "python setup.py install" might fail in case
that the current directory contains the symlink to Docker host file
system and the link target is not visible from container.
e.g.)
  .tox/py34/include/python3.4m -> /usr/include/python3.4m

This patch fixes to remove .tox directory on Docker container and also
clean the previous builds before installing.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-01-23 21:59:31 +09:00
Yury Kulazhenkov
9ccec7bb5a sync ryu.services.protocols.ovsdb.client.Idl code with ovs lib
The ovs library has changed its implementation of the idl.Idl class. The
CTOR in ryu.services.protocols.ovsdb.client.Idl updated to be compatible
with the current version.

Patch fix the problem:
    if table.cond_changed:
AttributeError: 'TableSchema' object has no attribute 'cond_changed'

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-01-16 16:28:22 +09:00
Olivier DESNOE
6d4b094dc3 packet lib: adding DHCPv6 support
Signed-off-by: Olivier DESNOE <olivier.desnoe@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-01-14 22:48:23 +09:00
Shinpei Muraoka
2197fd55d1 doc: library_packet_ref: Add reference of openflow
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-01-14 22:11:10 +09:00
Shinpei Muraoka
ca1a2a2781 test_openflow: Add unit tests for OpenFlow packet library
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-01-14 22:11:09 +09:00
Shinpei Muraoka
82b113afb6 packet lib: Add packet library of OpenFlow
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-01-14 22:11:06 +09:00
FUJITA Tomonori
ca5afabce9 Ryu 4.10
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-01-06 05:52:53 +09:00
Shinpei Muraoka
25a15406f6 library_packet_ref: Update dhcp reference method
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-01-06 05:27:09 +09:00
Shinpei Muraoka
c893ba04f7 test_dhcp: Extend unit test for fragmented options
Also, this patch removes the test case for __init__()
with "hlen" is zero,
because "hlen" should be recalculated at serialization.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-01-06 05:27:08 +09:00
Shinpei Muraoka
d908aff00c packet/dhcp: Revert b'str' conversion
This patch partially reverts 75e8c58916524243e6796e73c371981e14fff6ee
and 536a42d8c1c0be48e78d5f29b6fd55a38012d953.  dhcp.boot_file is ascii.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-01-06 05:27:07 +09:00
Shinpei Muraoka
a4d4291d10 packet/dhcp: Support fragmented options
Currently, if you set fragmented option data
for the packet library of dhcp, Traceback occurs.
This patch fixes to analyze up to options not corrupting data.
The remaining corrupting data will be appended
at the end of option list.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2017-01-06 05:26:59 +09:00
IWASE Yusuke
42c71ad0e6 BGPSpeaker/net_ctrl: Support multiple RPC sessions
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-29 22:58:50 +09:00
IWASE Yusuke
8555dda0f2 BGPSpeaker/base: Stop child activity by name
This patch enables Activity base to stop the child activity by name.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-29 22:58:49 +09:00
IWASE Yusuke
27b253d06e BGPSpeaker/net_ctrl: Move _send_*_response() function
This patch moves _send_*_response() function into RpcSession class
to use socket wrapper methods for maintaining the connection state
safely.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-29 22:58:43 +09:00
IWASE Yusuke
f1edc9fbd0 BGPSpeaker/net_ctrl: Close RPC session when disconnected
This patch fixes net_ctrl to check whether socket is connected and
to close RPC session when disconnected by RPC peer.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-29 22:58:38 +09:00
IWASE Yusuke
fcea0dc2af BGPSpeaker/net_ctrl: Pylint and fixes of typos
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-29 22:58:34 +09:00
IWASE Yusuke
7e30cf6b01 rpc_cli: Avoid to use eval()
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-29 22:58:23 +09:00
IWASE Yusuke
98a3b03792 rpc_cli: Close peer connections when exiting prompt
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-29 22:58:22 +09:00
IWASE Yusuke
daea96645a rpc_cli: Enable to execute a single command
This patch enables 'ryu rpc-cli' command to execute a single command
not interactively.

e.g.)
$ ryu rpc-cli --peers=bgp=localhost:50002 \
  --command='request bgp operator.show [{"params": ["rib", "ipv4"]}]'

This feature is convenient to controle BGPSpeaker states via shell
commands, for example.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-29 22:58:19 +09:00
IWASE Yusuke
49461e84ec ryu/app: Use Request/Response wrappers in REST Apps
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-29 22:14:01 +09:00
IWASE Yusuke
40178c92b2 wsgi: Wrapper classes of Request/Response in WebOb
With WebOB 1.7.0+, "charset" can not be omitted when constructing
Request/Response instance and exception will occur if omitted.
This patch adds wrapper classes of Request/Response for setting
charset="UTF-8" by default.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-29 22:13:56 +09:00
Shinpei Muraoka
95702135d4 library_bgp_speaker_ref: Fix unexpected unindent
This patch fixes unexpected unindent that occur when building.
Also, add ESI type to be specified for argument
esi of evpn_prefix_add and evpn_prefix_del.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-29 22:06:52 +09:00
IWASE Yusuke
6ebf0f7e4a optional-requires: Specify lxml version for OpenStack
OpenStack added "lxml!=3.7.0" into its requirements file, and this
patch adds the same specification for avoiding VersionConflict
error while installing.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-29 22:05:50 +09:00
IWASE Yusuke
73d331312e ryu-client: Remove client for OpenStack plugin/agent
This patch removes remaining of OpenStack Ryu plugin and agent.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-29 22:05:35 +09:00
IWASE Yusuke
cf1a2f37c8 doc: Deprecate OpenStack plugin ref
Because the Ryu plugin for OpenStack was deprecated and the description
in "using_with_openstack.rst" is obsoleted, this patch removes the link
to this page from the index and adds the cautions for it.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-29 22:05:27 +09:00
Shinpei Muraoka
eb646cee24 test_geneve: Add unit tests for Geneve
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-29 22:04:26 +09:00
Shinpei Muraoka
b6c1189cc9 packet lib: Add packet library of Geneve
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-29 22:04:20 +09:00
Shinpei Muraoka
6ea6e86e16 test_gre: Add unit tests for NVGRE
This patch adds test case of NVGRE.
Also, fixes unit tests for GRE to the method using packet capture.
For that reason, add packet capture files.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-29 22:04:15 +09:00
Shinpei Muraoka
19e415a19d packet/gre: Support NVGRE extension
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-29 22:04:13 +09:00
Shinpei Muraoka
d1c275ed6f doc: library_packet_ref: Update references
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-29 22:03:38 +09:00
IWASE Yusuke
9b2cb18729 rest_router: Fix ARP THA in reply message
Currently, rest_router sends ARP reply messages composing own MAC
address in Target MAC Address, and both Sender/Target MAC address
are MAC address of rest_router.
So, with this reply messages, Wireshark will report "Duplicate IP
address detected".
This patch fixes this problem.

This problem was reported by China Shenzhen TICOMM Information
Technology Co. Ltd.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-29 22:02:40 +09:00
IWASE Yusuke
cad9c8a940 install_docker_test_pkg: Remove unnecessary pip pacakges
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-14 13:23:33 +09:00
IWASE Yusuke
6da65f508e tox: Move dependencies installation to .travis.yml
This patch moves dependencies installation in tox.ini to .travis.yml
in order to avoid to install dependencies repeatedly when running
tox tests on locally.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-14 13:23:32 +09:00
IWASE Yusuke
f152c69ee0 bgp_scenario_test: Switch Python version
With Ubuntu base Docker image, Python 2.7 will always be used on
Scenario test containers if we just install "python-*".

This patch fixes to switch base Docker image and enables to use
the specific Python version.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-14 10:20:45 +09:00
IWASE Yusuke
c0e06c7ea7 test_requirements: Test cases for checking requirements
This patch adds the test cases for checking whether the requirements
of Ryu has no conflict with that of other projects (e.g., the global
requirements of OpenStack)

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-14 10:04:55 +09:00
IWASE Yusuke
c810965826 tox: Test ryu-manager without additional requirements
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-14 10:04:49 +09:00
IWASE Yusuke
1453f0f9e2 pip: Add doc requirements for convenience
This patch adds the requirements file for building the Ryu documentation.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-10 22:01:34 +09:00
IWASE Yusuke
bc9796b097 library_bgp_speaker_ref: Fix unexpected indentation
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-10 22:01:21 +09:00
IWASE Yusuke
f8fa7b68db doc: Add MRT file library reference
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-10 22:00:49 +09:00
IWASE Yusuke
d993e430ef test_mrtlib: Add unit tests for MRT paser
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-10 22:00:41 +09:00
IWASE Yusuke
b3804a8727 mrtlib: Add parser for MRT format [RFC6396]
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-10 22:00:34 +09:00
IWASE Yusuke
a6dc0bc8a7 packet/ospf: Reduce Pylint warnings
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-10 22:00:29 +09:00
IWASE Yusuke
5e8b6c69f2 type_desc: Define TypeDisp class for re-usability
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-10 22:00:22 +09:00
IWASE Yusuke
4a8c7245fa bgp_scenario_test/bgp: Pylint
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-10 21:40:07 +09:00
IWASE Yusuke
ee6cee3753 bgp_scenario_test/common: Pylint
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-10 21:40:05 +09:00
fumihiko kakuma
742c2a5e20 Delete an unnecessary function
Currently a scenario test doesn't use stream option of exec_on_ctn and
this function requires extra module(docker-py).
This patch deletes the unnecessary function.

Signed-off-by: Fumihiko Kakuma <kakuma@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-10 21:31:42 +09:00
fumihiko kakuma
46409763d4 Get some debug information
Get log for command execution error and ryu bgp app.

Signed-off-by: Fumihiko Kakuma <kakuma@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-10 21:31:34 +09:00
Omer Anson
b5d232d560 Add DHCP options constants to DHCP lib
Add DHCP options constants to DHCP lib for the following options:
* Domain name option (15)
* Interface MTU (26)
* Classless route (121)

These constants are used in Dragonflow, which uses ryu's DHCP lib to
construct a DHCP responder.

Signed-Off-By: Omer Anson <oaanson@gmail.com>

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-10 17:54:05 +09:00
IWASE Yusuke
e0c446a6b4 lib/ofctl_v_*: Enable to filter flow stats by priority
OpenFlow Spec does not allow to filter flow entries by priority,
but when with a large amount of flow entries, filtering by priority
is convenient to get statistics efficiently.

This patch enables lib/ofctl_v_* modules to filter flow stats by
priority.

This patch is suggested by China Shenzhen TICOMM Information
Technology Co. Ltd.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-10 15:29:37 +09:00
IWASE Yusuke
002cbbe1ec packet/bgp: Fix default of esi for IP Prefix route
"esi" value should be an instance of EvpnEsi subclass and not int
type value, this patch fixes the default value to "None".

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-10 14:59:29 +09:00
IWASE Yusuke
88c5be07de BGPSpeaker: ESI to be optional arg in MAC/IP Adv route
The ESI field should not be a route key for BGP processing in EVPN
MAC/IP Advertisement route, this patch confirms "esi" is an optional
argument for this route.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-10 14:59:26 +09:00
IWASE Yusuke
9e5f9d9d37 packet/bgp: Support multiple next_hop in BGPPathAttributeMpReachNLRI
In case of the IPv6 address family in MP-BGP, NLRI might has multipule
next_hop addresses (e.g., one is global unicast address and the other
is link local unicast address).

This patch fixes to support multipule next_hop addresses in MP-BGP
NLRIs.
For the backward compatibility, this patch make it to stor the first
next_hop address as next_hop attribute and all next_hop addresses
as next_hop_list.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-10 14:57:49 +09:00
IWASE Yusuke
ad5ce12e70 packet/bgp: Unpack mpls_label in BGPPathAttributePmsiTunnel
The decoded mpls_labe should be return as a tuple of (mpls_labe,
is_bos).
This patch fixes to unpack the returned tuple.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-10 14:57:43 +09:00
IWASE Yusuke
430424aac0 stringify: Add optional attributes list to be displayed
Currently, propery type attributes are ignored in the str and json
representations.
If we want to include them, it is required to override to_jsondict()
and from_jsondict() methods.

This patch adds the optional attributes list to specify the addtional
attributes included in the str and json representations.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-10 14:57:37 +09:00
IWASE Yusuke
197a6c49a6 packet/bgp: Support multiple BGP messages in a packet
This patch fixes to BGPMessage.parser() to return the reference to
its own class and to support multiple BGP messages in a single packet.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-10 14:57:34 +09:00
Shinpei Muraoka
17acdbb610 BGPSpeaker: Support Ethernet A-D Route and Ethernet Segment Route
This patch supports Ethernet Auto-discovery Route and
Ethernet Segment Route in BGPSpeaker.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-10 14:57:01 +09:00
Shinpei Muraoka
c4a84cb246 packet/bgp: Fix the ESI Label Extended Community to use mpls_label
Currently, ESI Label in BGPEvpnEsiLabelExtendedCommunity
has 3 byte integer set.
This patch fixes to use the mpls_label for ESI Label
of BGPEvpnEsiLabelExtendedCommunity.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-10 14:56:59 +09:00
FUJITA Tomonori
a3c1a8e06b Ryu 4.9
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-12-05 16:37:18 +09:00
fumihiko kakuma
5c5345e78c scenario test: Fix the wrong retry check in command execution
Signed-off-by: Fumihiko Kakuma <kakuma@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-24 15:14:35 +09:00
fumihiko kakuma
580f04d8a9 Enable to run a scenario test with a specific python version
Signed-off-by: Fumihiko Kakuma <kakuma@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-24 15:14:34 +09:00
IWASE Yusuke
d4d02dd0f6 rest_firewall: Compare reserved port in str representation
Along with the update of ofctl_rest, the output representation of
the port number in the OUTPUT action has been changed.
e.g.) In case of the OUTPUT action to the OFPP_NORMAL port
  OLD:
    'OUTPUT:4294967290'  # OFPP_NORMAL = 0xfffffffa
  NOW:
    'OUTPUT:NORMAL'

Currently, rest_firewall suposes the OLD format, and it will fail
to compare the port number, then all firewall rules will be shown
with "actions": "DENY".
This patch fixes to compare the port number in the NEW format and
fixes this problem.

Reported-by: Hong Panha <c011361065@edu.teu.ac.jp>
Reported-by: Ruy Takata <ruy.takata@gmail.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-18 15:56:45 +09:00
IWASE Yusuke
156b3d2a6e test_vsctl: Use osrg/ryu-book image as Mininet container
This patch fixes test_vsctl.py to use osrg/ryu-book image as
Mininet container and shortens the testing hours.

Also, this patch removes the Dockerfile for building the Mininet
Docker image.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-18 15:56:33 +09:00
IWASE Yusuke
fbda130ebf test_vsctl: Wait for loading OVS kernel module
If the OVS kernel module is loaded at first time, it might take
a few seconds.
This patch add a sleep before sending OVSDB requests.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-18 15:55:01 +09:00
IWASE Yusuke
33ecea2dd6 integrated/bgp: Use Ubuntu:16.04 for base image
Using osrg/ryu Docker image for the base image make it easy to build
the image for the integrated tests, but the installed packages are
remained on the site-packages unless they are explicitly uninstalled.
This problem can cause the miss configured dependency when the
requirment files are updated, for example.

This patch fixes to use Ubuntu:16.04, which is the default for the
base image, and to build the test image on the clean environment.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-18 15:54:53 +09:00
IWASE Yusuke
5c7129563d docker_base: Update base image to Ubuntu:16.04
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-18 15:54:43 +09:00
IWASE Yusuke
8065784ab1 BGPSpeaker: Confirm SSH feature to be optional
paramiko, which python library is used in bgp.operator.ssh, is defined
as the optional requirements.
This patch avoid to import this library in BGPSpeaker by the default.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-15 20:58:18 +09:00
IWASE Yusuke
2b57fadd2c docker_base: Add missing requirements for test-requires
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-15 20:58:16 +09:00
IWASE Yusuke
77f15902c4 README: Use pip to resolve dependencies
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-15 20:58:12 +09:00
IWASE Yusuke
03f77e7279 pip: Separate test-requires
Currently, in addition to "requirements for tests", test-requires
includes "optional requirements".
This makes it unclear to identify which packages are surely required
to use optional features (e.g., OF-Config, NETCONF, BGP speaker) and
causes the redundant installation when building Docker images.

This patch separates test-requires into two files("test requirements"
and "optional requirements").

Also, this patch reverts the version fixation for some packages.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-15 20:58:06 +09:00
IWASE Yusuke
1af384fa17 RPC: Specify encoding to msgpack.Packer/Unpacker
Currently, RPC requests using rpc_cli.py will crash on Python 3,
because the decoded string through msgpack-rpc is not str type
when the default encoding is not specified into msgpack.Unpacker.
On Python 2, bytes type is the same as str type, and this problem
does not occur.

The old spec of msgpack had no notation of the encoding, but now,
msgpack defines "UTF-8" as the default encoding and has the explicit
type definitions for String and Binary.
  https://github.com/msgpack/msgpack/blob/master/spec.md

This patch fixes to specify the encoding to msgpack.Packer/Unpacker
and enable to use Binary type when packing for the Python 3
compatibility.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-14 18:14:45 +09:00
IWASE Yusuke
a45c180447 test_rpc: Use numbers.Integral instead of long type
Currently, test_rpc.py uses long type for PyPy interpreter compatibility,
but log type is obsoleted in Python 3.
This patch fixes test_rpc.py to use numbers.Integral and makes its
implemetation more clean.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-14 18:14:39 +09:00
IWASE Yusuke
9f04612459 wsgi: Avoid using inspect.getargspec
Officially, "inspect.getargspec" is obsoleted in Python 3.0,
this patch fixes to avoid using this function.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-14 18:14:34 +09:00
IWASE Yusuke
99ebbcce0e wsgi: Reduce pylint warnings
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-14 18:14:29 +09:00
IWASE Yusuke
ffa736a835 wsgi: Use six.text_type instead of unicode
This issue is suggested by Marcel Grossmann on GitHub PR #53.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-14 18:14:25 +09:00
IWASE Yusuke
63ce337e1d contrib: Revert module path to ryu.contrib
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-14 18:14:20 +09:00
IWASE Yusuke
2dc7d403bb protocols/bgp/base: Add missing __next__ method
This patch adds the missing __next__ method for Python 3 iterable.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-14 18:14:15 +09:00
Shinpei Muraoka
444c29fd73 BGPSpeaker: Support to advertise EVPN IP Prefix route
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-14 13:21:08 +09:00
Shinpei Muraoka
972c31f0e6 packet/bgp: Support for IP Prefix Route encoding
This patch supports on the basis of
the [draft-ietf-bess-evpn-prefix-advertisement-03]

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-14 13:21:04 +09:00
Shinpei Muraoka
264d32ea2d packet/bgp: Fix the EvpnNLRI to use the ryu.lib.packet.vxlan
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-14 13:20:59 +09:00
Shinpei Muraoka
e84b21b5ed packet/bgp: Fix the EvpnNLRI to use the ryu.lib.packet.mpls
Also, this patch changes name of is_stack to is_bos.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-14 13:20:54 +09:00
Shinpei Muraoka
a376adf6b6 packet/bgp: Fix the EvpnNLRI to use the ryu.lib.ip
Also, this patch changes size of ip_len from bit to byte.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-14 12:49:14 +09:00
IWASE Yusuke
e760300e93 BGPSpeaker: Enable to set capability for IPv6
This patch enables BGPSpeaker to set the capability for IPv6 unicast
address family.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-14 12:15:00 +09:00
IWASE Yusuke
4ed018df09 test_bgp: Add test cases for IPv6 and VPNv6 routes
This patch adds the test cases for IPv6 unicast and VPNv6 unicast
routes in BGP UPDATE messages.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-14 12:14:53 +09:00
IWASE Yusuke
7e1f64865d test_bgp: Enable to check parsed BGP message
This patch fixes to check if the parsed protocols list contains
the BGP message as expected.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-14 12:14:38 +09:00
IWASE Yusuke
73f6105e88 packet/bgp: Refactor MP_REACH_NLRI and MP_UNREACH_NLRI
This patch refactors MP_REACH_NLRI and MP_UNREACH_NLRI path attribute
classes to support IPv6 unicast and Labeled VPNv6 unicast routes.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-14 12:14:33 +09:00
IWASE Yusuke
9e92d60427 lib/ip: Add method to convert IPv4/IPv6 to int
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-14 12:14:27 +09:00
IWASE Yusuke
48f577d1f8 test_bgp: Uncomment out test case for UPDATE
Now BGP packet library supports 32 bits AS number and Extended
Length flag in path attributes, this patch fixes to uncomment
out the test case for UPDATE message.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-14 12:14:19 +09:00
IWASE Yusuke
31364ba91d packet/bgp: Enable Extended Length flags if specified
Currently, the Extended Length flag in path attributes is evaluated
only when the length exceeds 1 byte (max 255) field.
This patch enables this flags if explicitly specified.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-11 15:27:52 +09:00
IWASE Yusuke
b9e4345d5d pip: Move tinyrpc to pip-requires
Because the embedded tinyrpc was removed, tinyrpc is required to
be install for running Ryu application.
This patch moves tinyrpc from test-requires to pip-requires.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-11 12:11:50 +09:00
FUJITA Tomonori
6e2fe4edc8 Ryu 4.8
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-07 10:07:47 +09:00
IWASE Yusuke
f0fb62cbf9 contrib/tinyrpc: Remove embedded tinyrpc, use upstream
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-04 09:51:36 +09:00
IWASE Yusuke
7e91a55a56 contrib/ncclient: Remove embedded ncclient, use upstream
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-04 09:51:27 +09:00
IWASE Yusuke
fba95e2afa ut/ovs: Add UT using Docker for ryu.lib.ovs
This patch adds UT cases using Docker for ryu.lib.ovs.
If Docker is not available, these tests will be skipped.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-11-04 09:32:10 +09:00
Shinpei Muraoka
8d9ce87653 BGPSpeaker: Support to advertise PMSI Tunnel Attribute
This patch adds support to advertise the BGP PMSI Tunnel Attribute
for the Path attributes.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-29 06:32:18 +09:00
Shinpei Muraoka
6e22fb4a05 packet/bgp: Add PMSI Tunnel Attribute
This patch adds the support for BGP PMSI Tunnel Attribute [RFC6514].

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-29 06:32:11 +09:00
Shinpei Muraoka
5360524b96 packet/vxlan: Add method to convert the format of vni
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-29 06:32:05 +09:00
Shinpei Muraoka
a582b0b0dc packet/mpls: Add method to convert the format of label
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-29 06:31:59 +09:00
Shinpei Muraoka
ec1749beca lib/ip: Add method to convert the format of Ipv4 or Ipv6
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-29 06:31:53 +09:00
fumihiko kakuma
df1434a9bb Enable to run a scnario test for ryu bgp on travis
Signed-off-by: Fumihiko Kakuma <kakuma@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-29 06:27:56 +09:00
fumihiko kakuma
76061634a0 Add scripts which install a dependency package
These install packages depended on a scenario test tool.

Signed-off-by: Fumihiko Kakuma <kakuma@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-29 06:27:54 +09:00
fumihiko kakuma
cd068e53ea Add bgp scenario tests
This adds some scenario tests using a scenario test tool.

Signed-off-by: Fumihiko Kakuma <kakuma@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-29 06:27:49 +09:00
fumihiko kakuma
0a60252208 Add bgp scenario tests tool
This provides an environment which test a peer between ryu and quagga.
I also consider that these modules are used from openstack or other
projects. So there may be some functions that are not used by test
for ryu.
This has the following functions.

- build docker image and run ryu and quagga on that container.
- configure ryu and quagga.
- have some operations for ryu, quagga and docker.

Signed-off-by: Fumihiko Kakuma <kakuma@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-29 06:27:10 +09:00
IWASE Yusuke
649d31afbe bgp/application: Re-implement base BGP application
Currently, options for bgp/application.py is not passed to 'ryu-manager',
bgp/application.py does only start RPC server and can not start other
threads including BGP core and SSH server using bgp_sample_conf.py.

This patch enables bgp/application.py to start BGP threads using
the specified configuration file and reconstructs configuration file
format.

With this patch, BGPSpaker application can be started like:
$ ryu-manager --bgp-app-config-file ryu/services/protocols/bgp/bgp_sample_conf.py
              ryu/services/protocols/bgp/application.py

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 22:41:21 +09:00
IWASE Yusuke
1dfe90d17a flags: Add CLI options for BGP application
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 22:41:08 +09:00
IWASE Yusuke
bc7f43aba3 BGPSpeaker: Enable to specify settings for SSH CLI
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 22:41:01 +09:00
IWASE Yusuke
09e57c5993 bgp/operator/ssh: Enable to quit gracefully
Currently, socket.error will be raised when 'quit' command is typed.
This patch enables to quit SSH session without tracebacks.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 22:40:49 +09:00
IWASE Yusuke
252591aaae bgp/operator/ssh: Reduce pylint warnings
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 22:40:43 +09:00
IWASE Yusuke
e635d68bfd BGPSpeaker: Use dictConfig in the standard library
logging.config.dictConfig has been added in Python 2.7, this patch
fixes to use dictConfig in the standard library and removes
bgp/utils/dictconfig.py.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 22:40:37 +09:00
IWASE Yusuke
a7721fcce4 utils: Backward compatibility for 'imp.load_source'
This patch adds a function for providing the backward compatibility
for 'imp.load_source' in Python 2 and fixes bgp/application.py to
use this wrapper.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 22:40:28 +09:00
IWAMOTO Toshihiro
6792d6df2a Log OFPErrorMsg.data as ascii when type is OFPET_HELLO_FAILED
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>
2016-10-25 16:23:07 +09:00
IWASE Yusuke
df95d2c660 ovs/vsctl: Fix API for parsing column/key/value set
Currently, VSCtlContext.parse_column_key_value() method fails to
parse "<column>:<key>=<value>" formatted str, which indicates
a "map" type column.
So some implementation to set "map" type column have avoided this
bug with "<column>=<key>=<value>" formatted str (not ":").

This patch fixes this problem and enable to parse the correct format
value.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 16:22:53 +09:00
IWASE Yusuke
d7cfe6687b ovs/vsctl: Add missing Controller commands in OVS v2.6.0
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 16:22:51 +09:00
IWASE Yusuke
05b3738359 ovs/vsctl: Add missing Port commands in OVS v2.6.0
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 16:22:46 +09:00
IWASE Yusuke
2744d0a9e3 ovs/vsctl: Add missing Interface commands in OVS v2.6.0
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 16:22:41 +09:00
IWASE Yusuke
3e19c38e9e ovs/vsctl: Add missing Bridge commands in OVS v2.6.0
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 16:22:35 +09:00
IWASE Yusuke
934e8dcd1a ovs/vsctl: Sort out commands order
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 16:22:28 +09:00
IWASE Yusuke
3aa49895fa ovs/bridge: Add APIs for missing Database commands
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 16:22:22 +09:00
IWASE Yusuke
589823beb5 ovs: Add API corresponding to ovs-vsctl remove command
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 16:22:20 +09:00
IWASE Yusuke
c21ad1237d ovs: Add API corresponding to ovs-vsctl add command
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 16:22:19 +09:00
IWASE Yusuke
c09c4e87a0 ovs: Add API corresponding to ovs-vsctl list command
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 16:22:13 +09:00
IWASE Yusuke
d19e7a3213 ovs: Add API corresponding to ovs-vsctl add-bond command
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 16:22:07 +09:00
IWASE Yusuke
fe83cfd66d ovs/vsctl: Update command list with OVS v2.6.0
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 16:22:06 +09:00
IWASE Yusuke
513bf4c48c ovs/vsctl: Avoid applying next() to non-iterator object
In Python 2, the builtin function next() can not be applied to
non-iterator object.
This patch fixes to use the list comprehensions and avoid applying
next() to a list type object.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 16:22:01 +09:00
IWASE Yusuke
895ddfca26 ovs/vsctl: Add missing required argument for find_vlan_bridge
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 16:21:54 +09:00
IWASE Yusuke
b9aab0af3f ovs: Reduce pylint warnings
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 16:21:46 +09:00
IWASE Yusuke
5748031635 ovs: Revert ovs module path
Because contrib.ovs has been removed, we no longer need to update
the path for loading ovs module.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 16:21:38 +09:00
IWASE Yusuke
4d1bfc8585 ovs/vsctl: Fix VSCtlCommand to inherit StringifyMixin
For convenience when printing command results, this patch fixes
VSCtlCommand to inherit StringifyMixin.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 16:21:31 +09:00
IWASE Yusuke
a354b456ea ovs/vswitch_idl: Update OVSDB schema with v7.14.0
This patch regenerates OVSDB schema with vswitchd/vswitch.ovsschema
v7.14.0 included in OVS v2.6.0 release.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 16:21:09 +09:00
IWASE Yusuke
55dc1158b8 ovs/vsctl: Change log level of redundant messages
Currently, ovs.vsctl outputs the messages (e.g. just "unchanged" or
"success") in the "info" log level for each transaction, but these
messages are not meaningful for users.
This patch changes the log level of these messages to "debug".

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 16:21:02 +09:00
IWASE Yusuke
2ebb9218b2 rest_router: Fix conversion of Packet Library to dict
On Python3, rest_router fails to compare the type of protocols in
the Packet Library instances, because the non-parsed packet data
is not str type but bytes type.
This patch fixes to compare the protocols instance type with
packet_base.PacketBase and enable to convert the Packet Library
instances to dict.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-25 16:20:12 +09:00
IWASE Yusuke
e80a36317a dpset: Fix iteration error when disconnecting switches
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>
2016-10-25 16:20:11 +09:00
IWAMOTO Toshihiro
022406507a test_parser: Add an truncate packet test
Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-12 09:08:57 +09:00
IWAMOTO Toshihiro
e8809649e6 test_parser: Enable tests for truncated packets
When there are files named "*.truncated%d" in the packet_data directories,
they are treated as special instructions; test method are generated
by truncating wire_msg from corresponding "*.packet" files.

Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-12 09:08:55 +09:00
IWAMOTO Toshihiro
6aa4adb070 ofproto_v1_3_parser: Raise OFPTruncatedMessage exception on truncated messages
OFPT_ERROR_MSG can return truncated messages.  Some users want to
see them in human-friendly format [1]. Catch exceptions caused
by such truncated messages and reraise as OFPTruncatedMessage
with incomplete ofpmsg in the exception class.

[1] https://bugs.launchpad.net/dragonflow/+bug/1624826

Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-12 09:08:52 +09:00
Shinpei Muraoka
b9a9f81ff0 ofproto/nicira_ext: Add missing NXMs in OVS v2.6.0
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-12 09:08:36 +09:00
Michał Rzepka
8d93787a6c ryu/lib/ofctl_v1_3: port name decoding fix
The patch resolves issue experienced when decoding certain values of
name field in OFPMP_PORT_DESCRIPTION body. Non-decodable bytes are
replaced with utf-8 replacement character.

This issue was observed while retrieving OFPMP_PORT_DESC reply from
OpenFlow 1.3 compliant HP switch. One of ofp_struct structures
describing OFPP_LOCAL port has a name field with value 4f 46 50 50 5f 4c
4f 43 41 4c 00 81 ff ff ff ff that translates to OFPP_LOCAL.......
Attempt to decode the value, as in modified line, raises an exception
"UnicodeDecodeError: 'utf8' codec can't decode byte 0x81 in position 11:
invalid start byte". In the submitted patch, non-decodable characters
are replaced with utf-8 REPLACEMENT CHARACTER (U+FFFD), which is
sufficient for the get_port_desc method to work seamlessly. Similar
usages of str.decode method may be found in ofctl_v1_3, ofctl_v1_4,
ofctl_v1_5 and need to be fixed in the future.

Signed-off-by: Michal Rzepka <mrzepka@student.agh.edu.pl>
Reviewed-by: Iwase Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-08 22:52:36 +09:00
IWASE Yusuke
6522ea1c83 BGPSpeaker: Enhance APIs for operator.show
This patch enhances the APIs of BGPSpeaker class which call
'operator.show' APIs.

Note: This patch renames the argument 'routetype' of neighbor_get()
into 'route_type' for the consistency of APIs.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-08 22:36:47 +09:00
FUJITA Tomonori
7201a6085d Ryu 4.7
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-04 07:56:38 +09:00
IWASE Yusuke
81d5d8f568 BGPSpeaker: Fix to enable to notify peer down
If BGPSpeaker.neighbor_del() is called, an event to notify peer down
via _notify_peer_down() method will be generated.
But when _notify_peer_down() method is called, peer.protocol is
already cleaned up with None, so _notify_peer_down() method will fail
to get the neighbor info (IP address, AS number).

This patch fixes to retrieve the neighbor info from the neighbor
configuration info of Peer class and fixes this problem.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-04 07:45:53 +09:00
FUJITA Tomonori
a3ab6c8ab3 use old cryptography version
Looks like that the latest version (1.5.2) doesn't work:

https://s3.amazonaws.com/archive.travis-ci.org/jobs/164527154/log.txt

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-04 07:38:03 +09:00
IWASE Yusuke
35973fcc20 packet: Avoid parsing an empty buffer
For example, the packet library detects the TCP payload type by using
the TCP src/dst port, but in case of the BGP packet, the packet
library will try to parse a TCP ACK packet as a BGP packet, and will
fail to parse.

This patch enables to ignore an empty buffer and fixes this problem.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-01 21:37:58 +09:00
IWASE Yusuke
51e0abd365 pip-requires: Add ovs>=2.6.0
Now OVS 2.6.0 has been released, which is including
Python 3 compatibility.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-01 21:28:52 +09:00
IWASE Yusuke
a443be9433 doc: Add API reference for REST EVPN switch
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-01 21:28:52 +09:00
IWASE Yusuke
ab92cc8529 app: Add sample application for REST EVPN switch
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-01 21:28:52 +09:00
Shinpei Muraoka
57056d1a0f app: Integrate aplication of Ryu-book
Henceforth, Ryu-Book includes the source files for application of Ryu.
This patch Integrates the source files for application of Ryu-Book.
Just for information, the source files for application of Ryu-Book
will Integrate as for OpenFlow1.3.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-01 21:22:00 +09:00
IWASE Yusuke
b302d725a0 ovs/bridge: Enable to request tunnel port number
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-01 21:13:27 +09:00
IWASE Yusuke
b77408d04c ovs/bridge: Add utility method to create VXLAN port
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-01 21:13:27 +09:00
IWASE Yusuke
8627c28070 ovs/bridge: Make local_ip to optional field for tunnel
To create GRE tunnel, the local_ip field is not mandatory field.
This patch makes the local_ip field to optional for the convenience.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-01 21:13:27 +09:00
IWASE Yusuke
3d815d3455 ovs/vsctl: Catch the default tag type in Port Table
According to ovs-vswitchd.conf.db(5), the tag column is an integer
in range 0 to 4095, but OVS may returns the empty list [] as the
default value.
OTOH, Ryu expects an integer type as the default and fails to get
the port information in the table.

This patch enables to catch the empty list as the default and
fixes this problem.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-01 21:13:27 +09:00
Shinpei Muraoka
25a7eb51fe stplib: Fix to store current OFPPort status
Currently, stplib compares the status of OFPPortStatus message with
that of Datapath instance, but this comparison returns always "equal",
so stplib fails to get the correct port status.

This patch fixes to store the current port status and to compare the
new status with the stored status.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-01 20:46:29 +09:00
Shinpei Muraoka
d23c07054e stplib: Fix to compare MAC address and Bridge ID
cmp() func was introduced for Python 3 compatibility before,
but this implementation is not enough, because a MAC address
can not be compared with a Bridge ID (integer value) by com() func.

This patch fixes to convert the MAC address into an integer value
before comparing with Bridge ID and fixes this problem.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-01 20:46:28 +09:00
IWASE Yusuke
29d1a97139 BGPSpeaker/api/operator: Simplify registration decorator
Currently, in Python3, api.operator call APIs, which are used by
BGPSpeaker.rib_get() for example, cannot be registered correctly.
So call('operator.show', **kwargs) fails to get the registered
method by the symbol 'operator.show'.

This patch simplifies the registration decorator for api.operator
call APIs and fixes this problem.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-01 20:12:36 +09:00
IWASE Yusuke
4348ae6a1f BGPSpeaker: Fix typos
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-10-01 20:12:36 +09:00
Michał Rzepka
cb83c858cd ofproto/ofproto_v1_5_parser: OFPMultipartReply malformed message offset fix
Recently, I discovered major multipart message parser flaw. The issue
was observed while testing Aggregate Flow Statistics message in OpenFlow
1.5 and Open vSwitch. Similar (and potentially also vulnerable) code
snippets are also present in other message parsers (e.g. OFPHello). I'd
like to ask for opinions on proposed solution. If accepted, similar
patches should also be applied for other message parsers.

Brief description (steps to reproduce the issue):
1. REST API is called to retrieve aggregate flow stats:
	curl http://localhost:8080/stats/aggregateflow/8796750139643
2. Open vSwitch replies to Aggregate Stats Request with Aggregate Stats
Reply:
	message buffer: 0x06 0x13 0x00 0x28 0x53 0xfe 0xc4 0xaf 0x00 0x02 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00
	(note that due to incomplete OF 1.5 support in OvS, message is
malformed - ofp_stats struct filled with zeros)
3. Message is processed by Ryu parsers:
	ofproto_parser.msg -> ofproto_v1_5_parser.msg_parser ->
ofproto_v1_5_parser.OFPMultipartReply.parser
4. Here, message body contents are parsed
(ofproto_v1_5_parser.OFPMultipartReply.parser, lines 1858-1861):
     while offset < msg_len:
         b = stats_type_cls.cls_stats_body_cls.parser(msg.buf, offset)
         body.append(b)
         offset += b.length if hasattr(b, 'length') else b.len
5. Due to incorrect message format, zero-filled message part is parsed
as b=OFPAggregateStats(length=0,stats=OFPStats(oxs_fields={})),
resulting in constant offset value, as in each iteration offset += 0.
6. Parser remains trapped in a infinite loop with offset = 16, msg_len =
40. Ryu controller hangs completely.

OFPMultipartReply parser was observed to handle malformed messages
improperly. The patch introduces offset check to fix processing of
malformed messages in ofproto_v1_5_parser.OFPMultipartReply.parser.

Signed-off-by: Michal Rzepka <mrzepka@student.agh.edu.pl>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-09-28 16:34:59 +09:00
Monthadar Al-Jaberi
513a9d93b2 tests/switch: fix bug in _diff_packets function
This fixes the problem of the payload being always shown when another field
differs between ingress and egress test.

Signed-off-by: Monthadar Al Jaberi <monthadar.al-jaberi@infinera.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-09-21 21:24:04 +09:00
IWAMOTO Toshihiro
827138298f Add Nicira extension vlan_tci field
This Nicira extension field is VLAN VID+CFI+PCP.
OXM_OF_VLAN_VID and OXM_OF_VLAN_PCP should work fine in theory, but
in OvS it seems vlan_tci must be used to access the CFI bit from
NX_LEARN actions.

Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-09-16 19:12:54 +09:00
IWASE Yusuke
e0e30d3d96 BGPSpeaker: Shutdown BGPSpeaker gracefully
Currently, when BGPSpeaker instance calls 'core.stop', CORE_MANAGER
fails to stop its own activities and outputs traceback, because the
dictionaries which maps name to instance are changed during iteration.
This patch makes a list copy of items() to avoid this problem and
enable to shutdown gracefully.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-09-07 10:25:12 +09:00
IWASE Yusuke
5d1d8648ab BGPSpeaker: Enable to get path from EventPrefix
To get more detail information about BGP route by using
best_path_change_handler, this patch adds path member into
EventPrefix and implements property to get existing attributes.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-09-07 10:02:15 +09:00
IWASE Yusuke
57aa646d61 BGPSpeaker/vrf: Handle non MPLS labled NLRI
Currently, VRF Table supposes the incoming NLRI has MPLS labels
field, but some EVPN NLRI don't have MPLS labels field, and
BGPSpeaker fails to import the incoming routes from the neighbours.

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-09-07 10:02:10 +09:00
IWASE Yusuke
3f104981d2 BGPSpeaker: Add EVPN routes from Global to VRF Table
This patch adds the missing support for importing EVPN Table from
the Global Table to VRF Table when BGPSpeaker recieved a new EVPN
route.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-09-07 10:02:04 +09:00
IWASE Yusuke
7af944dc0e table_manager: Fix conversion of De Morgan's laws
This patch fixes incorrect conversion of De Morgan's laws.
  e.g.) not (A and B) == not A or not B

Original:
    if not (vpn_path.source is None
            and route_dist == vrf_table.vrf_conf.route_dist):

Incorrect:
    if (vpn_path.source is not None and  # !!! Should be "or"
            route_dist != vrf_table.vrf_conf.route_dist):

Correct:
    if (vpn_path.source is not None or
            route_dist != vrf_table.vrf_conf.route_dist):

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-09-07 10:01:36 +09:00
IWASE Yusuke
c09925e1f5 test_bgpspeaker: Add UT for advertising VNI for EVPN
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-09-07 10:01:28 +09:00
IWASE Yusuke
396473593e BGPSpeaker: Extend to advertise VNI for EVPN routes
This patch enables to advertise VNI as MPLS lables field in the
MAC/IP Advertisement Route of EVPN.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-09-07 10:01:20 +09:00
IWASE Yusuke
40fe7ffdc5 BGPSpeaker: Support to advertise Tunnel Encapsulation
This patch adds support to advertise the BGP Tunnel Encapsulation
Attribute for the Ethernet VPN Routes.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-09-07 10:01:08 +09:00
IWASE Yusuke
bd4e8a70b5 packet/bgp: Add BGP Encapsulation Extended Community
This patch adds the support for BGP Encapsulation Extended Community
[RFC5512].

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-09-07 10:00:56 +09:00
Monthadar Al-Jaberi
cc24a85aad doc: specify OFP v1.0 for sample application
This is a minimal change to keep the supplied sample code
working with latest software. The sample code is not compatible
with OFP v1.3+, and if there is no requirement on supported version
Ryu will probably accept latest supported OF switch.

Signed-off-by: Monthadar Al Jaberi <monthadar.al-jaberi@infinera.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-09-07 09:51:31 +09:00
tungyueh
1970e70a0d add modify role API in ofctl_rest
add description about role API

Signed-off-by: tungyueh <tylin.cs03g@nctu.edu.tw>
Reviewed-by: Iwase Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-09-07 09:37:46 +09:00
Michał Rzepka
03e8028ce6 lib/ofctl_v1_4: correct argument order for OFPFlowMod constructor
Invalid OFPFlowMod flag and importance values were observed when using
app/ofctl_rest. This patch restores the proper order of arguments passed
to OFPFlowMod constructor in mod_flow_entry (ofctl_v1_4.py).

Signed-off-by: Michal Rzepka <mrzepka@student.agh.edu.pl>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-09-07 09:34:44 +09:00
FUJITA Tomonori
c09cd3dc68 Ryu 4.6
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-09-01 21:17:00 +09:00
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>
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
IWASE Yusuke
8cb23e19a7 test_packet: Avoid to use array.array as input binary
In Python 2.7, array.array cannot be converted correctly into binary
type by using six.binary_type().
So packet.Packet() cannot skip data effectively.
This patch remove to use array.array as input binary in test_packet.

Note: array.array can be used as input binary as the same as before,
but in this case, the padding data will be displayed in str or repr
representation in Python 2.7.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-11 16:46:30 +09:00
IWASE Yusuke
3736ab76a5 packet: Fix minimum ethernet frame length
In the Ethernet frame Spec (Both DIX EthernetII and IEEE 802.3),
the frame size must be at least 64 bytes long (not including the preamble).

  64 bytes = 14 bytes (Header) + 46 bytes (Payload) + 4 bytes (FCS)

This patch appends padding if the payload is less than 46 bytes long.

Reported-by: Kawai, Hiroaki <kawai@iij.ad.jp>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-11 16:46:27 +09:00
IWASE Yusuke
81d3d5647c test_peer: Unit test for peer.py of BGPSpeaker
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-11 16:46:13 +09:00
IWASE Yusuke
55d955f484 BGPSpeaker: Support Four-Octet AS number
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-11 16:45:43 +09:00
IWASE Yusuke
2039347560 packet/bgp: Support Four-Octet AGGREGATOR Path Attribute
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-11 16:45:36 +09:00
IWASE Yusuke
a6c5f27cbe BGPSpeaker: Fix capability check when MP-BGP not supported
Currently, BGPSpeaker skips sending the Update messages with an
IPv4/IPv6 prefix when the peer does not support MP-BGP.
This patch fixes capability check in order to send IP prefix when
MP-BGP not suppored by the peer.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-11 16:45:31 +09:00
Kawai, Hiroaki
04b4bbbe01 fix of13 VLAN_PCP test case
To test VLAN_PCP, VLAN_VID must match.
Table miss test was testing VLAN_VID instead of VLAN_PCP,
because the packet had mismatching VLAN_VID.
Fixes to set only OFPVID_PRESENT bit in the match field.

Reviewed-by: Iwase Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-11 16:44:22 +09:00
FUJITA Tomonori
400a98d4a7 Ryu 4.4
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-30 16:21:54 +09:00
Evan Gray
7d15368bf9 topology: ignore cfm packets on packet in
This commit will allow the host_discovery_packet_in_handler to ignore invalid
cfm packets. Ryu will fail to parse cfm packets with an interval of 0 -- We
discovered this when one of our systems sent cfm packets with an interval of 0.

Signed-off-by: Evan Gray <evanscottgray@gmail.com>
Reviewed-by: Iwase Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-01 12:23:17 +09:00
Evan Gray
2a2b2b1762 topology: pep8 fixes
Normal pep8 fixes, there were also two instances where I updated a commented
LOG.debug to include exc_info=True so that the traceback will be logged
instead of relying on the error passed in the except.

Signed-off-by: Evan Gray <evanscottgray@gmail.com>
Reviewed-by: Iwase Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-01 12:22:58 +09:00
IWASE Yusuke
658c754cbd ofproto: Fix example of OFPSetAsync message
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-01 12:17:53 +09:00
IWAMOTO Toshihiro
0dc79ddd7e Update the readthedoc URL
The hosting site has changed to use readthedocs.io instead of
readthedocs.org.

Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-01 12:14:51 +09:00
Jason Kölker
8b038a492e lib/ofctl_utils: Log the datapath sent to
If a controller has multiple switches connected it is useful to be able
to distinguish which datapath the msg is being sent to.

Signed-off-by: Jason Kölker <jason@koelker.net>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-01 11:37:09 +09:00
IWAMOTO Toshihiro
b0ab4f1602 Avoid parallel executions of AppManager.close()
If an AppManager.close call is started and all AppManager.services
are stopped, AppManager.run_apps starts another close() call,
resulting in a KeyError exception in close() (*1).  Prevent that using
a semaphore.

(*1) https://launchpad.net/bugs/1589746
Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-07-01 11:30:01 +09:00
fumihiko kakuma
d079bf38e7 python3: Use six.add_metaclass for metaclass
__metaclass__ can't be used with python 3 as metaclass syntax has been
changed in python 3.

Signed-off-by: Fumihiko Kakuma <kakuma@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-18 13:54:39 +09:00
fumihiko kakuma
c897ae7d8a python3: Use six.string_types instead of basestring
Signed-off-by: Fumihiko Kakuma <kakuma@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-18 13:54:37 +09:00
fumihiko kakuma
85023d4fdb python3: Improve Table class in services.protocols.bgp.info_base.base
Remove itervalues() and values() always returns iterator

Signed-off-by: Fumihiko Kakuma <kakuma@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-18 13:54:36 +09:00
Fumihiko Kakuma
9f4328682f python 3: Replace deprecated logging.warn with logging.warning
logging.warn is deprecated in Python 3 [1].
This patch switches it to the non-deprecated logging.warning.
This is bug-reported by openstack [2].

[1] https://docs.python.org/3/library/logging.html#logging.warning
[2] https://bugs.launchpad.net/magnum/+bug/1508442

Signed-off-by: Fumihiko Kakuma <kakuma@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-18 13:53:50 +09:00
IWASE Yusuke
f86499373a Python3: Explicit string type encoding
Reviewed-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-09 13:27:06 +09:00
IWASE Yusuke
55a88d6805 BGPSpeaker: Remove unused utility modules
Reviewed-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-09 13:27:03 +09:00
IWASE Yusuke
c263089e72 BGPSpeaker: Fix unresolved references in Python3
Additionally, this patch enforces the the explicit relative imports

Reviewed-by: Fumihiko Kakuma <kakuma@valinux.co.jp>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-09 13:26:59 +09:00
IWASE Yusuke
9393af3f06 BGPSpeaker: Support Per-Peer AS
This patch enables to override the AS number of BGPSpeaker instance
by the "local_as" argument of BGPSpeaker.neighbor_add().

e.g.)
  speaker = BGPSpeaker(as_number=65001,  # the default AS number
                       router_id='10.0.0.1',
                       ...)

  speaker.neighbor_add(address='10.0.0.2',
                       remote_as=65101,
                       local_as=65002,  # override AS number
                       ...)

Additionally, this patch fixes a typo and sorts the comments of
BGPSpeaker.neighbor_add() method.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-09 13:26:53 +09:00
Shinpei Muraoka
7b562c3700 packet_data_generator3/gen: Add some NXAction packets
This patch adds the following test packet.
 - NXActionController
 - NXActionFinTimeout
 - NXActionNote

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-09 13:07:48 +09:00
Shinpei Muraoka
7ca8690557 ofproto/nicira_ext: Move the variable and method for Nicira Extension
Move variable and method that exist in the ofproto_v1_0.py to the nicira_ext.py.
Move the oxm_types that exists in the nx_match.py to the nicira_ext.py.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-09 13:07:47 +09:00
Shinpei Muraoka
5ebf0fa5c4 tests/test_parser_v10: Update test parameter
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-09 13:07:35 +09:00
Shinpei Muraoka
3c3896fd77 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 value specified in the bit format to the start and end formats.
Update the following NXAction.

 - NXActionRegLoad
 - NXActionOutputReg
 - NXActionMultipath
 - NXActionBundle
 - NXActionBundleLoad
 - NXActionCT

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-09 13:07:33 +09:00
Shinpei Muraoka
ecc3ea296f ofproto/ofproto_v1_0: Delete some NX actions
This patch deletes some NX Actions in ofproto_v1_0_parser
and fixes to use actions in nx_actions.py.
Together, delete Obsolete action in OVS.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-09 13:07:32 +09:00
Shinpei Muraoka
462256198b ofproto/nx_actions: Porting the NX Action definition of ofproto_v1_0_parser
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-09 13:07:30 +09:00
Shinpei Muraoka
5dfdc856bc ofproto/nx_actions: Update serialize and parse
The serialize within each class has been changed to serialize_body.
And serialize_body is executed by the serialize of NXAction.
Also update the data format designated method in serialize_body and perse.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-09 13:07:29 +09:00
Alan Quillin
35a98fca3e Extend OVSDB api
Adds more ovsdb methods for setting key/values to other_config and
external_ids, adds bility to set the controller for a bridge, and adds the
ability to create a new port/interface on a bridge

Signed-off-by: Alan Quillin <alanquillin@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-09 13:06:57 +09:00
Yi Tseng
865d6e52d7 Fix RuntimeError of lldp_packet_in_handler
Items should not be removed during iteration

Error message
```
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/ryu/base/app_manager.py", line 290, in _event_loop
    handler(ev)
  File "/usr/local/lib/python3.4/dist-packages/ryu/topology/switches.py", line 821, in lldp_packet_in_handler
    for host in self.hosts.values():
RuntimeError: dictionary changed size during iteration
```

Signed-off-by: Yi Tseng <a86487817@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-05 15:24:42 +09:00
FUJITA Tomonori
d090b291be Ryu 4.3
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-03 08:01:56 +09:00
Atzm Watanabe
24a041ecca nx_match: add tun_ipv6_{src,dst}
Open vSwitch accepts NXM_NX_TUN_IPV6_SRC(109) and
NXM_NX_TUN_IPV6_DST(110) since v2.5.

Signed-off-by: Atzm Watanabe <atzm@iij.ad.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-01 20:43:01 +09:00
IWASE Yusuke
1bcb23e556 packet_data_generator3: Clear xid into zero
Because ovs-ofctl increments the xid field automatically, the xid
of the generated packets is set to be 0x02.
So, we should specify {"xid": 2} in json data, but when Ryu dumping
json data from message instance, "xid" are omitted and this causes
assertion error in test_parser.py

This patch enables to clear the xid filed in the generated packets
and solves this problem.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-01 20:40:17 +09:00
IWASE Yusuke
709b3ad28f ofproto: Implement OFPFlowMod parser
Currently, Ryu does not have the parser for Controller-to-Switch
one-way messages, but when testing Actions or Match fields,
OFPFlowMod parser is convenient in order to test them.

This patch implements the parser for OFPFlowMod messages.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-01 20:40:12 +09:00
IWASE Yusuke
f3e931b03f doc: Add PCAP file library reference
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-01 20:40:04 +09:00
IWASE Yusuke
ad481c7de8 test_pcaplib: Add unit tests for pcaplib
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-01 20:39:59 +09:00
IWASE Yusuke
6643bae823 pcaplib: Reduce Pylint warnings
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-01 20:39:54 +09:00
IWASE Yusuke
35fc29a8d3 test_bgp: Enable to test parser with pcap file
Currently, test_bgp uses packet_data/bgp4/* files which contain only
BGP protocol binary data.
This patch convert packet_data file into pcap file and enable to test
BGP packet library with pcap file.
With pcap file, we can easily check packet data validity by using
Wireshark or other packet sniffer tools.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-01 20:39:03 +09:00
IWASE Yusuke
b3b8238e6c packet/bgp: Reduce Pylint warnings
This patch removes the following Pylint warnings:
  - anomalous-backslash-in-string
  - arguments-differ
  - bad-builtin
  - bad-staticmethod-argument
  - superfluous-parens
  - super-init-not-called
  - unidiomatic-typecheck
  - unused-variable
  - wrong-import-order

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-01 20:38:57 +09:00
IWASE Yusuke
171b35f0db bgp: fix typos
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-01 20:38:50 +09:00
IWASE Yusuke
9b57e7bd07 test-requires: Update to use the latest Pylint
Current specified Pylint(==0.25.0) are not enough to support Python 3.
This patch updates test-requires to use the latest one.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-01 20:38:39 +09:00
IWASE Yusuke
4fa85d1e4b test-requires: Add tinyrpc for RPC controller in wsgi
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-06-01 20:38:27 +09:00
YAMAMOTO Takashi
9e3aaaf2d8 Make ovs optional
Requiring a dev version of ovs here causes version conflict issues
for projects which don't want to use dev versions of libraries. [1]

Make it optional and document it in README instead.

[1] https://bugs.launchpad.net/neutron/+bug/1584858

Signed-off-by: YAMAMOTO Takashi <yamamoto@ovn.org>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-26 23:30:49 +09:00
IWASE Yusuke
a6c3d38789 packet: Add VXLAN parser
IANA has assigned the value 4789 for the VXLAN UDP destination port,
this patch registers dst_port 4789 into UDP packet parser.
Additionally, early adopters might be using UDP dst_port 8472,
we register this number for the backward compatibility.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-23 12:48:08 +09:00
IWAMOTO Toshihiro
7f38397442 packet/bgp: Add missing __hash__ function
This commit fixes up the commit 7d42aecb, which added __eq__ without
adding __hash__ and left some copy-paste error.

Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-18 17:49:25 +09:00
IWASE Yusuke
a7e804fdec controller: Add backward compatibility for 6633 port
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-18 16:01:23 +09:00
IWASE Yusuke
7d446f3f79 Update default OpenFlow port to 6653
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>
2016-05-18 16:01:22 +09:00
IWASE Yusuke
a20b9e1fcd BGP: Make RouteFamily class hashable
In Python 3, the key objects of dict must be hashable,
but RouteFamily class does not have '__hash__' method.
This patch adds this method.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-18 16:01:16 +09:00
IWASE Yusuke
13ae023f2d doc: Remove warnings when building doc pages
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-18 16:00:51 +09:00
IWASE Yusuke
9d9f28519f doc: Move Ryu App API doc into each source code
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>
2016-05-18 16:00:34 +09:00
IWASE Yusuke
68025e66b1 network: Fix unresolved reference
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>
2016-05-18 16:00:09 +09:00
IWASE Yusuke
3cccf23238 doc: Add description for EventOFPPortStateChange
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-18 15:59:22 +09:00
IWASE Yusuke
9774eb60af controller: Implement EventOFPPortStateChange
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>
2016-05-18 15:59:13 +09:00
Shinpei Muraoka
af2ae13ae3 doc/app/ofctl_rest: Remove unused match field
This patch removed unused match field in Openflow1.2 or later.
The following is removed match filed.
 - dl_dst
 - dl_src
 - dl_type
 - dl_vlan
 - nw_src
 - nw_dst
 - nw_proto
 - tp_src
 - tp_dst

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-16 15:02:40 +09:00
Shinpei Muraoka
3f60665d1f doc/source/conf: Set the False to SmartyPants
This patch will not be converted to quotes and dashes to typographically correct entities.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-16 15:02:40 +09:00
Shinpei Muraoka
d435446ef5 doc/app/ofctl_rest: Add a description for openflow1.5
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-16 15:02:40 +09:00
Shinpei Muraoka
f351cd3977 doc/app/ofctl_rest: Update the optional parameter of the message
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-16 15:02:40 +09:00
Shinpei Muraoka
918edd4eff doc/app/ofctl_rest: Add pbb_uca to match field
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-16 13:15:24 +09:00
Shinpei Muraoka
a605021ccf doc/app/ofctl_rest: Update the description method of Example
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-16 13:15:22 +09:00
Shinpei Muraoka
7f1c91114b doc/app/ofctl_rest: Add Openflow version
This patch adds Openflow version to the Match message and Actions message.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-16 13:15:19 +09:00
Victor J. Orlikowski
89b2bf52d5 Bump version requirement for oslo.config, given usage of min parameter to IntOpt
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-13 23:03:52 +09:00
IWASE Yusuke
208ad9d11c tox: Integrate Coveralls.io
To check the code coverage of the unit tests on web, this patch
add integration of Coveralls.io (https://coveralls.io/).

Usage:
  1. Sign in to Coveralls.io with your GitHub account.
  2. Add repos at your account page.
  3. Execute tests on Travis-CI.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-13 22:33:21 +09:00
IWASE Yusuke
dc6e2b8691 tox: Add Python 3.5
>From Ubuntu 16.04 LTS, the default version of Python 3 has been
upgraded to 3.5.1.
  e.g.)
    $ python3 --version
    Python 3.5.1+

This patch enables to run unit tests on Python 3.5 environment.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-13 22:33:17 +09:00
Shinpei Muraoka
ead9ce79a5 test_ofctl: Add test cases for new Actions of of15
This patch adds the test cases for the following actions.
 - Copy Field Action
 - Meter Action

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-13 22:26:15 +09:00
Minoru TAKAHASHI
e30eebbc42 test_ofctl_rest: Add unit tests for ofctl_rest
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-13 22:26:13 +09:00
Minoru TAKAHASHI
4bec6aca3d test_ofctl: Add test cases for OpenFlow 1.5
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-13 22:26:03 +09:00
Minoru TAKAHASHI
255fd1564e ofctl_rest: Support OpenFlow 1.5
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-13 22:25:56 +09:00
Minoru TAKAHASHI
a7b092747f lib/ofctl: Support OpenFlow 1.5
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-13 22:25:50 +09:00
Shinpei Muraoka
1452facb25 ofproto_v1_5_parser: Fix serialized length of OFPActionCopyField
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-13 22:25:43 +09:00
IWASE Yusuke
c9132288eb ofctl_v1_4: Port some improvements from ofctl_v1_3
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-13 22:25:41 +09:00
IWASE Yusuke
ea8c3b8fb7 ofctl_v1_4: Rename to get_queue_desc for uniformity
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-13 22:25:32 +09:00
Minoru TAKAHASHI
a67f436b8d ofctl_v1_4: Support request parameters
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-13 22:25:31 +09:00
IWASE Yusuke
9dd3b3ce4a ofctl_utils: Enhance user value conversion
Currently, OFCtlUtil._reserved_num_from_user() fails to convert
an user specified value when it is a numeric string.
This patch enhances this conversion to enable to convert an user
value as follows.

e.g.)
 - Integer: 1 -> 1
 - Numeric string: "1" -> 1
 - Reserved number: "OFPP_ANY" -> 0xffffffff
 - Invalid value: "foobar" -> "foobar" (do not conversion)

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-13 22:25:21 +09:00
IWASE Yusuke
c1047818d3 REST Apps: Adopt to Python 3
In Python 3, webob.Request.body is a byte type value and json.loads()
cannot parse it, because json.loads() suppose a str type value.

This patch fixes to use webob.Request.json to parse request body
and avoids this problem.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-13 22:25:09 +09:00
IWASE Yusuke
326b46bf6d topology: Adopt to Python 3
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-13 22:24:53 +09:00
Shinpei Muraoka
4b99579249 ofctl_rest: Enable to omit port_no and queue_id
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-13 22:24:14 +09:00
IWASE Yusuke
f60c12cbbe ofctl_rest: Adopt decorator to simplify
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-13 22:18:14 +09:00
Shinpei Muraoka
dcb1efb8e5 test_ofctl: Test cases for omitting port_no in get_queue_config
Add test cases of specify the port number for get queues config.

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-13 22:18:05 +09:00
IWASE Yusuke
e721c181e0 lib/ofctl_v1_[23]: Unify the arguments order
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-13 22:17:56 +09:00
IWASE Yusuke
bea97ae66b ofctl_utils: Confirm binary type data in send_experimenter
In Python 3, the data field in OFPExperimenter must be a binary
type value, but when data_type='ascii', ofctl_utils may get it
as a str type value.
This patch confirms the data field is a binary type value.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-13 22:17:46 +09:00
Minoru TAKAHASHI
33d1023368 test_import_module: Update test cases
Because Python does not provides features to unimport modules which
ware imported before, this patch separates dummy modules to test
import features of Ryu.
e.g.) If 'aaa' was imported in the previous test case,
      'aaa' affects the subsequent test cases.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-13 22:17:25 +09:00
Minoru TAKAHASHI
c66b4b34e5 utils: fix for temporarily storing the value of sys.path
Currentry, the *reference* of sys.path is temporarily stored before
appending a path to the user modules.
However, the *value* of sys.path should be stored because the type
of sys.path is list (mutable object) type.

Reported-by: Xandaros <mz.bremerhaven@gmail.com>
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2016-05-13 22:17:23 +09:00
565 changed files with 43888 additions and 10807 deletions

25
.github/workflows/tests-unit.yml vendored Normal file
View File

@ -0,0 +1,25 @@
name: Unit tests
on: [push, pull_request]
jobs:
unit-tests:
name: Unit tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade -r pip-requirements.txt
pip install tox tox-gh-actions coveralls
bash ryu/tests/integrated/common/install_docker_test_pkg_for_github_actions.sh
- name: Test with tox
run: NOSE_VERBOSE=0 tox

11
.readthedocs.yml Normal file
View File

@ -0,0 +1,11 @@
version: 2
build:
image: latest
python:
version: 3.6
install:
- method: pip
path: .
sphinx:
configuration: doc/source/conf.py
formats: all

15
.renovaterc.json Normal file
View File

@ -0,0 +1,15 @@
{
"separateMajorMinor": false,
"schedule": [
"after 10pm every weekday",
"before 5am every weekday",
"every weekend"
],
"timezone": "Pacific/Auckland",
"extends": [
"config:base",
":prHourlyLimit1",
":preserveSemverRanges",
"docker:enableMajor"
]
}

9
.stickler.yml Normal file
View File

@ -0,0 +1,9 @@
---
linters:
flake8:
python: 3
max-line-length: 120
pep8:
python: 3
max-line-length: 120
py3k:

View File

@ -1,17 +0,0 @@
language: python
python:
- "2.7"
env:
- TOX_ENV=py27
- TOX_ENV=py34
- TOX_ENV=pypy26
- TOX_ENV=pep8
install:
- "pip install tox"
script:
- NOSE_VERBOSE=0 tox -e $TOX_ENV
sudo: false

View File

@ -5,46 +5,59 @@ How to Get Your Change Into Ryu
Submitting a change
===================
Send patches to ryu-devel@lists.sourceforge.net. Please don't use 'pull
request' on github. We expect you to send a patch in Linux kernel
development style. If you are not familiar with it, please read the
following document:
To send patches to ryu, please make a
`pull request <https://github.com/faucetsdn/ryu>`_ on GitHub.
https://www.kernel.org/doc/Documentation/SubmittingPatches
Please check your changes with autopep8, pycodestyle(pep8) and running
unit tests to make sure that they don't break the existing features.
The following command does all for you.
Please check your changes with pep8 and run unittests to make sure
that they don't break the existing features. The following command
does both for you:
.. code-block:: bash
fujita@rose:~/git/ryu$ ./run_tests.sh
# Install dependencies of tests
$ pip install -r tools/test-requires
Of course, you are encouraged to add unittests when you add new
# Execute autopep8
# Also, it is convenient to add settings of your editor or IDE for
# applying autopep8 automatically.
$ autopep8 --recursive --in-place ryu/
# Execute unit tests and pycodestyle(pep8)
$ ./run_tests.sh
Of course, you are encouraged to add unit tests when you add new
features (it's not a must though).
Python version and libraries
============================
* Python 2.6+
As RHEL 6 adopted python 2.6, features only for 2.7+ should be avoided.
* Python 3.5, 3.6, 3.7, 3.8, 3.9:
* standard library + widely used library
Basically widely used == OpenStack adopted
As usual there are exceptions. gevents. Or python binding library for other
Ryu supports multiple Python versions. CI tests on GitHub Actions is running
on these versions.
* standard library + widely used library:
Basically widely used == OpenStack adopted.
As usual there are exceptions. Or python binding library for other
component.
Coding style guide
==================
* pep8
As python is used, PEP8 is would be hopefully mandatory for
http://www.python.org/dev/peps/pep-0008/
* pep8:
As python is used, PEP8 is would be hopefully mandatory for
https://www.python.org/dev/peps/pep-0008/
* pylint:
* pylint
Although pylint is useful for finding bugs, but pylint score not very
important for now because we're still at early development stage.
https://www.pylint.org/
* Google python style guide is very helpful
http://google-styleguide.googlecode.com/svn/trunk/pyguide.html
* Google python style guide is very helpful:
http://google.github.io/styleguide/pyguide.html
Guidelines derived from Guido's Recommendations
* Guidelines derived from Guido's Recommendations:
============================= ================= ========
Type Public Internal
@ -62,10 +75,11 @@ Coding style guide
Local Variables lower_with_under
============================= ================= ========
* OpenStack Nova style guide
* OpenStack Nova style guide:
https://github.com/openstack/nova/blob/master/HACKING.rst
* JSON files
* JSON files:
Ryu source tree has JSON files under ryu/tests/unit/ofproto/json.
They are used by unit tests. To make patches easier to read,
they are normalized using tools/normalize_json.py. Please re-run

View File

@ -1,8 +1,13 @@
**PLEASE READ: RYU NOT CURRENTLY MAINTAINED**
* The Ryu project needs new maintainers - please file an issue if you are able to assist.
* see OpenStack's os-ken (`<https://github.com/openstack/os-ken>`_) for a maintained Ryu alternative.
What's Ryu
==========
Ryu is a component-based software defined networking framework.
Ryu provides software components with well defined API that make it
Ryu provides software components with well defined API's that make it
easy for developers to create new network management and control
applications. Ryu supports various protocols for managing network
devices, such as OpenFlow, Netconf, OF-config, etc. About OpenFlow,
@ -20,11 +25,11 @@ Installing Ryu is quite easy::
If you prefer to install Ryu from the source code::
% git clone git://github.com/osrg/ryu.git
% cd ryu; python ./setup.py install
% git clone https://github.com/faucetsdn/ryu.git
% cd ryu; pip install .
If you want to write your Ryu application, have a look at
`Writing ryu application <http://ryu.readthedocs.org/en/latest/writing_ryu_app.html>`_ document.
`Writing ryu application <http://ryu.readthedocs.io/en/latest/writing_ryu_app.html>`_ document.
After writing your application, just type::
% ryu-manager yourapp.py
@ -33,21 +38,33 @@ After writing your application, just type::
Optional Requirements
=====================
Some functionalities of ryu requires extra packages:
Some functions of ryu require extra packages:
- OF-Config requires lxml
- OF-Config requires lxml and ncclient
- NETCONF requires paramiko
- BGP speaker (ssh console) requires paramiko
- BGP speaker (SSH console) requires paramiko
- Zebra protocol service (database) requires SQLAlchemy
If you want to use the functionalities, please install requirements::
If you want to use these functions, please install the requirements::
% pip install lxml
% pip install paramiko
% pip install -r tools/optional-requires
Please refer to tools/optional-requires for details.
Prerequisites
=============
If you got some error messages at the installation stage, please confirm
dependencies for building the required Python packages.
On Ubuntu(16.04 LTS or later)::
% apt install gcc python-dev libffi-dev libssl-dev libxml2-dev libxslt1-dev zlib1g-dev
Support
=======
Ryu Official site is `<http://osrg.github.io/ryu/>`_.
Ryu Official site is `<https://ryu-sdn.org/>`_.
If you have any
questions, suggestions, and patches, the mailing list is available at

10
debian/control vendored
View File

@ -6,7 +6,7 @@ Build-Depends: debhelper (>= 9.0.0), python-all (>= 2.6), python-sphinx
Build-Depends-Indep:
python-eventlet,
python-lxml,
python-msgpack (>= 0.3.0),
python-msgpack (>= 0.4.0),
python-netaddr,
python-oslo.config (>= 1:1.2.0),
python-paramiko,
@ -17,9 +17,9 @@ Build-Depends-Indep:
python-pip,
python-pbr
Standards-Version: 3.9.5
Homepage: http://osrg.github.io/ryu/
Vcs-Git: git://github.com/osrg/ryu.git
Vcs-Browser: http://github.com/osrg/ryu
Homepage: https://ryu-sdn.org
Vcs-Git: git://github.com/faucetsdn/ryu.git
Vcs-Browser: https://github.com/faucetsdn/ryu
XS-Python-Version: >= 2.6
Package: python-ryu
@ -28,7 +28,7 @@ Section: python
Depends:
python-eventlet,
python-lxml,
python-msgpack (>= 0.3.0),
python-msgpack (>= 0.4.0),
python-netaddr,
python-oslo.config (>= 1:1.2.0),
python-paramiko,

2
debian/copyright vendored
View File

@ -1,6 +1,6 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: ryu
Source: http://github.com/osrg/ryu
Source: http://github.com/faucetsdn/ryu
Files: *
Copyright: 2014 Ryu Project Team <ryu-devel@lists.sourceforge.net>

View File

@ -11,3 +11,5 @@ Others provide some functionalities to other Ryu applications.
app/ofctl.rst
app/ofctl_rest.rst
app/rest_vtep.rst
app/bgp_application.rst

View File

@ -0,0 +1,6 @@
**************************************
ryu.services.protocols.bgp.application
**************************************
.. automodule:: ryu.services.protocols.bgp.application
:members:

View File

@ -6,7 +6,7 @@ ryu.app.ofctl_rest provides REST APIs for retrieving the switch stats
and Updating the switch stats.
This application helps you debug your application and get various statistics.
This application supports OpenFlow version 1.0, 1.2, 1.3 and 1.4.
This application supports OpenFlow version 1.0, 1.2, 1.3, 1.4 and 1.5.
.. contents::
:depth: 3
@ -248,8 +248,17 @@ Get flows stats filtered by fields
cookie Require matching entries to contain this cookie value (int) 1 0
cookie_mask Mask used to restrict the cookie bits that must match (int) 1 0
match Fields to match (dict) {"in_port": 1} {} #wildcarded
priority Priority of the entry (int) (See Note) 11111 #wildcarded
============ ================================================================== =============== ===============
.. NOTE::
OpenFlow Spec does not allow to filter flow entries by priority,
but when with a large amount of flow entries, filtering by priority
is convenient to get statistics efficiently.
So, this app provides priority field for filtering.
Response message body:
The same as :ref:`get-all-flows-stats`
@ -889,13 +898,25 @@ Get ports description
Get ports description of the switch which specified with Datapath ID in URI.
Usage:
Usage(OpenFlow1.4 or earlier):
======= =======================
Method GET
URI /stats/portdesc/<dpid>
======= =======================
Usage(OpenFlow1.5 or later):
======= ==================================
Method GET
URI /stats/portdesc/<dpid>/[<port>]
======= ==================================
.. NOTE::
Specification of port number is optional.
Response message body(OpenFlow1.3 or earlier):
============== ====================================== ====================
@ -1157,10 +1178,15 @@ Get queues config
Usage:
======= ================================
======= ==================================
Method GET
URI /stats/queueconfig/<dpid>/<port>
======= ================================
URI /stats/queueconfig/<dpid>/[<port>]
======= ==================================
.. NOTE::
Specification of port number is optional.
.. CAUTION::
@ -1236,10 +1262,20 @@ Get queues description
Usage:
======= =========================================
======= =============================================
Method GET
URI /stats/queuedesc/<dpid>/<port>/<queue_id>
======= =========================================
URI /stats/queuedesc/<dpid>[/<port>/[<queue_id>]]
======= =============================================
.. NOTE::
Specification of port number and queue id are optional.
If you want to omitting the port number and setting the queue id,
please specify the keyword "ALL" to the port number.
e.g. GET http://localhost:8080/stats/queuedesc/1/ALL/1
.. CAUTION::
@ -1370,13 +1406,25 @@ Get group description stats
Get group description stats of the switch which specified with Datapath ID in URI.
Usage:
Usage(Openflow1.4 or earlier):
======= ========================
Method GET
URI /stats/groupdesc/<dpid>
======= ========================
Usage(Openflow1.5 or later):
======= ====================================
Method GET
URI /stats/groupdesc/<dpid>/[<group_id>]
======= ====================================
.. NOTE::
Specification of group id is optional.
Response message body(Openflow1.3 or earlier):
=============== ======================================================= =============
@ -1625,17 +1673,33 @@ Get meters stats
.. _get-meter-config-stats:
Get meter config stats
------------------------
----------------------
Get meter description stats
---------------------------
Get meter config stats of the switch which specified with Datapath ID in URI.
Usage:
.. CAUTION::
This message has been renamed in openflow 1.5.
If Openflow 1.4 or earlier is in use, please used as Get meter description stats.
If Openflow 1.5 or later is in use, please used as Get meter description stats.
Usage(Openflow1.4 or earlier):
======= ======================================
Method GET
URI /stats/meterconfig/<dpid>[/<meter_id>]
======= ======================================
Usage(Openflow1.5 or later):
======= ======================================
Method GET
URI /stats/meterdesc/<dpid>[/<meter_id>]
======= ======================================
.. NOTE::
Specification of meter id is optional.
@ -1730,6 +1794,72 @@ Get meter features stats
}
Get role
--------
Get the current role of the controller from the switch.
Usage:
======= =========================
Method GET
URI /stats/role/<dpid>
======= =========================
Response message body(Openflow1.4 or earlier):
============= ============================= =========
Attribute Description Example
============= ============================= =========
dpid Datapath ID 1
role One of OFPCR_ROLE_* "EQUAL"
generation_id Master Election Generation Id 0
============= ============================= =========
Response message body(Openflow1.5 or later):
============= ============================= =========
Attribute Description Example
============= ============================= =========
dpid Datapath ID 1
role One of OFPCR_ROLE_* "EQUAL"
short_id ID number for the controller 0
generation_id Master Election Generation Id 0
============= ============================= =========
Example of use::
$ curl -X GET http://localhost:8080/stats/role/1
Response (Openflow1.4 or earlier):
.. code-block:: javascript
{
"1": [
{
"generation_id": 0,
"role": "EQUAL"
}
]
}
Response (Openflow1.5 or later):
.. code-block:: javascript
{
"1": [
{
"generation_id": 0,
"role": "EQUAL",
"short_id": 0
}
]
}
Update the switch stats
=======================
@ -1765,9 +1895,9 @@ Add a flow entry
Request message body(Openflow1.4 or later):
============= ===================================================== =============================== ===============
============= ===================================================== ================================ ===============
Attribute Description Example Default
============= ===================================================== =============================== ===============
============= ===================================================== ================================ ===============
dpid Datapath ID (int) 1 (Mandatory)
cookie Opaque controller-issued identifier (int) 1 0
cookie_mask Mask used to restrict the cookie bits (int) 1 0
@ -2457,6 +2587,33 @@ Delete a meter entry
"meter_id": 1
}' http://localhost:8080/stats/meterentry/delete
Modify role
--------------------
modify the role of the switch.
Usage:
======= =========================
Method POST
URI /stats/role
======= =========================
Request message body:
=========== ============================ ========= =================
Attribute Description Example Default
=========== ============================ ========= =================
dpid Datapath ID (int) 1 (Mandatory)
role One of OFPCR_ROLE_*(string) "MASTER" OFPCR_ROLE_EQUAL
=========== ============================ ========= =================
Example of use::
$ curl -X POST -d '{
"dpid": 1,
"role": "MASTER"
}' http://localhost:8080/stats/role
Support for experimenter multipart
==================================
@ -2500,7 +2657,7 @@ Send a experimenter message
.. _description-of-match-and-actions:
Reference: Description of Match and Actions
============================================
===========================================
Description of Match on request messages
----------------------------------------
@ -2540,26 +2697,15 @@ Description of Match on request messages
=============== ================================================== =======================================================================================================
in_port Switch input port (int) {"in_port": 7}
in_phy_port Switch physical input port (int) {"in_phy_port": 5, "in_port": 3}
metadata Metadata passed between tables (int or string) {"metadata": 12345}
| {"metadata": "0x1212/0xffff"}
dl_dst Ethernet destination address (string) {"dl_dst": "aa:bb:cc:11:22:33/00:00:00:00:ff:ff"}
dl_src Ethernet source address (string) {"dl_src": "aa:bb:cc:11:22:33"}
metadata Metadata passed between tables (int or string) {"metadata": 12345} or {"metadata": "0x1212/0xffff"}
eth_dst Ethernet destination address (string) {"eth_dst": "aa:bb:cc:11:22:33/00:00:00:00:ff:ff"}
eth_src Ethernet source address (string) {"eth_src": "aa:bb:cc:11:22:33"}
dl_type Ethernet frame type (int) {"dl_type": 123}
eth_type Ethernet frame type (int) {"eth_type": 2048}
dl_vlan VLAN id (int or string) See :ref:`example-of-vlan-id-match-field`
vlan_vid VLAN id (int or string) See :ref:`example-of-vlan-id-match-field`
vlan_pcp VLAN priority (int) {"vlan_pcp": 3, "vlan_vid": 3}
ip_dscp IP DSCP (6 bits in ToS field) (int) {"ip_dscp": 3, "eth_type": 2048}
ip_ecn IP ECN (2 bits in ToS field) (int) {"ip_ecn": 0, "eth_type": 34525}
nw_proto IP protocol (int) {"nw_proto": 5, "eth_type": 2048}
ip_proto IP protocol (int) {"ip_proto": 5, "eth_type": 34525}
tp_src Transport layer source port (int) {"tp_src": 1, "ip_proto": 6, "eth_type": 2048}
tp_dst Transport layer destination port (int) {"tp_dst": 2, "ip_proto": 6, "eth_type": 2048}
nw_src IPv4 source address (string) {"nw_src": "192.168.0.1", "eth_type": 2048}
nw_dst IPv4 destination address (string) {"nw_dst": "192.168.0.1/24", "eth_type": 2048}
ipv4_src IPv4 source address (string) {"ipv4_src": "192.168.0.1", "eth_type": 2048}
ipv4_dst IPv4 destination address (string) {"ipv4_dst": "192.168.10.10/255.255.255.0", "eth_type": 2048}
tcp_src TCP source port (int) {"tcp_src": 3, "ip_proto": 6, "eth_type": 2048}
@ -2586,15 +2732,21 @@ Description of Match on request messages
mpls_label MPLS label (int) {"mpls_label": 3, "eth_type": 34888}
mpls_tc MPLS Traffic Class (int) {"mpls_tc": 2, "eth_type": 34888}
mpls_bos MPLS BoS bit (int) {"mpls_bos": 1, "eth_type": 34888}
pbb_isid PBB I-SID (int or string) {"pbb_isid": 5, "eth_type": 35047}
| {"pbb_isid": "0x05/0xff", "eth_type": 35047}
tunnel_id Logical Port Metadata (int or string) {"tunnel_id": 7}
| {"tunnel_id": "0x07/0xff"}
ipv6_exthdr IPv6 Extension Header pseudo-field (int or string) {"ipv6_exthdr": 3, "eth_type": 34525}
| {"ipv6_exthdr": "0x40/0x1F0", "eth_type": 34525}
(Openflow1.3+)
pbb_isid PBB I-SID (int or string) {"pbb_isid": 5, "eth_type": 35047} or{"pbb_isid": "0x05/0xff", "eth_type": 35047}
(Openflow1.3+)
tunnel_id Logical Port Metadata (int or string) {"tunnel_id": 7} or {"tunnel_id": "0x07/0xff"}
(Openflow1.3+)
ipv6_exthdr IPv6 Extension Header pseudo-field (int or string) {"ipv6_exthdr": 3, "eth_type": 34525} or {"ipv6_exthdr": "0x40/0x1F0", "eth_type": 34525}
(Openflow1.3+)
pbb_uca PBB UCA hander field(int) {"pbb_uca": 1, "eth_type": 35047}
(Openflow1.4+)
tcp_flags TCP flags(int) {"tcp_flags": 2, "ip_proto": 6, "eth_type": 2048}
(Openflow1.5+)
actset_output Output port from action set metadata(int) {"actset_output": 3}
(Openflow1.5+)
packet_type Packet type value(int) {"packet_type": [1, 2048]}
(Openflow1.5+)
=============== ================================================== =======================================================================================================
.. NOTE::
@ -2726,9 +2878,9 @@ Description of Actions on request messages
List of Actions (OpenFlow1.2 or later):
=============== ============================================================================ ==================================================================
=============== ============================================================================ ========================================================================================================================
Actions Description Example
=============== ============================================================================ ==================================================================
=============== ============================================================================ ========================================================================================================================
OUTPUT Output packet from "port" {"type": "OUTPUT", "port": 3}
COPY_TTL_OUT Copy TTL outwards {"type": "COPY_TTL_OUT"}
COPY_TTL_IN Copy TTL inwards {"type": "COPY_TTL_IN"}
@ -2745,15 +2897,24 @@ Description of Actions on request messages
SET_FIELD Set a "field" using "value" See :ref:`example-of-set-field-action`
(The set of keywords available for "field" is the same as match field)
PUSH_PBB Push a new PBB service tag with "ethertype" {"type": "PUSH_PBB", "ethertype": 35047}
(Openflow1.3+)
POP_PBB Pop the outer PBB service tag {"type": "POP_PBB"}
(Openflow1.3+)
COPY_FIELD Copy value between header and register {"type": "COPY_FIELD", "n_bits": 32, "src_offset": 1, "dst_offset": 2, "src_oxm_id": "eth_src", "dst_oxm_id": "eth_dst"}
(Openflow1.5+)
METER Apply meter identified by "meter_id" {"type": "METER", "meter_id": 3}
(Openflow1.5+)
EXPERIMENTER Extensible action for the experimenter {"type": "EXPERIMENTER", "experimenter": 101, "data": "AAECAwQFBgc=", "data_type": "base64"}
(Set "base64" or "ascii" to "data_type" field)
GOTO_TABLE (Instruction) Setup the next table identified by "table_id" {"type": "GOTO_TABLE", "table_id": 8}
WRITE_METADATA (Instruction) Setup the metadata field using "metadata" and "metadata_mask" {"type": "WRITE_METADATA", "metadata": 0x3, "metadata_mask": 0x3}
METER (Instruction) Apply meter identified by "meter_id" {"type": "METER", "meter_id": 3}
(deprecated in Openflow1.5)
WRITE_ACTIONS (Instruction) Write the action(s) onto the datapath action set {"type": "WRITE_ACTIONS", actions":[{"type":"POP_VLAN",},{ "type":"OUTPUT", "port": 2}]}
CLEAR_ACTIONS (Instruction) Clears all actions from the datapath action set {"type": "CLEAR_ACTIONS"}
=============== ============================================================================ ==================================================================
=============== ============================================================================ ========================================================================================================================
.. _example-of-set-field-action:
@ -2767,19 +2928,20 @@ Example of set-field action
"match":{
"dl_type": "0x8000"
},
"actions":[
{
"type": "PUSH_VLAN", # Push a new VLAN tag if a input frame is non-VLAN-tagged
"ethertype": 33024 # Ethertype 0x8100(=33024): IEEE 802.1Q VLAN-tagged frame
},
{
"type": "SET_FIELD",
"field": "vlan_vid", # Set VLAN ID
"value": 4102 # Describe sum of vlan_id(e.g. 6) | OFPVID_PRESENT(0x1000=4096)
},
{
"type": "OUTPUT",
"port": 2
}
]
"actions":[
{
"type": "PUSH_VLAN", # Push a new VLAN tag if a input frame is non-VLAN-tagged
"ethertype": 33024 # Ethertype 0x8100(=33024): IEEE 802.1Q VLAN-tagged frame
},
{
"type": "SET_FIELD",
"field": "vlan_vid", # Set VLAN ID
"value": 4102 # Describe sum of vlan_id(e.g. 6) | OFPVID_PRESENT(0x1000=4096)
},
{
"type": "OUTPUT",
"port": 2
}
]
}' http://localhost:8080/stats/flowentry/add

View File

@ -0,0 +1,12 @@
*****************
ryu.app.rest_vtep
*****************
.. automodule:: ryu.app.rest_vtep
REST API
========
.. autoclass:: ryu.app.rest_vtep.RestVtepController
:members:
:member-order: bysource

View File

@ -132,6 +132,7 @@ html_static_path = ['_static']
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# (Deprecated since version 1.6)
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}

2
doc/source/docutils.conf Normal file
View File

@ -0,0 +1,2 @@
[parsers]
smart_quotes: false

View File

@ -16,7 +16,6 @@ Contents:
developing.rst
configuration.rst
tests.rst
using_with_openstack.rst
snort_integrate.rst
app.rst

View File

@ -9,7 +9,10 @@ Ryu provides some useful library for your network applications.
library_packet.rst
library_packet_ref.rst
library_pcap.rst
library_of_config.rst
library_bgp_speaker.rst
library_bgp_speaker_ref.rst
library_mrt.rst
library_ovsdb_manager.rst
library_ovsdb.rst

View File

@ -6,8 +6,8 @@ Introduction
============
Ryu BGP speaker library helps you to enable your code to speak BGP
protocol. The library supports ipv4, ipv4 vpn, and ipv6 vpn address
families.
protocol. The library supports IPv4, IPv4 MPLS-labeled VPN, IPv6
MPLS-labeled VPN and L2VPN EVPN address families.
Example
=======

View File

@ -0,0 +1,28 @@
****************
MRT file library
****************
Introduction
============
Ryu MRT file library helps you to read/write MRT
(Multi-Threaded Routing Toolkit) Routing Information Export Format
[`RFC6396`_].
.. _RFC6396: https://tools.ietf.org/html/rfc6396
Reading MRT file
================
For loading the routing information contained in MRT files, you can use
mrtlib.Reader.
.. autoclass:: ryu.lib.mrtlib.Reader
Writing MRT file
================
For dumping the routing information which your RyuApp generated, you can use
mrtlib.Writer.
.. autoclass:: ryu.lib.mrtlib.Writer

View File

@ -0,0 +1,76 @@
*************
OVSDB library
*************
Path: ``ryu.lib.ovs``
Similar to the :doc:`library_ovsdb_manager`, this library enables your
application to speak the OVSDB protocol (RFC7047_), but differ from the
:doc:`library_ovsdb_manager`, this library will initiate connections from
controller side as ovs-vsctl_ command does.
Please make sure that your devices are listening on either the Unix domain
socket or TCP/SSL port before calling the APIs of this library.
.. code-block:: bash
# Show current configuration
$ ovs-vsctl get-manager
# Set TCP listen address
$ ovs-vsctl set-manager "ptcp:6640"
See manpage of ovs-vsctl_ command for more details.
.. _RFC7047: https://tools.ietf.org/html/rfc7047
.. _ovs-vsctl: http://openvswitch.org/support/dist-docs/ovs-vsctl.8.txt
Basic Usage
===========
1. Instantiate :py:mod:`ryu.lib.ovs.vsctl.VSCtl`.
2. Construct commands with :py:mod:`ryu.lib.ovs.vsctl.VSCtlCommand`.
The syntax is almost the same as ovs-vsctl_ command.
3. Execute commands via :py:mod:`ryu.lib.ovs.vsctl.VSCtl.run_command`.
Example
-------
.. code-block:: python
from ryu.lib.ovs import vsctl
OVSDB_ADDR = 'tcp:127.0.0.1:6640'
ovs_vsctl = vsctl.VSCtl(OVSDB_ADDR)
# Equivalent to
# $ ovs-vsctl show
command = vsctl.VSCtlCommand('show')
ovs_vsctl.run_command([command])
print(command)
# >>> VSCtlCommand(args=[],command='show',options=[],result='830d781f-c3c8-4b4f-837e-106e1b33d058\n ovs_version: "2.8.90"\n')
# Equivalent to
# $ ovs-vsctl list Port s1-eth1
command = vsctl.VSCtlCommand('list', ('Port', 's1-eth1'))
ovs_vsctl.run_command([command])
print(command)
# >>> VSCtlCommand(args=('Port', 's1-eth1'),command='list',options=[],result=[<ovs.db.idl.Row object at 0x7f525fb682e8>])
print(command.result[0].name)
# >>> s1-eth1
API Reference
=============
ryu.lib.ovs.vsctl
-----------------
.. automodule:: ryu.lib.ovs.vsctl
:members:
ryu.lib.ovs.bridge
------------------
.. automodule:: ryu.lib.ovs.bridge
:members:

View File

@ -2,6 +2,8 @@
OVSDB Manager library
*********************
Path: ``ryu.services.protocols.ovsdb``
Introduction
============
@ -9,17 +11,47 @@ Ryu OVSDB Manager library allows your code to interact with devices
speaking the OVSDB protocol. This enables your code to perform remote
management of the devices and react to topology changes on them.
Please note this library will spawn a server listening on the port 6640 (the
IANA registered for OVSDB protocol), but does not initiate connections from
controller side.
Then, to make your devices connect to Ryu, you need to tell the controller IP
address and port to your devices.
.. code-block:: bash
# Show current configuration
$ ovs-vsctl get-manager
# Set manager (controller) address
$ ovs-vsctl set-manager "tcp:127.0.0.1:6640"
# If you want to specify IPv6 address, wrap ip with brackets
$ ovs-vsctl set-manager "tcp:[::1]:6640"
Also this library identifies the devices by "system-id" which should be unique,
persistent identifier among all devices connecting to a single controller.
Please make sure "system-id" is configured before connecting.
.. code-block:: bash
# Show current configuration
$ ovs-vsctl get Open_vSwitch . external_ids:system-id
# Set system-id manually
$ ovs-vsctl set Open_vSwitch . external_ids:system-id=<SYSTEM-ID>
Example
=======
The following logs all new OVSDB connections and allows creating a port
on a bridge.
The following logs all new OVSDB connections in "handle_new_ovsdb_connection"
and also provides the API "create_port" for creating a port on a bridge.
.. code-block:: python
import uuid
from ryu.base import app_manager
from ryu.controller.handler import set_ev_cls
from ryu.services.protocols.ovsdb import api as ovsdb
from ryu.services.protocols.ovsdb import event as ovsdb_event
@ -28,16 +60,22 @@ on a bridge.
@set_ev_cls(ovsdb_event.EventNewOVSDBConnection)
def handle_new_ovsdb_connection(self, ev):
system_id = ev.system_id
self.logger.info('New OVSDB connection from system id %s',
systemd_id)
address = ev.client.address
self.logger.info(
'New OVSDB connection from system-id=%s, address=%s',
system_id, address)
def create_port(self, systemd_id, bridge_name, name):
# Example: If device has bridge "s1", add port "s1-eth99"
if ovsdb.bridge_exists(self, system_id, "s1"):
self.create_port(system_id, "s1", "s1-eth99")
def create_port(self, system_id, bridge_name, name):
new_iface_uuid = uuid.uuid4()
new_port_uuid = uuid.uuid4()
def _create_port(tables, insert):
bridge = ovsdb.row_by_name(self, system_id, bridge_name)
bridge = ovsdb.row_by_name(self, system_id, bridge_name)
def _create_port(tables, insert):
iface = insert(tables['Interface'], new_iface_uuid)
iface.name = name
iface.type = 'internal'
@ -46,9 +84,9 @@ on a bridge.
port.name = name
port.interfaces = [iface]
brdige.ports = bridfe.ports + [port]
bridge.ports = bridge.ports + [port]
return (new_port_uuid, new_iface_uuid)
return new_port_uuid, new_iface_uuid
req = ovsdb_event.EventModifyRequest(system_id, _create_port)
rep = self.send_request(req)
@ -58,4 +96,4 @@ on a bridge.
name, bridge, rep.status)
return None
return reply.insert_uuid[new_port_uuid]
return rep.insert_uuids[new_port_uuid]

View File

@ -14,119 +14,15 @@ Stream Parser class
.. automodule:: ryu.lib.packet.stream_parser
:members:
.. autoclass:: ryu.lib.packet.bgp.StreamParser
:members:
List of the sub-classes:
- :py:mod:`ryu.lib.packet.bgp.StreamParser`
Protocol Header classes
=======================
.. automodule:: ryu.lib.packet.packet_base
:members:
.. toctree::
:glob:
.. automodule:: ryu.lib.packet.ethernet
:members:
.. automodule:: ryu.lib.packet.vlan
:members:
.. automodule:: ryu.lib.packet.pbb
:members:
.. automodule:: ryu.lib.packet.mpls
:members:
.. automodule:: ryu.lib.packet.arp
:members:
.. automodule:: ryu.lib.packet.ipv4
:members:
.. automodule:: ryu.lib.packet.icmp
:members:
.. automodule:: ryu.lib.packet.ipv6
:members:
.. automodule:: ryu.lib.packet.icmpv6
:members:
.. automodule:: ryu.lib.packet.cfm
:members:
.. automodule:: ryu.lib.packet.tcp
:members:
.. automodule:: ryu.lib.packet.udp
:members:
.. autoclass:: ryu.lib.packet.dhcp.dhcp
:members:
.. autoclass:: ryu.lib.packet.dhcp.options
:members:
.. autoclass:: ryu.lib.packet.dhcp.option
:members:
.. autoclass:: ryu.lib.packet.vrrp.vrrp
:members:
.. autoclass:: ryu.lib.packet.vrrp.vrrpv2
:members:
.. autoclass:: ryu.lib.packet.vrrp.vrrpv3
:members:
.. autoclass:: ryu.lib.packet.slow.slow
:members:
.. autoclass:: ryu.lib.packet.slow.lacp
:members:
.. autoclass:: ryu.lib.packet.llc.llc
:members:
.. autoclass:: ryu.lib.packet.llc.ControlFormatI
:members:
.. autoclass:: ryu.lib.packet.llc.ControlFormatS
:members:
.. autoclass:: ryu.lib.packet.llc.ControlFormatU
:members:
.. autoclass:: ryu.lib.packet.bpdu.bpdu
:members:
.. autoclass:: ryu.lib.packet.bpdu.ConfigurationBPDUs
:members:
.. autoclass:: ryu.lib.packet.bpdu.TopologyChangeNotificationBPDUs
:members:
.. autoclass:: ryu.lib.packet.bpdu.RstBPDUs
:members:
.. autoclass:: ryu.lib.packet.igmp.igmp
:members:
.. autoclass:: ryu.lib.packet.igmp.igmpv3_query
:members:
.. autoclass:: ryu.lib.packet.igmp.igmpv3_report
:members:
.. autoclass:: ryu.lib.packet.igmp.igmpv3_report_group
:members:
.. autoclass:: ryu.lib.packet.bgp.BGPMessage
:members:
.. autoclass:: ryu.lib.packet.bgp.BGPOpen
:members:
.. autoclass:: ryu.lib.packet.bgp.BGPUpdate
:members:
.. autoclass:: ryu.lib.packet.bgp.BGPKeepAlive
:members:
.. autoclass:: ryu.lib.packet.bgp.BGPNotification
:members:
.. automodule:: ryu.lib.packet.sctp
:members:
.. autoclass:: ryu.lib.packet.bfd.bfd
:members:
.. autoclass:: ryu.lib.packet.bfd.SimplePassword
:members:
.. autoclass:: ryu.lib.packet.bfd.KeyedMD5
:members:
.. autoclass:: ryu.lib.packet.bfd.MeticulousKeyedMD5
:members:
.. autoclass:: ryu.lib.packet.bfd.KeyedSHA1
:members:
.. autoclass:: ryu.lib.packet.bfd.MeticulousKeyedSHA1
:members:
library_packet_ref/packet_base
library_packet_ref/*

View File

@ -0,0 +1,6 @@
***
ARP
***
.. automodule:: ryu.lib.packet.arp
:members:

View File

@ -0,0 +1,6 @@
*****************
Packet Base Class
*****************
.. automodule:: ryu.lib.packet.packet_base
:members:

View File

@ -0,0 +1,6 @@
***
BFD
***
.. automodule:: ryu.lib.packet.bfd
:members:

View File

@ -0,0 +1,6 @@
***
BGP
***
.. automodule:: ryu.lib.packet.bgp
:members:

View File

@ -0,0 +1,6 @@
***
BMP
***
.. automodule:: ryu.lib.packet.bmp
:members:

View File

@ -0,0 +1,6 @@
****
BPDU
****
.. automodule:: ryu.lib.packet.bpdu
:members:

View File

@ -0,0 +1,6 @@
***
CFM
***
.. automodule:: ryu.lib.packet.cfm
:members:

View File

@ -0,0 +1,6 @@
****
DHCP
****
.. automodule:: ryu.lib.packet.dhcp
:members:

View File

@ -0,0 +1,6 @@
*****
DHCP6
*****
.. automodule:: ryu.lib.packet.dhcp6
:members:

View File

@ -0,0 +1,6 @@
********
Ethernet
********
.. automodule:: ryu.lib.packet.ethernet
:members:

View File

@ -0,0 +1,6 @@
******
Geneve
******
.. automodule:: ryu.lib.packet.geneve
:members:

View File

@ -0,0 +1,6 @@
***
GRE
***
.. automodule:: ryu.lib.packet.gre
:members:

View File

@ -0,0 +1,6 @@
****
ICMP
****
.. automodule:: ryu.lib.packet.icmp
:members:

View File

@ -0,0 +1,6 @@
******
ICMPv6
******
.. automodule:: ryu.lib.packet.icmpv6
:members:

View File

@ -0,0 +1,6 @@
****
IGMP
****
.. automodule:: ryu.lib.packet.igmp
:members:

View File

@ -0,0 +1,6 @@
****
IPv4
****
.. automodule:: ryu.lib.packet.ipv4
:members:

View File

@ -0,0 +1,6 @@
****
IPv6
****
.. automodule:: ryu.lib.packet.ipv6
:members:

View File

@ -0,0 +1,6 @@
***
LLC
***
.. automodule:: ryu.lib.packet.llc
:members:

View File

@ -0,0 +1,6 @@
****
LLDP
****
.. automodule:: ryu.lib.packet.lldp
:members:

View File

@ -0,0 +1,6 @@
****
MPLS
****
.. automodule:: ryu.lib.packet.mpls
:members:

View File

@ -0,0 +1,6 @@
********
OpenFlow
********
.. automodule:: ryu.lib.packet.openflow
:members:

View File

@ -0,0 +1,6 @@
****
OSPF
****
.. automodule:: ryu.lib.packet.ospf
:members:

View File

@ -0,0 +1,6 @@
***
PBB
***
.. automodule:: ryu.lib.packet.pbb
:members:

View File

@ -0,0 +1,6 @@
****
SCTP
****
.. automodule:: ryu.lib.packet.sctp
:members:

View File

@ -0,0 +1,6 @@
****
Slow
****
.. automodule:: ryu.lib.packet.slow
:members:

View File

@ -0,0 +1,6 @@
***
TCP
***
.. automodule:: ryu.lib.packet.tcp
:members:

View File

@ -0,0 +1,6 @@
***
UDP
***
.. automodule:: ryu.lib.packet.udp
:members:

View File

@ -0,0 +1,6 @@
****
VLAN
****
.. automodule:: ryu.lib.packet.vlan
:members:

View File

@ -0,0 +1,6 @@
****
VRRP
****
.. automodule:: ryu.lib.packet.vrrp
:members:

View File

@ -0,0 +1,6 @@
*****
VXLAN
*****
.. automodule:: ryu.lib.packet.vxlan
:members:

View File

@ -0,0 +1,6 @@
*****
Zebra
*****
.. automodule:: ryu.lib.packet.zebra
:members:

View File

@ -0,0 +1,27 @@
*****************
PCAP file library
*****************
Introduction
============
Ryu PCAP file library helps you to read/write PCAP file which file
format are described in `The Wireshark Wiki`_.
.. _The Wireshark Wiki: https://wiki.wireshark.org/Development/LibpcapFileFormat
Reading PCAP file
=================
For loading the packet data containing in PCAP files, you can use
pcaplib.Reader.
.. autoclass:: ryu.lib.pcaplib.Reader
Writing PCAP file
=================
For dumping the packet data which your RyuApp received, you can use
pcaplib.Writer.
.. autoclass:: ryu.lib.pcaplib.Writer

View File

@ -7,25 +7,63 @@ Nicira Extension Structures
Nicira Extension Actions Structures
===================================
The followings shows the supported NXAction classes in OF1.3,
but also available in OF1.2+.
The followings shows the supported NXAction classes only in OpenFlow1.0
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. py:currentmodule:: ryu.ofproto.ofproto_v1_0_parser
.. autoclass:: NXActionSetQueue
.. autoclass:: NXActionDecTtl
.. autoclass:: NXActionPushMpls
.. autoclass:: NXActionPopMpls
.. autoclass:: NXActionSetMplsTtl
.. autoclass:: NXActionDecMplsTtl
.. autoclass:: NXActionSetMplsLabel
.. autoclass:: NXActionSetMplsTc
The followings shows the supported NXAction classes in OpenFlow1.0 or later
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. py:currentmodule:: ryu.ofproto.ofproto_v1_3_parser
.. autoclass:: NXActionPopQueue
.. autoclass:: NXActionRegLoad
.. autoclass:: NXActionRegLoad2
.. autoclass:: NXActionNote
.. autoclass:: NXActionSetTunnel
.. autoclass:: NXActionSetTunnel64
.. autoclass:: NXActionRegMove
.. autoclass:: NXActionLearn
.. autoclass:: NXActionConjunction
.. autoclass:: NXActionResubmit
.. autoclass:: NXActionResubmitTable
.. autoclass:: NXActionOutputReg
.. autoclass:: NXActionOutputReg2
.. autoclass:: NXActionLearn
.. autoclass:: NXActionExit
.. autoclass:: NXActionController
.. autoclass:: NXActionController2
.. autoclass:: NXActionDecTtlCntIds
.. autoclass:: NXActionStackPush
.. autoclass:: NXActionStackPop
.. autoclass:: NXActionSample
.. autoclass:: NXActionSample2
.. autoclass:: NXActionFinTimeout
.. autoclass:: NXActionConjunction
.. autoclass:: NXActionMultipath
.. autoclass:: NXActionBundle
.. autoclass:: NXActionBundleLoad
.. autoclass:: NXActionCT
.. autoclass:: NXActionNAT
.. autoclass:: NXActionOutputTrunc
.. autoclass:: NXActionDecNshTtl
.. autoclass:: NXFlowSpecMatch
.. autoclass:: NXFlowSpecLoad
.. autoclass:: NXFlowSpecOutput
.. autofunction:: ryu.ofproto.nicira_ext.ofs_nbits
.. _nx_match_structures:
Nicira Extended Match Structures
================================
.. automodule:: ryu.ofproto.nx_match
.. automodule:: ryu.ofproto.nicira_ext

View File

@ -11,7 +11,7 @@ Threads, events, and event queues
Ryu applications are single-threaded entities which implement
various functionalities in Ryu. Events are messages between them.
Ryu applications send asynchronous events each other.
Ryu applications send asynchronous events to each other.
Besides that, there are some Ryu-internal event sources which
are not Ryu applications. One of examples of such event sources
is OpenFlow controller.
@ -22,11 +22,11 @@ between Ryu applications.
Each Ryu application has a receive queue for events.
The queue is FIFO and preserves the order of events.
Each Ryu application has a thread for event processing.
The thread keep draining the receive queue by dequeueing an event
The thread keeps draining the receive queue by dequeueing an event
and calling the appropritate event handler for the event type.
Because the event handler is called in the context of
the event processing thread, it should be careful for blocking.
I.e. while an event handler is blocked, no further events for
the event processing thread, it should be careful when blocking.
While an event handler is blocked, no further events for
the Ryu application will be processed.
There are kinds of events which are used to implement synchronous
@ -82,20 +82,10 @@ For example, EventOFPPacketIn for packet-in message.
The OpenFlow controller part of Ryu automatically decodes OpenFlow messages
received from switches and send these events to Ryu applications which
expressed an interest using ryu.controller.handler.set_ev_cls.
OpenFlow event classes have at least the following attributes.
OpenFlow event classes are subclasses of the following class.
.. tabularcolumns:: |l|L|
.. autoclass:: ryu.controller.ofp_event.EventOFPMsgBase
============ =============================================================
Attribute Description
============ =============================================================
msg An object which describes the corresponding OpenFlow message.
msg.datapath A ryu.controller.controller.Datapath instance which describes
an OpenFlow switch from which we received this OpenFlow message.
============ =============================================================
The msg object has some more additional members whose values are extracted
from the original OpenFlow message.
See :ref:`ofproto_ref` for more info about OpenFlow messages.
ryu.base.app_manager.RyuApp
@ -103,267 +93,87 @@ ryu.base.app_manager.RyuApp
See :ref:`api_ref`.
ryu.controller.handler.set_ev_cls(ev_cls, dispatchers=None)
===========================================================
ryu.controller.handler.set_ev_cls
=================================
A decorator for Ryu application to declare an event handler.
Decorated method will become an event handler.
ev_cls is an event class whose instances this RyuApp wants to receive.
dispatchers argument specifies one of the following negotiation phases
(or a list of them) for which events should be generated for this handler.
Note that, in case an event changes the phase, the phase before the change
is used to check the interest.
.. tabularcolumns:: |l|L|
=========================================== ==================================
Negotiation phase Description
=========================================== ==================================
ryu.controller.handler.HANDSHAKE_DISPATCHER Sending and waiting for hello
message
ryu.controller.handler.CONFIG_DISPATCHER Version negotiated and sent
features-request message
ryu.controller.handler.MAIN_DISPATCHER Switch-features message received
and sent set-config message
ryu.controller.handler.DEAD_DISPATCHER Disconnect from the peer. Or
disconnecting due to some
unrecoverable errors.
=========================================== ==================================
.. autofunction:: ryu.controller.handler.set_ev_cls
ryu.controller.controller.Datapath
==================================
A class to describe an OpenFlow switch connected to this controller.
An instance has the following attributes.
.. tabularcolumns:: |l|L|
====================================== =======================================
Attribute Description
====================================== =======================================
id 64-bit OpenFlow Datapath ID.
Only available for
ryu.controller.handler.MAIN_DISPATCHER
phase.
ofproto A module which exports OpenFlow
definitions, mainly constants appeared
in the specification, for the
negotiated OpenFlow version. For
example, ryu.ofproto.ofproto_v1_0 for
OpenFlow 1.0.
ofproto_parser A module which exports OpenFlow wire
message encoder and decoder for the
negotiated OpenFlow version. For
example, ryu.ofproto.ofproto_v1_0_parser
for OpenFlow 1.0.
ofproto_parser.OFPxxxx(datapath, ....) A callable to prepare an OpenFlow
message for the given switch. It can
be sent with Datapath.send_msg later.
xxxx is a name of the message. For
example OFPFlowMod for flow-mod
message. Arguemnts depend on the
message.
set_xid(self, msg) Generate an OpenFlow XID and put it
in msg.xid.
send_msg(self, msg) Queue an OpenFlow message to send to
the corresponding switch. If msg.xid
is None, set_xid is automatically
called on the message before queueing.
send_packet_out deprecated
send_flow_mod deprecated
send_flow_del deprecated
send_delete_all_flows deprecated
send_barrier Queue an OpenFlow barrier message to
send to the switch.
send_nxt_set_flow_format deprecated
is_reserved_port deprecated
====================================== =======================================
.. autoclass:: ryu.controller.controller.Datapath
ryu.controller.event.EventBase
==============================
The base of all event classes.
A Ryu application can define its own event type by creating a subclass.
.. autoclass:: ryu.controller.event.EventBase
ryu.controller.event.EventRequestBase
=====================================
The base class for synchronous request for RyuApp.send_request.
.. autoclass:: ryu.controller.event.EventRequestBase
ryu.controller.event.EventReplyBase
===================================
The base class for synchronous request reply for RyuApp.send_reply.
.. autoclass:: ryu.controller.event.EventReplyBase
ryu.controller.ofp_event.EventOFPStateChange
============================================
An event class for negotiation phase change notification.
An instance of this class is sent to observer after changing
the negotiation phase.
An instance has at least the following attributes.
.. autoclass:: ryu.controller.ofp_event.EventOFPStateChange
========= ====================================================================
Attribute Description
========= ====================================================================
datapath ryu.controller.controller.Datapath instance of the switch
========= ====================================================================
ryu.controller.ofp_event.EventOFPPortStateChange
================================================
.. autoclass:: ryu.controller.ofp_event.EventOFPPortStateChange
ryu.controller.dpset.EventDP
============================
An event class to notify connect/disconnect of a switch.
For OpenFlow switches, one can get the same notification by observing
ryu.controller.ofp_event.EventOFPStateChange.
An instance has at least the following attributes.
========= ====================================================================
Attribute Description
========= ====================================================================
dp A ryu.controller.controller.Datapath instance of the switch
enter True when the switch connected to our controller. False for
disconnect.
========= ====================================================================
.. autoclass:: ryu.controller.dpset.EventDP
ryu.controller.dpset.EventPortAdd
=================================
An event class for switch port status notification.
This event is generated when a new port is added to a switch.
For OpenFlow switches, one can get the same notification by observing
ryu.controller.ofp_event.EventOFPPortStatus.
An instance has at least the following attributes.
========= ====================================================================
Attribute Description
========= ====================================================================
dp A ryu.controller.controller.Datapath instance of the switch
port port number
========= ====================================================================
.. autoclass:: ryu.controller.dpset.EventPortAdd
ryu.controller.dpset.EventPortDelete
====================================
An event class for switch port status notification.
This event is generated when a port is removed from a switch.
For OpenFlow switches, one can get the same notification by observing
ryu.controller.ofp_event.EventOFPPortStatus.
An instance has at least the following attributes.
========= ====================================================================
Attribute Description
========= ====================================================================
dp A ryu.controller.controller.Datapath instance of the switch
port port number
========= ====================================================================
.. autoclass:: ryu.controller.dpset.EventPortDelete
ryu.controller.dpset.EventPortModify
====================================
An event class for switch port status notification.
This event is generated when some attribute of a port is changed.
For OpenFlow switches, one can get the same notification by observing
ryu.controller.ofp_event.EventOFPPortStatus.
An instance has at least the following attributes.
========= ====================================================================
Attribute Description
========= ====================================================================
dp A ryu.controller.controller.Datapath instance of the switch
port port number
========= ====================================================================
.. autoclass:: ryu.controller.dpset.EventPortModify
ryu.controller.network.EventNetworkPort
=======================================
An event class for notification of port arrival and deperture.
This event is generated when a port is introduced to or removed from a network
by the REST API.
An instance has at least the following attributes.
========== ===================================================================
Attribute Description
========== ===================================================================
network_id Network ID
dpid OpenFlow Datapath ID of the switch to which the port belongs.
port_no OpenFlow port number of the port
add_del True for adding a port. False for removing a port.
========== ===================================================================
.. autoclass:: ryu.controller.network.EventNetworkPort
ryu.controller.network.EventNetworkDel
======================================
An event class for network deletion.
This event is generated when a network is deleted by the REST API.
An instance has at least the following attributes.
========== ===================================================================
Attribute Description
========== ===================================================================
network_id Network ID
========== ===================================================================
.. autoclass:: ryu.controller.network.EventNetworkDel
ryu.controller.network.EventMacAddress
======================================
An event class for end-point MAC address registration.
This event is generated when a end-point MAC address is updated
by the REST API.
An instance has at least the following attributes.
=========== ==================================================================
Attribute Description
=========== ==================================================================
network_id Network ID
dpid OpenFlow Datapath ID of the switch to which the port belongs.
port_no OpenFlow port number of the port
mac_address The old MAC address of the port if add_del is False. Otherwise
the new MAC address.
add_del False if this event is a result of a port removal. Otherwise
True.
=========== ==================================================================
.. autoclass:: ryu.controller.network.EventMacAddress
ryu.controller.tunnels.EventTunnelKeyAdd
========================================
An event class for tunnel key registration.
This event is generated when a tunnel key is registered or updated
by the REST API.
An instance has at least the following attributes.
=========== ==================================================================
Attribute Description
=========== ==================================================================
network_id Network ID
tunnel_key Tunnel Key
=========== ==================================================================
.. autoclass:: ryu.controller.tunnels.EventTunnelKeyAdd
ryu.controller.tunnels.EventTunnelKeyDel
========================================
An event class for tunnel key registration.
This event is generated when a tunnel key is removed by the REST API.
An instance has at least the following attributes.
=========== ==================================================================
Attribute Description
=========== ==================================================================
network_id Network ID
tunnel_key Tunnel Key
=========== ==================================================================
.. autoclass:: ryu.controller.tunnels.EventTunnelKeyDel
ryu.controller.tunnels.EventTunnelPort
======================================
An event class for tunnel port registration.
This event is generated when a tunnel port is added or removed by the REST API.
An instance has at least the following attributes.
=========== ==================================================================
Attribute Description
=========== ==================================================================
dpid OpenFlow Datapath ID
port_no OpenFlow port number
remote_dpid OpenFlow port number of the tunnel peer
add_del True for adding a tunnel. False for removal.
=========== ==================================================================
.. autoclass:: ryu.controller.tunnels.EventTunnelPort

View File

@ -19,7 +19,7 @@ The test procedure
* run LINC switch
* run Ryu test_of_config app
For getting/installing Ryu itself, please refer to http://osrg.github.io/ryu/
For getting/installing Ryu itself, please refer to https://ryu-sdn.org/
Install Erlang environment

View File

@ -4,10 +4,17 @@
Using Ryu Network Operating System with OpenStack as OpenFlow controller
************************************************************************
.. CAUTION::
The Ryu plugin and OFAgent described in the following is deprecated,
because Ryu is officially integrated into Open vSwitch agent with
"of_interface = native" mode.
Ryu cooperates with OpenStack using Quantum Ryu plugin. The plugin is
available in the official Quantum releases.
For more information, please visit http://github.com/osrg/ryu/wiki/OpenStack .
For more information, please visit https://github.com/faucetsdn/ryu/wiki/OpenStack .
We described instructions of the installation / configuration of OpenStack
with Ryu, and we provide pre-configured VM image to be able to easily try
OpenStack with Ryu.

View File

@ -5,21 +5,21 @@ The First Application
Whetting Your Appetite
======================
If you want to manage the network gears (switches, routers, etc) at
your way, you need to write your Ryu application. Your application
tells Ryu how you want to manage the gears. Then Ryu configures the
gears by using OpenFlow protocol, etc.
If you want to manage network gear (switches, routers, etc) your
own way, you just need to write your own Ryu application. Your application
tells Ryu how you want to manage the gear. Then Ryu configures the
gear by using OpenFlow protocol, etc.
Writing Ryu application is easy. It's just Python scripts.
Writing Ryu applications is easy. They're just Python scripts.
Start Writing
=============
We show a Ryu application that make OpenFlow switches work as a dumb
Here we show a Ryu application that makes an OpenFlow switch work as a dumb
layer 2 switch.
Open a text editor creating a new file with the following content:
Open a text editor and create a new file with the following content:
.. code-block:: python
@ -29,9 +29,9 @@ Open a text editor creating a new file with the following content:
def __init__(self, *args, **kwargs):
super(L2Switch, self).__init__(*args, **kwargs)
Ryu application is just a Python script so you can save the file with
any name, extensions, and any place you want. Let's name the file
'l2.py' at your home directory.
Ryu applications are just Python scripts so you can save the file with
any name, any extension, and any place you want. Let's name the file
'l2.py' in your home directory.
This application does nothing useful yet, however it's a complete Ryu
application. In fact, you can run this Ryu application::
@ -41,10 +41,10 @@ application. In fact, you can run this Ryu application::
instantiating app /Users/fujita/l2.py
All you have to do is defining needs a new subclass of RyuApp to run
All you have to do is define a new subclass of RyuApp to run
your Python script as a Ryu application.
Next let's add the functionality of sending a received packet to all
Next let's add some functionality that sends a received packet to all
the ports.
.. code-block:: python
@ -53,8 +53,11 @@ the ports.
from ryu.controller import ofp_event
from ryu.controller.handler import MAIN_DISPATCHER
from ryu.controller.handler import set_ev_cls
from ryu.ofproto import ofproto_v1_0
class L2Switch(app_manager.RyuApp):
OFP_VERSIONS = [ofproto_v1_0.OFP_VERSION]
def __init__(self, *args, **kwargs):
super(L2Switch, self).__init__(*args, **kwargs)
@ -64,26 +67,31 @@ the ports.
dp = msg.datapath
ofp = dp.ofproto
ofp_parser = dp.ofproto_parser
actions = [ofp_parser.OFPActionOutput(ofp.OFPP_FLOOD)]
data = None
if msg.buffer_id == ofp.OFP_NO_BUFFER:
data = msg.data
out = ofp_parser.OFPPacketOut(
datapath=dp, buffer_id=msg.buffer_id, in_port=msg.in_port,
actions=actions)
actions=actions, data = data)
dp.send_msg(out)
A new method 'packet_in_handler' is added to L2Switch class. This is
called when Ryu receives an OpenFlow packet_in message. The trick is
A new method 'packet_in_handler' is added to the L2Switch class. This is
called when Ryu receives an OpenFlow packet_in message. The trick is the
'set_ev_cls' decorator. This decorator tells Ryu when the decorated
function should be called.
The first argument of the decorator indicates an event that makes
function called. As you expect easily, every time Ryu gets a
The first argument of the decorator indicates which type of event this
function should be called for. As you might expect, every time Ryu gets a
packet_in message, this function is called.
The second argument indicates the state of the switch. Probably, you
The second argument indicates the state of the switch. You probably
want to ignore packet_in messages before the negotiation between Ryu
and the switch finishes. Using 'MAIN_DISPATCHER' as the second
and the switch is finished. Using 'MAIN_DISPATCHER' as the second
argument means this function is called only after the negotiation
completes.
@ -100,24 +108,24 @@ Ready for the second half.
* OFPActionOutput class is used with a packet_out message to specify a
switch port that you want to send the packet out of. This
application need a switch to send out of all the ports so OFPP_FLOOD
constant is used.
application uses the OFPP_FLOOD flag to indicate that the packet should
be sent out on all ports.
* OFPPacketOut class is used to build a packet_out message.
* If you call Datapath class's send_msg method with a OpenFlow message
class object, Ryu builds and send the on-wire data format to the switch.
class object, Ryu builds and sends the on-wire data format to the switch.
Here, you finished implementing your first Ryu application. You are ready to
run this Ryu application that does something useful.
There, you finished implementing your first Ryu application. You are ready to
run a Ryu application that does something useful.
A dumb l2 switch is too dumb? You want to implement a learning l2
Is a dumb L2 switch is too dumb? You want to implement a learning L2
switch? Move to `the next step
<https://github.com/osrg/ryu/blob/master/ryu/app/simple_switch.py>`_. You
<https://github.com/faucetsdn/ryu/blob/master/ryu/app/simple_switch.py>`_. You
can learn from the existing Ryu applications at `ryu/app
<https://github.com/osrg/ryu/blob/master/ryu/app/>`_ directory and
<https://github.com/faucetsdn/ryu/blob/master/ryu/app/>`_ directory and
`integrated tests
<https://github.com/osrg/ryu/blob/master/ryu/tests/integrated/>`_
<https://github.com/faucetsdn/ryu/blob/master/ryu/tests/integrated/>`_
directory.

1
pip-requirements.txt Normal file
View File

@ -0,0 +1 @@
pip==20.3.4

View File

@ -8,16 +8,16 @@ usage() {
echo "Usage: $0 [OPTION]..."
echo "Run Ryu's test suite(s)"
echo ""
echo " -V, --virtual-env Always use virtualenv. Install automatically if not present"
echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local environment"
echo " -c, --coverage Generate coverage report"
echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added."
echo " -p, --pep8 Just run pep8"
echo " -P, --no-pep8 Don't run pep8"
echo " -l, --pylint Just run pylint"
echo " -i, --integrated Run integrated test"
echo " -v, --verbose Run verbose pylint analysis"
echo " -h, --help Print this usage message"
echo " -V, --virtual-env Always use virtualenv. Install automatically if not present"
echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local environment"
echo " -c, --coverage Generate coverage report"
echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added."
echo " -p, --pycodestyle, --pep8 Just run pycodestyle(pep8)"
echo " -P, --no-pycodestyle, --no-pep8 Don't run pycodestyle(pep8)"
echo " -l, --pylint Just run pylint"
echo " -i, --integrated Run integrated test"
echo " -v, --verbose Run verbose pylint analysis"
echo " -h, --help Print this usage message"
echo ""
echo "Note: with no options specified, the script will try to run the tests in a virtual environment,"
echo " If no virtualenv is found, the script will ask if you would like to create one. If you "
@ -31,8 +31,8 @@ process_option() {
-V|--virtual-env) always_venv=1; never_venv=0;;
-N|--no-virtual-env) always_venv=0; never_venv=1;;
-f|--force) force=1;;
-p|--pep8) just_pep8=1; never_venv=1; always_venv=0;;
-P|--no-pep8) no_pep8=1;;
-p|--pycodestyle|--pep8) just_pycodestyle=1; never_venv=1; always_venv=0;;
-P|--no-pycodestyle|--no-pep8) no_pycodestyle=1;;
-l|--pylint) just_pylint=1;;
-i|--integrated) integrated=1;;
-c|--coverage) coverage=1;;
@ -46,8 +46,8 @@ venv=.venv
with_venv=tools/with_venv.sh
always_venv=0
never_venv=0
just_pep8=0
no_pep8=0
just_pycodestyle=0
no_pycodestyle=0
just_pylint=0
integrated=0
force=0
@ -103,20 +103,26 @@ run_pylint() {
export PYTHONPATH=$OLD_PYTHONPATH
}
run_pep8() {
echo "Running pep8 ..."
run_pycodestyle() {
PYCODESTYLE=$(which pycodestyle || which pep8)
if [ -z "${PYCODESTYLE}" ]
then
echo "Please install pycodestyle or pep8"
return 1
fi
echo "Running $(basename ${PYCODESTYLE}) ..."
PEP8_OPTIONS="--repeat --show-source"
PEP8_INCLUDE="ryu setup*.py"
PEP8_LOG=pep8.log
${wrapper} pep8 $PEP8_OPTIONS $PEP8_INCLUDE | tee $PEP8_LOG
PYCODESTYLE_OPTIONS="--repeat --show-source"
PYCODESTYLE_INCLUDE="ryu setup*.py"
PYCODESTYLE_LOG=pycodestyle.log
${wrapper} ${PYCODESTYLE} $PYCODESTYLE_OPTIONS $PYCODESTYLE_INCLUDE | tee $PYCODESTYLE_LOG
}
run_integrated() {
echo "Running integrated test ..."
INTEGRATED_TEST_RUNNER="./ryu/tests/integrated/run_tests_with_ovs12.py"
sudo PYTHONPATH=. nosetests -s $INTEGRATED_TEST_RUNNER
sudo PYTHONPATH=. nosetests -s $INTEGRATED_TEST_RUNNER
}
#NOSETESTS="nosetests $noseopts $noseargs"
NOSETESTS="${PYTHON} ./ryu/tests/run_tests.py $noseopts $noseargs"
@ -161,8 +167,8 @@ if [ $coverage -eq 1 ]; then
${wrapper} coverage erase
fi
if [ $just_pep8 -eq 1 ]; then
run_pep8
if [ $just_pycodestyle -eq 1 ]; then
run_pycodestyle
exit
fi
if [ $just_pylint -eq 1 ]; then
@ -177,8 +183,8 @@ fi
run_tests
RV=$?
if [ $no_pep8 -eq 0 ]; then
run_pep8
if [ $no_pycodestyle -eq 0 ]; then
run_pycodestyle
fi
if [ $coverage -eq 1 ]; then

View File

@ -14,5 +14,5 @@
# limitations under the License.
version_info = (4, 2)
version_info = (4, 34)
version = '.'.join(map(str, version_info))

View File

@ -56,7 +56,7 @@ class GUIServerController(ControllerBase):
path = "%s/html/" % PATH
self.static_app = DirectoryApp(path)
@route('topology', '/{filename:.*}')
@route('topology', '/{filename:[^/]*}')
def static_handler(self, req, **kwargs):
if kwargs['filename']:
req.path_info = kwargs['filename']

View File

@ -16,22 +16,37 @@
# client for ryu.app.ofctl.service
import numbers
from ryu.base import app_manager
from . import event
def get_datapath(app, dpid):
def get_datapath(app, dpid=None):
"""
Get datapath object by dpid.
:param app: Client RyuApp instance
:param dpid: Datapath-id (in integer)
:param dpid: Datapath ID (int type) or None to get all datapath objects
Returns None on error.
Returns a object of datapath, a list of datapath objects when no dpid
given or None when error.
Raises an exception if any of the given values is invalid.
Example::
# ...(snip)...
import ryu.app.ofctl.api as ofctl_api
class MyApp(app_manager.RyuApp):
def _my_handler(self, ev):
# Get all datapath objects
result = ofctl_api.get_datapath(self)
# Get the datapath object which has the given dpid
result = ofctl_api.get_datapath(self, dpid=1)
"""
assert isinstance(dpid, numbers.Integral)
return app.send_request(event.GetDatapathRequest(dpid=dpid))()
@ -55,12 +70,19 @@ def send_msg(app, msg, reply_cls=None, reply_multi=False):
Example::
import ryu.app.ofctl.api as api
# ...(snip)...
import ryu.app.ofctl.api as ofctl_api
msg = parser.OFPPortDescStatsRequest(datapath=datapath)
result = api.send_msg(self, msg,
reply_cls=parser.OFPPortDescStatsReply,
reply_multi=True)
class MyApp(app_manager.RyuApp):
def _my_handler(self, ev):
# ...(snip)...
msg = parser.OFPPortDescStatsRequest(datapath=datapath)
result = ofctl_api.send_msg(
self, msg,
reply_cls=parser.OFPPortDescStatsReply,
reply_multi=True)
"""
return app.send_request(event.SendMsgRequest(msg=msg,
reply_cls=reply_cls,

View File

@ -33,8 +33,8 @@ class _ReplyBase(event.EventReplyBase):
# get datapath
class GetDatapathRequest(_RequestBase):
def __init__(self, dpid):
assert isinstance(dpid, numbers.Integral)
def __init__(self, dpid=None):
assert dpid is None or isinstance(dpid, numbers.Integral)
super(GetDatapathRequest, self).__init__()
self.dpid = dpid

View File

@ -64,6 +64,22 @@ class OfctlService(app_manager.RyuApp):
self.unobserve_event(ev_cls)
self.logger.debug('ofctl: stop observing %s', ev_cls)
def _cancel(self, info, barrier_xid, exception):
xid = info.barriers.pop(barrier_xid)
req = info.xids.pop(xid)
msg = req.msg
datapath = msg.datapath
parser = datapath.ofproto_parser
is_barrier = isinstance(msg, parser.OFPBarrierRequest)
info.results.pop(xid)
if not is_barrier and req.reply_cls is not None:
self._unobserve_msg(req.reply_cls)
self.logger.error('failed to send message <%s>', req.msg)
self.reply_to_request(req, event.Reply(exception=exception))
@staticmethod
def _is_error(msg):
return (ofp_event.ofp_msg_to_ev_cls(type(msg)) ==
@ -79,6 +95,11 @@ class OfctlService(app_manager.RyuApp):
self.logger.debug('add dpid %s datapath %s new_info %s old_info %s',
id, datapath, new_info, old_info)
self._switches[id] = new_info
if old_info:
old_info.datapath.close()
for xid in list(old_info.barriers):
self._cancel(
old_info, xid, exception.InvalidDatapath(result=id))
@set_ev_cls(ofp_event.EventOFPStateChange, DEAD_DISPATCHER)
def _handle_dead(self, ev):
@ -94,23 +115,25 @@ class OfctlService(app_manager.RyuApp):
if info.datapath is datapath:
self.logger.debug('forget info %s', info)
self._switches.pop(id)
for xid in list(info.barriers):
self._cancel(info, xid, exception.InvalidDatapath(result=id))
@set_ev_cls(event.GetDatapathRequest, MAIN_DISPATCHER)
def _handle_get_datapath(self, req):
id = req.dpid
assert isinstance(id, numbers.Integral)
try:
datapath = self._switches[id].datapath
except KeyError:
datapath = None
self.logger.debug('dpid %s -> datapath %s', id, datapath)
rep = event.Reply(result=datapath)
self.reply_to_request(req, rep)
result = None
if req.dpid is None:
result = [v.datapath for v in self._switches.values()]
else:
if req.dpid in self._switches:
result = self._switches[req.dpid].datapath
self.reply_to_request(req, event.Reply(result=result))
@set_ev_cls(event.SendMsgRequest, MAIN_DISPATCHER)
def _handle_send_msg(self, req):
msg = req.msg
datapath = msg.datapath
parser = datapath.ofproto_parser
is_barrier = isinstance(msg, parser.OFPBarrierRequest)
try:
si = self._switches[datapath.id]
@ -121,28 +144,40 @@ class OfctlService(app_manager.RyuApp):
self.reply_to_request(req, rep)
return
if req.reply_cls is not None:
self._observe_msg(req.reply_cls)
def _store_xid(xid, barrier_xid):
assert xid not in si.results
assert xid not in si.xids
assert barrier_xid not in si.barriers
si.results[xid] = []
si.xids[xid] = req
si.barriers[barrier_xid] = xid
datapath.set_xid(msg)
xid = msg.xid
barrier = datapath.ofproto_parser.OFPBarrierRequest(datapath)
datapath.set_xid(barrier)
barrier_xid = barrier.xid
assert xid not in si.results
assert xid not in si.xids
assert barrier_xid not in si.barriers
si.results[xid] = []
si.xids[xid] = req
si.barriers[barrier_xid] = xid
if is_barrier:
barrier = msg
datapath.set_xid(barrier)
_store_xid(barrier.xid, barrier.xid)
else:
if req.reply_cls is not None:
self._observe_msg(req.reply_cls)
datapath.set_xid(msg)
barrier = datapath.ofproto_parser.OFPBarrierRequest(datapath)
datapath.set_xid(barrier)
_store_xid(msg.xid, barrier.xid)
if not datapath.send_msg(msg):
return self._cancel(
si, barrier.xid,
exception.InvalidDatapath(result=datapath.id))
datapath.send_msg(msg)
datapath.send_msg(barrier)
if not datapath.send_msg(barrier):
return self._cancel(
si, barrier.xid,
exception.InvalidDatapath(result=datapath.id))
@set_ev_cls(ofp_event.EventOFPBarrierReply, MAIN_DISPATCHER)
def _handle_barrier(self, ev):
msg = ev.msg
datapath = msg.datapath
parser = datapath.ofproto_parser
try:
si = self._switches[datapath.id]
except KeyError:
@ -155,9 +190,12 @@ class OfctlService(app_manager.RyuApp):
return
result = si.results.pop(xid)
req = si.xids.pop(xid)
if req.reply_cls is not None:
is_barrier = isinstance(req.msg, parser.OFPBarrierRequest)
if req.reply_cls is not None and not is_barrier:
self._unobserve_msg(req.reply_cls)
if any(self._is_error(r) for r in result):
if is_barrier and req.reply_cls == parser.OFPBarrierReply:
rep = event.Reply(result=ev.msg)
elif any(self._is_error(r) for r in result):
rep = event.Reply(exception=exception.OFError(result=result))
elif req.reply_multi:
rep = event.Reply(result=result)
@ -185,7 +223,7 @@ class OfctlService(app_manager.RyuApp):
self.logger.error('unknown error xid %s', msg.xid)
return
if ((not isinstance(ev, ofp_event.EventOFPErrorMsg)) and
(req.reply_cls is None or not isinstance(ev.msg, req.reply_cls))):
(req.reply_cls is None or not isinstance(ev.msg, req.reply_cls))):
self.logger.error('unexpected reply %s for xid %s', ev, msg.xid)
return
try:

File diff suppressed because it is too large Load Diff

View File

@ -21,12 +21,12 @@ This module provides a set of REST API for switch configuration.
Used by OpenStack Ryu agent.
"""
from six.moves import http_client
import json
import logging
from webob import Response
from six.moves import http_client
from ryu.app.wsgi import ControllerBase
from ryu.app.wsgi import Response
from ryu.base import app_manager
from ryu.controller import conf_switch
from ryu.lib import dpid as dpid_lib
@ -111,7 +111,11 @@ class ConfSwitchController(ControllerBase):
def set_key(self, req, dpid, key, **_kwargs):
def _set_val(dpid, key):
val = json.loads(req.body)
try:
val = req.json if req.body else {}
except ValueError:
return Response(status=http_client.BAD_REQUEST,
body='invalid syntax %s' % req.body)
self.conf_switch.set_key(dpid, key, val)
return None

View File

@ -17,9 +17,8 @@
import logging
import json
from webob import Response
from ryu.app.wsgi import ControllerBase
from ryu.app.wsgi import Response
from ryu.app.wsgi import WSGIApplication
from ryu.base import app_manager
from ryu.controller import ofp_event
@ -492,8 +491,8 @@ class FirewallController(ControllerBase):
def _set_rule(self, req, switchid, vlan_id=VLANID_NONE):
try:
rule = json.loads(req.body)
except SyntaxError:
rule = req.json if req.body else {}
except ValueError:
FirewallController._LOGGER.debug('invalid syntax %s', req.body)
return Response(status=400)
@ -516,8 +515,8 @@ class FirewallController(ControllerBase):
def _delete_rule(self, req, switchid, vlan_id=VLANID_NONE):
try:
ruleid = json.loads(req.body)
except SyntaxError:
ruleid = req.json if req.body else {}
except ValueError:
FirewallController._LOGGER.debug('invalid syntax %s', req.body)
return Response(status=400)
@ -679,8 +678,7 @@ class Firewall(object):
def _set_log_status(self, is_enable, waiters):
if is_enable:
actions = Action.to_openflow(self.dp,
{REST_ACTION: REST_ACTION_PACKETIN})
actions = Action.to_openflow({REST_ACTION: REST_ACTION_PACKETIN})
details = 'Log collection started.'
else:
actions = []
@ -722,7 +720,7 @@ class Firewall(object):
priority = ARP_FLOW_PRIORITY
match = {REST_DL_TYPE: ether.ETH_TYPE_ARP}
action = {REST_ACTION: REST_ACTION_ALLOW}
actions = Action.to_openflow(self.dp, action)
actions = Action.to_openflow(action)
flow = self._to_of_flow(cookie=cookie, priority=priority,
match=match, actions=actions)
@ -754,7 +752,7 @@ class Firewall(object):
result = self.get_log_status(waiters)
if result[REST_LOG_STATUS] == REST_STATUS_ENABLE:
rest[REST_ACTION] = REST_ACTION_PACKETIN
actions = Action.to_openflow(self.dp, rest)
actions = Action.to_openflow(rest)
flow = self._to_of_flow(cookie=cookie, priority=priority,
match=match, actions=actions)
@ -881,7 +879,7 @@ class Firewall(object):
rule = {REST_RULE_ID: ruleid}
rule.update({REST_PRIORITY: flow[REST_PRIORITY]})
rule.update(Match.to_rest(flow))
rule.update(Action.to_rest(self.dp, flow))
rule.update(Action.to_rest(flow))
return rule
@ -1079,19 +1077,17 @@ class Match(object):
class Action(object):
@staticmethod
def to_openflow(dp, rest):
def to_openflow(rest):
value = rest.get(REST_ACTION, REST_ACTION_ALLOW)
if value == REST_ACTION_ALLOW:
out_port = dp.ofproto.OFPP_NORMAL
action = [{'type': 'OUTPUT',
'port': out_port}]
'port': 'NORMAL'}]
elif value == REST_ACTION_DENY:
action = []
elif value == REST_ACTION_PACKETIN:
out_port = dp.ofproto.OFPP_CONTROLLER
action = [{'type': 'OUTPUT',
'port': out_port,
'port': 'CONTROLLER',
'max_len': 128}]
else:
raise ValueError('Invalid action type.')
@ -1099,9 +1095,9 @@ class Action(object):
return action
@staticmethod
def to_rest(dp, openflow):
def to_rest(openflow):
if REST_ACTION in openflow:
action_allow = 'OUTPUT:%d' % dp.ofproto.OFPP_NORMAL
action_allow = 'OUTPUT:NORMAL'
if openflow[REST_ACTION] == [action_allow]:
action = {REST_ACTION: REST_ACTION_ALLOW}
else:

View File

@ -18,10 +18,11 @@ import logging
import json
import re
from webob import Response
from ryu.app import conf_switch_key as cs_key
from ryu.app.wsgi import ControllerBase, WSGIApplication, route
from ryu.app.wsgi import ControllerBase
from ryu.app.wsgi import Response
from ryu.app.wsgi import route
from ryu.app.wsgi import WSGIApplication
from ryu.base import app_manager
from ryu.controller import conf_switch
from ryu.controller import ofp_event
@ -424,7 +425,8 @@ class QoSController(ControllerBase):
@staticmethod
def delete_ovsdb_addr(dpid):
ofs = QoSController._OFS_LIST.get(dpid, None)
ofs.set_ovsdb_addr(dpid, None)
if ofs is not None:
ofs.set_ovsdb_addr(dpid, None)
@route('qos_switch', BASE_URL + '/queue/{switchid}',
methods=['GET'], requirements=REQUIREMENTS)
@ -506,8 +508,8 @@ class QoSController(ControllerBase):
def _access_switch(self, req, switchid, vlan_id, func, waiters):
try:
rest = json.loads(req.body) if req.body else {}
except SyntaxError:
rest = req.json if req.body else {}
except ValueError:
QoSController._LOGGER.debug('invalid syntax %s', req.body)
return Response(status=400)
@ -556,6 +558,22 @@ class QoS(object):
self.vlan_list[VLANID_NONE] = 0 # for VLAN=None
self.dp = dp
self.version = dp.ofproto.OFP_VERSION
# Dictionary of port name to Queue config.
# e.g.)
# self.queue_list = {
# "s1-eth1": {
# "0": {
# "config": {
# "max-rate": "600000"
# }
# },
# "1": {
# "config": {
# "min-rate": "900000"
# }
# }
# }
# }
self.queue_list = {}
self.CONF = CONF
self.ovsdb_addr = None
@ -583,25 +601,22 @@ class QoS(object):
self.ofctl.mod_flow_entry(self.dp, flow, cmd)
def set_ovsdb_addr(self, dpid, ovsdb_addr):
# easy check if the address format valid
_proto, _host, _port = ovsdb_addr.split(':')
old_address = self.ovsdb_addr
if old_address == ovsdb_addr:
return
if ovsdb_addr is None:
elif ovsdb_addr is None:
# Determine deleting OVSDB address was requested.
if self.ovs_bridge:
self.ovs_bridge.del_controller()
self.ovs_bridge = None
return
ovs_bridge = bridge.OVSBridge(self.CONF, dpid, ovsdb_addr)
try:
ovs_bridge.init()
except:
raise ValueError('ovsdb addr is not available.')
self.ovsdb_addr = ovsdb_addr
if self.ovs_bridge is None:
ovs_bridge = bridge.OVSBridge(self.CONF, dpid, ovsdb_addr)
self.ovs_bridge = ovs_bridge
try:
ovs_bridge.init()
except:
raise ValueError('ovsdb addr is not available.')
self.ovs_bridge = ovs_bridge
def _update_vlan_list(self, vlan_list):
for vlan_id in self.vlan_list.keys():
@ -664,7 +679,15 @@ class QoS(object):
'details': 'ovs_bridge is not exists'}
return REST_COMMAND_RESULT, msg
self.queue_list.clear()
port_name = rest.get(REST_PORT_NAME, None)
vif_ports = self.ovs_bridge.get_port_name_list()
if port_name is not None:
if port_name not in vif_ports:
raise ValueError('%s port is not exists' % port_name)
vif_ports = [port_name]
queue_list = {}
queue_type = rest.get(REST_QUEUE_TYPE, 'linux-htb')
parent_max_rate = rest.get(REST_QUEUE_MAX_RATE, None)
queues = rest.get(REST_QUEUES, [])
@ -682,17 +705,9 @@ class QoS(object):
config['min-rate'] = min_rate
if len(config):
queue_config.append(config)
self.queue_list[queue_id] = {'config': config}
queue_list[queue_id] = {'config': config}
queue_id += 1
port_name = rest.get(REST_PORT_NAME, None)
vif_ports = self.ovs_bridge.get_port_name_list()
if port_name is not None:
if port_name not in vif_ports:
raise ValueError('%s port is not exists' % port_name)
vif_ports = [port_name]
for port_name in vif_ports:
try:
self.ovs_bridge.set_qos(port_name, type=queue_type,
@ -700,9 +715,10 @@ class QoS(object):
queues=queue_config)
except Exception as msg:
raise ValueError(msg)
self.queue_list[port_name] = queue_list
msg = {'result': 'success',
'details': self.queue_list}
'details': queue_list}
return REST_COMMAND_RESULT, msg
@ -717,9 +733,9 @@ class QoS(object):
@rest_command
def delete_queue(self, rest, vlan_id):
self.queue_list.clear()
if self._delete_queue():
msg = 'success'
self.queue_list.clear()
else:
msg = 'failure'
@ -1127,20 +1143,20 @@ class Match(object):
class Action(object):
@staticmethod
def to_rest(openflow):
if REST_ACTION in openflow:
def to_rest(flow):
if REST_ACTION in flow:
actions = []
for action in openflow[REST_ACTION]:
field_value = re.search('SET_FIELD: {ip_dscp:(\d+)', action)
for act in flow[REST_ACTION]:
field_value = re.search(r'SET_FIELD: \{ip_dscp:(\d+)', act)
if field_value:
actions.append({REST_ACTION_MARK: field_value.group(1)})
meter_value = re.search('METER:(\d+)', action)
meter_value = re.search(r'METER:(\d+)', act)
if meter_value:
actions.append({REST_ACTION_METER: meter_value.group(1)})
queue_value = re.search('SET_QUEUE:(\d+)', action)
queue_value = re.search(r'SET_QUEUE:(\d+)', act)
if queue_value:
actions.append({REST_ACTION_QUEUE: queue_value.group(1)})
action = {REST_ACTION: actions}
action = {REST_ACTION: actions}
else:
action = {REST_ACTION: 'Unknown action type.'}

View File

@ -20,9 +20,9 @@ import socket
import struct
import json
from webob import Response
from ryu.app.wsgi import ControllerBase
from ryu.app.wsgi import Response
from ryu.app.wsgi import WSGIApplication
from ryu.base import app_manager
from ryu.controller import dpset
@ -40,6 +40,7 @@ from ryu.lib.packet import ethernet
from ryu.lib.packet import icmp
from ryu.lib.packet import ipv4
from ryu.lib.packet import packet
from ryu.lib.packet import packet_base
from ryu.lib.packet import tcp
from ryu.lib.packet import udp
from ryu.lib.packet import vlan
@ -376,42 +377,45 @@ class RouterController(ControllerBase):
@rest_command
def get_data(self, req, switch_id, **_kwargs):
return self._access_router(switch_id, VLANID_NONE,
'get_data', req.body)
'get_data', req)
# GET /router/{switch_id}/{vlan_id}
@rest_command
def get_vlan_data(self, req, switch_id, vlan_id, **_kwargs):
return self._access_router(switch_id, vlan_id,
'get_data', req.body)
'get_data', req)
# POST /router/{switch_id}
@rest_command
def set_data(self, req, switch_id, **_kwargs):
return self._access_router(switch_id, VLANID_NONE,
'set_data', req.body)
'set_data', req)
# POST /router/{switch_id}/{vlan_id}
@rest_command
def set_vlan_data(self, req, switch_id, vlan_id, **_kwargs):
return self._access_router(switch_id, vlan_id,
'set_data', req.body)
'set_data', req)
# DELETE /router/{switch_id}
@rest_command
def delete_data(self, req, switch_id, **_kwargs):
return self._access_router(switch_id, VLANID_NONE,
'delete_data', req.body)
'delete_data', req)
# DELETE /router/{switch_id}/{vlan_id}
@rest_command
def delete_vlan_data(self, req, switch_id, vlan_id, **_kwargs):
return self._access_router(switch_id, vlan_id,
'delete_data', req.body)
'delete_data', req)
def _access_router(self, switch_id, vlan_id, func, rest_param):
def _access_router(self, switch_id, vlan_id, func, req):
rest_message = []
routers = self._get_router(switch_id)
param = json.loads(rest_param) if rest_param else {}
try:
param = req.json if req.body else {}
except ValueError:
raise SyntaxError('invalid syntax %s', req.body)
for router in routers.values():
function = getattr(router, func)
data = function(vlan_id, param, self.waiters)
@ -566,7 +570,8 @@ class Router(dict):
# TODO: Packet library convert to string
# self.logger.debug('Packet in = %s', str(pkt), self.sw_id)
header_list = dict((p.protocol_name, p)
for p in pkt.protocols if type(p) != str)
for p in pkt.protocols
if isinstance(p, packet_base.PacketBase))
if header_list:
# Check vlan-tag
vlan_id = VLANID_NONE
@ -1005,14 +1010,14 @@ class VlanRouter(object):
else:
if header_list[ARP].opcode == arp.ARP_REQUEST:
# ARP request to router port -> send ARP reply
src_mac = header_list[ARP].src_mac
dst_mac = self.port_data[in_port].mac
src_mac = self.port_data[in_port].mac
dst_mac = header_list[ARP].src_mac
arp_target_mac = dst_mac
output = in_port
in_port = self.ofctl.dp.ofproto.OFPP_CONTROLLER
self.ofctl.send_arp(arp.ARP_REPLY, self.vlan_id,
dst_mac, src_mac, dst_ip, src_ip,
src_mac, dst_mac, dst_ip, src_ip,
arp_target_mac, in_port, output)
log_msg = 'Receive ARP request from [%s] to router port [%s].'

View File

@ -14,9 +14,11 @@
# limitations under the License.
import json
from webob import Response
from ryu.app.wsgi import ControllerBase, WSGIApplication, route
from ryu.app.wsgi import ControllerBase
from ryu.app.wsgi import Response
from ryu.app.wsgi import route
from ryu.app.wsgi import WSGIApplication
from ryu.base import app_manager
from ryu.lib import dpid as dpid_lib
from ryu.topology.api import get_switch, get_link, get_host

1842
ryu/app/rest_vtep.py Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,95 @@
# Copyright (C) 2016 Nippon Telegraph and Telephone Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from operator import attrgetter
from ryu.app import simple_switch_13
from ryu.controller import ofp_event
from ryu.controller.handler import MAIN_DISPATCHER, DEAD_DISPATCHER
from ryu.controller.handler import set_ev_cls
from ryu.lib import hub
class SimpleMonitor13(simple_switch_13.SimpleSwitch13):
def __init__(self, *args, **kwargs):
super(SimpleMonitor13, self).__init__(*args, **kwargs)
self.datapaths = {}
self.monitor_thread = hub.spawn(self._monitor)
@set_ev_cls(ofp_event.EventOFPStateChange,
[MAIN_DISPATCHER, DEAD_DISPATCHER])
def _state_change_handler(self, ev):
datapath = ev.datapath
if ev.state == MAIN_DISPATCHER:
if datapath.id not in self.datapaths:
self.logger.debug('register datapath: %016x', datapath.id)
self.datapaths[datapath.id] = datapath
elif ev.state == DEAD_DISPATCHER:
if datapath.id in self.datapaths:
self.logger.debug('unregister datapath: %016x', datapath.id)
del self.datapaths[datapath.id]
def _monitor(self):
while True:
for dp in self.datapaths.values():
self._request_stats(dp)
hub.sleep(10)
def _request_stats(self, datapath):
self.logger.debug('send stats request: %016x', datapath.id)
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
req = parser.OFPFlowStatsRequest(datapath)
datapath.send_msg(req)
req = parser.OFPPortStatsRequest(datapath, 0, ofproto.OFPP_ANY)
datapath.send_msg(req)
@set_ev_cls(ofp_event.EventOFPFlowStatsReply, MAIN_DISPATCHER)
def _flow_stats_reply_handler(self, ev):
body = ev.msg.body
self.logger.info('datapath '
'in-port eth-dst '
'out-port packets bytes')
self.logger.info('---------------- '
'-------- ----------------- '
'-------- -------- --------')
for stat in sorted([flow for flow in body if flow.priority == 1],
key=lambda flow: (flow.match['in_port'],
flow.match['eth_dst'])):
self.logger.info('%016x %8x %17s %8x %8d %8d',
ev.msg.datapath.id,
stat.match['in_port'], stat.match['eth_dst'],
stat.instructions[0].actions[0].port,
stat.packet_count, stat.byte_count)
@set_ev_cls(ofp_event.EventOFPPortStatsReply, MAIN_DISPATCHER)
def _port_stats_reply_handler(self, ev):
body = ev.msg.body
self.logger.info('datapath port '
'rx-pkts rx-bytes rx-error '
'tx-pkts tx-bytes tx-error')
self.logger.info('---------------- -------- '
'-------- -------- -------- '
'-------- -------- --------')
for stat in sorted(body, key=attrgetter('port_no')):
self.logger.info('%016x %8x %8d %8d %8d %8d %8d %8d',
ev.msg.datapath.id, stat.port_no,
stat.rx_packets, stat.rx_bytes, stat.rx_errors,
stat.tx_packets, stat.tx_bytes, stat.tx_errors)

View File

@ -36,11 +36,12 @@ class SimpleSwitch(app_manager.RyuApp):
super(SimpleSwitch, self).__init__(*args, **kwargs)
self.mac_to_port = {}
def add_flow(self, datapath, in_port, dst, actions):
def add_flow(self, datapath, in_port, dst, src, actions):
ofproto = datapath.ofproto
match = datapath.ofproto_parser.OFPMatch(
in_port=in_port, dl_dst=haddr_to_bin(dst))
in_port=in_port,
dl_dst=haddr_to_bin(dst), dl_src=haddr_to_bin(src))
mod = datapath.ofproto_parser.OFPFlowMod(
datapath=datapath, match=match, cookie=0,
@ -81,7 +82,7 @@ class SimpleSwitch(app_manager.RyuApp):
# install a flow to avoid packet_in next time
if out_port != ofproto.OFPP_FLOOD:
self.add_flow(datapath, msg.in_port, dst, actions)
self.add_flow(datapath, msg.in_port, dst, src, actions)
data = None
if msg.buffer_id == ofproto.OFP_NO_BUFFER:

View File

@ -30,11 +30,12 @@ class SimpleSwitch12(app_manager.RyuApp):
super(SimpleSwitch12, self).__init__(*args, **kwargs)
self.mac_to_port = {}
def add_flow(self, datapath, port, dst, actions):
def add_flow(self, datapath, port, dst, src, actions):
ofproto = datapath.ofproto
match = datapath.ofproto_parser.OFPMatch(in_port=port,
eth_dst=dst)
eth_dst=dst,
eth_src=src)
inst = [datapath.ofproto_parser.OFPInstructionActions(
ofproto.OFPIT_APPLY_ACTIONS, actions)]
@ -80,7 +81,7 @@ class SimpleSwitch12(app_manager.RyuApp):
# install a flow to avoid packet_in next time
if out_port != ofproto.OFPP_FLOOD:
self.add_flow(datapath, in_port, dst, actions)
self.add_flow(datapath, in_port, dst, src, actions)
data = None
if msg.buffer_id == ofproto.OFP_NO_BUFFER:

View File

@ -85,7 +85,7 @@ class SimpleSwitch13(app_manager.RyuApp):
dst = eth.dst
src = eth.src
dpid = datapath.id
dpid = format(datapath.id, "d").zfill(16)
self.mac_to_port.setdefault(dpid, {})
self.logger.info("packet in %s %s %s %s", dpid, src, dst, in_port)
@ -102,7 +102,7 @@ class SimpleSwitch13(app_manager.RyuApp):
# install a flow to avoid packet_in next time
if out_port != ofproto.OFPP_FLOOD:
match = parser.OFPMatch(in_port=in_port, eth_dst=dst)
match = parser.OFPMatch(in_port=in_port, eth_dst=dst, eth_src=src)
# verify if we have a valid buffer_id, if yes avoid to send both
# flow_mod & packet_out
if msg.buffer_id != ofproto.OFP_NO_BUFFER:

View File

@ -93,7 +93,7 @@ class SimpleSwitch14(app_manager.RyuApp):
# install a flow to avoid packet_in next time
if out_port != ofproto.OFPP_FLOOD:
match = parser.OFPMatch(in_port=in_port, eth_dst=dst)
match = parser.OFPMatch(in_port=in_port, eth_dst=dst, eth_src=src)
self.add_flow(datapath, 1, match, actions)
data = None

107
ryu/app/simple_switch_15.py Normal file
View File

@ -0,0 +1,107 @@
# Copyright (C) 2011 Nippon Telegraph and Telephone Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from ryu.base import app_manager
from ryu.controller import ofp_event
from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER
from ryu.controller.handler import set_ev_cls
from ryu.ofproto import ofproto_v1_5
from ryu.lib.packet import packet
from ryu.lib.packet import ethernet
from ryu.lib.packet import ether_types
class SimpleSwitch15(app_manager.RyuApp):
OFP_VERSIONS = [ofproto_v1_5.OFP_VERSION]
def __init__(self, *args, **kwargs):
super(SimpleSwitch15, self).__init__(*args, **kwargs)
self.mac_to_port = {}
@set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
def switch_features_handler(self, ev):
datapath = ev.msg.datapath
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
# install table-miss flow entry
#
# We specify NO BUFFER to max_len of the output action due to
# OVS bug. At this moment, if we specify a lesser number, e.g.,
# 128, OVS will send Packet-In with invalid buffer_id and
# truncated packet data. In that case, we cannot output packets
# correctly. The bug has been fixed in OVS v2.1.0.
match = parser.OFPMatch()
actions = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER,
ofproto.OFPCML_NO_BUFFER)]
self.add_flow(datapath, 0, match, actions)
def add_flow(self, datapath, priority, match, actions):
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS,
actions)]
mod = parser.OFPFlowMod(datapath=datapath, priority=priority,
match=match, instructions=inst)
datapath.send_msg(mod)
@set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
def _packet_in_handler(self, ev):
msg = ev.msg
datapath = msg.datapath
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
in_port = msg.match['in_port']
pkt = packet.Packet(msg.data)
eth = pkt.get_protocols(ethernet.ethernet)[0]
if eth.ethertype == ether_types.ETH_TYPE_LLDP:
# ignore lldp packet
return
dst = eth.dst
src = eth.src
dpid = datapath.id
self.mac_to_port.setdefault(dpid, {})
self.logger.info("packet in %s %s %s %s", dpid, src, dst, in_port)
# learn a mac address to avoid FLOOD next time.
self.mac_to_port[dpid][src] = in_port
if dst in self.mac_to_port[dpid]:
out_port = self.mac_to_port[dpid][dst]
else:
out_port = ofproto.OFPP_FLOOD
actions = [parser.OFPActionOutput(out_port)]
# install a flow to avoid packet_in next time
if out_port != ofproto.OFPP_FLOOD:
match = parser.OFPMatch(in_port=in_port, eth_dst=dst)
self.add_flow(datapath, 1, match, actions)
data = None
if msg.buffer_id == ofproto.OFP_NO_BUFFER:
data = msg.data
match = parser.OFPMatch(in_port=in_port)
out = parser.OFPPacketOut(datapath=datapath, buffer_id=msg.buffer_id,
match=match, actions=actions, data=data)
datapath.send_msg(out)

View File

@ -0,0 +1,92 @@
# Copyright (C) 2016 Nippon Telegraph and Telephone Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from ryu.base import app_manager
from ryu.controller import ofp_event
from ryu.controller.handler import CONFIG_DISPATCHER
from ryu.controller.handler import MAIN_DISPATCHER
from ryu.controller.handler import set_ev_cls
from ryu.ofproto import ofproto_v1_3
from ryu.lib import igmplib
from ryu.lib.dpid import str_to_dpid
from ryu.lib.packet import packet
from ryu.lib.packet import ethernet
from ryu.app import simple_switch_13
class SimpleSwitchIgmp13(simple_switch_13.SimpleSwitch13):
OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
_CONTEXTS = {'igmplib': igmplib.IgmpLib}
def __init__(self, *args, **kwargs):
super(SimpleSwitchIgmp13, self).__init__(*args, **kwargs)
self.mac_to_port = {}
self._snoop = kwargs['igmplib']
self._snoop.set_querier_mode(
dpid=str_to_dpid('0000000000000001'), server_port=2)
@set_ev_cls(igmplib.EventPacketIn, MAIN_DISPATCHER)
def _packet_in_handler(self, ev):
msg = ev.msg
datapath = msg.datapath
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
in_port = msg.match['in_port']
pkt = packet.Packet(msg.data)
eth = pkt.get_protocols(ethernet.ethernet)[0]
dst = eth.dst
src = eth.src
dpid = datapath.id
self.mac_to_port.setdefault(dpid, {})
self.logger.info("packet in %s %s %s %s", dpid, src, dst, in_port)
# learn a mac address to avoid FLOOD next time.
self.mac_to_port[dpid][src] = in_port
if dst in self.mac_to_port[dpid]:
out_port = self.mac_to_port[dpid][dst]
else:
out_port = ofproto.OFPP_FLOOD
actions = [parser.OFPActionOutput(out_port)]
# install a flow to avoid packet_in next time
if out_port != ofproto.OFPP_FLOOD:
match = parser.OFPMatch(in_port=in_port, eth_dst=dst)
self.add_flow(datapath, 1, match, actions)
data = None
if msg.buffer_id == ofproto.OFP_NO_BUFFER:
data = msg.data
out = parser.OFPPacketOut(datapath=datapath, buffer_id=msg.buffer_id,
in_port=in_port, actions=actions, data=data)
datapath.send_msg(out)
@set_ev_cls(igmplib.EventMulticastGroupStateChanged,
MAIN_DISPATCHER)
def _status_changed(self, ev):
msg = {
igmplib.MG_GROUP_ADDED: 'Multicast Group Added',
igmplib.MG_MEMBER_CHANGED: 'Multicast Group Member Changed',
igmplib.MG_GROUP_REMOVED: 'Multicast Group Removed',
}
self.logger.info("%s: [%s] querier:[%s] hosts:%s",
msg.get(ev.reason), ev.address, ev.src,
ev.dsts)

View File

@ -0,0 +1,106 @@
# Copyright (C) 2016 Nippon Telegraph and Telephone Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from ryu.base import app_manager
from ryu.controller import ofp_event
from ryu.controller.handler import CONFIG_DISPATCHER
from ryu.controller.handler import MAIN_DISPATCHER
from ryu.controller.handler import set_ev_cls
from ryu.ofproto import ofproto_v1_3
from ryu.lib import lacplib
from ryu.lib.dpid import str_to_dpid
from ryu.lib.packet import packet
from ryu.lib.packet import ethernet
from ryu.app import simple_switch_13
class SimpleSwitchLacp13(simple_switch_13.SimpleSwitch13):
OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
_CONTEXTS = {'lacplib': lacplib.LacpLib}
def __init__(self, *args, **kwargs):
super(SimpleSwitchLacp13, self).__init__(*args, **kwargs)
self.mac_to_port = {}
self._lacp = kwargs['lacplib']
self._lacp.add(
dpid=str_to_dpid('0000000000000001'), ports=[1, 2])
def del_flow(self, datapath, match):
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
mod = parser.OFPFlowMod(datapath=datapath,
command=ofproto.OFPFC_DELETE,
out_port=ofproto.OFPP_ANY,
out_group=ofproto.OFPG_ANY,
match=match)
datapath.send_msg(mod)
@set_ev_cls(lacplib.EventPacketIn, MAIN_DISPATCHER)
def _packet_in_handler(self, ev):
msg = ev.msg
datapath = msg.datapath
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
in_port = msg.match['in_port']
pkt = packet.Packet(msg.data)
eth = pkt.get_protocols(ethernet.ethernet)[0]
dst = eth.dst
src = eth.src
dpid = datapath.id
self.mac_to_port.setdefault(dpid, {})
self.logger.info("packet in %s %s %s %s", dpid, src, dst, in_port)
# learn a mac address to avoid FLOOD next time.
self.mac_to_port[dpid][src] = in_port
if dst in self.mac_to_port[dpid]:
out_port = self.mac_to_port[dpid][dst]
else:
out_port = ofproto.OFPP_FLOOD
actions = [parser.OFPActionOutput(out_port)]
# install a flow to avoid packet_in next time
if out_port != ofproto.OFPP_FLOOD:
match = parser.OFPMatch(in_port=in_port, eth_dst=dst)
self.add_flow(datapath, 1, match, actions)
data = None
if msg.buffer_id == ofproto.OFP_NO_BUFFER:
data = msg.data
out = parser.OFPPacketOut(datapath=datapath, buffer_id=msg.buffer_id,
in_port=in_port, actions=actions, data=data)
datapath.send_msg(out)
@set_ev_cls(lacplib.EventSlaveStateChanged, MAIN_DISPATCHER)
def _slave_state_changed_handler(self, ev):
datapath = ev.datapath
dpid = datapath.id
port_no = ev.port
enabled = ev.enabled
self.logger.info("slave state changed port: %d enabled: %s",
port_no, enabled)
if dpid in self.mac_to_port:
for mac in self.mac_to_port[dpid]:
match = datapath.ofproto_parser.OFPMatch(eth_dst=mac)
self.del_flow(datapath, match)
del self.mac_to_port[dpid]
self.mac_to_port.setdefault(dpid, {})

View File

@ -0,0 +1,116 @@
# Copyright (C) 2016 Nippon Telegraph and Telephone Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import json
from ryu.app import simple_switch_13
from ryu.controller import ofp_event
from ryu.controller.handler import CONFIG_DISPATCHER
from ryu.controller.handler import set_ev_cls
from ryu.app.wsgi import ControllerBase
from ryu.app.wsgi import Response
from ryu.app.wsgi import route
from ryu.app.wsgi import WSGIApplication
from ryu.lib import dpid as dpid_lib
simple_switch_instance_name = 'simple_switch_api_app'
url = '/simpleswitch/mactable/{dpid}'
class SimpleSwitchRest13(simple_switch_13.SimpleSwitch13):
_CONTEXTS = {'wsgi': WSGIApplication}
def __init__(self, *args, **kwargs):
super(SimpleSwitchRest13, self).__init__(*args, **kwargs)
self.switches = {}
wsgi = kwargs['wsgi']
wsgi.register(SimpleSwitchController,
{simple_switch_instance_name: self})
@set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
def switch_features_handler(self, ev):
super(SimpleSwitchRest13, self).switch_features_handler(ev)
datapath = ev.msg.datapath
self.switches[datapath.id] = datapath
self.mac_to_port.setdefault(datapath.id, {})
def set_mac_to_port(self, dpid, entry):
mac_table = self.mac_to_port.setdefault(dpid, {})
datapath = self.switches.get(dpid)
entry_port = entry['port']
entry_mac = entry['mac']
if datapath is not None:
parser = datapath.ofproto_parser
if entry_port not in mac_table.values():
for mac, port in mac_table.items():
# from known device to new device
actions = [parser.OFPActionOutput(entry_port)]
match = parser.OFPMatch(in_port=port, eth_dst=entry_mac)
self.add_flow(datapath, 1, match, actions)
# from new device to known device
actions = [parser.OFPActionOutput(port)]
match = parser.OFPMatch(in_port=entry_port, eth_dst=mac)
self.add_flow(datapath, 1, match, actions)
mac_table.update({entry_mac: entry_port})
return mac_table
class SimpleSwitchController(ControllerBase):
def __init__(self, req, link, data, **config):
super(SimpleSwitchController, self).__init__(req, link, data, **config)
self.simple_switch_app = data[simple_switch_instance_name]
@route('simpleswitch', url, methods=['GET'],
requirements={'dpid': dpid_lib.DPID_PATTERN})
def list_mac_table(self, req, **kwargs):
simple_switch = self.simple_switch_app
dpid = kwargs['dpid']
if dpid not in simple_switch.mac_to_port:
return Response(status=404)
mac_table = simple_switch.mac_to_port.get(dpid, {})
body = json.dumps(mac_table)
return Response(content_type='application/json', text=body)
@route('simpleswitch', url, methods=['PUT'],
requirements={'dpid': dpid_lib.DPID_PATTERN})
def put_mac_table(self, req, **kwargs):
simple_switch = self.simple_switch_app
dpid = kwargs['dpid']
try:
new_entry = req.json if req.body else {}
except ValueError:
raise Response(status=400)
if dpid not in simple_switch.mac_to_port:
return Response(status=404)
try:
mac_table = simple_switch.set_mac_to_port(dpid, new_entry)
body = json.dumps(mac_table)
return Response(content_type='application/json', text=body)
except Exception as e:
return Response(status=500)

View File

@ -0,0 +1,121 @@
# Copyright (C) 2016 Nippon Telegraph and Telephone Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from ryu.base import app_manager
from ryu.controller import ofp_event
from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER
from ryu.controller.handler import set_ev_cls
from ryu.ofproto import ofproto_v1_3
from ryu.lib import dpid as dpid_lib
from ryu.lib import stplib
from ryu.lib.packet import packet
from ryu.lib.packet import ethernet
from ryu.app import simple_switch_13
class SimpleSwitch13(simple_switch_13.SimpleSwitch13):
OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
_CONTEXTS = {'stplib': stplib.Stp}
def __init__(self, *args, **kwargs):
super(SimpleSwitch13, self).__init__(*args, **kwargs)
self.mac_to_port = {}
self.stp = kwargs['stplib']
# Sample of stplib config.
# please refer to stplib.Stp.set_config() for details.
config = {dpid_lib.str_to_dpid('0000000000000001'):
{'bridge': {'priority': 0x8000}},
dpid_lib.str_to_dpid('0000000000000002'):
{'bridge': {'priority': 0x9000}},
dpid_lib.str_to_dpid('0000000000000003'):
{'bridge': {'priority': 0xa000}}}
self.stp.set_config(config)
def delete_flow(self, datapath):
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
for dst in self.mac_to_port[datapath.id].keys():
match = parser.OFPMatch(eth_dst=dst)
mod = parser.OFPFlowMod(
datapath, command=ofproto.OFPFC_DELETE,
out_port=ofproto.OFPP_ANY, out_group=ofproto.OFPG_ANY,
priority=1, match=match)
datapath.send_msg(mod)
@set_ev_cls(stplib.EventPacketIn, MAIN_DISPATCHER)
def _packet_in_handler(self, ev):
msg = ev.msg
datapath = msg.datapath
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
in_port = msg.match['in_port']
pkt = packet.Packet(msg.data)
eth = pkt.get_protocols(ethernet.ethernet)[0]
dst = eth.dst
src = eth.src
dpid = datapath.id
self.mac_to_port.setdefault(dpid, {})
self.logger.info("packet in %s %s %s %s", dpid, src, dst, in_port)
# learn a mac address to avoid FLOOD next time.
self.mac_to_port[dpid][src] = in_port
if dst in self.mac_to_port[dpid]:
out_port = self.mac_to_port[dpid][dst]
else:
out_port = ofproto.OFPP_FLOOD
actions = [parser.OFPActionOutput(out_port)]
# install a flow to avoid packet_in next time
if out_port != ofproto.OFPP_FLOOD:
match = parser.OFPMatch(in_port=in_port, eth_dst=dst)
self.add_flow(datapath, 1, match, actions)
data = None
if msg.buffer_id == ofproto.OFP_NO_BUFFER:
data = msg.data
out = parser.OFPPacketOut(datapath=datapath, buffer_id=msg.buffer_id,
in_port=in_port, actions=actions, data=data)
datapath.send_msg(out)
@set_ev_cls(stplib.EventTopologyChange, MAIN_DISPATCHER)
def _topology_change_handler(self, ev):
dp = ev.dp
dpid_str = dpid_lib.dpid_to_str(dp.id)
msg = 'Receive topology change event. Flush MAC table.'
self.logger.debug("[dpid=%s] %s", dpid_str, msg)
if dp.id in self.mac_to_port:
self.delete_flow(dp)
del self.mac_to_port[dp.id]
@set_ev_cls(stplib.EventPortStateChange, MAIN_DISPATCHER)
def _port_state_change_handler(self, ev):
dpid_str = dpid_lib.dpid_to_str(ev.dp.id)
of_state = {stplib.PORT_STATE_DISABLE: 'DISABLE',
stplib.PORT_STATE_BLOCK: 'BLOCK',
stplib.PORT_STATE_LISTEN: 'LISTEN',
stplib.PORT_STATE_LEARN: 'LEARN',
stplib.PORT_STATE_FORWARD: 'FORWARD'}
self.logger.debug("[dpid=%s][port=%d] state=%s",
dpid_str, ev.port_no, of_state[ev.port_state])

View File

@ -42,15 +42,14 @@ Get arp table:
15:0c:de:49": 2}}}
"""
import json
from webob import Response
from ryu.app import simple_switch_13
from ryu.app.wsgi import route, websocket, ControllerBase, WSGIApplication
from ryu.app.wsgi import rpc_public, WebSocketRPCServer
from ryu.app.wsgi import ControllerBase
from ryu.app.wsgi import rpc_public
from ryu.app.wsgi import websocket
from ryu.app.wsgi import WebSocketRPCServer
from ryu.app.wsgi import WSGIApplication
from ryu.controller import ofp_event
from ryu.controller.handler import set_ev_cls
from ryu.lib import hub
from ryu.lib.packet import packet

View File

@ -35,7 +35,7 @@ $ sudo mn --controller=remote --topo linear,2
""" # noqa
from socket import error as SocketError
from ryu.contrib.tinyrpc.exc import InvalidReplyError
from tinyrpc.exc import InvalidReplyError
from ryu.app.wsgi import (

View File

@ -17,27 +17,34 @@
import inspect
from types import MethodType
import webob.dec
from webob.response import Response
from ryu import cfg
from ryu.lib import hub
from routes import Mapper
from routes.util import URLGenerator
import ryu.contrib
ryu.contrib.update_module_path()
import six
from tinyrpc.server import RPCServer
from tinyrpc.dispatch import RPCDispatcher
from tinyrpc.dispatch import public as rpc_public
from tinyrpc.protocols.jsonrpc import JSONRPCProtocol
from tinyrpc.transports import ServerTransport, ClientTransport
from tinyrpc.client import RPCClient
ryu.contrib.restore_module_path()
import webob.dec
import webob.exc
from webob.request import Request as webob_Request
from webob.response import Response as webob_Response
from ryu import cfg
from ryu.lib import hub
DEFAULT_WSGI_HOST = '0.0.0.0'
DEFAULT_WSGI_PORT = 8080
CONF = cfg.CONF
CONF.register_cli_opts([
cfg.StrOpt('wsapi-host', default='', help='webapp listen host'),
cfg.IntOpt('wsapi-port', default=8080, help='webapp listen port')
cfg.StrOpt(
'wsapi-host', default=DEFAULT_WSGI_HOST,
help='webapp listen host (default %s)' % DEFAULT_WSGI_HOST),
cfg.IntOpt(
'wsapi-port', default=DEFAULT_WSGI_PORT,
help='webapp listen port (default %s)' % DEFAULT_WSGI_PORT),
])
HEX_PATTERN = r'0x[0-9a-z]+'
@ -56,6 +63,33 @@ def route(name, path, methods=None, requirements=None):
return _route
class Request(webob_Request):
"""
Wrapper class for webob.request.Request.
The behavior of this class is the same as webob.request.Request
except for setting "charset" to "UTF-8" automatically.
"""
DEFAULT_CHARSET = "UTF-8"
def __init__(self, environ, charset=DEFAULT_CHARSET, *args, **kwargs):
super(Request, self).__init__(
environ, charset=charset, *args, **kwargs)
class Response(webob_Response):
"""
Wrapper class for webob.response.Response.
The behavior of this class is the same as webob.response.Response
except for setting "charset" to "UTF-8" automatically.
"""
DEFAULT_CHARSET = "UTF-8"
def __init__(self, charset=DEFAULT_CHARSET, *args, **kwargs):
super(Response, self).__init__(charset=charset, *args, **kwargs)
class WebSocketRegistrationWrapper(object):
def __init__(self, func, controller):
@ -74,8 +108,15 @@ class WebSocketRegistrationWrapper(object):
class _AlreadyHandledResponse(Response):
# XXX: Eventlet API should not be used directly.
from eventlet.wsgi import ALREADY_HANDLED
_ALREADY_HANDLED = ALREADY_HANDLED
# https://github.com/benoitc/gunicorn/pull/2581
from packaging import version
import eventlet
if version.parse(eventlet.__version__) >= version.parse("0.30.3"):
import eventlet.wsgi
_ALREADY_HANDLED = getattr(eventlet.wsgi, "ALREADY_HANDLED", None)
else:
from eventlet.wsgi import ALREADY_HANDLED
_ALREADY_HANDLED = ALREADY_HANDLED
def __call__(self, environ, start_response):
return self._ALREADY_HANDLED
@ -83,7 +124,7 @@ class _AlreadyHandledResponse(Response):
def websocket(name, path):
def _websocket(controller_func):
def __websocket(self, req, **kwargs):
def __websocket(self, req, **_):
wrapper = WebSocketRegistrationWrapper(controller_func, self)
ws_wsgi = hub.WebSocketWSGI(wrapper)
ws_wsgi(req.environ, req.start_response)
@ -108,6 +149,7 @@ class ControllerBase(object):
def __init__(self, req, link, data, **config):
self.req = req
self.link = link
self.data = data
self.parent = None
for name, value in config.items():
setattr(self, name, value)
@ -138,10 +180,10 @@ class WebSocketServerTransport(ServerTransport):
if message is None:
raise WebSocketDisconnectedError()
context = None
return (context, message)
return context, message
def send_reply(self, context, reply):
self.ws.send(unicode(reply))
self.ws.send(six.text_type(reply))
class WebSocketRPCServer(RPCServer):
@ -171,7 +213,7 @@ class WebSocketClientTransport(ClientTransport):
self.queue = queue
def send_message(self, message, expect_reply=True):
self.ws.send(unicode(message))
self.ws.send(six.text_type(message))
if expect_reply:
return self.queue.get()
@ -224,23 +266,15 @@ class WSGIApplication(object):
self.registory = {}
self._wsmanager = WebSocketManager()
super(WSGIApplication, self).__init__()
# XXX: Switch how to call the API of Routes for every version
match_argspec = inspect.getargspec(self.mapper.match)
if 'environ' in match_argspec.args:
# New API
self._match = self._match_with_environ
else:
# Old API
self._match = self._match_with_path_info
def _match_with_environ(self, req):
match = self.mapper.match(environ=req.environ)
return match
def _match_with_path_info(self, req):
self.mapper.environ = req.environ
match = self.mapper.match(req.path_info)
return match
def _match(self, req):
# Note: Invoke the new API, first. If the arguments unmatched,
# invoke the old API.
try:
return self.mapper.match(environ=req.environ)
except TypeError:
self.mapper.environ = req.environ
return self.mapper.match(req.path_info)
@wsgify_hack
def __call__(self, req, start_response):

View File

@ -386,6 +386,7 @@ class AppManager(object):
self.applications = {}
self.contexts_cls = {}
self.contexts = {}
self.close_sem = hub.Semaphore()
def load_app(self, name):
mod = utils.import_module(name)
@ -541,7 +542,10 @@ class AppManager(object):
self._close(app)
close_dict.clear()
for app_name in list(self.applications.keys()):
self.uninstantiate(app_name)
assert not self.applications
close_all(self.contexts)
# This semaphore prevents parallel execution of this function,
# as run_apps's finally clause starts another close() call.
with self.close_sem:
for app_name in list(self.applications.keys()):
self.uninstantiate(app_name)
assert not self.applications
close_all(self.contexts)

View File

@ -36,6 +36,7 @@ CONF = oslo_config.cfg.ConfigOpts()
from oslo_config.cfg import ConfigOpts
from oslo_config.cfg import Opt
from oslo_config.cfg import BoolOpt
from oslo_config.cfg import IntOpt
from oslo_config.cfg import ListOpt

View File

@ -16,22 +16,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys
from ryu.lib import hub
hub.patch(thread=False)
# TODO:
# Right now, we have our own patched copy of ovs python bindings
# Once our modification is upstreamed and widely deployed,
# use it
#
# NOTE: this modifies sys.path and thus affects the following imports.
import ryu.contrib
ryu.contrib.update_module_path()
from ryu import cfg
import logging
import sys
import logging
from ryu import log
log.early_init_log(logging.DEBUG)
@ -53,10 +46,28 @@ CONF.register_cli_opts([
cfg.BoolOpt('enable-debugger', default=False,
help='don\'t overwrite Python standard threading library'
'(use only for debugging)'),
cfg.StrOpt('user-flags', default=None,
help='Additional flags file for user applications'),
])
def _parse_user_flags():
"""
Parses user-flags file and loads it to register user defined options.
"""
try:
idx = list(sys.argv).index('--user-flags')
user_flags_file = sys.argv[idx + 1]
except (ValueError, IndexError):
user_flags_file = ''
if user_flags_file and os.path.isfile(user_flags_file):
from ryu.utils import _import_module_file
_import_module_file(user_flags_file)
def main(args=None, prog=None):
_parse_user_flags()
try:
CONF(args=args, prog=prog,
project='ryu', version='ryu-manager %s' % version,
@ -66,21 +77,20 @@ def main(args=None, prog=None):
project='ryu', version='ryu-manager %s' % version)
log.init_log()
logger = logging.getLogger(__name__)
if CONF.enable_debugger:
LOG = logging.getLogger('ryu.cmd.manager')
msg = 'debugging is available (--enable-debugger option is turned on)'
LOG.info(msg)
logger.info(msg)
else:
hub.patch(thread=True)
if CONF.pid_file:
import os
with open(CONF.pid_file, 'w') as pid_file:
pid_file.write(str(os.getpid()))
app_lists = CONF.app_lists + CONF.app
# keep old behaivor, run ofp if no application is specified.
# keep old behavior, run ofp if no application is specified.
if not app_lists:
app_lists = ['ryu.controller.ofp_handler']
@ -97,6 +107,9 @@ def main(args=None, prog=None):
try:
hub.joinall(services)
except KeyboardInterrupt:
logger.debug("Keyboard Interrupt received. "
"Closing RYU application manager...")
finally:
app_mgr.close()

View File

@ -25,18 +25,15 @@
from __future__ import print_function
import ryu.contrib
ryu.contrib.update_module_path()
from ryu import cfg
import cmd
import sys
import lxml.etree as ET
import lxml.etree as ET
from ncclient.operations.rpc import RPCError
from ryu import cfg
from ryu.lib import of_config
from ryu.lib.of_config import capable_switch
from ncclient.operations.rpc import RPCError
import ryu.lib.of_config.classes as ofc

View File

@ -31,24 +31,25 @@
from __future__ import print_function
import ryu.contrib
ryu.contrib.update_module_path()
from ryu import cfg
import ast
import cmd
import signal
import socket
import sys
import termios
from ryu import cfg
from ryu.lib import rpc
CONF = cfg.CONF
CONF.register_cli_opts([
# eg. rpc-cli --peers=hoge=localhost:9998,fuga=localhost:9999
cfg.ListOpt('peers', default=[], help='list of peers')
cfg.ListOpt('peers', default=[],
help='List of peers, separated by commas. '
'(e.g., "hoge=localhost:9998,fuga=localhost:9999")'),
cfg.StrOpt('command', short='c', default=None,
help='Command to be executed as single command. '
'The default is None and opens interactive console.'),
])
@ -56,16 +57,18 @@ class Peer(object):
def __init__(self, name, addr):
self._name = name
self._addr = addr
self.socket = None
self.client = None
try:
self.connect()
except:
pass
except ConnectionError as e:
print('Exception when connecting to peer "%s": %s' % (name, e))
raise e
def connect(self):
self.client = None
s = socket.create_connection(self._addr)
self.client = rpc.Client(s, notification_callback=self.notification)
self.socket = socket.create_connection(self._addr)
self.client = rpc.Client(self.socket,
notification_callback=self.notification)
def try_to_connect(self, verbose=False):
if self.client:
@ -104,12 +107,25 @@ class Peer(object):
print("connected. retrying the request...")
return g()
def close(self):
self.socket.close()
peers = {}
def add_peer(name, host, port):
peers[name] = Peer(name, (host, port))
try:
peer = Peer(name, (host, port))
except ConnectionError:
return
peers[name] = peer
def close_peers():
for peer in peers.values():
peer.socket.close()
class Cmd(cmd.Cmd):
@ -124,9 +140,9 @@ class Cmd(cmd.Cmd):
try:
peer = args[0]
method = args[1]
params = eval(args[2])
except:
print("argument error")
params = ast.literal_eval(args[2])
except (IndexError, ValueError) as e:
print("argument error: %s" % e)
return
try:
p = peers[peer]
@ -174,7 +190,8 @@ class Cmd(cmd.Cmd):
def complete_notify(self, text, line, begidx, endidx):
return self._complete_peer(text, line, begidx, endidx)
def do_EOF(self, _line):
def do_EOF(self, _line=None):
close_peers()
sys.exit(0)
def emptyline(self):
@ -205,6 +222,9 @@ class Cmd(cmd.Cmd):
signal.signal(signal.SIGALRM, self._timeout)
signal.alarm(1)
def postloop(self):
close_peers()
def onecmd(self, string):
self._in_onecmd = True
try:
@ -233,6 +253,11 @@ def main(args=None, prog=None):
host, port = addr.rsplit(':', 1)
add_peer(name, host, port)
if CONF.command:
command = Cmd()
command.onecmd(CONF.command)
command.do_EOF()
Cmd().cmdloop()

View File

@ -14,15 +14,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import ryu.contrib
ryu.contrib.update_module_path()
import argparse
import os.path
import sys
from ryu import cfg
from ryu import utils
from ryu import version
import argparse
import os.path
import sys
subcommands = {

View File

@ -1,68 +0,0 @@
# Copyright 2009 Shikhar Bhushan
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
def _abbreviate(uri):
if uri.startswith("urn:ietf:params") and ":netconf:" in uri:
splitted = uri.split(":")
if ":capability:" in uri:
if uri.startswith("urn:ietf:params:xml:ns:netconf"):
name, version = splitted[7], splitted[8]
else:
name, version = splitted[5], splitted[6]
return [ ":" + name, ":" + name + ":" + version ]
elif ":base:" in uri:
if uri.startswith("urn:ietf:params:xml:ns:netconf"):
return [ ":base", ":base" + ":" + splitted[7] ]
else:
return [ ":base", ":base" + ":" + splitted[5] ]
return []
def schemes(url_uri):
"Given a URI that has a *scheme* query string (i.e. `:url` capability URI), will return a list of supported schemes."
return url_uri.partition("?scheme=")[2].split(",")
class Capabilities:
"Represents the set of capabilities available to a NETCONF client or server. It is initialized with a list of capability URI's."
def __init__(self, capabilities):
self._dict = {}
for uri in capabilities:
self._dict[uri] = _abbreviate(uri)
def __contains__(self, key):
if key in self._dict:
return True
for abbrs in self._dict.values():
if key in abbrs:
return True
return False
def __len__(self):
return len(self._dict)
def __iter__(self):
return self._dict.iterkeys()
def __repr__(self):
return repr(self._dict.keys())
def add(self, uri):
"Add a capability."
self._dict[uri] = _abbreviate(uri)
def remove(self, uri):
"Remove a capability."
if key in self._dict:
del self._dict[key]

View File

@ -1,24 +0,0 @@
# Copyright 2009 Shikhar Bhushan
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from ncclient.transport import SessionListener
class PrintListener(SessionListener):
def callback(self, root, raw):
print('\n# RECEIVED MESSAGE with root=[tag=%r, attrs=%r] #\n%r\n' %
(root[0], root[1], raw))
def errback(self, err):
print('\n# RECEIVED ERROR #\n%r\n' % err)

View File

@ -1,177 +0,0 @@
# Copyright 2009 Shikhar Bhushan
# Copyright 2011 Leonidas Poulopoulos
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""This module is a thin layer of abstraction around the library. It exposes all core functionality."""
import capabilities
import operations
import transport
import logging
logger = logging.getLogger('ncclient.manager')
CAPABILITIES = [
"urn:ietf:params:netconf:base:1.0",
"urn:ietf:params:netconf:capability:writable-running:1.0",
"urn:ietf:params:netconf:capability:candidate:1.0",
"urn:ietf:params:netconf:capability:confirmed-commit:1.0",
"urn:ietf:params:netconf:capability:rollback-on-error:1.0",
"urn:ietf:params:netconf:capability:startup:1.0",
"urn:ietf:params:netconf:capability:url:1.0?scheme=http,ftp,file,https,sftp",
"urn:ietf:params:netconf:capability:validate:1.0",
"urn:ietf:params:netconf:capability:xpath:1.0",
"urn:liberouter:params:netconf:capability:power-control:1.0",
"urn:ietf:params:netconf:capability:interleave:1.0"
]
"""A list of URI's representing the client's capabilities. This is used during the initial capability exchange. Modify this if you need to announce some capability not already included."""
OPERATIONS = {
"get": operations.Get,
"get_config": operations.GetConfig,
"dispatch": operations.Dispatch,
"edit_config": operations.EditConfig,
"copy_config": operations.CopyConfig,
"validate": operations.Validate,
"commit": operations.Commit,
"discard_changes": operations.DiscardChanges,
"delete_config": operations.DeleteConfig,
"lock": operations.Lock,
"unlock": operations.Unlock,
"close_session": operations.CloseSession,
"kill_session": operations.KillSession,
"poweroff_machine": operations.PoweroffMachine,
"reboot_machine": operations.RebootMachine
}
"""Dictionary of method names and corresponding :class:`~ncclient.operations.RPC` subclasses. It is used to lookup operations, e.g. `get_config` is mapped to :class:`~ncclient.operations.GetConfig`. It is thus possible to add additional operations to the :class:`Manager` API."""
def connect_ssh(*args, **kwds):
"""Initialize a :class:`Manager` over the SSH transport. For documentation of arguments see :meth:`ncclient.transport.SSHSession.connect`.
The underlying :class:`ncclient.transport.SSHSession` is created with :data:`CAPABILITIES`. It is first instructed to :meth:`~ncclient.transport.SSHSession.load_known_hosts` and then all the provided arguments are passed directly to its implementation of :meth:`~ncclient.transport.SSHSession.connect`.
"""
session = transport.SSHSession(capabilities.Capabilities(CAPABILITIES))
session.load_known_hosts()
session.connect(*args, **kwds)
return Manager(session)
connect = connect_ssh
"Same as :func:`connect_ssh`, since SSH is the default (and currently, the only) transport."
class OpExecutor(type):
def __new__(cls, name, bases, attrs):
def make_wrapper(op_cls):
def wrapper(self, *args, **kwds):
return self.execute(op_cls, *args, **kwds)
wrapper.func_doc = op_cls.request.func_doc
return wrapper
for op_name, op_cls in OPERATIONS.iteritems():
attrs[op_name] = make_wrapper(op_cls)
return super(OpExecutor, cls).__new__(cls, name, bases, attrs)
class Manager(object):
"""For details on the expected behavior of the operations and their parameters refer to :rfc:`4741`.
Manager instances are also context managers so you can use it like this::
with manager.connect("host") as m:
# do your stuff
... or like this::
m = manager.connect("host")
try:
# do your stuff
finally:
m.close_session()
"""
__metaclass__ = OpExecutor
def __init__(self, session, timeout=30):
self._session = session
self._async_mode = False
self._timeout = timeout
self._raise_mode = operations.RaiseMode.ALL
def __enter__(self):
return self
def __exit__(self, *args):
self.close_session()
return False
def __set_timeout(self, timeout):
self._timeout = timeout
def __set_async_mode(self, mode):
self._async_mode = mode
def __set_raise_mode(self, mode):
assert(mode in (operations.RaiseMode.NONE, operations.RaiseMode.ERRORS, operations.RaiseMode.ALL))
self._raise_mode = mode
def execute(self, cls, *args, **kwds):
return cls(self._session,
async=self._async_mode,
timeout=self._timeout,
raise_mode=self._raise_mode).request(*args, **kwds)
def locked(self, target):
"""Returns a context manager for a lock on a datastore, where *target* is the name of the configuration datastore to lock, e.g.::
with m.locked("running"):
# do your stuff
... instead of::
m.lock("running")
try:
# do your stuff
finally:
m.unlock("running")
"""
return operations.LockContext(self._session, target)
@property
def client_capabilities(self):
":class:`~ncclient.capabilities.Capabilities` object representing the client's capabilities."
return self._session._client_capabilities
@property
def server_capabilities(self):
":class:`~ncclient.capabilities.Capabilities` object representing the server's capabilities."
return self._session._server_capabilities
@property
def session_id(self):
"`session-id` assigned by the NETCONF server."
return self._session.id
@property
def connected(self):
"Whether currently connected to the NETCONF server."
return self._session.connected
async_mode = property(fget=lambda self: self._async_mode, fset=__set_async_mode)
"Specify whether operations are executed asynchronously (`True`) or synchronously (`False`) (the default)."
timeout = property(fget=lambda self: self._timeout, fset=__set_timeout)
"Specify the timeout for synchronous RPC requests."
raise_mode = property(fget=lambda self: self._raise_mode, fset=__set_raise_mode)
"Specify which errors are raised as :exc:`~ncclient.operations.RPCError` exceptions. Valid values are the constants defined in :class:`~ncclient.operations.RaiseMode`. The default value is :attr:`~ncclient.operations.RaiseMode.ALL`."

View File

@ -1,51 +0,0 @@
# Copyright 2009 Shikhar Bhushan
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from errors import OperationError, TimeoutExpiredError, MissingCapabilityError
from rpc import RPC, RPCReply, RPCError, RaiseMode
# rfc4741 ops
from retrieve import Get, GetConfig, GetReply, Dispatch
from edit import EditConfig, CopyConfig, DeleteConfig, Validate, Commit, DiscardChanges
from session import CloseSession, KillSession
from lock import Lock, Unlock, LockContext
# others...
from flowmon import PoweroffMachine, RebootMachine
__all__ = [
'RPC',
'RPCReply',
'RPCError',
'RaiseMode',
'Get',
'GetConfig',
'Dispatch',
'GetReply',
'EditConfig',
'CopyConfig',
'Validate',
'Commit',
'DiscardChanges',
'DeleteConfig',
'Lock',
'Unlock',
'PoweroffMachine',
'RebootMachine',
'LockContext',
'CloseSession',
'KillSession',
'OperationError',
'TimeoutExpiredError',
'MissingCapabilityError'
]

View File

@ -1,143 +0,0 @@
# Copyright 2009 Shikhar Bhushan
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from ncclient.xml_ import *
from rpc import RPC
import util
import logging
logger = logging.getLogger("ncclient.operations.edit")
"Operations related to changing device configuration"
class EditConfig(RPC):
"`edit-config` RPC"
def request(self, target, config, default_operation=None, test_option=None, error_option=None):
"""Loads all or part of the specified *config* to the *target* configuration datastore.
*target* is the name of the configuration datastore being edited
*config* is the configuration, which must be rooted in the `config` element. It can be specified either as a string or an :class:`~xml.etree.ElementTree.Element`.
*default_operation* if specified must be one of { `"merge"`, `"replace"`, or `"none"` }
*test_option* if specified must be one of { `"test_then_set"`, `"set"` }
*error_option* if specified must be one of { `"stop-on-error"`, `"continue-on-error"`, `"rollback-on-error"` }
The `"rollback-on-error"` *error_option* depends on the `:rollback-on-error` capability.
"""
node = new_ele("edit-config")
node.append(util.datastore_or_url("target", target, self._assert))
if error_option is not None:
if error_option == "rollback-on-error":
self._assert(":rollback-on-error")
sub_ele(node, "error-option").text = error_option
if test_option is not None:
self._assert(':validate')
sub_ele(node, "test-option").text = test_option
if default_operation is not None:
# TODO: check if it is a valid default-operation
sub_ele(node, "default-operation").text = default_operation
node.append(validated_element(config, ("config", qualify("config"))))
return self._request(node)
class DeleteConfig(RPC):
"`delete-config` RPC"
def request(self, target):
"""Delete a configuration datastore.
*target* specifies the name or URL of configuration datastore to delete
:seealso: :ref:`srctarget_params`"""
node = new_ele("delete-config")
node.append(util.datastore_or_url("target", target, self._assert))
return self._request(node)
class CopyConfig(RPC):
"`copy-config` RPC"
def request(self, source, target):
"""Create or replace an entire configuration datastore with the contents of another complete
configuration datastore.
*source* is the name of the configuration datastore to use as the source of the copy operation or `config` element containing the configuration subtree to copy
*target* is the name of the configuration datastore to use as the destination of the copy operation
:seealso: :ref:`srctarget_params`"""
node = new_ele("copy-config")
node.append(util.datastore_or_url("target", target, self._assert))
node.append(util.datastore_or_url("source", source, self._assert))
return self._request(node)
class Validate(RPC):
"`validate` RPC. Depends on the `:validate` capability."
DEPENDS = [':validate']
def request(self, source):
"""Validate the contents of the specified configuration.
*source* is the name of the configuration datastore being validated or `config` element containing the configuration subtree to be validated
:seealso: :ref:`srctarget_params`"""
node = new_ele("validate")
try:
src = validated_element(source, ("config", qualify("config")))
except Exception as e:
logger.debug(e)
src = util.datastore_or_url("source", source, self._assert)
(node if src.tag == "source" else sub_ele(node, "source")).append(src)
return self._request(node)
class Commit(RPC):
"`commit` RPC. Depends on the `:candidate` capability, and the `:confirmed-commit`."
DEPENDS = [':candidate']
def request(self, confirmed=False, timeout=None):
"""Commit the candidate configuration as the device's new current configuration. Depends on the `:candidate` capability.
A confirmed commit (i.e. if *confirmed* is `True`) is reverted if there is no followup commit within the *timeout* interval. If no timeout is specified the confirm timeout defaults to 600 seconds (10 minutes). A confirming commit may have the *confirmed* parameter but this is not required. Depends on the `:confirmed-commit` capability.
*confirmed* whether this is a confirmed commit
*timeout* specifies the confirm timeout in seconds"""
node = new_ele("commit")
if confirmed:
self._assert(":confirmed-commit")
sub_ele(node, "confirmed")
if timeout is not None:
sub_ele(node, "confirm-timeout").text = timeout
return self._request(node)
class DiscardChanges(RPC):
"`discard-changes` RPC. Depends on the `:candidate` capability."
DEPENDS = [":candidate"]
def request(self):
"""Revert the candidate configuration to the currently running configuration. Any uncommitted changes are discarded."""
return self._request(new_ele("discard-changes"))

View File

@ -1,24 +0,0 @@
# Copyright 2009 Shikhar Bhushan
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from ncclient import NCClientError
class OperationError(NCClientError):
pass
class TimeoutExpiredError(NCClientError):
pass
class MissingCapabilityError(NCClientError):
pass

View File

@ -1,39 +0,0 @@
# Copyright 2h009 Shikhar Bhushan
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
'Power-control operations'
from ncclient.xml_ import *
from rpc import RPC
PC_URN = "urn:liberouter:params:xml:ns:netconf:power-control:1.0"
class PoweroffMachine(RPC):
"*poweroff-machine* RPC (flowmon)"
DEPENDS = ["urn:liberouter:param:netconf:capability:power-control:1.0"]
def request(self):
return self._request(new_ele(qualify("poweroff-machine", PC_URN)))
class RebootMachine(RPC):
"*reboot-machine* RPC (flowmon)"
DEPENDS = ["urn:liberouter:params:netconf:capability:power-control:1.0"]
def request(self):
return self._request(new_ele(qualify("reboot-machine", PC_URN)))

View File

@ -1,70 +0,0 @@
# Copyright 2h009 Shikhar Bhushan
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"Locking-related NETCONF operations"
from ncclient.xml_ import *
from rpc import RaiseMode, RPC
# TODO: parse session-id from a lock-denied error, and raise a tailored exception?
class Lock(RPC):
"`lock` RPC"
def request(self, target):
"""Allows the client to lock the configuration system of a device.
*target* is the name of the configuration datastore to lock
"""
node = new_ele("lock")
sub_ele(sub_ele(node, "target"), target)
return self._request(node)
class Unlock(RPC):
"`unlock` RPC"
def request(self, target):
"""Release a configuration lock, previously obtained with the lock operation.
*target* is the name of the configuration datastore to unlock
"""
node = new_ele("unlock")
sub_ele(sub_ele(node, "target"), target)
return self._request(node)
class LockContext:
"""A context manager for the :class:`Lock` / :class:`Unlock` pair of RPC's.
Any `rpc-error` will be raised as an exception.
Initialise with (:class:`Session <ncclient.transport.Session>`) instance and lock target.
"""
def __init__(self, session, target):
self.session = session
self.target = target
def __enter__(self):
Lock(self.session, raise_mode=RaiseMode.ERRORS).request(self.target)
return self
def __exit__(self, *args):
Unlock(self.session, raise_mode=RaiseMode.ERRORS).request(self.target)
return False

Some files were not shown because too many files have changed in this diff Show More