Hi,

On 2016年12月05日 17:26, 黃奕欽 wrote:
> Hi all,
> 
>     Sometimes app can't get EventOFPSwitchFeatures ( CONFIG_DISPATCHER)
> event when OVS(especially, Openflow 1.0)  enter. But 
> EventOFPStateChange( MAIN_DISPATCHER ) was received.

Hummm...

EventOFPStateChange(MAIN_DISPATCHER) event should not be triggered without
EventOFPSwitchFeatures(CONFIG_DISPATCHER).
Because EventOFPStateChange event should be raised by "ofp_handler.py"
when "ofp_handler.py" receiving EventOFPSwitchFeatures.
  
https://github.com/osrg/ryu/blob/master/ryu/controller/ofp_handler.py#L209-L211
  https://github.com/osrg/ryu/blob/master/ryu/controller/controller.py#L222-L226


> In ryu/app/ofctl/service.py, add new switch by get
> EventOFPSwitchFeatures. If this event was not sent, _switches is empty.
> 
> Could the decorator of _switch_features_handler()  replace
> EventOFPSwitchFeatures with EventOFPStateChange?  Like this patch. Or
> it's not a good idea.

On my environment, I can replace it.

$ git diff
diff --git a/ryu/app/ofctl/service.py b/ryu/app/ofctl/service.py
index 19aebd4..141dc61 100644
--- a/ryu/app/ofctl/service.py
+++ b/ryu/app/ofctl/service.py
@@ -69,14 +69,14 @@ class OfctlService(app_manager.RyuApp):
         return (ofp_event.ofp_msg_to_ev_cls(type(msg)) ==
                 ofp_event.EventOFPErrorMsg)
 
-    @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
+    @set_ev_cls(ofp_event.EventOFPStateChange, MAIN_DISPATCHER)
     def _switch_features_handler(self, ev):
-        datapath = ev.msg.datapath
+        datapath = ev.datapath
         id = datapath.id
         assert isinstance(id, numbers.Integral)
         old_info = self._switches.get(id, None)
         new_info = _SwitchInfo(datapath=datapath)
-        self.logger.debug('add dpid %s datapath %s new_info %s old_info %s',
+        self.logger.info('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:
diff --git a/ryu/app/simple_switch.py b/ryu/app/simple_switch.py
index 862b830..a94551f 100644
--- a/ryu/app/simple_switch.py
+++ b/ryu/app/simple_switch.py
@@ -28,6 +28,8 @@ from ryu.lib.packet import packet
 from ryu.lib.packet import ethernet
 from ryu.lib.packet import ether_types
 
+from ryu.app.ofctl import api
+
 
 class SimpleSwitch(app_manager.RyuApp):
     OFP_VERSIONS = [ofproto_v1_0.OFP_VERSION]



$ ryu-manager ryu.app.simple_switch
...
add dpid 1 datapath <ryu.controller.controller.Datapath object at
0x7fe60756ae48> new_info <ryu.app.ofctl.service._SwitchInfo object at
0x7fe6083aeb38> old_info None
...


Thanks,
Iwase


> 
> Thank u!
> 
> diff --git a/ryu/app/ofctl/service.py b/ryu/app/ofctl/service.py
> index 19aebd4..2d98278 100644
> --- a/ryu/app/ofctl/service.py
> +++ b/ryu/app/ofctl/service.py
> @@ -69,9 +69,9 @@ class OfctlService(app_manager.RyuApp):
>          return (ofp_event.ofp_msg_to_ev_cls(type(msg)) ==
>                  ofp_event.EventOFPErrorMsg)
>  
> -    @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
> +    @set_ev_cls(ofp_event.EventOFPStateChange, MAIN_DISPATCHER)
>      def _switch_features_handler(self, ev):
> -        datapath = ev.msg.datapath
> +        datapath = ev.datapath
>          id = datapath.id
>          assert isinstance(id, numbers.Integral)
>          old_info = self._switches.get(id, None)
> 
> 
> 
> 
> 
> 
> 
> *
> 
> 本信件可能包含中華電信股份有限公司機密資訊,非指定之收件者,請勿蒐集、處理
> 或利用本信件內容,並請銷毀此信件. 如為指定收件者,應確實保護郵件中本公司之
> 營業機密及個人資料,不得任意傳佈或揭露,並應自行確認本郵件之附檔與超連結之
> 安全性,以共同善盡資訊安全與個資保護責任.
> Please be advised that this email message (including any attachments)
> contains confidential information and may be legally privileged. If you
> are not the intended recipient, please destroy this message and all
> attachments from your system and do not further collect, process, or use
> them. Chunghwa Telecom and all its subsidiaries and associated companies
> shall not be liable for the improper or incomplete transmission of the
> information contained in this email nor for any delay in its receipt or
> damage to your system. If you are the intended recipient, please protect
> the confidential and/or personal information contained in this email
> with due care. Any unauthorized use, disclosure or distribution of this
> message in whole or in part is strictly prohibited. Also, please
> self-inspect attachments and hyperlinks contained in this email to
> ensure the information security and to protect personal information.*
> 
> 
> ------------------------------------------------------------------------------
> 
> 
> 
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
> 

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to