Commit Graph

295 Commits

Author SHA1 Message Date
FUJITA Tomonori
03b42e23d4 add packet library
As discussed on the mailing list, there is no good packet library
(parses and builds various protocol packets). dpkt isn't flexible
enough (can't nicely handle stacked protocols such as vlan, mpls,
gre). NOX's one is nice but released under GPL3.

So we need our own packet library.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-08-21 18:52:15 +09:00
Isaku Yamahata
3579a3e37c controller: print backtrace when exception in addition to stacktrace
This is useful when debugging. it's difficult to debug without
backtrace.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-08-20 11:25:06 +09:00
FUJITA Tomonori
c771dc8d6f test: add stats and config tests to integrated test suite
Run this in the following way:

$ ryu-manager ryu/ryu/tests/integrated/test_request_reply_v12.py

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-08-20 09:52:23 +09:00
FUJITA Tomonori
2a7f243425 of: Fix OFPEchoRequest serialize
The spec allows zero-length data.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Reviewed-by: Simon Horman <horms@verge.net.au>
2012-08-10 10:19:17 +09:00
FUJITA Tomonori
1eb52f7671 of1.2: pretty OFPGetConfigReply parser
Make OFPGetConfigReply parser consistent with the rest

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-08-06 14:29:49 +09:00
FUJITA Tomonori
b49ccfc11b clean up ETH_TYPE_ constants
Use ofproto/ether.py

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Reviewed-by: Simon Horman <horms@verge.net.au>
2012-07-31 13:26:53 +09:00
FUJITA Tomonori
7830a134de add ethernet type constants
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Reviewed-by: Simon Horman <horms@verge.net.au>
2012-07-31 13:26:36 +09:00
FUJITA Tomonori
254db170ec test: fix SET_NW_TOS action in test_add_flow_v10
The lowest two bits must be zero.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Reviewed-by: Simon Horman <horms@verge.net.au>
2012-07-31 13:26:17 +09:00
FUJITA Tomonori
89b5f3c5d0 clean up IPPROTO_ constants
Use ofproto/inet.py.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-31 13:25:49 +09:00
FUJITA Tomonori
6ba1075b6c add IPPROTO_SCTP constant
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-31 13:25:47 +09:00
FUJITA Tomonori
562515949d rename ryu/ofproto/in.py to ryu/ofproto/inet.py
Avoid a reserved word.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-31 13:25:45 +09:00
FUJITA Tomonori
a41029a2b9 test: specify OF version in integrated test suite
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-31 13:25:40 +09:00
FUJITA Tomonori
be18e1b4b1 Ryu 1.1
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-30 20:05:59 +09:00
FUJITA Tomonori
6b99b1408b of1.2: handle unknown match field properly
Ryu crashes when it finds an unknown match field in OFPMatch. Instead,
Ryu should just ignore it and continue to parse.

With this patch, Ryu uses OFPmatchField class for an unknown match
field and continue to parse.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Tested-by: Simon Horman <horms@verge.net.au>
2012-07-30 11:58:23 +09:00
FUJITA Tomonori
8c1978942d test: simplify integrated OVS test suite
This patch simplifies integrated OVS test suite. Currently, we wait
for a barrier response before moving to the next test. However, we
don't need. The logic works like the following:

sending a flow mod (deleting all the flows)
sending a barrier
sending a flow mod (set up a flow to test)
sending a barrier
sending a flow stats

Then the reply handler for flow stats verifies the result and move to
the next.

You can run a test suite like:

$ ryu-manager ~/git/ryu/ryu/tests/integrated/test_add_flow_v12_actions.py

We can try two more suites:

ryu/tests/integrated/test_add_flow_v10.py
ryu/tests/integrated/test_add_flow_v12_matches.py

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-28 10:24:46 +09:00
FUJITA Tomonori
dfa4ab185a test: add more of1.2 unittests
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-26 19:44:40 +09:00
FUJITA Tomonori
696639de4e of1.2: fix IPv6 match parsers
Fix the folloing problem in MTIPv6Src, MTIPv6Src, MTIPv6Dst, and
MTIPv6NdTarget's parsers:

