Skip to content

Commit

Permalink
ofp-monitor: Support flow monitoring for OpenFlow 1.3, 1.4+.
Browse files Browse the repository at this point in the history
Extended OpenFlow monitoring support
* OpenFlow 1.3 with ONF extensions
* OpenFlow 1.4+ as defined in OpenFlow specification 1.4+.

ONF extensions are similar to Nicira extensions except for onf_flow_monitor_request{}
where out_port is defined as 32-bit number OF(1.1) number, oxm match formats are
used in update and request messages.

Flow monitoring support in 1.4+ is slightly different from Nicira and ONF
extensions.
 * More flow monitoring flags are defined.
 * Monitor add/modify/delete command is introduced in flow_monitor
   request message.
 * Addition of out_group as part of flow_monitor request message

Description of changes:
1. Generate ofp-msgs.inc to be able to support 1.3, 1.4+ flow Monitoring messages.
    include/openvswitch/ofp-msgs.h

2. Modify openflow header files with protocol specific headers.
    include/openflow/openflow-1.3.h
    include/openflow/openflow-1.4.h

3. Modify OvS abstraction of openflow headers. ofp-monitor.h leverages  enums
   from on nicira extensions for creating protocol abstraction headers. OF(1.4+)
   enums are superset of nicira extensions.
    include/openvswitch/ofp-monitor.h

4. Changes to these files reflect encoding and decoding of new protocol messages.
    lib/ofp-monitor.c

5. Changes to modules using ofp-monitor APIs. Most of the changes here are to
   migrate enums from nicira to OF 1.4+ versions.
    ofproto/connmgr.c
    ofproto/connmgr.h
    ofproto/ofproto-provider.h
    ofproto/ofproto.c

6. Extended protocol decoding tests to verify all protocol versions
        FLOW_MONITOR_CANCEL
        FLOW_MONITOR_PAUSED
        FLOW_MONITOR_RESUMED
        FLOW_MONITOR request
        FLOW_MONITOR reply
    tests/ofp-print.at

7. Modify flow monitoring tests to be able executed by all protocol versions.
    tests/ofproto.at

7. Modified documentation highlighting the change
    utilities/ovs-ofctl.8.in
    NEWS

Signed-off-by: Vasu Dasari <[email protected]>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2021-June/383915.html
Acked-by: Aaron Conole <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
vasu-dasari authored and igsilya committed Apr 28, 2022
1 parent d8ab75c commit c3e6404
Show file tree
Hide file tree
Showing 15 changed files with 1,265 additions and 292 deletions.
6 changes: 4 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ Post-v2.17.0
applications to relax atomicity requirements when dealing with
columns whose value has been rewritten (but not changed).
- OpenFlow:
* Added Flow Monitoring support for OpenFlow 1.0-1.2 with Nicira
Extensions.
* Extended Flow Monitoring support for all supported OpenFlow versions:
OpenFlow versions 1.0-1.2 with Nicira Extensions
OpenFlow versions 1.3 with Open Network Foundation extension
OpenFlow versions 1.4+, as defined in the OpenFlow specification


v2.17.0 - 17 Feb 2022
Expand Down
89 changes: 89 additions & 0 deletions include/openflow/openflow-1.3.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,4 +374,93 @@ struct ofp13_async_config {
};
OFP_ASSERT(sizeof(struct ofp13_async_config) == 24);

struct onf_flow_monitor_request {
ovs_be32 id; /* Controller-assigned ID for this monitor. */
ovs_be16 flags; /* ONFFMF_*. */
ovs_be16 match_len; /* Length of oxm_fields. */
ovs_be32 out_port; /* Required output port, if not OFPP_NONE. */
uint8_t table_id; /* One table's ID or 0xff for all tables. */
uint8_t zeros[3]; /* Align to 64 bits (must be zero). */
/* Followed by an ofp11_match structure. */
};
OFP_ASSERT(sizeof(struct onf_flow_monitor_request) == 16);

