Hi  Iwase,

Thank you for the workaround suggested.

Regards,
Shivani.

On Fri, Feb 23, 2018 at 6:52 AM, Iwase Yusuke <iwase.yusu...@gmail.com>
wrote:

> Hi Shivani,
>
> The AGGREGATE_STATS message has the same problem as what I mentioned on my
> previous mail. OpenFlow 1.5 introduced "OXS" structure (EXT-334) and this
> structure is also used in The AGGREGATE_STATS message, but OVS does not
> support
> it...
>
> FYI, I found a workaround for this issue, but please note this is a very
> dirty
> way.
>
> $ git diff
> diff --git a/ryu/app/simple_switch_15.py b/ryu/app/simple_switch_15.py
> index 6a86ba7..b04ce81 100644
> --- a/ryu/app/simple_switch_15.py
> +++ b/ryu/app/simple_switch_15.py
> @@ -17,12 +17,27 @@ 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_4
> +from ryu.ofproto import ofproto_v1_4_parser
>  from ryu.ofproto import ofproto_v1_5
> +from ryu.ofproto import ofproto_v1_5_parser
>  from ryu.lib.packet import packet
>  from ryu.lib.packet import ethernet
>  from ryu.lib.packet import ether_types
>
>
> +# HACK: OVS 2.9.0 does not yet support the EXT-334, here injects OF14
> parser
> +# for the workaround.
> +class OFPFlowStatsReply(ofproto_v1_5_parser.OFPMultipartReply,
> +                        ofproto_v1_4_parser.OFPFlowStatsReply):
> +    pass
> +
> +
> +ofproto_v1_5_parser.OFPMultipartReply._STATS_MSG_TYPES[
> +    # Note: not OFPMP_FLOW_STATS(=17), use OFPMP_FLOW_DESC(=1)
> +    ofproto_v1_5.OFPMP_FLOW_DESC] = OFPFlowStatsReply
> +
> +
>  class SimpleSwitch15(app_manager.RyuApp):
>      OFP_VERSIONS = [ofproto_v1_5.OFP_VERSION]
>
> @@ -48,6 +63,8 @@ class SimpleSwitch15(app_manager.RyuApp):
>                                            ofproto.OFPCML_NO_BUFFER)]
>          self.add_flow(datapath, 0, match, actions)
>
> +        self.send_flow_stats_request(datapath)
> +
>      def add_flow(self, datapath, priority, match, actions):
>          ofproto = datapath.ofproto
>          parser = datapath.ofproto_parser
> @@ -59,6 +76,40 @@ class SimpleSwitch15(app_manager.RyuApp):
>                                  match=match, instructions=inst)
>          datapath.send_msg(mod)
>
> +    def send_flow_stats_request(self, datapath):
> +        # HACK: Use OF14 parser
> +        ofp = ofproto_v1_4
> +        ofp_parser = ofproto_v1_4_parser
> +
> +        cookie = cookie_mask = 0
> +        match = ofp_parser.OFPMatch()
> +        req = ofp_parser.OFPFlowStatsRequest(datapath, 0,
> +                                             ofp.OFPTT_ALL,
> +                                             ofp.OFPP_ANY, ofp.OFPG_ANY,
> +                                             cookie, cookie_mask,
> +                                             match)
> +        datapath.send_msg(req)
> +
> +    @set_ev_cls(ofp_event.EventOFPFlowStatsReply, MAIN_DISPATCHER)
> +    def flow_stats_reply_handler(self, ev):
> +        # HACK: Use OF14 parser
> +        flows = []
> +        for stat in ev.msg.body:
> +            flows.append('table_id=%s '
> +                         'duration_sec=%d duration_nsec=%d '
> +                         'priority=%d '
> +                         'idle_timeout=%d hard_timeout=%d flags=0x%04x '
> +                         'importance=%d cookie=%d packet_count=%d '
> +                         'byte_count=%d match=%s instructions=%s' %
> +                         (stat.table_id,
> +                          stat.duration_sec, stat.duration_nsec,
> +                          stat.priority,
> +                          stat.idle_timeout, stat.hard_timeout,
> +                          stat.flags, stat.importance,
> +                          stat.cookie, stat.packet_count, stat.byte_count,
> +                          stat.match, stat.instructions))
> +        self.logger.debug('FlowStats: %s', flows)
> +
>      @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
>      def _packet_in_handler(self, ev):
>          msg = ev.msg
>
>
> $ ryu-manager ryu/app/simple_switch_15.py --verbose
> ...(snip)...
> EVENT ofp_event->SimpleSwitch15 EventOFPFlowStatsReply
> FlowStats: ["table_id=0 duration_sec=3644 duration_nsec=58000000
> priority=1 idle_timeout=0 hard_timeout=0 flags=0x0000 importance=0 cookie=0
> packet_count=9 byte_count=826 match=OFPMatch(oxm_fields={'in_port': 2,
> 'eth_dst': '7a:12:92:fb:67:25'}) instructions=[OFPInstructionAc
> tions(actions=[OFPActionOutput(len=16,max_len
> =65509,port=1,type=0)],len=24,type=4)]", "table_id=0 duration_sec=3644
> duration_nsec=55000000 priority=1 idle_timeout=0 hard_timeout=0
> flags=0x0000 importance=0 cookie=0 packet_count=8 byte_count=728
> match=OFPMatch(oxm_fields={'in_port': 1, 'eth_dst': '7e:76:39:e3:b8:c1'})
> instructions=[OFPInstructionActions(actions=[
> OFPActionOutput(len=16,max_len=65509,port=2,type=0)],len=24,type=4)]",
> 'table_id=0 duration_sec=0 duration_nsec=0 priority=0 idle_timeout=0
> hard_timeout=0 flags=0x0000 importance=0 cookie=0 packet_count=3
> byte_count=182 match=OFPMatch(oxm_fields={}) instructions=[OFPInstructionAc
> tions(actions=[OFPActionOutput(len=16,max_len
> =65535,port=4294967293,type=0)],len=24,type=4)]']
>
>
> Thanks,
> Iwase
>
>
> On 2018年02月23日 01:05, shivani dommeti wrote:
>
>> Hi Iwase Yusuke,
>>
>> Thank you for the response.
>>
>> Working on:
>>      RYU version:3.27
>>      Ovs version: 27.2
>>      OpenFlow version:1.5.
>>
>> I have tried to get the flow stats using OFPAggregateStatsRequest API and
>> i see the following error:
>>
>> Encounter an error during parsing OpenFlow packet from switch.This
>> implies switch sending a malformed OpenFlow packet.version 0x06 msg_type 19
>> msg_len 40 xid 2049228120 buf 0x06 0x13 0x00 0x28 0x7a 0x24 0xbd 0x58
>> 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 0x02 0x00 0x00
>> 0x00 0x00
>> Traceback (most recent call last):
>>    File "/usr/lib/python2.7/site-packages/ryu/ofproto/ofproto_parser.py",
>> line 69, in msg
>>      return msg_parser(datapath, version, msg_type, msg_len, xid, buf)
>>    File 
>> "/usr/lib/python2.7/site-packages/ryu/ofproto/ofproto_v1_5_parser.py",
>> line 59, in msg_parser
>>      return parser(datapath, version, msg_type, msg_len, xid, buf)
>>    File 
>> "/usr/lib/python2.7/site-packages/ryu/ofproto/ofproto_v1_5_parser.py",
>> line 1895, in parser
>>      raise exception.OFPMalformedMessage()
>> OFPMalformedMessage: malformed message
>> EVENT ofp_event->Controller EventOFPPortStatsReply
>> Fetching next instruction to send to CP
>>
>> i see the OVS sending the stats :
>> 2018-02-22T05:06:10.923Z|05694|vconn|DBG|tcp:127.0.0.1:6633 <
>> http://127.0.0.1:6633>: received: OFPST_AGGREGATE request (OF1.5)
>> (xid=0x6ba32021): table=1 in_port=193
>> 2018-02-22T05:06:10.923Z|05695|vconn|DBG|tcp:127.0.0.1:6633 <
>> http://127.0.0.1:6633>: sent (Success): OFPST_AGGREGATE reply (OF1.5)
>> (xid=0x6ba32021): packet_count=0 byte_count=0 flow_count=2
>>
>> is there any fix to get the stats for each flow on openflow version1.5
>>
>> Tried with openflow version 1.3 and i see no issues.
>>
>> Regards,
>> Shivani Dommeti.
>>
>>
>>
>>
>>
>> On Wed, Feb 21, 2018 at 7:01 AM, Iwase Yusuke <iwase.yusu...@gmail.com
>> <mailto:iwase.yusu...@gmail.com>> wrote:
>>
>>     Hi,
>>
>>     I'm using the newer version of OVS though, I guess OVS does not
>> supports the
>>     OpenFlow 1.5 structured FlowStats message.
>>     the FlowStats message was restructured in the OpenFlow 1.5 according
>> to
>>     introduction of the FlowDesc message, but OVS does not implement the
>> new
>>     structure of the FlowStats (looks like up to OF version 1.4 or
>> earlier).
>>     https://github.com/openvswitch/ovs/blob/bd916d13dbb845746983
>> a6780da772154df647ba/lib/ofp-util.c#L2757-L2799
>>     <https://github.com/openvswitch/ovs/blob/bd916d13dbb84574698
>> 3a6780da772154df647ba/lib/ofp-util.c#L2757-L2799>
>>
>>     Also, the FlowDesc message does not seem to be supported,
>> implementation not
>>     found and the Extensible Flow Entry Statistics(EXT-334) is still on
>> TODOs which
>>     required to implement the FlowDesc message.
>>     https://github.com/openvswitch/ovs/blob/master/Documentation
>> /topics/openflow.rst#openflow-15-only
>>     <https://github.com/openvswitch/ovs/blob/master/Documentatio
>> n/topics/openflow.rst#openflow-15-only>
>>
>>     OVS seems to support the OpenFlow 1.5 partially...
>>
>>     Thanks,
>>     Iwase
>>
>>     On 2018年02月20日 18:27, shivani dommeti wrote:
>>
>>         Hi,
>>
>>         Can  you please let me know if there is any Fix for the below
>> stated
>>         issue which i see when i try to retrieve the Flow statistics using
>>         OFPFlowStatsRequest API with OpenFlow version1.5.
>>
>>         Since this is blocking some features, it would be very helpful if
>> there
>>         is any fix for the following. Will be looking forward for your
>> response.
>>
>>         Thanks,
>>         Shivani Dommeti.
>>
>>
>>
>>         On Thu, Feb 15, 2018 at 5:03 PM, shivani dommeti
>>         <shivani.domm...@gmail.com <mailto:shivani.domm...@gmail.com>
>>         <mailto:shivani.domm...@gmail.com <mailto:shivani.dommeti@gmail.
>> com>>>
>>
>>         wrote:
>>
>>              Hi,
>>
>>              Working on:
>>              RYU version:3.27
>>              Ovs version: 27.2
>>              OpenFlow version:1.5.
>>
>>
>>              I  tried getting the statistics of each flow using the
>> following API:
>>                match = ofp_parser .OFPMatch(in_port=1)
>>                req = ofp_parser .OFPFlowStatsRequest(datapath,
>> 0,1,ofp.OFPP_ANY
>>              ,ofp.OFPG_ANY,0,0,match)
>>
>>              And i see the following error:
>>
>>              EVENT ofp_event->Controller EventOFPErrorMsg
>>              EVENT ofp_event->ofctl_service EventOFPErrorMsg
>>              EventOFPErrorMsg received.
>>              version=0x6, msg_type=0x1, msg_len=0x4c, xid=0x6659cf
>>                `-- msg_type: OFPT_ERROR(1)
>>              OFPErrorMsg(type=0x1, code=0x2,
>>              data=b'\x06\x12\x00\x40\x00\x66\x59\xcf\x00\x11\
>>
>>                                x00\x00\x00\x00\x00\x00\x01\x
>> 00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\
>>
>>  
>> x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\
>>
>>                      x00\x0c\x80\x00\x00\x04\x00\x
>> 00\x00\xc1\x00\x00\x00\x00\x06\x13\x10\xb0\x00\x66\x59\xd0')
>>                |-- type: OFPET_BAD_REQUEST(1)
>>                |-- code: OFPBRC_BAD_MULTIPART(2)
>>                `-- data: version=0x6, msg_type=0x12, msg_len=0x40,
>> xid=0x6659cf
>>                    `-- msg_type: OFPT_MULTIPART_REQUEST(18)
>>              EVENT ofp_event->Controller EventOFPPortStatsReply
>>              OFPErrorMsg received: type=0x01 code=0x02 message=0x06 0x12
>> 0x00
>>         0x40 0x00
>>              0x660x59 0xcf 0x00 0x11 0x00 0x00 0x00 0x00 0x00 0x00 0x01
>> 0x00
>>         0x00 0x00
>>              0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x00 0x00 0x00 0x00
>> 0x00
>>         0x00 0x00
>>              0x000x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
>> 0x01
>>         0x00 0x0c
>>              0x80 0x000x00 0x04 0x00 0x00 0x00 0xc1 0x00 0x00 0x00 0x00
>> 0x06
>>         0x13 0x10
>>              0xb0 0x00 0x66 0x59 0xd0
>>              unknown error xid 6707663
>>
>>
>>              i dint see this issue when i was using OpenFlow v1.3.
>>
>>
>>              Please let me know if i am missing something, and what can
>> be done
>>         to fix this.
>>
>>              Thanks,
>>              Shivani Dommeti.
>>
>>
>>
>>         ------------------------------------------------------------
>> ------------------
>>         Check out the vibrant tech community on one of the world's most
>>         engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>>
>>
>>
>>         _______________________________________________
>>         Ryu-devel mailing list
>>         Ryu-devel@lists.sourceforge.net <mailto:Ryu-devel@lists.source
>> forge.net>
>>         https://lists.sourceforge.net/lists/listinfo/ryu-devel
>>         <https://lists.sourceforge.net/lists/listinfo/ryu-devel>
>>
>>
>>
>>
>> ------------------------------------------------------------
>> ------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>>
>>
>>
>> _______________________________________________
>> Ryu-devel mailing list
>> Ryu-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/ryu-devel
>>
>>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to