[ovs-dev] [of1.1 v6 4/5] openflow: Separate OF1.0, OF1.1 flow_mod constants and types.
Ben Pfaff
blp at nicira.com
Fri Jul 20 06:28:50 UTC 2012
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
v3->v4: Builds, passes unit tests.
---
include/openflow/nicira-ext.h | 2 +-
include/openflow/openflow-1.0.h | 19 ++++---------------
include/openflow/openflow-common.h | 14 ++++++++++++++
lib/ofp-msgs.h | 2 +-
lib/ofp-print.c | 6 +++---
lib/ofp-util.c | 4 ++--
ofproto/ofproto.c | 2 +-
utilities/ovs-ofctl.c | 8 ++++----
8 files changed, 30 insertions(+), 27 deletions(-)
diff --git a/include/openflow/nicira-ext.h b/include/openflow/nicira-ext.h
index 97715c8..73effff 100644
--- a/include/openflow/nicira-ext.h
+++ b/include/openflow/nicira-ext.h
@@ -118,7 +118,7 @@ enum nx_hash_fields {
* 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
+ * When this feature is enabled, Open vSwitch treats struct ofp10_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.
diff --git a/include/openflow/openflow-1.0.h b/include/openflow/openflow-1.0.h
index b2077f0..75c5fc3 100644
--- a/include/openflow/openflow-1.0.h
+++ b/include/openflow/openflow-1.0.h
@@ -271,14 +271,6 @@ struct ofp_packet_out {
};
OFP_ASSERT(sizeof(struct ofp_packet_out) == 8);
-enum ofp_flow_mod_command {
- OFPFC_ADD, /* New flow. */
- OFPFC_MODIFY, /* Modify all matching flows. */
- OFPFC_MODIFY_STRICT, /* Modify entry strictly matching wildcards */
- OFPFC_DELETE, /* Delete all matching flows. */
- OFPFC_DELETE_STRICT /* Strictly match wildcards and priority. */
-};
-
/* Flow wildcards. */
enum ofp_flow_wildcards {
OFPFW10_IN_PORT = 1 << 0, /* Switch input port. */
@@ -363,15 +355,12 @@ OFP_ASSERT(sizeof(struct ofp10_match) == 40);
/* By default, choose a priority in the middle. */
#define OFP_DEFAULT_PRIORITY 0x8000
-enum ofp_flow_mod_flags {
- OFPFF_SEND_FLOW_REM = 1 << 0, /* Send flow removed message when flow
- * expires or is deleted. */
- OFPFF_CHECK_OVERLAP = 1 << 1, /* Check for overlapping entries first. */
- OFPFF_EMERG = 1 << 2 /* Ramark this is for emergency. */
+enum ofp10_flow_mod_flags {
+ OFPFF10_EMERG = 1 << 2 /* Ramark this is for emergency. */
};
/* Flow setup and teardown (controller -> datapath). */
-struct ofp_flow_mod {
+struct ofp10_flow_mod {
struct ofp10_match match; /* Fields to match */
ovs_be64 cookie; /* Opaque controller-issued identifier. */
@@ -391,7 +380,7 @@ struct ofp_flow_mod {
from the length field in the
header. */
};
-OFP_ASSERT(sizeof(struct ofp_flow_mod) == 64);
+OFP_ASSERT(sizeof(struct ofp10_flow_mod) == 64);
/* Flow removed (datapath -> controller). */
struct ofp_flow_removed {
diff --git a/include/openflow/openflow-common.h b/include/openflow/openflow-common.h
index 3c456ba..4ab3780 100644
--- a/include/openflow/openflow-common.h
+++ b/include/openflow/openflow-common.h
@@ -195,6 +195,20 @@ enum ofp_packet_in_reason {
OFPR_N_REASONS
};
+enum ofp_flow_mod_command {
+ OFPFC_ADD, /* New flow. */
+ OFPFC_MODIFY, /* Modify all matching flows. */
+ OFPFC_MODIFY_STRICT, /* Modify entry strictly matching wildcards */
+ OFPFC_DELETE, /* Delete all matching flows. */
+ OFPFC_DELETE_STRICT /* Strictly match wildcards and priority. */
+};
+
+enum ofp_flow_mod_flags {
+ OFPFF_SEND_FLOW_REM = 1 << 0, /* Send flow removed message when flow
+ * expires or is deleted. */
+ OFPFF_CHECK_OVERLAP = 1 << 1, /* Check for overlapping entries first. */
+};
+
/* Action structure for OFPAT10_SET_VLAN_VID and OFPAT11_SET_VLAN_VID. */
struct ofp_action_vlan_vid {
ovs_be16 type; /* Type. */
diff --git a/lib/ofp-msgs.h b/lib/ofp-msgs.h
index 162d6e0..5ff5976 100644
--- a/lib/ofp-msgs.h
+++ b/lib/ofp-msgs.h
@@ -145,7 +145,7 @@ enum ofpraw {
/* OFPT 1.1+ (13): struct ofp11_packet_out, uint8_t[]. */
OFPRAW_OFPT11_PACKET_OUT,
- /* OFPT 1.0 (14): struct ofp_flow_mod, struct ofp_action_header[]. */
+ /* OFPT 1.0 (14): struct ofp10_flow_mod, struct ofp_action_header[]. */
OFPRAW_OFPT10_FLOW_MOD,
/* OFPT 1.1+ (14): struct ofp11_flow_mod, struct ofp11_instruction[]. */
OFPRAW_OFPT11_FLOW_MOD,
diff --git a/lib/ofp-print.c b/lib/ofp-print.c
index 13577af..7a18830 100644
--- a/lib/ofp-print.c
+++ b/lib/ofp-print.c
@@ -711,7 +711,7 @@ ofp_print_flow_mod(struct ds *s, const struct ofp_header *oh, int verbosity)
ds_put_char(s, ' ');
ofpraw_decode(&raw, oh);
if (verbosity >= 3 && raw == OFPRAW_OFPT10_FLOW_MOD) {
- const struct ofp_flow_mod *ofm = ofpmsg_body(oh);
+ const struct ofp10_flow_mod *ofm = ofpmsg_body(oh);
ofp10_match_print(s, &ofm->match, verbosity);
/* ofp_print_match() doesn't print priority. */
@@ -770,11 +770,11 @@ ofp_print_flow_mod(struct ds *s, const struct ofp_header *oh, int verbosity)
if (flags & OFPFF_CHECK_OVERLAP) {
ds_put_cstr(s, "check_overlap ");
}
- if (flags & OFPFF_EMERG) {
+ if (flags & OFPFF10_EMERG) {
ds_put_cstr(s, "emerg ");
}
- flags &= ~(OFPFF_SEND_FLOW_REM | OFPFF_CHECK_OVERLAP | OFPFF_EMERG);
+ flags &= ~(OFPFF_SEND_FLOW_REM | OFPFF_CHECK_OVERLAP | OFPFF10_EMERG);
if (flags) {
ds_put_format(s, "flags:0x%"PRIx16" ", flags);
}
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index f772f2b..063de78 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -1084,7 +1084,7 @@ ofputil_decode_flow_mod(struct ofputil_flow_mod *fm,
raw = ofpraw_pull_assert(&b);
if (raw == OFPRAW_OFPT10_FLOW_MOD) {
/* Standard OpenFlow 1.1 flow_mod. */
- const struct ofp_flow_mod *ofm;
+ const struct ofp10_flow_mod *ofm;
uint16_t priority;
enum ofperr error;
@@ -1173,7 +1173,7 @@ struct ofpbuf *
ofputil_encode_flow_mod(const struct ofputil_flow_mod *fm,
enum ofputil_protocol protocol)
{
- struct ofp_flow_mod *ofm;
+ struct ofp10_flow_mod *ofm;
struct nx_flow_mod *nfm;
struct ofpbuf *msg;
uint16_t command;
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 522b791..5fa57d8 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -3209,9 +3209,9 @@ handle_flow_mod(struct ofconn *ofconn, const struct ofp_header *oh)
goto exit_free_ofpacts;
}
+ if (fm.flags & OFPFF10_EMERG) {
/* We do not support the OpenFlow 1.0 emergency flow cache, which is not
* required in OpenFlow 1.0.1 and removed from OpenFlow 1.1. */
- if (fm.flags & OFPFF_EMERG) {
/* We do not support the emergency flow cache. It will hopefully get
* dropped from OpenFlow in the near future. There is no good error
* code, so just state that the flow table is full. */
diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index b328c7a..f7600b1 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -1837,7 +1837,7 @@ read_flows_from_file(const char *filename, struct classifier *cls, int index)
version->cookie = fm.new_cookie;
version->idle_timeout = fm.idle_timeout;
version->hard_timeout = fm.hard_timeout;
- version->flags = fm.flags & (OFPFF_SEND_FLOW_REM | OFPFF_EMERG);
+ version->flags = fm.flags & (OFPFF_SEND_FLOW_REM | OFPFF10_EMERG);
version->ofpacts = fm.ofpacts;
version->ofpacts_len = fm.ofpacts_len;
@@ -1862,8 +1862,8 @@ recv_flow_stats_reply(struct vconn *vconn, ovs_be32 send_xid,
struct ofpbuf *reply = *replyp;
for (;;) {
- ovs_be16 flags;
int retval;
+ bool more;
/* Get a flow stats reply message, if we don't already have one. */
if (!reply) {
@@ -1891,10 +1891,10 @@ recv_flow_stats_reply(struct vconn *vconn, ovs_be32 send_xid,
return true;
case EOF:
- flags = ((const struct ofp_stats_msg *) reply->l2)->flags;
+ more = ofpmp_more(reply->l2);
ofpbuf_delete(reply);
reply = NULL;
- if (!(flags & htons(OFPSF_REPLY_MORE))) {
+ if (!more) {
*replyp = NULL;
return false;
}
--
1.7.2.5
More information about the dev
mailing list