Dear Ryu support team,

I have a simple Ryu app which should be responsible for

   - initiating a packet-send after setting a register bit
   - Receiving that packet in the user-space when it propagates through the
   switch

The problem I'm having is that the message is not being sent to the switch
(or not being sent to the user space after because I'm not able to receive
anything with a @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER).

As I want to initiate the packet-send from outside the Ryu app, I'm storing
the datapath of the ryu app when it's being initialized and then getting
the instance of the app from the AppManager and call the send_packet on the
instance of the app.

Main component:

# ... Initialize with AppManager.run_apps and do some other initializations

# Create a sample packet
pkt = ethernet.ethernet(dst='5e:cc:cc:b1:49:4b') /\
    arp.arp(src_ip='192.168.70.2', dst_ip='192.168.70.3')
pkt.serialize()


manager = AppManager.get_instance()
manager.applications[PacketTracingController.__name__] \
.send_packet(pkt.data)

import time
time.sleep(5)


Ryu App:

# Set up ARP r

class PacketTracingController(app_manager.RyuApp):

    @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)

    def initialize_on_connect(self, ev):
        self._datapath = ev.msg.datapath
        # Error handling and what happens on disconnect is removed for
        # simplicity

    @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
    def handle_packet_in_user_space(self, ev):
        msg = ev.msg
        self.log.info("[TRACER] table_id: {}".format(msg.table_id))
        self.log.info("[TRACER] received data: {}".format(msg.data))

    def send_packet(self, packet):

        data = packet.data
        ofproto = self._datapath.ofproto
        ofp_parser = self._datapath.ofproto_parser
        actions = [
            ofp_parser.NXActionRegLoad2(dst='reg5', value=0x100),
            ofp_parser.NXActionRegLoad2(dst='reg1', value=0x10),
            ofp_parser.OFPActionOutput(port=ofproto.OFPP_FLOOD)
        ]
        req = ofp_parser.OFPPacketOut(datapath=self._datapath,
                                      buffer_id=ofproto.OFP_NO_BUFFER,
                                      in_port=ofproto.OFPP_CONTROLLER,
                                      actions=actions,
                                      data=data)
    self._datapath.send_msg(req)
    self.log.info(
        'dp.id: {} pkt: {}'.format(self._datapath.id, packet))


I can see that initialize_on_connect works fine, send_packet is getting
triggered, but unfortunately, I cannot get any message in
handle_packet_in_user_space.

And if I print the flows with ovs-ofctl dump-flows before and after sending
the packet they are identical (in terms of n_packets and n_bytes).

Here is the dump output:

NXST_FLOW reply (xid=0x4):
 cookie=0x0, duration=135.952s, table=0, n_packets=0, n_bytes=0,
idle_age=135, priority=5,ip,nw_dst=192.168.128.0/24
actions=CONTROLLER:65535
 cookie=0x0, duration=135.952s, table=0, n_packets=1, n_bytes=70,
idle_age=11, priority=0 actions=resubmit(,1)
 cookie=0x0, duration=195.940s, table=1, n_packets=0, n_bytes=0,
idle_age=195, priority=10,in_port=32768
actions=set_field:0x1->reg1,resubmit(,2),set_field:0->reg0
 cookie=0x0, duration=195.940s, table=1, n_packets=1, n_bytes=70,
idle_age=11, priority=10,in_port=LOCAL
actions=set_field:0x10->reg1,resubmit(,2),set_field:0->reg0
 cookie=0x0, duration=195.941s, table=2, n_packets=0, n_bytes=0,
