MFP_NONE,
true,
NXM_OF_IN_PORT, "NXM_OF_IN_PORT",
+ NXM_OF_IN_PORT, "NXM_OF_IN_PORT",
+ }, {
+ MFF_IN_PORT_OXM, "in_port_oxm", NULL,
+ MF_FIELD_SIZES(be32),
+ MFM_NONE,
+ MFS_OFP_PORT_OXM,
+ MFP_NONE,
+ true,
+ OXM_OF_IN_PORT, "OXM_OF_IN_PORT",
OXM_OF_IN_PORT, "OXM_OF_IN_PORT",
}, {
MFF_SKB_PRIORITY, "skb_priority", NULL,
case MFF_METADATA:
return !wc->masks.metadata;
case MFF_IN_PORT:
+ case MFF_IN_PORT_OXM:
return !wc->masks.in_port;
case MFF_SKB_PRIORITY:
return !wc->masks.skb_priority;
case MFF_ND_TLL:
return true;
+ case MFF_IN_PORT_OXM: {
+ uint16_t port;
+ return !ofputil_port_from_ofp11(value->be32, &port);
+ }
+
case MFF_IP_DSCP:
return !(value->u8 & ~IP_DSCP_MASK);
case MFF_IP_DSCP_SHIFTED:
value->be16 = htons(flow->in_port);
break;
+ case MFF_IN_PORT_OXM:
+ value->be32 = ofputil_port_to_ofp11(flow->in_port);
+ break;
+
case MFF_SKB_PRIORITY:
value->be32 = htonl(flow->skb_priority);
break;
match_set_in_port(match, ntohs(value->be16));
break;
+ case MFF_IN_PORT_OXM: {
+ uint16_t port;
+ if (ofputil_port_from_ofp11(value->be32, &port)) {
+ port = OFPP_NONE;
+ }
+ match_set_in_port(match, port);
+ break;
+ }
+
case MFF_SKB_PRIORITY:
match_set_skb_priority(match, ntohl(value->be32));
break;
flow->in_port = ntohs(value->be16);
break;
+ case MFF_IN_PORT_OXM: {
+ uint16_t port;
+ if (ofputil_port_from_ofp11(value->be32, &port)) {
+ port = OFPP_NONE;
+ }
+ flow->in_port = port;
+ break;
+ }
+
case MFF_SKB_PRIORITY:
flow->skb_priority = ntohl(value->be32);
break;
break;
case MFF_IN_PORT:
+ case MFF_IN_PORT_OXM:
match->flow.in_port = 0;
match->wc.masks.in_port = 0;
break;
switch (mf->id) {
case MFF_IN_PORT:
+ case MFF_IN_PORT_OXM:
case MFF_SKB_MARK:
case MFF_SKB_PRIORITY:
case MFF_ETH_TYPE:
case MFF_ND_TLL:
break;
+ case MFF_IN_PORT_OXM:
+ value->be32 = ofputil_port_to_ofp11(ntohs(value->be16));
+ break;
+
case MFF_IPV6_LABEL:
value->be32 &= ~htonl(IPV6_LABEL_MASK);
break;
return xasprintf("%s: port value out of range for %s", s, mf->name);
}
+static char *
+mf_from_ofp_port_string32(const struct mf_field *mf, const char *s,
+ ovs_be32 *valuep, ovs_be32 *maskp)
+{
+ uint16_t port;
+
+ ovs_assert(mf->n_bytes == sizeof(ovs_be32));
+ if (ofputil_port_from_string(s, &port)) {
+ *valuep = ofputil_port_to_ofp11(port);
+ *maskp = htonl(UINT32_MAX);
+ return NULL;
+ }
+ return xasprintf("%s: port value out of range for %s", s, mf->name);
+}
+
struct frag_handling {
const char *name;
uint8_t mask;
case MFS_OFP_PORT:
return mf_from_ofp_port_string(mf, s, &value->be16, &mask->be16);
+ case MFS_OFP_PORT_OXM:
+ return mf_from_ofp_port_string32(mf, s, &value->be32, &mask->be32);
+
case MFS_FRAG:
return mf_from_frag_string(s, &value->u8, &mask->u8);
}
switch (mf->string) {
+ case MFS_OFP_PORT_OXM:
+ if (!mask) {
+ uint16_t port;
+ if (ofputil_port_from_ofp11(value->be32, &port)) {
+ port = OFPP_NONE;
+ }
+ ofputil_format_port(port, s);
+ break;
+ }
+ /* fall through */
case MFS_OFP_PORT:
if (!mask) {
ofputil_format_port(ntohs(value->be16), s);
error = OFPERR_OFPBMC_BAD_PREREQ;
} else if (!mf_is_all_wild(mf, &match->wc)) {
error = OFPERR_OFPBMC_DUP_FIELD;
- } else if (header != OXM_OF_IN_PORT) {
+ } else {
unsigned int width = mf->n_bytes;
union mf_value value;
mf_set(mf, &value, &mask, match);
}
}
- } else {
- /* Special case for 32bit ports when using OXM,
- * ports are 16 bits wide otherwise. */
- ovs_be32 port_of11;
- uint16_t port;
-
- memcpy(&port_of11, p + 4, sizeof port_of11);
- error = ofputil_port_from_ofp11(port_of11, &port);
- if (!error) {
- match_set_in_port(match, port);
- }
}
/* Check if the match is for a cookie rather than a classifier rule. */
]])
AT_CLEANUP
+AT_SETUP([learning action - parsing and formatting - illegal in_port_oxm])
+AT_CHECK([[ovs-ofctl parse-flow 'actions=learn(table=1, in_port_oxm=123456)']],
+ [1], [], [stderr])
+AT_CHECK([sed -e 's/.*|ofp_util|WARN|//' < stderr], [0],
+ [[port 123456 is outside the supported range 0 through ffff or 0xffffff00 through 0xffffffff
+ovs-ofctl: 123456: port value out of range for in_port_oxm
+]], [[]])
+AT_CLEANUP
+
+AT_SETUP([learning action - parsing and formatting - OXM])
+AT_DATA([flows.txt], [[
+actions=learn(output:OXM_OF_IN_PORT[])
+actions=learn(table=1, in_port=1, load:OXM_OF_IN_PORT[]->NXM_NX_REG1[], load:0xfffffffe->OXM_OF_IN_PORT[])
+]])
+AT_CHECK([ovs-ofctl parse-flows flows.txt], [0],
+[[usable protocols: any
+chosen protocol: OpenFlow10-table_id
+OFPT_FLOW_MOD (xid=0x1): ADD actions=learn(table=1,output:OXM_OF_IN_PORT[])
+OFPT_FLOW_MOD (xid=0x2): ADD actions=learn(table=1,in_port=1,load:OXM_OF_IN_PORT[]->NXM_NX_REG1[],load:0xfffffffe->OXM_OF_IN_PORT[])
+]])
+AT_CLEANUP
+
AT_SETUP([learning action - examples])
AT_DATA([flows.txt], [[
# These are the examples from nicira-ext.h.