/* Header for experimenter requests and replies. */
struct onf_experimenter_header {
struct ofp_header header;
ovs_be32 vendor; /* ONF_EXPERIMENTER_ID. */
ovs_be32 subtype; /* One of ONFT_*. */
};
OFP_ASSERT(sizeof(struct onf_experimenter_header) == 16);

enum onf_flow_monitor_msg_type {
ONFT_FLOW_MONITOR_CANCEL = 1870,
ONFT_FLOW_MONITOR_PAUSED = 1871,
ONFT_FLOW_MONITOR_RESUMED = 1872
};

/* 'flags' bits in struct onf_flow_monitor_request. */
enum onf_flow_monitor_flags {
/* When to send updates. */
ONFFMF_INITIAL = 1 << 0, /* Initially matching flows. */
ONFFMF_ADD = 1 << 1, /* New matching flows as they are added. */
ONFFMF_DELETE = 1 << 2, /* Old matching flows as they are removed. */
ONFFMF_MODIFY = 1 << 3, /* Matching flows as they are changed. */

/* What to include in updates. */
ONFFMF_ACTIONS = 1 << 4, /* If set, actions are included. */
ONFFMF_OWN = 1 << 5, /* If set, include own changes in full. */
};

/* ONFST_FLOW_MONITOR reply header. */
struct onf_flow_update_header {
ovs_be16 length; /* Length of this entry. */
ovs_be16 event; /* One of ONFFME_*. */
/* ...other data depending on 'event'... */
};
OFP_ASSERT(sizeof(struct onf_flow_update_header) == 4);

/* 'event' values in struct onf_flow_update_header. */
enum onf_flow_update_event {
/* struct onf_flow_update_full. */
ONFFME_ADDED = 0, /* Flow was added. */
ONFFME_DELETED = 1, /* Flow was deleted. */
ONFFME_MODIFIED = 2, /* Flow (generally its actions) was changed. */

/* struct onf_flow_update_abbrev. */
ONFFME_ABBREV = 3, /* Abbreviated reply. */
};

/* ONFST_FLOW_MONITOR reply for ONFFME_ADDED, ONFFME_DELETED, and
* ONFFME_MODIFIED. */
struct onf_flow_update_full {
ovs_be16 length; /* Length is 24. */
ovs_be16 event; /* One of ONFFME_*. */
ovs_be16 reason; /* OFPRR_* for ONFFME_DELETED, else zero. */
ovs_be16 priority; /* Priority of the entry. */
ovs_be16 idle_timeout; /* Number of seconds idle before expiration. */
ovs_be16 hard_timeout; /* Number of seconds before expiration. */
ovs_be16 match_len; /* Length of oxm_fields. */
uint8_t table_id; /* ID of flow's table. */
uint8_t pad; /* Reserved, currently zeroed. */
ovs_be64 cookie; /* Opaque controller-issued identifier. */
/* Followed by:
* - Exactly match_len (possibly 0) bytes containing the oxm_fields, then
* - Exactly (match_len + 7)/8*8 - match_len (between 0 and 7) bytes of
* all-zero bytes, then
* - Instructions to fill out the remainder 'length' bytes (always a
* multiple of 8). If ONFFMF_ACTIONS was not specified, or 'event' is
* ONFFME_DELETED, no actions are included.
*/
};
OFP_ASSERT(sizeof(struct onf_flow_update_full) == 24);

/* ONFST_FLOW_MONITOR reply for ONFFME_ABBREV. */
struct onf_flow_update_abbrev {
ovs_be16 length; /* Length is 8. */
ovs_be16 event; /* ONFFME_ABBREV. */
ovs_be32 xid; /* Controller-specified xid from flow_mod. */
};
OFP_ASSERT(sizeof(struct onf_flow_update_abbrev) == 8);

#endif /* openflow/openflow-1.3.h */
93 changes: 83 additions & 10 deletions include/openflow/openflow-1.4.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,27 +358,100 @@ OFP_ASSERT(sizeof(struct ofp14_flow_monitor_request) == 16);

