summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJarno Rajahalme <jarno.rajahalme@nsn.com>2013-05-19 15:44:53 +0300
committerBen Pfaff <blp@nicira.com>2013-05-20 11:14:53 -0700
commit72333065758f8d7de2de0b047da781ee444904d1 (patch)
treec26b1f79320ea1c319a52548653a5ab85e0f7c1c /lib
parent213b00cfb6282bdbd6023b54a81865c79252a593 (diff)
downloadopenvswitch-72333065758f8d7de2de0b047da781ee444904d1.tar.gz
meta-flow: Add MFF_IN_PORT_OXM, a 32-bit in_port.
This helps get rid of one special case in nx_pull_raw() and allows loading of 32-bit values from/to OXM_OF_IN_PORT in NXAST_LEARN actions. Previously the 16-bit limit acted the same on both NXM_OF_IN_PORT and OXM_OF_IN_PORT, even though OF1.1+ controllers would expect OXM_OF_IN_PORT to be 32 bits wide. Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/meta-flow.c71
-rw-r--r--lib/meta-flow.h2
-rw-r--r--lib/nx-match.c13
3 files changed, 74 insertions, 12 deletions
diff --git a/lib/meta-flow.c b/lib/meta-flow.c
index 16850ec35..c59d82aec 100644
--- a/lib/meta-flow.c
+++ b/lib/meta-flow.c
@@ -116,6 +116,15 @@ static const struct mf_field mf_fields[MFF_N_IDS] = {
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,
@@ -688,6 +697,7 @@ mf_is_all_wild(const struct mf_field *mf, const struct flow_wildcards *wc)
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;
@@ -926,6 +936,11 @@ mf_is_value_valid(const struct mf_field *mf, const union mf_value *value)
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:
@@ -999,6 +1014,10 @@ mf_get_value(const struct mf_field *mf, const struct flow *flow,
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;
@@ -1182,6 +1201,15 @@ mf_set_value(const struct mf_field *mf,
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;
@@ -1365,6 +1393,15 @@ mf_set_flow_value(const struct mf_field *mf,
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;
@@ -1561,6 +1598,7 @@ mf_set_wild(const struct mf_field *mf, struct match *match)
break;
case MFF_IN_PORT:
+ case MFF_IN_PORT_OXM:
match->flow.in_port = 0;
match->wc.masks.in_port = 0;
break;
@@ -1742,6 +1780,7 @@ mf_set(const struct mf_field *mf,
switch (mf->id) {
case MFF_IN_PORT:
+ case MFF_IN_PORT_OXM:
case MFF_SKB_MARK:
case MFF_SKB_PRIORITY:
case MFF_ETH_TYPE:
@@ -1977,6 +2016,10 @@ mf_random_value(const struct mf_field *mf, union mf_value *value)
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;
@@ -2177,6 +2220,21 @@ mf_from_ofp_port_string(const struct mf_field *mf, const char *s,
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;
@@ -2314,6 +2372,9 @@ mf_parse(const struct mf_field *mf, const char *s,
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);
@@ -2417,6 +2478,16 @@ mf_format(const struct mf_field *mf,
}
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);
diff --git a/lib/meta-flow.h b/lib/meta-flow.h
index 9577a100f..a85a19376 100644
--- a/lib/meta-flow.h
+++ b/lib/meta-flow.h
@@ -39,6 +39,7 @@ enum mf_field_id {
MFF_TUN_TOS, /* u8 */
MFF_METADATA, /* be64 */
MFF_IN_PORT, /* be16 */
+ MFF_IN_PORT_OXM, /* be32 */
MFF_SKB_PRIORITY, /* be32 */
MFF_SKB_MARK, /* be32 */
@@ -220,6 +221,7 @@ enum mf_string {
MFS_IPV4,
MFS_IPV6,
MFS_OFP_PORT, /* An OpenFlow port number or name. */
+ MFS_OFP_PORT_OXM, /* An OpenFlow port number or name (32-bit). */
MFS_FRAG, /* no, yes, first, later, not_later */
MFS_TNL_FLAGS, /* FLOW_TNL_F_* flags */
};
diff --git a/lib/nx-match.c b/lib/nx-match.c
index 51b6dc645..a91d56b9a 100644
--- a/lib/nx-match.c
+++ b/lib/nx-match.c
@@ -148,7 +148,7 @@ nx_pull_raw(const uint8_t *p, unsigned int match_len, bool strict,
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;
@@ -170,17 +170,6 @@ nx_pull_raw(const uint8_t *p, unsigned int match_len, bool strict,
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. */