File "/home/openflow/ryu/ryu/ofproto/ofproto_v1_2_parser.py", line 1705, in parser
  field = OFPMatchField.parser(buf, offset)
File "/home/openflow/ryu/ryu/ofproto/ofproto_v1_2_parser.py", line 1934, in parser
  field = cls_.field_parser(header, buf, offset)
File "/home/openflow/ryu/ryu/ofproto/ofproto_v1_2_parser.py", line 1949, in field_parser
  (value,) = struct.unpack_from(cls.pack_str, buf, offset + 4)
ValueError: too many values to unpack

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-26 19:41:08 +09:00
FUJITA Tomonori
2bf07c065a of1.2: make set_metadata implementation consistent with the rest
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-25 11:48:43 +09:00
FUJITA Tomonori
f2ac2b5e15 of1.2: fix OFPExperimenter parser
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-25 11:46:36 +09:00
FUJITA Tomonori
ef5c5e45d3 of1.2: fix Instruction parser
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-24 15:19:47 +09:00
Simon Horman
a7eb8c4254 of1.2: add OXM_OF_METADATA support
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-24 07:55:40 +09:00
FUJITA Tomonori
68bfa1f84d fix 475ca44ef4 regression
Needs __init__.py

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-20 07:48:30 +09:00
FUJITA Tomonori
475ca44ef4 test: add integrated OVS test suite
This patch adds a test framework with OVS to test various matches and
actions; adding various matches and actions and check `ovs-ofctl
dump-flows' output.

First, create 'br-tester' bridge:

fujita@rose:~$ sudo ovs-vsctl add-br br-tester

Secondly, configure the bridge to use the local controller:

fujita@rose:~$ sudo ovs-vsctl set-controller br-tester tcp:127.0.0.1

Thirdly, run what you want to test. If you want to try adding flows on
OF1.0:

fujita@rose:~$ ryu-manager --verbose --run_test_mod ryu.tests.integrated.test_add_flow_v10 ryu.tests.integrated.tester

This patch adds three test sets:

ryu.tests.integrated.test_add_flow_v10
ryu.tests.integrated.test_add_flow_v12_actions
ryu.tests.integrated.test_add_flow_v12_matches

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-20 06:27:16 +09:00
FUJITA Tomonori
bdaafadc3f of1.2: fix OFPPortStatsRequest typo
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-19 21:07:54 +09:00
FUJITA Tomonori
b281cc72bc of1.2: OFPGroupMod and OFPGroupFeaturesStats
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-19 21:07:31 +09:00
FUJITA Tomonori
b5d462f615 simple_switch: remove outside module dependence
simple_switch is a a learing material (who uses this in
production?). It should be the simple learning switch code like one in
OpenFlow tutorial. It's easier for learniners if simple_switch doesn't
use the outside modules.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-19 14:59:58 +09:00
FUJITA Tomonori
e3e703970d cbench: specify OF1.0
cbench works with only OF1.0 and OF1.0 provides all cbench needs. So
specify OF1.0.

Also it doesn't need nxm so use OFPMatch and OFPFlowMod.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Reviewed-by: Isaku Yamahata <yamahata@valinux.co.jp>
2012-07-18 16:54:43 +09:00
FUJITA Tomonori
112c7e5496 simple_switch: specify OF1.0
simple_switch works with only OF1.0 and OF1.0 provides all
simple_switch needs. So specify OF1.0.

simple_switch doesn't need nxm so use OFPMatch and OFPFlowMod (and
avoid the helper functions).

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-18 16:54:18 +09:00
FUJITA Tomonori
4c2de66d32 stop import ofproto_v1_0 as ofproto
'from . import ofproto_v1_0 as ofproto' in ryu/ofproto/__init__.py is
a wrong assumption. We need to remove it.

This introduces ryu/ofproto/ofproto_common.py including only constatns
that OF version independent code must use. Note that I don't move data
structures there that multiple OF versions can share (like OVS does).

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-17 19:32:13 +09:00
FUJITA Tomonori
ad184686a8 nxm: remove import ofproto
Use ofproto_v1_0 explicitly instead.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-17 19:31:58 +09:00
Simon Horman
f8b75c92a8 of1.2: OFPMatch serialiser: fix ARP_SPA, ARP_TPA and IPV6_FLABEL masking
* In the case of ARP_SPA, ARP_TPA and IPV6_FLABEL a masked match should be
  used unless the mask is all ones.

  Previously a non-masked matched was used in the case were the mask was
  zero, leading to the value being unmasked, whereas in should be completely
  masked out.

* An un-masked IPV6_FLABEL should internally use a mask of UINT32_MAX

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-17 16:21:12 +09:00
KAWAI Hiroaki
c46fdc6bf1 simple_switch: fix port_status_handler
port_no is not a member of msg, but a member of msg.desc.

Signed-off-by: Hiroaki KAWAI <kawai@stratosphere.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-17 10:40:46 +09:00
FUJITA Tomonori
fc05f44eaf of1.2: add OFPSF_REPLY_MORE constant
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-17 06:25:27 +09:00
FUJITA Tomonori
bff41cb952 of1.2: remove unused mask in MTEthType
EthType doesn't support mask.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-17 06:25:25 +09:00
FUJITA Tomonori
42f704f943 enable applications to specify OF versions
Some applications need to use particular OF versions.

With this patch, applications can specify OF versions in the following
way:

class YourApplication(app_manager.RyuApp):
    OFP_VERSIONS = [ofproto_v1_1.OFP_VERSION, ofproto_v1_2.OFP_VERSION]

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Reviewed-by: Isaku Yamahata <yamahata@valinux.co.jp>
2012-07-16 14:39:39 +09:00
FUJITA Tomonori
c9edce4872 of1.2: add OFPQueuePropMinRate and OFPQueuePropMaxRate
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-14 08:52:53 +09:00
FUJITA Tomonori
323610d21f nxm: fix nxm to OFPMatch conversion
This fixes a bug that the conversion ignores dl_dst.

Soheil Hassas Yeganeh reported a problem about simple_isolation:

The problem is that the isolation service tries to install
flow-entries for a specific src and dst (in
SimpleIsolation._modflow_and_send_packet), but instead the nx match
code installs flow-entries only with src addresses and ignores the
dst.  So, when I boot multiple vms, only one of them is reachable.

For instance, assume that you have two VM's A and B. When a packet
comes from the gw to A, it installs "gw->A: A's port", but the acutal
installed rule is "gw: A's port". This works for A, but, when you boot
B, it tries to install "gw->B: B's port", but the acutal rule to be
installed is "gw: B's port".  So, it always connect the gateway to
only one VM at a time.

Reported-by: Soheil Hassas Yeganeh <soheil@cs.toronto.edu>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Reviewed-by: Soheil Hassas Yeganeh <soheil@cs.toronto.edu>
2012-07-13 16:43:18 +09:00
FUJITA Tomonori
d73680f303 of1.2: fix OFPGroupMod serialize
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Reviewed-by: Simon Horman <horms@verge.net.au>
2012-07-13 16:14:37 +09:00
Isaku Yamahata
007d735ec1 of1.2: OFPSetField serializer pads too much
The calculation of padding size was wrong. Calculate correct padding size.

Following the sample frame.

0000  00 23 5d 76 13 c2 00 26  b9 76 5c 81 08 00 45 00
0010  00 a4 43 8b 40 00 40 06  5e c0 ac 10 03 21 ac 11
0020  3c c6 19 e9 ae 7a 18 cf  dd ef d7 26 45 ec 80 18
0030  00 7a 98 9f 00 00 01 01  08 0a 50 db 9e 5e 01 30
0040  7e 3d

            03 0e 00 70 e4 f7  ea 88
            Start of OF packet

                                     00 00 00 00 00 00
0050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
0060  00 00 ff ff ff ff ff ff  ff ff ff ff ff ff 00 00
                                                 flags

0070  00 00
      pad

            00 01 00 0c 80 00  00 04 00 00 00 01 00 00
            type  len   oxm_header   value
            ofp_match   in_port
            Start of matching
                        Start of OXM TLV

0080  00 00

            00 04 00 30 00 00  00 00
            type  len   pad[4]
            apply_actions
            start of instruction

                                     00 19 00 18
                                     type  len
                                     start of set_field

                                                 80 00
                                                 oxm_header
                                                 oxm class
0090  08 06
      ETH_SRC

            22 22 22 22 22 22  00 00
                                      00 00 00 00 00 00
                                      <--Wrong padding-
00a0  00 00
      ---->
             00 00 00 10 00 00  00 02 05 dc 00 00 00 00
             type  len   port         maxlen
             start of ofp_action_output

00b0  00 00

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Reviewed-by: Simon Horman <horms@verge.net.au>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-12 11:36:22 +09:00
FUJITA Tomonori
da26715d80 of1.2: fix OFPPacketIn parser
We need two bytes padding right after the match.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-12 10:21:17 +09:00
FUJITA Tomonori
b389c933fb of1.2: fix MTIPv6NdTarget
AttributeError: 'MTIPv6NdTarget' object has no attribute 'mask

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-08 20:21:18 -07:00
FUJITA Tomonori
cb41bff9a5 of1.2: fix OFPActionPopVlan parser
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-08 20:20:35 -07:00
FUJITA Tomonori
a8938cb61e of1.2: fix OFPActionSetField padding
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-07 22:51:12 -07:00
FUJITA Tomonori
e97dd714ea of1.2: fix vlan_vid match
Fix the following error:

  File "/Users/fujita/git/ryu/ryu/ofproto/ofproto_v1_2_parser.py",
  line 1501, in serialize
    self.append_field(header, self.flow.vlan_vid, self.vlan_vid_mask)
AttributeError: 'OFPMatch' object has no attribute 'vlan_vid_mask'

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-07 18:55:15 -07:00
Yoshihiro Kaneko
b15a6649f3 app/rest: fix value error exception
This patch fixes value error exception.
The datapath-id is given in hex.

> Traceback (most recent call last):
>   File "/usr/lib/python2.7/dist-packages/gevent/pywsgi.py", line 438,
>   in handle_one_response
>     self.run_application()
>   File "/usr/lib/python2.7/dist-packages/gevent/pywsgi.py", line 424,
>   in run_application
>     self.result = self.application(self.environ, self.start_response)
>   File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line
>   130, in __call__
>     resp = self.call_func(req, *args, **self.kwargs)
>   File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line
>   195, in call_func
>     return self.func(req, *args, **kwargs)
>   File "/opt/stack/ryu/ryu/app/wsgi.py", line 81, in __call__
>     return controller(req)
>   File "/opt/stack/ryu/ryu/app/wsgi.py", line 52, in __call__
>     return getattr(self, action)(req, **kwargs)
>   File "/opt/stack/ryu/ryu/app/rest.py", line 104, in create
>     self.nw.create_port(network_id, int(dpid), int(port_id))
> ValueError: invalid literal for int() with base 10: '0000666a9c296241'

Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-06 16:38:31 +09:00
FUJITA Tomonori
b983bae62b of1.2: change IPv6 address representation
8H is more fitter than 4I for IPV6 address string representation.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-06 14:24:38 +09:00
FUJITA Tomonori
5b0fc9041f of1.2: fix OFPActionSetField
Fix some alignment bugs.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-06 14:24:35 +09:00
Simon Horman
e7a9ad2048 of1.2: Correct pad calculation for OFPMatch
In the case where the match length is a multiple of 8 the pad should be 0.
Previously a pad of 8 was used.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-06 12:39:45 +09:00
FUJITA Tomonori
8843a8d9cc of1.2: fix OFPBucket parser and serialize methods
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-06 01:06:32 +09:00
FUJITA Tomonori
8de8d653cc of1.2: fix OFAActionCopyTtlOut and OFPActionCopyTtlIn's parsers
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2012-07-06 01:06:30 +09:00