On Thu, 21 Aug 2014 11:02:26 -0300
Edvar Afonso <[email protected]> wrote:
> Hi everybody,
>
> I'm a beginner in the Ryu enviroment and would like to clarify a basic
> issue.
> I started with some exercises to add flows in switch tables. I'm working
> with mininet and openflow 1.3.
> I succefully add flows but how can I delete a specific flow in a table?
>
> I tried to use ofproto.OFPFC_DELETE command but something is going wrong.
> Here is my simple code, where I add a flow in table 0 and 5 seconds after
> it, I try to delete the same flow. Unfortunely, anything happens.
> Could anyone tell me how to delete a specific flow in Ryu?
> Thanks a lot!
>
> 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_3
> from ryu.lib.packet import packet
> from ryu.lib.packet import ethernet
> from ryu.lib.packet import arp, ipv4
> from ryu.ofproto.ofproto_v1_2 import OFPG_ANY
> from ryu.ofproto.ofproto_v1_3 import OFP_VERSION
> import time
>
> class SimpleSwitch13(app_manager.RyuApp):
> OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
>
> def __init__(self, *args, **kwargs):
> super(SimpleSwitch13, self).__init__(*args, **kwargs)
> self.mac_to_port = {}
>
> @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
> def switch_features_handler(self, ev):
> datapath = ev.msg.datapath
> ofproto = datapath.ofproto
> parser = datapath.ofproto_parser
>
> # install table-miss flow entry
> #
> # We specify NO BUFFER to max_len of the output action due to
> # OVS bug. At this moment, if we specify a lesser number, e.g.,
> # 128, OVS will send Packet-In with invalid buffer_id and
> # truncated packet data. In that case, we cannot output packets
> # correctly.
> match = parser.OFPMatch()
> actions = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER,
> ofproto.OFPCML_NO_BUFFER)]
> self.add_flow(0, datapath, 0, match, actions)
>
> # ===== ADICIONANDO FLUXO SIMPLES ======
>
> match = parser.OFPMatch(in_port=2)
> actions = [parser.OFPActionOutput(1)]
> #self.add_flow(0, datapath, 35000, match, actions)
> mod = parser.OFPFlowMod(datapath=datapath, table_id=0, cookie=1,
> command=datapath.ofproto.OFPFC_ADD, priority=35000, match=match)
> datapath.send_msg(mod)
>
>
> # ===== DELETANDO FLUXO SIMPLES ======
>
> time.sleep(2)
> print 'APAGANDO!!!'
> time.sleep(5)
> match = parser.OFPMatch(in_port=2)
> actions = [parser.OFPActionOutput(1)]
> #self.add_flow(0, datapath, 35000, match, actions)
> mod = parser.OFPFlowMod(datapath=datapath, table_id=0, cookie=1,
> command=datapath.ofproto.OFPFC_DELETE, priority=35000, match=match)
How about specifying out_port and out_group parameters (OFPP_ANY and
OFPG_ANY respectively)?
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds. Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel