Hi list, I'm trying to figure out on how to place a flow into a specific table using a pox extension. I can easily place flows into standard tables using the following (python) code:
def create_flow_install_msg(ip, table, mask, srcMac, dstMac, dstPort): ofm = ofp_flow_mod() ofm_match_dl(ofm, OFPFW_DL_TYPE, 0x0800) if (MATCH_L2): ofm_match_dl(ofm, OFPFW_DL_DST, srcMac) ofm.match.set_nw_dst(ip) ofm.priority = OFP_DEFAULT_PRIORITY + mask ofm.command = 1 #(OFPFC_ADD) if (mask == 32): ofm.idle_timeout = 300 else: ofm.idle_timeout = OFP_FLOW_PERMANENT ofm.hard_timeout = OFP_FLOW_PERMANENT ofm.out_port = OFPP_NONE ofm.actions.append(ofp_action_dl_addr(type=OFPAT_SET_DL_SRC, dl_addr=EthAddr(srcMac))) ofm.actions.append(ofp_action_dl_addr(type=OFPAT_SET_DL_DST, dl_addr=EthAddr(dstMac))) #ofm.actions.append(ofp_action_tp_port(type=OFPAT_SET_TP_DST, tp_port=20005)) ofm.actions.append(ofp_action_output(port=dstPort)) return ofm Now I'm trying to understand how the Nicira extension of openvswitch can be enabled. I've read through the following: /* This command enables or disables an Open vSwitch extension that allows a * controller to specify the OpenFlow table to which a flow should be added, * instead of having the switch decide which table is most appropriate as * required by OpenFlow 1.0. By default, the extension is disabled. * * When this feature is enabled, Open vSwitch treats struct ofp_flow_mod's * 16-bit 'command' member as two separate fields. The upper 8 bits are used * as the table ID, the lower 8 bits specify the command as usual. A table ID * of 0xff is treated like a wildcarded table ID. * * The specific treatment of the table ID depends on the type of flow mod: * * - OFPFC_ADD: Given a specific table ID, the flow is always placed in that * table. If an identical flow already exists in that table only, then it * is replaced. If the flow cannot be placed in the specified table, * either because the table is full or because the table cannot support * flows of the given type, the switch replies with an * OFPFMFC_ALL_TABLES_FULL error. (A controller can distinguish these * cases by comparing the current and maximum number of entries reported * in ofp_table_stats.) * * If the table ID is wildcarded, the switch picks an appropriate table * itself. If an identical flow already exist in the selected flow table, * then it is replaced. The choice of table might depend on the flows * that are already in th switch; for example, if one table fills up then * the switch might fall back to another one. * * - OFPFC_MODIFY, OFPFC_DELETE: Given a specific table ID, only flows * within that table are matched and modified or deleted. If the table ID * is wildcarded, flows within any table may be matched and modified or * deleted. * * - OFPFC_MODIFY_STRICT, OFPFC_DELETE_STRICT: Given a specific table ID, * only a flow within that table may be matched and modified or deleted. * If the table ID is wildcarded and exactly one flow within any table * matches, then it is modified or deleted; if flows in more than one * table match, then none is modified or deleted. */ struct nxt_flow_mod_table_id { struct ofp_header header; uint32_t vendor; /* NX_VENDOR_ID. */ uint32_t subtype; /* NXT_FLOW_MOD_TABLE_ID. */ uint8_t set; /* Nonzero to enable, zero to disable. */ uint8_t pad[7]; }; commands are represented by 16 bit integers (0 - OFPFC_ADD; 1 - OFPFC_MODIFY ...). In order to add a flow into table 1 I changed the command 16 bit int from 0 to 256 (0000 0001 0000 0000). So the upper 8 bit specify the table 1, the lower 8 bit the command (0 = ADD). When snooping the bridge I'm getting the following output: Jan 06 22:54:16|00049|ofp_util|INFO|normalization changed ofp_match, details: Jan 06 22:54:16|00050|ofp_util|INFO| pre: priority=32772,ip,dl_dst=a1:a1:a1:a1:a1:a1,nw_dst=240.0.0.0/4,tp_src=0,tp_dst=0 Jan 06 22:54:16|00051|ofp_util|INFO|post: priority=32772,ip,dl_dst=a1:a1:a1:a1:a1:a1,nw_dst=240.0.0.0/4 OFPT_FLOW_MOD (xid=0x15): ADD table:1 priority=32772,ip,dl_dst=a1:a1:a1:a1:a1:a1,nw_dst=240.0.0.0/4 actions=mod_dl_src:a1:a1:a1:a1:a1:a1,mod_dl_dst:a2:a2:a2:a2:a2:a2,output:6 OFPT_ERROR (xid=0x15): type OFPET_FLOW_MOD_FAILED, code OFPFMFC_BAD_COMMAND (***truncated to 64 bytes from 112***) 00000000 01 0e 00 70 00 00 00 15-00 37 20 27 00 00 00 00 |...p.....7 '....| 00000010 00 00 00 00 a1 a1 a1 a1-a1 a1 00 00 00 00 08 00 |................| 00000020 00 00 00 00 00 00 00 00-ff ff ff 00 00 00 00 00 |................| 00000030 00 00 00 00 00 00 00 00-01 00 00 00 00 00 80 04 |................| The command is correctly identified as well as the table but I am still getting an OFPFMFC_BAD_COMMAND code. Any thoughts? I'm running a stock openvswitch 1.4.0 with OF 1.0. Using the ofctl works without any issues. Thanks, Michael
_______________________________________________ discuss mailing list discuss@openvswitch.org http://openvswitch.org/mailman/listinfo/discuss