GithubHelp home page GithubHelp logo

faucetsdn / ryu Goto Github PK

View Code? Open in Web Editor NEW
1.5K 155.0 1.2K 13.95 MB

Ryu component-based software defined networking framework

Home Page: https://ryu-sdn.org

License: Apache License 2.0

Python 86.84% Shell 0.25% HTML 0.01% CSS 0.01% JavaScript 0.12% Makefile 0.01% Erlang 12.37% C 0.40% Gnuplot 0.02%

ryu's People

Contributors

alanquillin avatar alextwl avatar anarkiwi avatar cannium avatar cglewis avatar cloudysunny14 avatar fkakuma avatar fortitudepub avatar fujimoto-s avatar fujita avatar gizmoguy avatar horms avatar ihiroakikawai avatar iwaseyusuke avatar jkoelker avatar kondo-t avatar ohmk avatar satosi-k avatar shinpeimuraoka avatar snrism avatar takahashiminoru avatar toshiiw avatar ttsubo avatar vjorlikowski avatar watanabefumitaka avatar yamt avatar yi-tseng avatar ykaneko avatar yokoi-h avatar zhiweicen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ryu's Issues

Ryu import error

I have ubuntu 16.04 with virtualenv setup. When I try to run 12.py sample file ryu-manger giver following errors.

File "/home/user/ryu_project/bin/ryu-manager", line 5, in
from ryu.cmd.manager import main
File "/home/user/ryu_project/lib/python3.6/site-packages/ryu/cmd/manager.py", line 33, in
from ryu.app import wsgi
File "/home/zubair/projects/ryu2/lib/python3.6/site-packages/ryu/app/wsgi.py", line 109, in

I think I have import error for main and wsgi. How this problem will be resolved.

struct.error: required argument is not an integer

when i run this -> datapath.send_msg(mod)

File "/usr/local/lib/python3.6/dist-packages/ryu/ofproto/ofproto_v1_3_parser.py", line 1770, in _put
msg_pack_into(self.pack_str, buf, offset, value)
File "/usr/local/lib/python3.6/dist-packages/ryu/lib/pack_utils.py", line 25, in msg_pack_into
struct.pack_into(fmt, buf, offset, *args)
struct.error: required argument is not an integer

IDL issue with using Ryu as the OVSDB manager

I'm currently using latest Ryu from git with OVS 2.13.3, trying to replicate the simple example from https://ryu.readthedocs.io/en/latest/library_ovsdb_manager.html

I'm getting an exception in the event after receiving the connection from OVS:

New connection from 127.0.0.1:50278
hub: uncaught exception: Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/ryu/lib/hub.py", line 60, in _launch
return func(*args, **kwargs)
File "/usr/lib/python3.8/site-packages/ryu/services/protocols/ovsdb/manager.py", line 145, in _start_remote
app = client.RemoteOvsdb.factory(sock, client_address,
File "/usr/lib/python3.8/site-packages/ryu/services/protocols/ovsdb/client.py", line 325, in factory
system_id = discover_system_id(idl)
File "/usr/lib/python3.8/site-packages/ryu/services/protocols/ovsdb/client.py", line 126, in discover_system_id
idl.run()
File "/usr/lib/python3.8/site-packages/ovs/db/idl.py", line 257, in run
self.__send_server_schema_request()
File "/usr/lib/python3.8/site-packages/ovs/db/idl.py", line 584, in __send_server_schema_request
"get_schema", [self._server_db_name, str(self.uuid)])
AttributeError: 'Idl' object has no attribute '_server_db_name'

In

# NOTE(jkoelker) Wrap ovs's Idl to accept an existing session, and
there's an ovs's Idl wrapper that seems to be out of sync with private members defined in https://github.com/openvswitch/ovs/blob/c5a58ec155d89addeaff73cef95dc5f0dce2ef97/python/ovs/db/idl.py#L105

Not sure if the wrapper class should be calling super() or just adding the missing attributes?

ryu-manager run time error

Hi,
I have installed gevent (1.0b), sphinx, gflags, scapy on cygwin and fedora and in both cases,
I see run time error.
------------------ cygwin ---------
$ ryu-manager of1.py
Traceback (most recent call last):
File "/usr/bin/ryu-manager", line 32, in
from ryu.app import wsgi
File "/usr/lib/python2.6/site-packages/ryu/app/wsgi.py", line 19, in
import webob.dec
ImportError: No module named webob.dec
Exception KeyError: KeyError(4294130380L,) in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored

------------------- Fedora 11 ------------
$ ryu-manager of1.py
Traceback (most recent call last):
File "/usr/bin/ryu-manager", line 32, in
from ryu.app import wsgi
File "/usr/lib/python2.6/site-packages/ryu/app/wsgi.py", line 19, in
import webob.dec
ImportError: No module named webob.dec
Exception KeyError: KeyError(4294130380L,) in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored

I appreciate any help.

Regards
Syed Raihan

Add a flow entry together with table-miss when starting the Ryu controller!

Hello! everyone advise me plz....
I wanna to add flow entry together with table miss entry in every switch in the topology when starting the ryu controller.
the flow entry that i want to added is

match = parser.OFPMatch(in_port=in_port, eth_dst=('33:33:00:00:00:fb'))
actions = drop

I edit the code to add a flow in simple-switch_13.py

_@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 the table-miss flow entry.
    match = parser.OFPMatch()
    matchmulti = parser.OFPMatch(in_port=in_port, eth_dst=('33:33:00:00:00:fb'))
    actions = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER,
                                      ofproto.OFPCML_NO_BUFFER)]
    actionsmulti = [parser.OFPActionOutput(ofproto.OFPP_FLOOD)]        
    self.add_flow(datapath, 0, match, actions)
    self.add_flow(datapath, 0, matchmulti, actionsmulti)_

/home/chitsu/Pictures/1.jpg

but It's not okay the code.
plz, give me the correct code.
I'm poor in coding.

python dict issue in ofctl_v1_0.py

There are is an error in send_stats_request in ofctl_v1_0.py, please see the inline comment.

def send_stats_request(dp, stats, waiters, msgs):
dp.set_xid(stats)
waiters = waiters.setdefault(dp.id, {})
lock = gevent.event.AsyncResult()
# seems waiters[stats.xid] should be waiters[dp.id][stats.xid]
waiters[stats.xid] = (lock, msgs)
dp.send_msg(stats)

Docs have been broken?

It looks like the API documentation has been broken. Before the swap I think that was populated. I'm now trying to find the docs for OFPFlowMod and I'm pretty sure that's where it used to be.

Suggestion for OFPQueueGetConfigReply parser with queue.len=0