/* Flow monitor commands */
enum ofp14_flow_monitor_command {
OFPFMC14_ADD = 0, /* New flow monitor. */
OFPFMC14_MODIFY = 1, /* Modify existing flow monitor. */
OFPFMC14_DELETE = 2, /* Delete/cancel existing flow monitor. */
OFPFMC_ADD = 0, /* New flow monitor. */
OFPFMC_MODIFY = 1, /* Modify existing flow monitor. */
OFPFMC_DELETE = 2, /* Delete/cancel existing flow monitor. */
};

/* 'flags' bits in struct of_flow_monitor_request. */
enum ofp14_flow_monitor_flags {
/* When to send updates. */
/* Common to NX and OpenFlow 1.4 */
OFPFMF14_INITIAL = 1 << 0, /* Initially matching flows. */
OFPFMF14_ADD = 1 << 1, /* New matching flows as they are added. */
OFPFMF14_REMOVED = 1 << 2, /* Old matching flows as they are removed. */
OFPFMF14_MODIFY = 1 << 3, /* Matching flows as they are changed. */
OFPFMF_INITIAL = 1 << 0, /* Initially matching flows. */
OFPFMF_ADD = 1 << 1, /* New matching flows as they are added. */
OFPFMF_REMOVED = 1 << 2, /* Old matching flows as they are removed. */
OFPFMF_MODIFY = 1 << 3, /* Matching flows as they are changed. */

/* What to include in updates. */
/* Common to NX and OpenFlow 1.4 */
OFPFMF14_INSTRUCTIONS = 1 << 4, /* If set, instructions are included. */
OFPFMF14_NO_ABBREV = 1 << 5, /* If set, include own changes in full. */
OFPFMF_INSTRUCTIONS = 1 << 4, /* If set, instructions are included. */
OFPFMF_NO_ABBREV = 1 << 5, /* If set, include own changes in full. */
/* OpenFlow 1.4 */
OFPFMF14_ONLY_OWN = 1 << 6, /* If set, don't include other controllers.
OFPFMF_ONLY_OWN = 1 << 6, /* If set, don't include other controllers.
*/
};

/* OFPMP_FLOW_MONITOR reply header.
*
* The body of an OFPMP_FLOW_MONITOR reply is an array of variable-length
* structures, each of which begins with this header. The 'length' member may
* be used to traverse the array, and the 'event' member may be used to
* determine the particular structure.
* Every instance is a multiple of 8 bytes long. */
struct ofp_flow_update_header {
ovs_be16 length; /* Length of this entry. */
ovs_be16 event; /* One of OFPFME_*. */
/* ...other data depending on 'event'... */
};
OFP_ASSERT(sizeof(struct ofp_flow_update_header) == 4);

/* 'event' values in struct ofp_flow_update_header. */
enum ofp_flow_update_event {
/* struct ofp_flow_update_full. */
OFPFME_INITIAL = 0, /* Flow present when flow monitor created. */
OFPFME_ADDED = 1, /* Flow was added. */
OFPFME_REMOVED = 2, /* Flow was removed. */
OFPFME_MODIFIED = 3, /* Flow instructions were changed. */

/* struct ofp_flow_update_abbrev. */
OFPFME_ABBREV = 4, /* Abbreviated reply. */

/* struct ofp_flow_update_header. */
OFPFME_PAUSED = 5, /* Monitoring paused (out of buffer space). */
OFPFME_RESUMED = 6, /* Monitoring resumed. */
};

/* OFPMP_FLOW_MONITOR reply for OFPFME_INITIAL, OFPFME_ADDED, OFPFME_REMOVED,
* and OFPFME_MODIFIED. */
struct ofp_flow_update_full {
ovs_be16 length; /* Length is 32 + match + instructions. */
ovs_be16 event; /* One of OFPFME_*. */
uint8_t table_id; /* ID of flow's table. */
uint8_t reason; /* OFPRR_* for OFPFME_REMOVED, else zero. */
ovs_be16 idle_timeout; /* Number of seconds idle before expiration. */
ovs_be16 hard_timeout; /* Number of seconds before expiration. */
ovs_be16 priority; /* Priority of the entry. */
uint8_t zeros[4]; /* Reserved, currently zeroed. */
ovs_be64 cookie; /* Opaque controller-issued identifier. */
/* Instruction set.
* If OFPFMF_INSTRUCTIONS was not specified, or 'event' is
* OFPFME_REMOVED, no instructions are included.
*/
};
OFP_ASSERT(sizeof(struct ofp_flow_update_full) == 24);

