Hi all,

We are having difficulties on setting the match fields of a flow entry
using Ryu. Our OpenFlow switch is a Pica8 running openvswitch 2.0.90.

We inject some traffic in the interface of the switch by using tcpreplay.
This traffic consists of a single 12-second IP connection. As a reply for
the first packet_in msg, we define the match fields of our flow entry as:
ipv4 src and dst addr, src and dst ports and protocol (tcp or udp).

Our goal is to create a drop-everything flow entry just for matters of
checking packet and bytes counters in the flow table.

Our problem is that the match fields seem to be incorrect. Although the
switch accepts the flow_mod msg to add the flow entry, we continue to
receive packet_in msgs. Therefore, counters for the added flow entry are
always empty, like if the match fields are not correct (we see that by
dumping the flow entries of the flow table). If we ask for the info of the
wildcard flow entry, we see that the value of its counters are those that
we actually wanted to be in the added flow entry.

To do so, we use the code lines below. Please, let us know if we are doing
something wrong. For example, we were wondering if we should use the fields
nw_src, nw_dst and nw_proto, instead of, respectively, ipv4_src, ipv4_dst,
ip_proto.

def add_flow(self, datapath, priority, match, actions):
    ofproto = datapath.ofproto
    parser = datapath.ofproto_parser
    inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS,
                                         actions)]
    mod = parser.OFPFlowMod(datapath=datapath, priority=priority,
                            match=match, instructions=inst, hard_timeout=20,
                            idle_timeout=10,
                            flags=ofproto.OFPFF_SEND_FLOW_REM)
    datapath.send_msg(mod)

@set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
def _packet_dropper(self, ev):
msg = ev.msg
    datapath = msg.datapath
    ofproto = datapath.ofproto
    parser = datapath.ofproto_parser
    in_port = msg.match['in_port']
    pkt = packet.Packet(msg.data)
    eth = pkt.get_protocols(ethernet.ethernet)[0]
    nw = pkt.get_protocol(ipv4.ipv4)
# for simplicity we assume it is a TCP in this example code
    tp = pkt.get_protocol(tcp.tcp
    match = parser.OFPMatch(    ipv4_src=nw.src,
                                    ipv4_dst=nw.dst,
                                    ip_proto=nw.proto,
                                    eth_type=eth.ethertype,
                                    tcp_src=tp.src_port,
                                    tcp_dst=tp.dst_port
                                )
    self.add_flow(datapath, 2, match, [])

* All packets are considered to be eth.ethertype.

Thanks in advance,
Ricardo
------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
• 3 signs your SCM is hindering your productivity
• Requirements for releasing software faster
• Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to