idle_age=195, priority=10,arp,reg1=0x10,arp_tpa=192.168.128.0/24
actions=move:NXM_OF_ETH_SRC[]->NXM_OF_ETH_DST[],mod_dl_src:ca:cc:21:51:b0:45,load:0x2->NXM_OF_ARP_OP[],move:NXM_NX_ARP_SHA[]->NXM_NX_ARP_THA[],load:0xcacc2151b045->NXM_NX_ARP_SHA[],move:NXM_OF_ARP_TPA[]->NXM_NX_REG0[],move:NXM_OF_ARP_SPA[]->NXM_OF_ARP_TPA[],move:NXM_NX_REG0[]->NXM_OF_ARP_SPA[],IN_PORT
 cookie=0x0, duration=195.941s, table=2, n_packets=0, n_bytes=0,
idle_age=195, priority=1,arp,reg1=0x10,reg5=0 actions=drop
 cookie=0x0, duration=195.941s, table=2, n_packets=0, n_bytes=0,
idle_age=195, priority=8,arp,reg1=0x10,reg5=0x100
actions=CONTROLLER:65535
 cookie=0x0, duration=195.941s, table=2, n_packets=0, n_bytes=0,
idle_age=195, priority=1,ip,reg1=0x1
actions=set_field:ca:cc:21:51:b0:45->eth_dst,resubmit(,3),set_field:0->reg0
 cookie=0x0, duration=195.941s, table=2, n_packets=1, n_bytes=70,
idle_age=11, priority=1 actions=resubmit(,3),set_field:0->reg0
 cookie=0x0, duration=195.941s, table=4, n_packets=0, n_bytes=0,
idle_age=195, priority=1 actions=resubmit(,5),set_field:0->reg0
 cookie=0x1, duration=195.940s, table=5, n_packets=0, n_bytes=0,
idle_age=195, priority=1,ip,reg1=0x10,metadata=0x1/0x1
actions=CONTROLLER:65535
 cookie=0x1, duration=195.940s, table=5, n_packets=0, n_bytes=0,
idle_age=195, priority=1,ip,reg1=0x1,metadata=0x1/0x1
actions=CONTROLLER:65535
 cookie=0x0, duration=195.940s, table=6, n_packets=0, n_bytes=0,
idle_age=195, priority=1,ip,reg1=0x10
actions=resubmit(,7),set_field:0->reg0
 cookie=0x0, duration=195.940s, table=6, n_packets=0, n_bytes=0,
idle_age=195, priority=1,ip,reg1=0x1
actions=resubmit(,7),set_field:0->reg0
 cookie=0x0, duration=195.941s, table=7, n_packets=0, n_bytes=0,
idle_age=195, priority=1,ip,reg1=0x10
actions=resubmit(,20),set_field:0->reg0
 cookie=0x0, duration=195.941s, table=7, n_packets=0, n_bytes=0,
idle_age=195, priority=1,ip,reg1=0x1
actions=resubmit(,20),set_field:0->reg0
 cookie=0x0, duration=195.941s, table=20, n_packets=0, n_bytes=0,
idle_age=195, priority=1,reg1=0x10 actions=output:32768
 cookie=0x0, duration=195.941s, table=20, n_packets=0, n_bytes=0,
idle_age=195, priority=1,reg1=0x1 actions=LOCAL

Sending: 
ethernet(dst='5e:cc:cc:b1:49:4b',ethertype=2048,src='00:00:00:00:00:00'),
arp(dst_ip='192.168.70.3',dst_mac='ff:ff:ff:ff:ff:ff',hlen=6,hwtype=1,opcode=1,plen=4,proto=2048,src_ip='192.168.70.2',src_mac='ff:ff:ff:ff:ff:ff')


----- AFTER SEND -----
NXST_FLOW reply (xid=0x4):
 cookie=0x0, duration=137.961s, table=0, n_packets=0, n_bytes=0,
idle_age=137, priority=5,ip,nw_dst=192.168.128.0/24
actions=CONTROLLER:65535
 cookie=0x0, duration=137.961s, table=0, n_packets=1, n_bytes=70,
idle_age=13, priority=0 actions=resubmit(,1)
 cookie=0x0, duration=197.949s, table=1, n_packets=0, n_bytes=0,
