Hi Ramzah Rehman,

Refer this below tutorial for Group Table in RYU, also sample exercise also
present in this git repository.

https://github.com/knetsolutions/learn-sdn-with-ryu/blob/master/ryu_part8.md


https://github.com/knetsolutions/learn-sdn-with-ryu

Thanks
Suresh.


On Fri, Jan 4, 2019 at 5:03 PM Ramzah Rehman <ramzahreh...@gmail.com> wrote:

> Hi,
> I tried to add a Group Entry in my OVS version 2.8.6 switch via RYU
> controller using ofproto_v1_5 (switch has been configured to support
> OpenFlow 1.5 ). I found send_group_mod
> <https://ryu.readthedocs.io/en/latest/ofproto_v1_5_ref.html> function
> here. I used the exact code to check if it's working but got this
> OFPGMFC_BAD_BUCKET(12) error.
>
> The code for adding a group entry is as follows:
>
> def send_group_mod(self, datapath):
>     ofp = datapath.ofproto
>     ofp_parser = datapath.ofproto_parser
>
>     port = 1
>     max_len = 2000
>     actions = [ofp_parser.OFPActionOutput(port, max_len)]
>
>     weight = 100
>     watch_port = 0
>     watch_group = 0
>     buckets = [ofp_parser.OFPBucket(weight, watch_port, watch_group,
>                                     actions)]
>
>     group_id = 1
>     command_bucket_id=1
>     req = ofp_parser.OFPGroupMod(datapath, ofp.OFPGC_ADD,
>                                  ofp.OFPGT_SELECT, group_id,
>                                  command_bucket_id, buckets)
>     datapath.send_msg(req)
>
> The error I got is:
>
> OFPErrorMsg(type=0x6, code=0xc, 
> data=b'\x06\x0f\x00\x20\x4c\x6d\x56\x22\x00\x00\x01\x00\x00\x00\x00\x01\x00\x08\x00\x00\x00\x00\x00\x01\x00\x08\x00\x00\x00\x00\x00\x64')
>  |-- type: OFPET_GROUP_MOD_FAILED(6)
>  |-- code: *OFPGMFC_BAD_BUCKET(12)*
>  `-- data: version=0x6, msg_type=0xf, msg_len=0x20, xid=0x4c6d5622
>      `-- msg_type: OFPT_GROUP_MOD(15)
>
>
> Error BAD_BUCKET(12) is thrown when there is a error in bucket. Since I was 
> using SELECT type of group I did not require watch_port and watch_group. So I 
> set these variables to these:
>
>   watch_port = ofproto_v1_5.OFPP_ANY
>   watch_group =  ofproto_v1_5.OFPQ_ALL
>
> I restarted my controller, this time I got this error:
>
>
> SimpleSwitch15: Exception occurred during handler processing. Backtrace from 
> offending handler [switch_features_handler] servicing event 
> [EventOFPSwitchFeatures] follows.
> Traceback (most recent call last):
>   File 
> "/home/aa/PycharmProjects/ovs-controller/venv/lib/python3.4/site-packages/ryu/base/app_manager.py",
>  line 290, in _event_loop
>     handler(ev)
>   File "/home/aa/PycharmProjects/ovs-controller/mycontroller.py", line 55, in 
> switch_features_handler
>     self.send_group_mod(datapath)
>   File "/home/aa/PycharmProjects/ovs-controller/mycontroller.py", line 348, 
> in send_group_mod
>     datapath.send_msg(req)
>   File 
> "/home/aa/PycharmProjects/ovs-controller/venv/lib/python3.4/site-packages/ryu/controller/controller.py",
>  line 423, in send_msg
>     msg.serialize()
>   File 
> "/home/aa/PycharmProjects/ovs-controller/venv/lib/python3.4/site-packages/ryu/ofproto/ofproto_parser.py",
>  line 270, in serialize
>     self._serialize_body()
>   File 
> "/home/aa/PycharmProjects/ovs-controller/venv/lib/python3.4/site-packages/ryu/ofproto/ofproto_v1_5_parser.py",
>  line 6281, in _serialize_body
>     b.serialize(self.buf, offset)
>   File 
> "/home/aa/PycharmProjects/ovs-controller/venv/lib/python3.4/site-packages/ryu/ofproto/ofproto_v1_5_parser.py",
>  line 6509, in serialize
>    * for a in self.actions:*
> *TypeError: 'int' object is not iterable*
>
> I debugged my code to check if actions are being set properly in buckets. To 
> my chagrin, actions were not being set at all in the OFPBucket. I got an 
> interger instead of a list of actions in OFPBucket. I have attached the 
> screenshot of debugging.
>
> Then I checked the implementation of OFPBucket  in ofproto_v1_5_parser.py 
> file here 
> <https://github.com/osrg/ryu/blob/master/ryu/ofproto/ofproto_v1_5_parser.py> 
> and to my surprise, OFPBucket constructor had a very different signature i.e.:
>
> def __init__(self, bucket_id=0, actions=None, properties=None, len_=None, 
> action_array_len=None)
> The way I was calling OFPBucket constructor was valid for version 1.3 not 
> version 1.5. (I check the send_group_mod for version 1.3 
> <https://ryu.readthedocs.io/en/latest/ofproto_v1_3_ref.html> here and it was 
> working properly).
> Anyhow, since I had been initializing my OFPButcket wrongly, I modified my 
> code as follows. This time, the actions list was being set properly in the 
> bucket but  still, I got bad_BUCKET(12) error. Please help.
> *Modified Code:*
>
> def send_group_mod(self, datapath):
>         ofp = datapath.ofproto
>         ofp_parser = datapath.ofproto_parser
>
>         port = 1
>         max_len = 2000
>         actions = [ofp_parser.OFPActionOutput(port, max_len)]
>
>         weight = 100
>         #watch_port = ofproto_v1_5.OFPP_ANY
>         #watch_group =  ofproto_v1_5.OFPQ_ALL
>
>         bucket = datapath.ofproto_parser.OFPBucket(bucket_id=1, 
> actions=actions, properties=None, len_=32,action_array_len=None)
>         buckets = [bucket]
>         #buckets = [ofp_parser.OFPBucket(weight, watch_port, 
> watch_group,actions)]
>
>         group_id = 1
>         command_bucket_id = 1
>         req = ofp_parser.OFPGroupMod(datapath, ofp.OFPGC_ADD,
>                                      ofp.OFPGT_SELECT, group_id,
>                                      command_bucket_id, buckets)
>         datapath.send_msg(req)
>
> *Error:*
>
> EventOFPErrorMsg received.
> version=0x6, msg_type=0x1, msg_len=0x3c, xid=0x1d46ee73
>  `-- msg_type: OFPT_ERROR(1)
> OFPErrorMsg(type=0x6, code=0xc, 
> data=b'\x06\x0f\x00\x30\x1d\x46\xee\x73\x00\x00\x01\x00\x00\x00\x00\x01\x00\x18\x00\x00\x00\x00\x00\x01\x00\x18\x00\x10\x00\x00\x00\x01\x00\x00\x00\x10\x00\x00\x00\x01\x07\xd0\x00\x00\x00\x00\x00\x00')
>  |-- type: OFPET_GROUP_MOD_FAILED(6)
>  |-- code: OFPGMFC_BAD_BUCKET(12)
>  `-- data: version=0x6, msg_type=0xf, msg_len=0x30, xid=0x1d46ee73
>      `-- msg_type: OFPT_GROUP_MOD(15)
>
> _______________________________________________
> Ryu-devel mailing list
> Ryu-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
>


-- 

*Regards, *
*Knet solutions.*
Whatsapp/Mobile:  +919445042007
website:  http://knetsolutions.in/
Facebook Page :   https://www.facebook.com/sdntraining/
youtube channel:  https://www.youtube.com/channel/UCTD6X9_oDqIYs_xpE7moFnQ
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to