Hi, Aravind

On 2015年01月03日 02:00, Aravindhan Dhanasekaran wrote:
> Hello,
> 
> I'd like to delete all the flows in case of a SIGINT signal.
> 
> I added a handler for SIGINT signal and tried to delete the flows inside the
> handler. But, it doesn't seem to work. I'm not getting errors when I try to 
> send
> the flow-mod message, though. I captured all control packets at the 
> controller;
> I don't see these delete flow-mods.

Ryu are sequentially processing the buffer send queue, using the thread of each 
Datapath.
https://github.com/osrg/ryu/blob/master/ryu/controller/controller.py#L219
I think that this thread has gone to the end before processing the buffer of 
Flow_mod.

Note:
  By adding the following code, it is possible to send the FLOW_MOD.

    dp.send_msg(flow_mod)
    # get buffer from the send queue
    buf = dp.send_q.get()
    # send buffer
    dp.socket.sendall(buf)

  Because I think that this is forcibly approach, 
  it is recommended that you try the other way.

> 
> Skeleton code below. Any help would be appreciated.
> 
> Thanks,
> /Aravind
> 
> fw_dp = None
> 
> def delete_flow(dp, table_id, match):
>     ofp = dp.ofproto
>     parser = dp.ofproto_parser
>     instructions = []
>     flow_mod = parser.OFPFlowMod(dp, 0, 0, table_id, ofp.OFPFC_DELETE, 0, 0, 
> 1,
>         ofp.OFPCML_NO_BUFFER, ofp.OFPP_ANY, ofp.OFPG_ANY, 0, match, 
> instructions)

Please specify the bufferID or "OFP_NO_BUFFER" to "buffer_id" of OFPFlowMod 
class.
                                ^^^
https://github.com/osrg/ryu/blob/master/ryu/ofproto/ofproto_v1_3_parser.py#L2412

Incidentally,there is no problem in this case.
This is because "buffer_id" is ignored if you specify "OFPFC_DELETE *".
(This is described in "7.3.4.1 Modify Flow Entry Message" of OFspec1.3.4)

>     dp.send_msg(flow_mod)
> 
> 
> def handler_signals(signal_num, frame):
>     global fw_dp
> 
>     if signal_num == signal.SIGINT:
>         dp = fw_dp
>       ofp = dp.ofproto
>       parser = dp.ofproto_parser
>       match = parser.OFPMatch()
> 
>        for table_id in range(TABLE_ID_DUMMY, TABLE_ID_NON_FPM + 1):
>            delete_flow(dp, table_id, match)

"6.4 Flow Table Modification Messages" of OFSpec1.3.4 says:
  Delete commands can use the OFPTT_ALL value for table-id to indicate that 
matching flow entries are
  to be deleted from all flow tables.

So,if you want to delete the entry of all the tables, it is recommended that be 
described as follows.

match = parser.OFPMatch()
delete_flow(dp, dp.ofproto.OFPTT_ALL, match)

>         sys.exit(0)
> 
> 
> class fw_app(app_manager.RyuApp):
>     def __init__(self, *args, **kwargs):
>         super(fw_app, self).__init__(args, **kwargs)
>         signal.signal(signal.SIGINT, handler_signals)
> 
>     # Switch/controller bringup
>     @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
>     def handle_switch_bringup(self, ev):
>         global fpm_dp
> 
>         dp = ev.msg.datapath
>         fw_dp = dp
> 
>       # Default rules and PACKET_IN handling code here
> 
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming! The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
> 

------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to