Hi Marcelo,
There is a "wildcards" field on struct ofp_match.
You should take care the "wildcards" field if you intend to ignore some fields. 
If no wildcards are set, it means exact match over the entire 
11-tuple(10-tuple/12-tuple).
Hope it helps

Regards,
MinChi
-----Original Message-----
From: nox-dev-boun...@noxrepo.org [mailto:nox-dev-boun...@noxrepo.org] On 
Behalf Of Marcelo Ribeiro Nascimento
Sent: Monday, April 26, 2010 10:44 PM
To: nox-dev@noxrepo.org
Subject: [nox-dev] Installing flows by NOX

Hi all,

I have recently started working with NOX development and I am facing problems 
installing flows by NOX into switch table. I would like to install a flow to 
forward UDP packets with a specific IP destination address (i.e. 192.168.0.1) 
to controller. My problem is: I don't care about the others fields (vlanid, 
port_in, dl_src, dl_dst and so on), so how should I fill the struct ofp_match? 

My code is bellow:

        ofp_flow_mod* ofm;
        size_t size = sizeof *ofm + sizeof(ofp_action_output);
        boost::shared_array<char> raw_of(new char[size]);
        ofm = (ofp_flow_mod*) raw_of.get();

        ofm->header.version = OFP_VERSION;
        ofm->header.type = OFPT_FLOW_MOD;
        ofm->header.length = htons(size);
        ofm->header.xid = 0;

        std::memset(&(ofm->match), 0, sizeof(struct ofp_match));
        ofm->match.dl_type = ethernet::IP;             /* IP Protocol*/
        ofm->match.nw_proto = 0x11;                    /* UDP IP Protocol*/
        ofm->match.nw_dst =  inet_addr("192.168.0.1"); /* Dest. IP Addr */

        ofm->cookie = htonl(0);
        ofm->out_port = OFPP_NONE;
        ofm->command = htons(OFPFC_ADD);
        ofm->buffer_id = htonl(UINT32_MAX);
        ofm->idle_timeout = htons(OFP_FLOW_PERMANENT);
        ofm->hard_timeout = htons(OFP_FLOW_PERMANENT);
        ofm->priority = htons(OFP_DEFAULT_PRIORITY);
        ofm->flags = htons(ofd_flow_mod_flags());

        ofp_action_output& action = *((ofp_action_output*) ofm->actions);
        memset(&action, 0, sizeof(ofp_action_output));
        action.type = htons(OFPAT_OUTPUT);
        action.len = htons(sizeof(ofp_action_output));
        action.port = htons(OFPP_CONTROLLER);
        action.max_len = htons(ETH_DATA_LEN);       /*Send up to 1500 bytes*/

        send_openflow_command(dj.datapath_id, &ofm->header, true);

This code doesn't work. That packets are forwarded to controller but with 
reason OFPR_NO_MATCH.

NOX message:
00637|my_program|INFO:handle_packet_in: A packet has been received (port: 1, 
reason: 0, len=200, buf_size=128)

The output of "dpctl dump-flows" command:

#./dpctl dump-flows unix:/var/run/sp0.sock

stats_reply (xid=0xd14d1b1c): flags=none type=1(flow)
cookie=0, duration_sec=4s, duration_nsec=857000000s, table_id=0, 
priority=65535, n_packets=0, n_bytes=0, idle_timeout=0, hard_timout=0, udp, 
in_port=0, dl_vlan=0, dl_vlan_pcp=0, dl_src=00:00:00:00:00:00, 
dl_dst=00:00:00:00:00:00,nw_src=0.0.0.0, nw_dst=192.168.0.1, nw_tos=0x00, 
tp_src=0, tp_dst=0, actions=CONTROLLER:1500

I think the problem is the fields filled with ZERO. When I set the flow by 
dpctl, it seems to work! But in this case I don't know how to specify max_len 
and ZERO bytes are sent to controller.

#./dpctl add-flow unix:/var/run/dp0.sock 
dl_type=0x0800,nw_proto=0x11,nw_dst=192.168.0.1,actions=CONTROLLER

#./dpctl dump-flows unix:/var/run/sp0.sock
stats_reply (xid=0x96173c8e): flags=none type=1(flow)
cookie=0, duration_src=2s, durations_nsec=800000000s, table_id=1, 
priority=32768, n_packets=0, n_bytes=0, idle_timoue=60, hard_timout=0, upd, 
nw_dst=192.168.0.1, actions=CONTROLLER:all

Unlike the flow installed by NOX, here I have the fields that were specified 
only.

NOX messages:
00463|my_program|INFO:handle_packet_in: A packet has been received (port: 1, 
reason: 1, len=200, buf_size=0)
00464|flow|ERR:Packet length 0 less than minimum Ethernet packet 14: 
port0100:vlanffff:pcp:0 mac00:00:00:00:00:00->00:00:00:00:00:00 proto0000 
ip0.0.0.0->0.0.0.0 port0->0

I would be very grateful for any help!

Best Regards,
Marcelo


_______________________________________________
nox-dev mailing list
nox-dev@noxrepo.org
http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org

_______________________________________________
nox-dev mailing list
nox-dev@noxrepo.org
http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org

Reply via email to