/* OFPMP_FLOW_MONITOR reply for OFPFME_ABBREV.
*
* When the controller does not specify OFPFMF_NO_ABBREV in a monitor request,
* any flow tables changes due to the controller's own requests (on the same
* OpenFlow channel) will be abbreviated, when possible, to this form, which
* simply specifies the 'xid' of the OpenFlow request (e.g. an OFPT_FLOW_MOD)
* that caused the change.
* Some changes cannot be abbreviated and will be sent in full.
*/
struct ofp_flow_update_abbrev {
ovs_be16 length; /* Length is 8. */
ovs_be16 event; /* OFPFME_ABBREV. */
ovs_be32 xid; /* Controller-specified xid from flow_mod. */
};
OFP_ASSERT(sizeof(struct ofp_flow_update_abbrev) == 8);

/* OFPMP_FLOW_MONITOR reply for OFPFME_PAUSED and OFPFME_RESUMED.*/
struct ofp_flow_update_paused {
ovs_be16 length; /* Length is 8. */
ovs_be16 event; /* One of OFPFME_*. */
uint8_t zeros[4]; /* Reserved, currently zeroed. */
};
OFP_ASSERT(sizeof(struct ofp_flow_update_paused) == 8);

#endif /* openflow/openflow-1.4.h */
9 changes: 7 additions & 2 deletions include/openvswitch/ofp-monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ void ofputil_flow_removed_format(struct ds *,
/* Abstract nx_flow_monitor_request. */
struct ofputil_flow_monitor_request {
uint32_t id;
enum nx_flow_monitor_flags flags;
enum ofp14_flow_monitor_command command;
enum ofp14_flow_monitor_flags flags;
ofp_port_t out_port;
uint32_t out_group;
uint8_t table_id;
struct match match;
};
Expand All @@ -85,7 +87,7 @@ char *parse_flow_monitor_request(struct ofputil_flow_monitor_request *,

/* Abstract nx_flow_update. */
struct ofputil_flow_update {
enum nx_flow_update_event event;
enum ofp_flow_update_event event;

/* Used only for NXFME_ADDED, NXFME_DELETED, NXFME_MODIFIED. */
enum ofp_flow_removed_reason reason;
Expand Down Expand Up @@ -119,6 +121,9 @@ uint32_t ofputil_decode_flow_monitor_cancel(const struct ofp_header *);
struct ofpbuf *ofputil_encode_flow_monitor_cancel(
uint32_t id, enum ofputil_protocol protocol);

struct ofpbuf * ofputil_encode_flow_monitor_pause(
enum ofp_flow_update_event command, enum ofputil_protocol protocol);

struct ofputil_requestforward {
ovs_be32 xid;
/* Also used for OF 1.0-1.3 when using Nicira Extension: */
Expand Down
39 changes: 27 additions & 12 deletions include/openvswitch/ofp-msgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -453,14 +453,33 @@ enum ofpraw {

/* OFPST 1.4+ (16): uint8_t[8][]. */
OFPRAW_OFPST14_FLOW_MONITOR_REQUEST,
/* ONFST 1.3 (1870): uint8_t[8][]. */
OFPRAW_ONFST13_FLOW_MONITOR_REQUEST,
/* NXST 1.0-1.2 (2): uint8_t[8][]. */
OFPRAW_NXST_FLOW_MONITOR_REQUEST,

/* OFPST 1.4+ (16): uint8_t[8][]. */
OFPRAW_OFPST14_FLOW_MONITOR_REPLY,
/* ONFST 1.3 (1870): uint8_t[8][]. */
OFPRAW_ONFST13_FLOW_MONITOR_REPLY,
/* NXST 1.0-1.2 (2): uint8_t[8][]. */
OFPRAW_NXST_FLOW_MONITOR_REPLY,

/* ONFT 1.3 (1870): struct nx_flow_monitor_cancel. */
OFPRAW_ONFT13_FLOW_MONITOR_CANCEL,
/* NXT 1.0-1.2 (21): struct nx_flow_monitor_cancel. */
OFPRAW_NXT_FLOW_MONITOR_CANCEL,

/* ONFT 1.3 (1871): void. */
OFPRAW_ONFT13_FLOW_MONITOR_PAUSED,
/* NXT 1.0-1.2 (22): void. */
OFPRAW_NXT_FLOW_MONITOR_PAUSED,

/* ONFT 1.3 (1872): void. */
OFPRAW_ONFT13_FLOW_MONITOR_RESUMED,
/* NXT 1.0-1.2 (23): void. */
OFPRAW_NXT_FLOW_MONITOR_RESUMED,

/* Nicira extension messages.
*
* Nicira extensions that correspond to standard OpenFlow messages are listed
Expand All @@ -481,15 +500,6 @@ enum ofpraw {
/* NXT 1.0+ (20): struct nx_controller_id. */
OFPRAW_NXT_SET_CONTROLLER_ID,

/* NXT 1.0+ (21): struct nx_flow_monitor_cancel. */
OFPRAW_NXT_FLOW_MONITOR_CANCEL,

/* NXT 1.0+ (22): void. */
OFPRAW_NXT_FLOW_MONITOR_PAUSED,

/* NXT 1.0+ (23): void. */
OFPRAW_NXT_FLOW_MONITOR_RESUMED,

/* NXT 1.0+ (24): struct nx_tlv_table_mod, struct nx_tlv_map[]. */
OFPRAW_NXT_TLV_TABLE_MOD,

Expand Down Expand Up @@ -741,8 +751,10 @@ enum ofptype {
* OFPRAW_OFPST14_PORT_DESC_REPLY. */

OFPTYPE_FLOW_MONITOR_STATS_REQUEST, /* OFPRAW_OFPST14_FLOW_MONITOR_REQUEST.
* OFPRAW_ONFST13_FLOW_MONITOR_REQUEST.
* OFPRAW_NXST_FLOW_MONITOR_REQUEST. */
OFPTYPE_FLOW_MONITOR_STATS_REPLY, /* OFPRAW_OFPST14_FLOW_MONITOR_REPLY.
* OFPRAW_ONFST13_FLOW_MONITOR_REPLY.
* OFPRAW_NXST_FLOW_MONITOR_REPLY. */

/* Nicira extensions. */
Expand All @@ -762,9 +774,12 @@ enum ofptype {
OFPTYPE_CT_FLUSH_ZONE, /* OFPRAW_NXT_CT_FLUSH_ZONE. */

/* Flow monitor extension. */
OFPTYPE_FLOW_MONITOR_CANCEL, /* OFPRAW_NXT_FLOW_MONITOR_CANCEL. */
OFPTYPE_FLOW_MONITOR_PAUSED, /* OFPRAW_NXT_FLOW_MONITOR_PAUSED. */
OFPTYPE_FLOW_MONITOR_RESUMED, /* OFPRAW_NXT_FLOW_MONITOR_RESUMED. */
OFPTYPE_FLOW_MONITOR_CANCEL, /* OFPRAW_NXT_FLOW_MONITOR_CANCEL.
* OFPRAW_ONFT13_FLOW_MONITOR_CANCEL. */
OFPTYPE_FLOW_MONITOR_PAUSED, /* OFPRAW_NXT_FLOW_MONITOR_PAUSED.
* OFPRAW_ONFT13_FLOW_MONITOR_PAUSED. */
OFPTYPE_FLOW_MONITOR_RESUMED, /* OFPRAW_NXT_FLOW_MONITOR_RESUMED.
* OFPRAW_ONFT13_FLOW_MONITOR_RESUMED */
};

/* Decoding messages into OFPTYPE_* values. */
Expand Down
Loading

0 comments on commit c3e6404

Please sign in to comment.