In /ryu/ofproto/ofproto_v1_3_parser.py about line=6073

If queue with len=0, while loop will not stop.

class OFPQueueGetConfigReply(MsgBase):
....
        offset = ofproto.OFP_QUEUE_GET_CONFIG_REPLY_SIZE
        while offset < msg_len:
            queue = OFPPacketQueue.parser(msg.buf, offset)
            msg.queues.append(queue)
            offset += queue.len

Flooding becomes drop

I have a mininet environment on Ubuntu VPS and I also installed Ryu and curl. I'm trying to test flooding between hosts but when I add flow entry, it becomes actions=drop. My mininet code:

sudo mn --controller=remote,ip=127.0.0.1 --mac --switch=ovsk,protocol=OpenFlow13 --topo=single,3

After starting up Ryu Controller

ryu-manager ryu.app.ofctl_rest

hub_flow.json code:

{
    "dpid": 1,
    "table_id": 0,
    "idle_timeout": 0,
    "hard_timeout": 0,
    "priority": 100,
    "match":{
    },
    "actions":[
        {
            "type":"OUTPUT",
            "port": 4294967291
        }
    ]
}

Adding flow entry via curl:

curl -X POST http://localhost:8080/stats/flowentry/add -d '@hub_flow.json'

Normally I should see this on dump flow:

cookie=0x0, duration=9.837s, table=0, n_packets=0, n_bytes=0, priority=100 actions=flood
But It shows:

cookie=0x0, duration=9.837s, table=0, n_packets=0, n_bytes=0, priority=100 actions=drop

So, there is no flooding, only drop. What causes this? Is it about Ryu Controller or mininet environment?

ovs-ofctl queue-stats not show queues after adding link bandwidth on mininet

The problem is that after adding the link bandwidth on mininet, like that,
net.addLink(s1,s2,1,1,cls=TCLink,bw=1000)
that I tried to check queue-stats but there was not queue on switch port,
but ovs-vsctl list qos and ovs-vsctl list queue these two commands still worked

If I delete the bandwidth on mininet, like that,
net.addLink(s1,s2,1,1)
that ovs-ofctl queue-stats is working again

I tried google this problem on mininet-discuss but seem to be no answer on it,
was there someone facing this problem before?

Running Ryu - PYTHONPATH=

Apologies if this is more a bug reporting area, I could not find a SDN Ryu forum to post queries.

I have followed the Ryu OpenFlow_Tutorial steps using the OpenFlow_Tutorial_Ryu3.2.ova build. All was going great until I ran the command" PYTHONPATH=. ./bin/ryu-manager ryu/app/simple_switch.py" which started but seemed to hang on "instantiating app ryu/app/simple_switch.py". After leaving it for 3 hours I escaped the process and tried a few more times after restarts, through SSH etc to no success. I was wondering if this is a common issue or if someone knows what I am doing wrong.
Thanks,
Meirbhin

troubleshoot

Next release date

Hello,

We are using ryu as package from pypi but TLS issues from PR #100 are showstopper for our app. Is there release incorporating those changes coming anytime soon?

Thank you

Using ryu/ofproto/ofproto_v1_5_parser.py in OpenFlow 1.3 application

I'm tryig to use the ping responder application from the ryu book @
https://osrg.github.io/ryu-book/en/html/packet_lib.html#application-examples

During the tests I get the following exception:

  File "/home/student/.local/lib/python3.8/site-packages/ryu/ofproto/ofproto_v1_5_parser.py", line 5137, in __init__
    assert 'in_port' in match
TypeError: argument of type 'NoneType' is not iterable

Why is the OpenFlow15 parser used in an OpenFlow13 application?

Ryu TLS support broken for python versions 3.7 and above

Due to eventlet/eventlet#526 ryu will crash on startup when TLS is configured and python 3.7 or 3.8 is used:

root@ff4214bc0796:/# ryu-manager --verbose --ctl-cert /tmp/ryu/ryu/tests/unit/controller/cert.crt --ctl-privkey /tmp/ryu/ryu/tests/unit/controller/cert.key

loading app ryu.controller.ofp_handler
instantiating app ryu.controller.ofp_handler of OFPHandler
BRICK ofp_event
  CONSUMES EventOFPEchoReply
  CONSUMES EventOFPEchoRequest
  CONSUMES EventOFPErrorMsg
  CONSUMES EventOFPHello
  CONSUMES EventOFPPortDescStatsReply
  CONSUMES EventOFPPortStatus
  CONSUMES EventOFPSwitchFeatures
hub: uncaught exception: Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/ryu/lib/hub.py", line 60, in _launch
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/ryu/lib/hub.py", line 140, in wrap_and_handle
    handle(ctx.wrap_socket(sock, **ssl_args), addr)
  File "/usr/local/lib/python3.7/dist-packages/eventlet/green/ssl.py", line 437, in wrap_socket
    return GreenSSLSocket(sock, *a, _context=self, **kw)
  File "/usr/local/lib/python3.7/dist-packages/eventlet/green/ssl.py", line 76, in __new__
    *args, **kw
TypeError: wrap_socket() got an unexpected keyword argument '_context'

Timeout when OF controller is restarting

Hello:

In OpenStack Neutron, we use a fork of ryu library, os-ken. Recently we have backported two patches related to app/ofctl, when the datapath disconnects:

That solved some issues we had initially when the OF controller is restarting. For example, when we define new OpenFlow protocols.

Error snippet: https://paste.opendev.org/show/810072/

After we set the new OF protocols, the OF controller is restarted. When we try to execute a command, we receive the "unknown dpid" error (a InvalidDatapath exception is thrown) until the new OF controller is registered in "OfctlService._switches".

However, in some cases the OF controller is present and we try to process the message. The message XID should be None, but as you can see in the snippet, the XID has been already set. What I don't know is if this is an old message being processed again and what can we do:

  • Just skip this assertion, reset message XID and reply.
  • Raise a InvalidDatapath, discarding this message.

In any case, because of this assertion exception, we never receive a reply and we timeout. I think "OfctlService._handle_send_msg" should handle this possible situation, returning a normal reply or an exception.

Regards.

Ryu + CPqD software switch

Hey, I encountered error messages when I tried to add meter table using dpctl

dpctl tcp:127.0.0.1:6633 meter-mod cmd=add,flags=1,meter=3 drop:rate=10000

I was running simple_switch_13.py as a basic test to configure switch using dpctl without changing simple_switch_13.py.

The error message showed up in controller are ..

