Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ryu and Busylink detection #101

Closed
wants to merge 38 commits into from

Conversation

hsiaohsuan1l1l
Copy link
Contributor

Ryu adapter
Busylink detection
Ryu source code modification (switches.py, event.py)

@@ -5,7 +5,9 @@ Ryu adapter module for OmniUI
###Installation###
1. Download the Ryu Controller
$ `git clone git://github.com/osrg/ryu.git`
$ `cd ryu; sudo python ./setup.py install`
$ `cd OpenADM/adapter/ryu; cp event.py event.py ~/ryu/ryu/topology`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicated event.py

@starbops
Copy link
Member

I followed the README but I cannot start up Ryu controller:

$ ./bin/ryu-manager --observe-links /vagrant_data/adapter/ryu/omniui/omniui.py ryu/app/simple_switch.py
loading app /vagrant_data/adapter/ryu/omniui/omniui.py
Traceback (most recent call last):
  File "./bin/ryu-manager", line 19, in <module>
    main()
  File "/usr/local/lib/python2.7/dist-packages/ryu/cmd/manager.py", line 88, in main
    app_mgr.load_apps(app_lists)
  File "/usr/local/lib/python2.7/dist-packages/ryu/base/app_manager.py", line 414, in load_apps
    cls = self.load_app(app_cls_name)
  File "/usr/local/lib/python2.7/dist-packages/ryu/base/app_manager.py", line 391, in load_app
    mod = utils.import_module(name)
  File "/usr/local/lib/python2.7/dist-packages/ryu/utils.py", line 91, in import_module
    __import__(name)
  File "/vagrant_data/adapter/ryu/omniui/omniui.py", line 32, in <module>
    class OmniUI(app_manager.RyuApp):
  File "/vagrant_data/adapter/ryu/omniui/omniui.py", line 382, in OmniUI
    @set_ev_cls(event.EventHostDelete)
AttributeError: 'module' object has no attribute 'EventHostDelete'

Please update the installation steps in README as clear as possible if you believe your code is correct, thank you.

@starbops
Copy link
Member

Sorry I make some mistakes, please ignore previous comments.

self.statistics[link_id] = dict(self.links[link_id])
self.statistics[link_id]['state'] = self.baseState
# Remove unexisted link info
for link_id in self.statistics:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add/removing elements in a dictionary while iterating through it could lead to runtime error like the following:

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/vagrant/.local/lib/python2.7/site-packages/omniui-1.0.0-py2.7.egg/src/core.py", line 266, in iterate
    handler.handler(event)
  File "/home/vagrant/.local/lib/python2.7/site-packages/omniui-1.0.0-py2.7.egg/src/floodlight_modules/busylink_detect.py", line 79, in getPort
    self.busyLinkDetect()
  File "/home/vagrant/.local/lib/python2.7/site-packages/omniui-1.0.0-py2.7.egg/src/floodlight_modules/busylink_detect.py", line 173, in busyLinkDetect
    for link_id in self.statistics:
RuntimeError: dictionary changed size during iteration

@starbops starbops added the Ryu label May 11, 2016
@starbops starbops self-assigned this May 11, 2016
flowstatsReplyAPI["flows"] = []
i = 0
for inflow in flows[key]:
if inflow["priority"] == 1:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my testing environment, the priority of flows are 65535. So all the flow processing things below this "if" condition are skipped. Therefore this handler posted an empty flows dictionary to Core.

@starbops
Copy link
Member

It's recommended that do one thing in a single app. The OpenADM app of Ryu controller, i.e. omniui.py (I know the name is confusing...), should theoretically handle all the events we want, but not forward packets (which simple_switch.py does). Just strip those functionality off in omniui.py and test whether it works with simple_switch.py or not.

global coreIP
coreIP = '127.0.0.1'
global corePort
corePort = '5567'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To improve the flexibility further, please load these value from config file so users don't have to modify the code to apply new configuration.

mod = parser.OFPFlowMod(datapath=datapath, match=match, cookie=0, command=ofproto.OFPFC_ADD, idle_timeout=0,
hard_timeout=0, priority=priority, flags=ofproto.OFPFF_SEND_FLOW_REM, actions=actions)
datapath.send_msg(mod)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that the flow entries installed by omniui.py are slightly different from the ones installed by simple_switch.py. This situation happens on both OpenFlow10 & OpenFlow13. I still recommend you to try to split two functionalities apart (learning switch mechanism and event forwarding). Let the original simple_switch.py and simple_switch_13.py do their jobs, unless the same event cannot handled by two or more functions at the same time.

@starbops
Copy link
Member

