On Wed, 01 Aug 2012 17:10:54 +0800, CHEN Fuyu <[email protected]> wrote:

Hi, All,

I'm running the nox controller hub.cc which is from the nox source. How to
set up the match field match.wildcards?

What I want to do, for example, is to set up a match rule for some
particular fields.

If I want the match field to be, for instance, in_port and eth_src, then I
put

        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->match.wildcards = htonl(0);
        ofm->match.in_port = htons(flow.in_port);
        memcpy(ofm->match.dl_src, flow.dl_src.octet, sizeof
ofm->match.dl_src);
        ofm->match.dl_type = flow.dl_type;
        ofm->cookie = htonl(0);
        ofm->command = htons(OFPFC_ADD);
        ofm->buffer_id = htonl(buffer_id);
        ofm->idle_timeout = htons(OFP_FLOW_PERMANENT);
        ofm->hard_timeout = htons(OFP_FLOW_PERMANENT);
        ofm->priority = htons(OFP_DEFAULT_PRIORITY);
        ofm->flags = htons(0);
        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_FLOOD);
        action.max_len = htons(0);
        send_openflow_command(pi.datapath_id, &ofm->header, true);

However, from the wireshark output, it seems the switch are doing the exact
match for all field, including the fields I didn't specify in the hub.cc,
all the packet will go to the controller, even the packet with the same
value of in_port, dl_type, dl_src with the previous packet.

If the modify the line to ofm->match.wildcards = 0xffffffff, then only the
first packet will go to controller. If I didn't setup any value for
match.wildcards, it seems the same results as the case of 0xffffffff

So what value of wildcards I need to setup if I only some particular field
to match?

Thanks.


Have you read the openflow spec? I think you should take a look at the
flow match structure section.
In your situation, if you would like match field to be in_port and eth_src,
you should set the wildcard flags on the others. Thus, setting
ofm->match.wildcards to (OFPFW_IN_PORT|OFPFW_DL_SRC)^OFPFW_ALL would be
satisfactory.


--
Regards,
Hunt

Reply via email to