Encounter an error during parsing OpenFlow packet from switch.This implies switch sending a malfold OpenFlow packet.version 0x04 msg_type 29 msg_len 32 xid 4043243760 buf 0x4 0x1d 0x0 0x20 0xf0 0xff 0x0 0xf0 0x0 0x0 0x0 0x1 0x0 0x0 0x0 0x3 0x0 0x1 0x0 0x10 0x0 0x0 0x27 0x10 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/ryu/ofproto/ofproto_parser.py", line 56, in msg
return msg_parser(datapath, version, msg_type, msg_len, xid, buf)
File "/usr/local/lib/python2.7/dist-packages/ryu/ofproto/ofproto_v1_3_parser.py", line 52, in msg_parser
return parser(datapath, version, msg_type, msg_len, xid, buf)
TypeError: 'NoneType' object is not callable
Encounter an error during parsing OpenFlow packet from switch.This implies switch sending a malfold OpenFlow packet.version 0x04 msg_type 20 msg_len 8 xid 4043243760 buf 0x4 0x14 0x0 0x8 0xf0 0xff 0x0 0xf0
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/ryu/ofproto/ofproto_parser.py", line 56, in msg
return msg_parser(datapath, version, msg_type, msg_len, xid, buf)
File "/usr/local/lib/python2.7/dist-packages/ryu/ofproto/ofproto_v1_3_parser.py", line 52, in msg_parser
return parser(datapath, version, msg_type, msg_len, xid, buf)
TypeError: 'NoneType' object is not callable

It seems to be that my controller was unable to parse the packet from switch, why would this happen ?

I installed CPqD software switch supporting version 1.3.

Is there any problems with my setting ?

Missing version in PyPi

Versions 4.33 and 4.34 are not published to PyPi.
Can they be made available too (or at least the latest 4.34)?

why datapath id is registered with integer type in ryu/app/simple_switch_rest_13.py ?

When I learned Ryu Rest, I found that the datapath ID is set to int at registration time

@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, {})

so mac_to_port = {1: {}}
however, when updating mac_to_port with api, i got dpid is a string, and decorator validates string the dpid.

@route('simpleswitch', url, methods=['PUT'],
     requirements={'dpid': dpid_lib.DPID_PATTERN})

then, string dpid "0000000000000001" not in mac_to_port, return 404.

if dpid not in simple_switch.mac_to_port:
    return Response(status=404)

if i reset bridge datapath-id with command ovs-vsctl set bridge br0 other-config:datapath-id=<random string>, then got random number from event message.

gui_topology.py throws version error when using OF 1.5

I am running mininet version 2.13.3. Receiving error AssertionError: No OpenFlow version is available

ryu-manager /ryu/ryu/app/simple_switch_15.py /ryu/ryu/app/gui_topology/gui_topology.py --observe-links

loading app /ryu/ryu/app/simple_switch_15.py
loading app //ryu/ryu/app/gui_topology/gui_topology.py
loading app ryu.controller.ofp_handler
loading app ryu.app.ofctl_rest
loading app ryu.app.rest_topology
loading app ryu.app.ws_topology
loading app ryu.controller.ofp_handler
creating context wsgi
instantiating app None of DPSet
creating context dpset
instantiating app None of Switches
creating context switches
instantiating app /home/ryu/ryu/app/simple_switch_15.py of SimpleSwitch15
Traceback (most recent call last):
File "/.venv/bin/ryu-manager", line 8, in
sys.exit(main())
File "/.venv/lib/python3.8/site-packages/ryu/cmd/manager.py", line 101, in main
services.extend(app_mgr.instantiate_apps(**contexts))
File "/.venv/lib/python3.8/site-packages/ryu/base/app_manager.py", line 509, in instantiate_apps
self._instantiate(app_name, cls, *args, **kwargs)
File "/.venv/lib/python3.8/site-packages/ryu/base/app_manager.py", line 491, in _instantiate
ofproto_protocol.set_app_supported_versions(cls.OFP_VERSIONS)
File "/.venv/lib/python3.8/site-packages/ryu/ofproto/ofproto_protocol.py", line 46, in set_app_supported_versions
assert _supported_versions, 'No OpenFlow version is available'
AssertionError: No OpenFlow version is available

I have confirmed that my mininet switch supports OF1.5, as shown below

mininet> sh ovs-ofctl dump-flows -O Openflow15 s1
cookie=0x0, duration=3.955s, table=0, n_packets=0, n_bytes=0, idle_age=3, priority=1,in_port="s1-eth16",dl_dst=aa:00:00:00:00:06 actions=output:"s1-eth1"
cookie=0x0, duration=3.923s, table=0, n_packets=0, n_bytes=0, idle_age=3, priority=1,in_port="s1-eth1",dl_dst=aa:00:00:00:00:01 actions=output:"s1-eth16"
cookie=0x0, duration=9.084s, table=0, n_packets=59, n_bytes=4910, idle_age=3, priority=0 actions=CONTROLLER:65535

If i launch only the simply_switch_15.py file, everything works fine. So it's the gui file that doesnt work for some reason.

Any ideas ?

I also tested with OF 1.4, which also works fine.

Thanks

Decoding of packet_in version 4

When I'm sending a packet_in message from the switch (LINC) using OFP 1.3.1 (4), which looks like this (it includes a match for an ARP request packet):

04 0A 00 94 00 00 02 6F FF FF FF FF 00 2A 00 00
00 00 00 00 00 00 00 00 00 01 00 50 80 00 00 04
00 00 00 02 80 00 0A 02 08 06 80 00 06 06 FF FF
FF FF FF FF 80 00 08 06 00 BB CC DD EE FF 80 00
2A 02 00 01 80 00 2C 04 C0 A8 01 02 80 00 2E 04
C0 A8 01 01 80 00 30 06 00 BB CC DD EE FF 80 00
32 06 00 00 00 00 00 00 00 00 FF FF FF FF FF FF
00 BB CC DD EE FF 08 06 00 01 08 00 06 04 00 01
00 BB CC DD EE FF C0 A8 01 02 00 00 00 00 00 00
C0 A8 01 01

... Ryu is crashing with the following error:

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/gevent/greenlet.py", line 390, in run
    result = self._run(*self.args, **self.kwargs)
  File "/usr/local/lib/python2.7/dist-packages/ryu/controller/controller.py", line 298, in datapath_connection_factory
    datapath.serve()
  File "/usr/local/lib/python2.7/dist-packages/ryu/controller/controller.py", line 217, in serve
    self._recv_loop()
  File "/usr/local/lib/python2.7/dist-packages/ryu/controller/controller.py", line 94, in deactivate
    method(self)
  File "/usr/local/lib/python2.7/dist-packages/ryu/controller/controller.py", line 170, in _recv_loop
    version, msg_type, msg_len, xid, buf)
  File "/usr/local/lib/python2.7/dist-packages/ryu/ofproto/ofproto_parser.py", line 50, in msg
    return msg_parser(datapath, version, msg_type, msg_len, xid, buf)
  File "/usr/local/lib/python2.7/dist-packages/ryu/ofproto/ofproto_v1_3_parser.py", line 50, in msg_parser
    return parser(datapath, version, msg_type, msg_len, xid, buf)
  File "/usr/local/lib/python2.7/dist-packages/ryu/ofproto/ofproto_v1_3_parser.py", line 1287, in parser
    msg.buf, ofproto_v1_3.OFP_HEADER_SIZE)