When I tried to add a flow entry, I got the following error which displayed on the console of Ryu controller:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/eventlet/wsgi.py", line 481, in handle_one_response
    result = self.application(self.environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/ryu/app/wsgi.py", line 201, in __call__
    return super(wsgify_hack, self).__call__(environ, 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 "/usr/local/lib/python2.7/dist-packages/ryu/app/wsgi.py", line 263, in __call__
    return controller(req)
  File "/usr/local/lib/python2.7/dist-packages/ryu/app/wsgi.py", line 125, in __call__
    return getattr(self, action)(req, **kwargs)
  File "/home/vagrant/OpenADM/adapter/ryu/omniui/omniui.py", line 684, in mod_flow_entry
    ofctl_v1_3.mod_flow_entry(dp, ryuFlow, cmd)
  File "/usr/local/lib/python2.7/dist-packages/ryu/lib/ofctl_v1_3.py", line 1051, in mod_flow_entry
    inst = to_actions(dp, flow.get('actions', []))
  File "/usr/local/lib/python2.7/dist-packages/ryu/lib/ofctl_v1_3.py", line 49, in to_actions
    action = to_action(dp, a)
  File "/usr/local/lib/python2.7/dist-packages/ryu/lib/ofctl_v1_3.py", line 39, in to_action
    return ofctl_utils.to_action(dic, ofp, parser, action_type, UTIL)
  File "/usr/local/lib/python2.7/dist-packages/ryu/lib/ofctl_utils.py", line 87, in to_action
    out_port = util.ofp_port_from_user(dic.get('port', ofp.OFPP_ANY))
  File "/usr/local/lib/python2.7/dist-packages/ryu/lib/ofctl_utils.py", line 329, in ofp_port_from_user
    return self._reserved_num_from_user(port, 'OFPP_')
  File "/usr/local/lib/python2.7/dist-packages/ryu/lib/ofctl_utils.py", line 247, in _reserved_num_from_user
    return getattr(self.ofproto, prefix + num.upper())
AttributeError: 'module' object has no attribute 'OFPP_3'

The flow entry I added through web UI is listed below for the purpose of reproducing the error:

  • switch: "00:00:00:00:00:00:00:01"
  • priority: "99"
  • ingressPort: "3"
  • OUTPUT: "3"

P.S. OpenFlow 1.3

@starbops
Copy link
Member

starbops commented May 16, 2016

Under the same input as the above comment, while using OpenFlow 1.0, will bring up following traceback:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/eventlet/wsgi.py", line 481, in handle_one_response
    result = self.application(self.environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/ryu/app/wsgi.py", line 201, in __call__
    return super(wsgify_hack, self).__call__(environ, 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 "/usr/local/lib/python2.7/dist-packages/ryu/app/wsgi.py", line 263, in __call__
    return controller(req)
  File "/usr/local/lib/python2.7/dist-packages/ryu/app/wsgi.py", line 125, in __call__
    return getattr(self, action)(req, **kwargs)
  File "/home/vagrant/OpenADM/adapter/ryu/omniui/omniui.py", line 680, in mod_flow_entry
    ryuFlow = self.ryuFlow_v1_0(dp, omniFlow)
  File "/home/vagrant/OpenADM/adapter/ryu/omniui/omniui.py", line 716, in ryuFlow_v1_0
    'nw_src': flows.get('srcIP').split('/')[0],
AttributeError: 'NoneType' object has no attribute 'split'

It seems that the error was introduced before this PR, maybe open another issue?

Update: issue #102

@starbops
Copy link
Member

I cannot delete any flows, including the flow I added and generated by pingall. The Ryu controller gave me these:

  • OpenFlow 1.0
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/eventlet/wsgi.py", line 481, in handle_one_response
    result = self.application(self.environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/ryu/app/wsgi.py", line 201, in __call__
    return super(wsgify_hack, self).__call__(environ, 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 "/usr/local/lib/python2.7/dist-packages/ryu/app/wsgi.py", line 263, in __call__
    return controller(req)
  File "/usr/local/lib/python2.7/dist-packages/ryu/app/wsgi.py", line 125, in __call__
    return getattr(self, action)(req, **kwargs)
  File "/home/vagrant/OpenADM/adapter/ryu/omniui/omniui.py", line 680, in mod_flow_entry
    ryuFlow = self.ryuFlow_v1_0(dp, omniFlow)
  File "/home/vagrant/OpenADM/adapter/ryu/omniui/omniui.py", line 713, in ryuFlow_v1_0
    'dl_type': int(flows.get('dlType', 0)),
ValueError: invalid literal for int() with base 10: '0x0'
  • OpenFlow 1.3
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/eventlet/wsgi.py", line 481, in handle_one_response
    result = self.application(self.environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/ryu/app/wsgi.py", line 201, in __call__
    return super(wsgify_hack, self).__call__(environ, 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 "/usr/local/lib/python2.7/dist-packages/ryu/app/wsgi.py", line 263, in __call__
    return controller(req)
  File "/usr/local/lib/python2.7/dist-packages/ryu/app/wsgi.py", line 125, in __call__
    return getattr(self, action)(req, **kwargs)
  File "/home/vagrant/OpenADM/adapter/ryu/omniui/omniui.py", line 684, in mod_flow_entry
    ofctl_v1_3.mod_flow_entry(dp, ryuFlow, cmd)
  File "/usr/local/lib/python2.7/dist-packages/ryu/lib/ofctl_v1_3.py", line 1050, in mod_flow_entry
    match = to_match(dp, flow.get('match', {}))
  File "/usr/local/lib/python2.7/dist-packages/ryu/lib/ofctl_v1_3.py", line 275, in to_match
    key = conv[ip_proto][key]
KeyError: 0

return
elif (srcp not in self.switches[src]) | (destp not in self.switches[dest]):
print 'Not Ready'
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use logical operator instead of "bitwise or"?

@starbops
Copy link
Member

Hosts lose connectivity when Mininet topology is larger than 4-level tree. It seems that the controller (adapter) could not handle that huge number of bursting events.

@waynelkh waynelkh force-pushed the master branch 2 times, most recently from 838ed1c to 17837ac Compare May 28, 2016 11:51
@hsiaohsuan1l1l hsiaohsuan1l1l force-pushed the adapter branch 2 times, most recently from 13ed654 to c541194 Compare May 28, 2016 12:46
@starbops
Copy link
Member

+2
Thank you!

@starbops starbops closed this May 28, 2016
@starbops
Copy link
Member

Manually rebased.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants