[ovs-discuss] add a flow to a specific table

Jesse Gross jesse at nicira.com
Wed Jan 9 18:21:08 UTC 2013


The entire extension is sending the command plus encoding the table in
the flow mod so I'm not sure that there is a difference.

On Wed, Jan 9, 2013 at 9:14 AM, Henkel, Michael <michael.henkel at hp.com> wrote:
> Thanks Jesse,
>
> In order to do that need my controller to support the entire Nicira extension or is there a simple way to send the NXT_FLOW_MOD_TABLE_ID command to the switch?
>
> Regards,
> Michael
>
> -----Original Message-----
> From: Jesse Gross [mailto:jesse at nicira.com]
> Sent: Mittwoch, 9. Januar 2013 16:58
> To: Henkel, Michael
> Cc: discuss at openvswitch.org
> Subject: Re: [ovs-discuss] add a flow to a specific table
>
> On Wed, Jan 9, 2013 at 7:00 AM, Henkel, Michael <michael.henkel at hp.com> wrote:
>> 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).
>
> I think you haven't enabled the extension.  You must first send the NXT_FLOW_MOD_TABLE_ID command to turn it on and then encode the table ID in the flow mod.



More information about the discuss mailing list