ValueError: too many values to unpack

I've checked the binary against the 1.3.1 spec and I'm 99% sure it's a valid message.

Any ideas?

Ryu-manager crash on Ubuntu 22.04 (Python3.10.4)

Installed ryu on Ubuntu22.04. Trying to run the simple-switch-13 application:

student@uc3m:~$ ryu-manager ryu.app.simple_switch_13
Traceback (most recent call last):
  File "/home/student/.local/bin/ryu-manager", line 5, in <module>
    from ryu.cmd.manager import main
  File "/home/student/.local/lib/python3.10/site-packages/ryu/cmd/manager.py", line 33, in <module>
    from ryu.app import wsgi
  File "/home/student/.local/lib/python3.10/site-packages/ryu/app/wsgi.py", line 109, in <module>
    class _AlreadyHandledResponse(Response):
  File "/home/student/.local/lib/python3.10/site-packages/ryu/app/wsgi.py", line 111, in _AlreadyHandledResponse
    from eventlet.wsgi import ALREADY_HANDLED
ImportError: cannot import name 'ALREADY_HANDLED' from 'eventlet.wsgi' (/home/student/.local/lib/python3.10/site-packages/eventlet/wsgi.py)
student@uc3m:~$ python3 --version
Python 3.10.4```

gui_topology html folder is missing

gui_topology.py does not find the html folder.

From the docs I simply run PYTHONPATH=. ./bin/ryu run --observe-links ryu/app/gui_topology/gui_topology.py but no html folder is found.

Looking in the source code the html folder exists.
However, in the released version on pypi there is no html folder.

Any solution?

How to use the Ryu REST API to add flow tables using MAC address matching.

How to use Ryu restAPI to add stream entries to a switch?
for example:
curl -X POST -d '{
"dpid": 2,
"cookie": 1,
"cookie_mask": 1,
"table_id": 0,
"idle_timeout": 0,
"hard_timeout": 0,
"priority": 11111,
"flags": 1,
"match":{
"in_port":3,
"dl_dst":"00:00:00:00:00:01"
},
"actions":[
{
"type":"OUTPUT",
"port": 1
}
]
}' http://localhost:8080/stats/flowentry/add
In the example above, what format should the MAC address match be in? What went wrong?

Error when adding flow entry

Hello,

I got an error upon adding a new flow entry via ofctl_rest, using different docker images for ryu (latarc/ryu and osrg/ryu):

Error traceback

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/eventlet/wsgi.py", line 573, in handle_one_response
    result = self.application(self.environ, start_response)
  File "/usr/local/lib/python3.8/site-packages/ryu/app/wsgi.py", line 236, in __call__
    return super(wsgify_hack, self).__call__(environ, start_response)
  File "/usr/local/lib/python3.8/site-packages/webob/dec.py", line 129, in __call__
    resp = self.call_func(req, *args, **kw)
  File "/usr/local/lib/python3.8/site-packages/webob/dec.py", line 193, in call_func
    return self.func(req, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/ryu/app/wsgi.py", line 290, in __call__
    return controller(req)
  File "/usr/local/lib/python3.8/site-packages/ryu/app/wsgi.py", line 160, in __call__
    return getattr(self, action)(req, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/ryu/app/ofctl_rest.py", line 276, in wrapper
    method(self, req, dp, ofctl, body, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/ryu/app/ofctl_rest.py", line 436, in mod_flow_entry
    ofctl.mod_flow_entry(dp, flow, mod_cmd)
  File "/usr/local/lib/python3.8/site-packages/ryu/lib/ofctl_v1_4.py", line 847, in mod_flow_entry
    ofctl_utils.send_msg(dp, flow_mod, LOG)
  File "/usr/local/lib/python3.8/site-packages/ryu/lib/ofctl_utils.py", line 242, in send_msg
    dp.send_msg(msg)
  File "/usr/local/lib/python3.8/site-packages/ryu/controller/controller.py", line 438, in send_msg
    msg.serialize()
  File "/usr/local/lib/python3.8/site-packages/ryu/ofproto/ofproto_parser.py", line 270, in serialize
    self._serialize_body()
  File "/usr/local/lib/python3.8/site-packages/ryu/ofproto/ofproto_v1_4_parser.py", line 4433, in _serialize_body
    inst.serialize(self.buf, offset)
  File "/usr/local/lib/python3.8/site-packages/ryu/ofproto/ofproto_v1_4_parser.py", line 4600, in serialize
    a.serialize(buf, action_offset)
  File "/usr/local/lib/python3.8/site-packages/ryu/ofproto/ofproto_v1_4_parser.py", line 4709, in serialize
    msg_pack_into(ofproto.OFP_ACTION_OUTPUT_PACK_STR, buf,
  File "/usr/local/lib/python3.8/site-packages/ryu/lib/pack_utils.py", line 25, in msg_pack_into
    struct.pack_into(fmt, buf, offset, *args)
struct.error: required argument is not an integer

When debugging with curl, I found out that the problem was in the port field of the actions of the flow entry, as shown below:

No zero padding on osrg/ryu gives me a HTTP 200.
With zero padding on osrg/ryu gives me a HTTP 200.
No zero padding on latarc/ryu gives me a HTTP 200.
With zero padding on latarc/ryu gives me a HTTP 400 and an error.

  • I'm running Ryu using docker containers, and the docker host OS is Ubuntu 20.04.1 LTS.
  • Ryu Manager command (on both containers): ryu-manager --observe-links ryu.app.ofctl_rest ryu.app.rest_topology
  • The Python version on the latarc/ryu container is 3.8.5, while osrg/ryu uses Python 2.7.12 so it could also be related to the python version.

The curl commands and respective output are as follow:

Not zero padded port value on v4.31

curl -v -d '{ "dpid": "1", "idle_timeout": 30, "hard_timeout": 30,  "instructions": [  { "type": "APPLY_ACTIONS", "actions": [ { "max_len": 65535, "port": "3", "type": "OUTPUT" } ] } ] }' http://172.17.0.4:8080/stats/flowentry/add
*   Trying 172.17.0.4:8080...
* TCP_NODELAY set
* Connected to 172.17.0.4 (172.17.0.4) port 8080 (#0)
> POST /stats/flowentry/add HTTP/1.1
> Host: 172.17.0.4:8080
> User-Agent: curl/7.68.0
> Accept: */*
> Content-Length: 174
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 174 out of 174 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=UTF-8
< Content-Length: 0
< Date: Sat, 22 Aug 2020 04:49:14 GMT
< 
* Connection #0 to host 172.17.0.4 left intact

Zero padded port value on v4.31

curl -v -d '{ "dpid": "1", "idle_timeout": 30, "hard_timeout": 30,  "instructions": [  { "type": "APPLY_ACTIONS", "actions": [ { "max_len": 65535, "port": "000003", "type": "OUTPUT" } ] } ] }' http://172.17.0.4:8080/stats/flowentry/add
*   Trying 172.17.0.4:8080...
* TCP_NODELAY set
* Connected to 172.17.0.4 (172.17.0.4) port 8080 (#0)
> POST /stats/flowentry/add HTTP/1.1
> Host: 172.17.0.4:8080
> User-Agent: curl/7.68.0
> Accept: */*
> Content-Length: 179
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 179 out of 179 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=UTF-8
< Content-Length: 0
< Date: Sat, 22 Aug 2020 04:49:19 GMT
< 
* Connection #0 to host 172.17.0.4 left intact

Not zero padded port value on v4.34

curl -v -d '{ "dpid": "1", "idle_timeout": 30, "hard_timeout": 30,  "instructions": [  { "type": "APPLY_ACTIONS", "actions": [ { "max_len": 65535, "port": "3", "type": "OUTPUT" } ] } ] }' http://172.17.0.3:8080/stats/flowentry/add   
*   Trying 172.17.0.3:8080...
* TCP_NODELAY set
* Connected to 172.17.0.3 (172.17.0.3) port 8080 (#0)
> POST /stats/flowentry/add HTTP/1.1
> Host: 172.17.0.3:8080
> User-Agent: curl/7.68.0
> Accept: */*
> Content-Length: 174
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 174 out of 174 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=UTF-8
< Content-Length: 0
< Date: Sat, 22 Aug 2020 04:53:59 GMT
< 
* Connection #0 to host 172.17.0.3 left intact

Zero padded port value on v4.34 with traceback

curl -v -d '{ "dpid": "1", "idle_timeout": 30, "hard_timeout": 30,  "instructions": [  { "type": "APPLY_ACTIONS", "actions": [ { "max_len": 65535, "port": "000003", "type": "OUTPUT" } ] } ] }' http://172.17.0.3:8080/stats/flowentry/add
*   Trying 172.17.0.3:8080...
* TCP_NODELAY set
* Connected to 172.17.0.3 (172.17.0.3) port 8080 (#0)
> POST /stats/flowentry/add HTTP/1.1
> Host: 172.17.0.3:8080
> User-Agent: curl/7.68.0
> Accept: */*
> Content-Length: 179
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 179 out of 179 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 500 Internal Server Error
< Content-Type: text/plain
< Content-Length: 2309
< Date: Sat, 22 Aug 2020 04:53:38 GMT
< Connection: close
< 
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/eventlet/wsgi.py", line 573, in handle_one_response
    result = self.application(self.environ, start_response)
  File "/usr/local/lib/python3.8/site-packages/ryu/app/wsgi.py", line 236, in __call__
    return super(wsgify_hack, self).__call__(environ, start_response)
  File "/usr/local/lib/python3.8/site-packages/webob/dec.py", line 129, in __call__
    resp = self.call_func(req, *args, **kw)
  File "/usr/local/lib/python3.8/site-packages/webob/dec.py", line 193, in call_func
    return self.func(req, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/ryu/app/wsgi.py", line 290, in __call__
    return controller(req)
  File "/usr/local/lib/python3.8/site-packages/ryu/app/wsgi.py", line 160, in __call__
    return getattr(self, action)(req, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/ryu/app/ofctl_rest.py", line 276, in wrapper
    method(self, req, dp, ofctl, body, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/ryu/app/ofctl_rest.py", line 436, in mod_flow_entry
    ofctl.mod_flow_entry(dp, flow, mod_cmd)
  File "/usr/local/lib/python3.8/site-packages/ryu/lib/ofctl_v1_4.py", line 847, in mod_flow_entry
    ofctl_utils.send_msg(dp, flow_mod, LOG)
  File "/usr/local/lib/python3.8/site-packages/ryu/lib/ofctl_utils.py", line 242, in send_msg
    dp.send_msg(msg)
  File "/usr/local/lib/python3.8/site-packages/ryu/controller/controller.py", line 438, in send_msg
    msg.serialize()
  File "/usr/local/lib/python3.8/site-packages/ryu/ofproto/ofproto_parser.py", line 270, in serialize
    self._serialize_body()
  File "/usr/local/lib/python3.8/site-packages/ryu/ofproto/ofproto_v1_4_parser.py", line 4433, in _serialize_body
    inst.serialize(self.buf, offset)
  File "/usr/local/lib/python3.8/site-packages/ryu/ofproto/ofproto_v1_4_parser.py", line 4600, in serialize
    a.serialize(buf, action_offset)
  File "/usr/local/lib/python3.8/site-packages/ryu/ofproto/ofproto_v1_4_parser.py", line 4709, in serialize
    msg_pack_into(ofproto.OFP_ACTION_OUTPUT_PACK_STR, buf,
  File "/usr/local/lib/python3.8/site-packages/ryu/lib/pack_utils.py", line 25, in msg_pack_into
    struct.pack_into(fmt, buf, offset, *args)
struct.error: required argument is not an integer
* Closing connection 0

I am not certain if this is intended behavior, but I'm still reporting this as an issue, mainly because legacy code using this format may break upon updating Ryu to a newer version and maybe it is preferred to maximize compatibility.

Regards,
Lucas Schneider

Flow stats 'in_port' error

When I try to get flow stats, I get a keyerror: 'in_port'.
At times I get the flow stats reply perfectly but most of the time I get this error with any reason.
15986931488468818718086300836189

RYU v4.34 does not pin eventlet version.

Eventlet 0.31.0 causes runtime exception in RYU v4.34

...
./ryu/app/wsgi.py:111: in _AlreadyHandledResponse
    from eventlet.wsgi import ALREADY_HANDLED
E   ImportError: cannot import name 'ALREADY_HANDLED'

gunicorn has same problems: eventlet/eventlet#702

This PR looks like a solution #137

Would it be possible to merge it and release a new version soon?

Suggestion for OFPMatch class to OpenFlow 1.2/1.3

I am implementing a simple switch for OpenFlow 1.3 and I need to retrieve the in_port value from the match fields. To do that I need to search the list for the field (as the specification doesn't require ordered fields).

My suggestion is to have a dictionary instead of a list to ease the access to the fields, using the header as the key. Something like:

in_port =  msg.match.fields[ofproto.OXM_OF_IN_PORT].value

I implemented a patch for this. If you think it's good, or have suggestions, I can submit to the developer list.

Adding Spanning Tree Protocol (STP) in my_controller.py

Hello ryu team.

I want to ask if it's possible add the stp in my customized ryu controller? I saw the simple_switch_stp_13.py and found that there were some different with simple_switch_13.py

In _packet_in_handler function, the stp oriented stplib.EventPacketIn from stplib.py and simple_switch_13 oriented ofp_event.EventOFPPacketIn from ofp_event.py

But I saw input variable were also ev in openflow.

I had tried move the _packet_in_handler from simple_switch_stp_13.py to my controller but it occurred some problem that there were two blocked port in my topology. So I posed this issue, wanna to know whether someone used this case.

My object is to use STP to solve the ARP storm in my cycle topology, and hope the flow dropped is dedicated for ARP packet not all packet in STP

Modifying a Nicira Action

Hi,

I'm trying to modify the NXActionSample2 action and wanted to ask for your help. Basically I have an OVS patch that modifies the Sampling action and adds a few custom fields. I currently use it with ovs-ofctl, but It would be great if I can just modify Ryu to accept the new args.

Here is my ovs-ofctl

sudo ovs-ofctl add-flow cwag_br0 "table=15,priority=12,metadata=0x75945885e85,actions=sample(probability=600,collector_set_id=1,obs_domain_id=1,obs_point_id=1,apn_mac_addr=58:bc:27:13:31:50,msisdn=5101006096,apn_name=\"cwc wifi offload\",pdp_start_epoch=100,sampling_port=gre0),resubmit(,20)"

Here is the corresponding OVS flow it creates

 cookie=0x0, duration=33.792s, table=15, n_packets=0, n_bytes=0, priority=12,metadata=0x75945885e85 actions=sample(probability=600,collector_set_id=1,obs_domain_id=1,obs_point_id=1,pdp_start_epoch=100,apn_mac_addr=58:bc:27:13:31:50,msisdn=5101006096,apn_name="cwc wifi offload",sampling_port=gre0),resubmit(,20)

The added fields from the standard Sample action are:

msisdn:
apn_mac_addr
apn_name
pdp_start_epoch

Here is the struct in ovs:

struct nx_action_sample2 {
    ovs_be16 type;                  /* OFPAT_VENDOR. */
    ovs_be16 len;                   /* Length is 32. */
    ovs_be32 vendor;                /* NX_VENDOR_ID. */
    ovs_be16 subtype;               /* NXAST_SAMPLE. */
    ovs_be16 probability;           /* Fraction of packets to sample. */
    ovs_be32 collector_set_id;      /* ID of collector set in OVSDB. */
    ovs_be32 obs_domain_id;         /* ID of sampling observation domain. */
    ovs_be32 obs_point_id;          /* ID of sampling observation point. */
    ovs_be16 sampling_port;         /* Sampling port. */
    uint8_t  msisdn[16];
    struct   eth_addr apn_mac_addr;
    uint8_t  apn_name[24];
    uint64_t pdp_start_epoch;
    uint8_t  direction;             /* NXAST_SAMPLE3 only. */
    uint8_t  zeros[5];              /* Pad to a multiple of 8 bytes */
 };
 OFP_ASSERT(sizeof(struct nx_action_sample2) == 88);

/* not sure if this is requried */
struct ofpact_sample {
    OFPACT_PADDED_MEMBERS(
        struct ofpact ofpact;
        uint16_t probability;   /* Always positive. */
        uint32_t collector_set_id;
        uint32_t obs_domain_id;
        uint32_t obs_point_id;
        ofp_port_t sampling_port;
        enum nx_action_sample_direction direction;
        uint8_t msisdn[16];
        struct eth_addr apn_mac_addr;
        uint8_t apn_name[24];
        uint64_t pdp_start_epoch;
    );
};

Currently with some hacking I've achieved this with RYU:

parser.NXActionSample2(
            probability=self.ipfix_config.probability, collector_set_id=self.ipfix_config.collector_set_id,
            obs_domain_id=self.ipfix_config.obs_domain_id, obs_point_id=self.ipfix_config.obs_point_id,
            apn_mac_addr=[10, 0, 39, 0, 0, 5],
            msisdn="5101006096", apn_name="cwc wifi offload", pdp_start_epoch=100,
            sampling_port=32768,
            )

 cookie=0x0, duration=11.112s, table=203, n_packets=0, n_bytes=0, priority=12 actions=sample(probability=65535,collector_set_id=1,obs_domain_id=1,obs_point_id=1,pdp_start_epoch=7205759403792793600,apn_mac_addr=0a:00:27:00:00:05,msisdn=5101006096,apn_name="cwc wifi offload",sampling_port=gre0),resubmit(,16),set_field:0->reg0,set_field:0->reg3

All the fields are correct except the pdp_start_epoch. I assume its because I messed up the struct packing as I'm not sure how to properly pack/encode the mac addr. Here is the relevant RYU code ( I've tried using ofp.oxm_from_user_header, ofp.oxm_serialize_header functions but didn't get anywhere so just encoding to ascii worked best for me.


    class NXActionSample2(NXAction):

        _subtype = nicira_ext.NXAST_SAMPLE2

        # probability, collector_set_id, obs_domain_id,
        # obs_point_id, msisdn, apn_mac_addr, apn_name, sampling_port
        _fmt_str = '!HIIIH16s6s24sQ6x'

        def __init__(self,
                     probability,
                     msisdn,
                     apn_mac_addr,
                     apn_name,
                     pdp_start_epoch,
                     collector_set_id=0,
                     obs_domain_id=0,
                     obs_point_id=0,
                     sampling_port=0,
                     type_=None, len_=None, experimenter=None, subtype=None):
            super(NXActionSample2, self).__init__()
            self.probability = probability
            self.collector_set_id = collector_set_id
            self.obs_domain_id = obs_domain_id
            self.obs_point_id = obs_point_id

            self.msisdn = msisdn.encode('ascii')
            self.apn_mac_addr = apn_mac_addr
            self.apn_name = apn_name.encode('ascii')
            self.pdp_start_epoch = pdp_start_epoch

            self.sampling_port = sampling_port

        @classmethod
        def parser(cls, buf):
            (probability,
             collector_set_id,
             obs_domain_id,
             obs_point_id,
             sampling_port,
             msisdn,
             apn_mac_addr,
             apn_name,
             pdp_start_epoch) = struct.unpack_from(
                cls._fmt_str, buf, 0)

            return cls(probability,
                       msisdn,
                       apn_mac_addr,
                       apn_name,
                       pdp_start_epoch,
                       collector_set_id,
                       obs_domain_id,
                       obs_point_id,
                       sampling_port)

        def serialize_body(self):
            data = bytearray()
            msg_pack_into(self._fmt_str, data, 0,
                          self.probability,
                          self.collector_set_id,
                          self.obs_domain_id,
                          self.obs_point_id,
                          self.sampling_port,
                          self.msisdn,
                          *self.apn_mac_addr,
                          self.apn_name,
                          self.pdp_start_epoch)
            return data

Would really appreciate your help, thank you!

EventDP not triggering

If I catch dpset.EventDP, my function is never called. If I change it to ofp_event.EventOFPStateChange, it works.

Doesn't work:

from ryu.base import app_manager
from ryu.controller import ofp_event
from ryu.controller import dpset
from ryu.controller.handler import MAIN_DISPATCHER
from ryu.controller.handler import set_ev_cls

class Example(app_manager.RyuApp):
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)

    @set_ev_cls(dpset.EventDP, MAIN_DISPATCHER)
    def switch_up_handler(self, ev):
        print "DP  Up!"

Works:

from ryu.base import app_manager
from ryu.controller import ofp_event
from ryu.controller import dpset
from ryu.controller.handler import MAIN_DISPATCHER
from ryu.controller.handler import set_ev_cls

class Example(app_manager.RyuApp):
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)

    @set_ev_cls(ofp_event.EventOFPStateChange, MAIN_DISPATCHER)
    def switch_up_handler(self, ev):
        print "DP  Up!"

P.S. If I named the file "test.py" ryu-manager seemed to just ignore it.

Issue Integrating snort with Ryu

I setup my topoloyg with 4 hosts, with a remote ryu controller(which is on same machine) and host4(s1-eth4 on switch as snort port)
image

Modified the snort file:
image
enabled promiscuous mode on snort interface of OVS switch:
image
ran the snort script:
image

image

Manually started snort on host4's interface, with the ping rules enabled to test.
image
image

I run h1 hping3 --flood h3 on mininet but dont get any snort alerts.

Flow removed message doesn't work (mininet+ryu controller in ubuntu20.10)

Flow removed message:When flow entries time out or are deleted, the switch notifies controller with this message.
I write the following example to my ryu app.
And the ryu controller can't detect the flow removed message from switches, when the flow entries timeout or are deleted by hand. Plz tell me what the problem is......

    @set_ev_cls(ofp_event.EventOFPFlowRemoved, MAIN_DISPATCHER)
    def flow_removed_handler(self, ev):
        msg = ev.msg
        dp = msg.datapath
        ofp = dp.ofproto

        if msg.reason == ofp.OFPRR_IDLE_TIMEOUT:
            reason = 'IDLE TIMEOUT'
        elif msg.reason == ofp.OFPRR_HARD_TIMEOUT:
            reason = 'HARD TIMEOUT'
        elif msg.reason == ofp.OFPRR_DELETE:
            reason = 'DELETE'
        elif msg.reason == ofp.OFPRR_GROUP_DELETE:
            reason = 'GROUP DELETE'
        else:
            reason = 'unknown'

        self.logger.debug('OFPFlowRemoved received: '
                          'cookie=%d priority=%d reason=%s table_id=%d '
                          'duration_sec=%d duration_nsec=%d '
                          'idle_timeout=%d hard_timeout=%d '
                          'packet_count=%d byte_count=%d match.fields=%s',
                          msg.cookie, msg.priority, reason, msg.table_id,
                          msg.duration_sec, msg.duration_nsec,
                          msg.idle_timeout, msg.hard_timeout,
                          msg.packet_count, msg.byte_count, msg.match)

How to add a CT action in the switch's flow table?

I'm a new beginner learning ovs and ryu and I encountered a problem, which I still cannot solve after searching the
official documents
.

As far as I know, for example, to tell the switch to hand in any incoming ARP flows to the controller, I can do the below thing in python:

match = parser.OFPMatch(eth_type=ether_types.ETH_TYPE_ARP)
actions = [
    parser.OFPActionOutput(ofproto.OFPP_CONTROLLER, ofproto.OFPCML_NO_BUFFER)
]
self.add_flow(datapath, 1, match, actions)

which are equivalent to the followings ovs-ofctl command.

ovs-ofctl add-flow <bridge> "priority=1,arp,actions=CONTROLLER:65535"

And my question is, how to tell the switch to do the specified CT action? or what are equivalent to the command below?

ovs-ofctl add-flow <bridge> "ip,nw_dst=10.0.0.1,actions=ct(commit,table=1,nat(dst=10.0.0.2))"

PS:

If there is any info that may help but not posted here, please feel free to let me know!

Can support multi-controller?

Can Ryu support Multi-controller or not??
how to create multi-controller network in mininet and how to run Ryu app in each controller??

To drop multicast packet

which is used to drop the packet.

OFPP_MAX = 0xffffff00 # Maximum number of physical and logical
# switch ports.
OFPP_UNSET = 0xfffffff7 # Output port not set in action-set.
# used only in OXM_OF_ACTSET_OUTPUT.
OFPP_IN_PORT = 0xfffffff8 # Send the packet out the input port. This
# reserved port must be explicitly used in
# order to send back out of the input port.
OFPP_TABLE = 0xfffffff9 # Submit the packet to the first flow table
# NB: This destination port can only be used
# in packet-out messages.
OFPP_NORMAL = 0xfffffffa # Forward using non-OpenFlow pipeline.
OFPP_FLOOD = 0xfffffffb # Flood using non-OpenFlow pipeline.
OFPP_ALL = 0xfffffffc # All standard ports except input port.
OFPP_CONTROLLER = 0xfffffffd # Send to controller.
OFPP_LOCAL = 0xfffffffe # Local openflow "port".
OFPP_ANY = 0xffffffff

ovsdb events not firing.

I'm trying to use the qos_rest example in the repo. I cannot manage to create a queue because of this response:

[
    {
        "switch_id": "0000000c298b1415",
        "command_result": {
            "result": "failure",
            "details": "ovs_bridge is not exists"
        }
    }
]

By looking at the code i think there is a problem related to ovsdb
I have already tried the simple switch example, without any problem, but the real issue for me is that the handlers for ovsdb related events are never fired.

One thing i know for sure is that it's not a connection problem, my switched can reach the controller/manager.

Using the example written here ( Link from the Ryu docs ), i can clearly see the connection in the log ( using ryu-manager --verbose ) but the following exception occour:

root@controller# ryu-manager test_ovsdb.py --verbose
loading app test_ovsdb.py
loading app ryu.services.protocols.ovsdb.manager
instantiating app test_ovsdb.py of MyApp
instantiating app ryu.services.protocols.ovsdb.manager of OVSDB
BRICK MyApp
  CONSUMES EventNewOVSDBConnection
BRICK OVSDB
  PROVIDES EventNewOVSDBConnection TO {'MyApp': set()}
  PROVIDES EventModifyRequest TO {'OVSDB': set()}
  PROVIDES EventReadRequest TO {'OVSDB': set()}
  CONSUMES EventModifyRequest
  CONSUMES EventReadRequest
Listening on 0.0.0.0:6640 for clients
New connection from 192.168.2.24:58662
hub: uncaught exception: Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/ryu/lib/hub.py", line 60, in _launch
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/ryu/services/protocols/ovsdb/manager.py", line 145, in _start_remote
    app = client.RemoteOvsdb.factory(sock, client_address,
  File "/usr/local/lib/python3.9/dist-packages/ryu/services/protocols/ovsdb/client.py", line 322, in factory
    session = jsonrpc.Session(fsm, connection)
TypeError: __init__() missing 1 required positional argument: 'remotes'

Bug in ofproto_v1_3_parser.

Hello, I have found a bug when test ryu for OpenFlow 1.3, the bug is inlined in the following code.

class OFPGetConfigReply(MsgBase):
def init(self, datapath):
super(OFPGetConfigReply, self).init(datapath)

@classmethod
def parser(cls, datapath, version, msg_type, msg_len, xid, buf):
    msg = super(OFPGetConfigReply, cls).parser(datapath, version, msg_type,
                                               msg_len, xid, buf)
    # Bug, the parameter 'buf' for unpack_from should be 'msg.buf'.
    msg.flags, msg.miss_send_len = struct.unpack_from(
        ofproto_v1_3.OFP_SWITCH_CONFIG_PACK_STR, buf,  
        ofproto_v1_3.OFP_HEADER_SIZE)
    return msg

Drop python2 support

Some of our upstream dependencies (like ovs) have already dropped python 2 support, this makes it not possible for us to install the latest versions of these dependencies.

I propose dropping python2 support for Ryu since it has been EOL since beginning of 2020.

set_qos function problem

My problem is that if I want to set up the queues on port "eth1" of switch "s1"
https://sourceforge.net/p/ryu/mailman/message/36150616/

The difference of my code is that mine config_path is controller_ip "tcp:127.0.0.1:6653"

I have saw the use of "set_qos" on it. But when I compile my ryu.py it occurs different error in the following.

Invalid or incomplete multibyte or wide character
SimpleSwitch13: Exception occurred during handler processing. Backtrace from offending handler [switch_features_handler] servicing event [EventOFPSwitchFeatures] follows.
Traceback (most recent call last):
File "/home/sdn/.local/lib/python3.5/site-packages/ryu/base/app_manager.py", line 290, in _event_loop
handler(ev)
File "/home/sdn/ryu/ryu/app/loadbalancer.py", line 80, in switch_features_handler
ovs_bridge.set_qos("eth1", type='linux-htb', max_rate="1000000", queues=[{'min-rate':'10000', 'max-rate':'100000'}])
File "/home/sdn/.local/lib/python3.5/site-packages/ryu/lib/ovs/bridge.py", line 536, in set_qos
self.run_command([command_qos, command_queue])
File "/home/sdn/.local/lib/python3.5/site-packages/ryu/lib/ovs/bridge.py", line 137, in run_command
self.vsctl.run_command(commands, self.timeout, self.exception)
File "/home/sdn/.local/lib/python3.5/site-packages/ryu/lib/ovs/vsctl.py", line 1295, in run_command
self._run_command(commands)
File "/home/sdn/.local/lib/python3.5/site-packages/ryu/lib/ovs/vsctl.py", line 1275, in _run_command
self._do_main(commands)
File "/home/sdn/.local/lib/python3.5/site-packages/ryu/lib/ovs/vsctl.py", line 1172, in _do_main
self._init_schema_helper()
File "/home/sdn/.local/lib/python3.5/site-packages/ryu/lib/ovs/vsctl.py", line 1059, in _init_schema_helper
vswitch_idl.OVSREC_DB_NAME)
File "/home/sdn/.local/lib/python3.5/site-packages/ryu/lib/ovs/vsctl.py", line 1051, in _rpc_get_schema_json
vsctl_fatal(os.strerror(error))
File "/home/sdn/.local/lib/python3.5/site-packages/ryu/lib/ovs/vsctl.py", line 180, in vsctl_fatal
raise Exception(msg) # not call ovs.utils.ovs_fatal for reusability
Exception: Invalid or incomplete multibyte or wide character

This typeerror I google for it that I get some solution is encoding with my code.
I have checked that my encoding is UTF-8 or ASCII, so I think that may not be the problem I found.

If someone has met this problem plz let me know it, thanks!!

Endless loop when parsing packets

I see issues have been open. Copying my email from the sourceforge mailing list here.

https://github.com/osrg/ryu/blob/master/ryu/lib/packet/packet.py#L76

If rest_data returned is the same size as it was when passed to cls.parse(rest_data) this will loop endlessly because parser does not consume any data.

Real world example:
In InPacket message we receive a TCP packet on port 6653 that is NOT OpenFlow or corrupted OF packet. We pass data from InPacket message to packet.Packet(msg.data). Ethernet layer gets parsed correctly, IP layer gets parsed correctly, TCP layer gets parsed correctly but because TCP is on port 6653, OpenFlow parser gets called.
But because this is not OF message or message is corrupted, there is a chance that msg_length is 0. OpenFlow parser returns UnparsableMsg and rest_data[msg_length:].
https://github.com/osrg/ryu/blob/master/ryu/lib/packet/openflow.py#L67

Because of this parser enters an endless loop since rest_data is never consumed. This in turn hangs the whole ryu process.

My suggestion is that if rest_data is not consumed the loop must be broken:

try:
    proto, cls, unused_data = cls.parser(rest_data)
    if len(unused_data) == len(rest_data):
        break
    else: 
        rest_data = unused_data
except struct.error:
    break

Can Remove Multicast Packets??

Multicast packets do not match any of the flow entries.
I wanna drop this multicast packets. Which affect can occur ???

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.