idle_age=197, priority=10,in_port=32768
actions=set_field:0x1->reg1,resubmit(,2),set_field:0->reg0
 cookie=0x0, duration=197.949s, table=1, n_packets=1, n_bytes=70,
idle_age=13, priority=10,in_port=LOCAL
actions=set_field:0x10->reg1,resubmit(,2),set_field:0->reg0
 cookie=0x0, duration=197.950s, table=2, n_packets=0, n_bytes=0,
idle_age=197, priority=10,arp,reg1=0x10,arp_tpa=192.168.128.0/24
actions=move:NXM_OF_ETH_SRC[]->NXM_OF_ETH_DST[],mod_dl_src:ca:cc:21:51:b0:45,load:0x2->NXM_OF_ARP_OP[],move:NXM_NX_ARP_SHA[]->NXM_NX_ARP_THA[],load:0xcacc2151b045->NXM_NX_ARP_SHA[],move:NXM_OF_ARP_TPA[]->NXM_NX_REG0[],move:NXM_OF_ARP_SPA[]->NXM_OF_ARP_TPA[],move:NXM_NX_REG0[]->NXM_OF_ARP_SPA[],IN_PORT
 cookie=0x0, duration=197.950s, table=2, n_packets=0, n_bytes=0,
idle_age=197, priority=1,arp,reg1=0x10,reg5=0 actions=drop
 cookie=0x0, duration=197.950s, table=2, n_packets=0, n_bytes=0,
idle_age=197, priority=8,arp,reg1=0x10,reg5=0x100
actions=CONTROLLER:65535
 cookie=0x0, duration=197.950s, table=2, n_packets=0, n_bytes=0,
idle_age=197, priority=1,ip,reg1=0x1
actions=set_field:ca:cc:21:51:b0:45->eth_dst,resubmit(,3),set_field:0->reg0
 cookie=0x0, duration=197.950s, table=2, n_packets=1, n_bytes=70,
idle_age=13, priority=1 actions=resubmit(,3),set_field:0->reg0
 cookie=0x0, duration=197.950s, table=4, n_packets=0, n_bytes=0,
idle_age=197, priority=1 actions=resubmit(,5),set_field:0->reg0
 cookie=0x1, duration=197.949s, table=5, n_packets=0, n_bytes=0,
idle_age=197, priority=1,ip,reg1=0x10,metadata=0x1/0x1
actions=CONTROLLER:65535
 cookie=0x1, duration=197.949s, table=5, n_packets=0, n_bytes=0,
idle_age=197, priority=1,ip,reg1=0x1,metadata=0x1/0x1
actions=CONTROLLER:65535
 cookie=0x0, duration=197.949s, table=6, n_packets=0, n_bytes=0,
idle_age=197, priority=1,ip,reg1=0x10
actions=resubmit(,7),set_field:0->reg0
 cookie=0x0, duration=197.949s, table=6, n_packets=0, n_bytes=0,
idle_age=197, priority=1,ip,reg1=0x1
actions=resubmit(,7),set_field:0->reg0
 cookie=0x0, duration=197.950s, table=7, n_packets=0, n_bytes=0,
idle_age=197, priority=1,ip,reg1=0x10
actions=resubmit(,20),set_field:0->reg0
 cookie=0x0, duration=197.950s, table=7, n_packets=0, n_bytes=0,
idle_age=197, priority=1,ip,reg1=0x1
actions=resubmit(,20),set_field:0->reg0
 cookie=0x0, duration=197.950s, table=20, n_packets=0, n_bytes=0,
idle_age=197, priority=1,reg1=0x10 actions=output:32768
 cookie=0x0, duration=197.950s, table=20, n_packets=0, n_bytes=0,
idle_age=197, priority=1,reg1=0x1 actions=LOCAL


I'm using OFP_VERSIONS = [ofproto_v1_4.OFP_VERSION]
Can you please point me to what I'm doing wrong?

Thanks a lot!
Best,
Martin
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to