2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 22:35:15 +00:00

ovs-ofctl: Add bundle support and unit testing.

All existing ovs-ofctl flow mod commands now take an optional
'--bundle' argument, which executes the flow mods as a single
transaction.  OpenFlow 1.4+ is implicitly assumed when '--bundle' is
specified.

ovs-ofctl 'add-flow' and 'add-flows' commands now accept flow
specifications that start with an optional 'add', 'modify', 'delete',
'modify_strict', or 'delete_strict' keyword, so that arbitrary flow
table modifications may be specified.  For backwards compatibility, a
missing keyword is treated as an 'add'.  With the new '--bundle'
option all the modifications are executed as a single transaction
using an OpenFlow 1.4 bundle.

OpenFlow 1.4 requires bundles to support at least flow and port mods.
This implementation does not yet support port mods in bundles.

Another restriction is that the atomic transactions are not yet
supported.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
Jarno Rajahalme
2015-06-05 14:03:12 -07:00
parent 4fcb208348
commit db5076eee4
14 changed files with 812 additions and 54 deletions

View File

@@ -258,6 +258,29 @@ parse_ofp_str__(struct ofputil_flow_mod *fm, int command, char *string,
*usable_protocols = OFPUTIL_P_ANY;
if (command == -2) {
size_t len;
string += strspn(string, " \t\r\n"); /* Skip white space. */
len = strcspn(string, ", \t\r\n"); /* Get length of the first token. */
if (!strncmp(string, "add", len)) {
command = OFPFC_ADD;
} else if (!strncmp(string, "delete", len)) {
command = OFPFC_DELETE;
} else if (!strncmp(string, "delete_strict", len)) {
command = OFPFC_DELETE_STRICT;
} else if (!strncmp(string, "modify", len)) {
command = OFPFC_MODIFY;
} else if (!strncmp(string, "modify_strict", len)) {
command = OFPFC_MODIFY_STRICT;
} else {
len = 0;
command = OFPFC_ADD;
}
string += len;
}
switch (command) {
case -1:
fields = F_OUT_PORT;
@@ -486,6 +509,10 @@ parse_ofp_str__(struct ofputil_flow_mod *fm, int command, char *string,
* constant for 'command'. To parse syntax for an OFPST_FLOW or
* OFPST_AGGREGATE (or NXST_FLOW or NXST_AGGREGATE), use -1 for 'command'.
*
* If 'command' is given as -2, 'str_' may begin with a command name ("add",
* "modify", "delete", "modify_strict", or "delete_strict"). A missing command
* name is treated as "add".
*
* Returns NULL if successful, otherwise a malloc()'d string describing the
* error. The caller is responsible for freeing the returned string. */
char * OVS_WARN_UNUSED_RESULT
@@ -818,14 +845,19 @@ parse_flow_monitor_request(struct ofputil_flow_monitor_request *fmr,
/* Parses 'string' as an OFPT_FLOW_MOD or NXT_FLOW_MOD with command 'command'
* (one of OFPFC_*) into 'fm'.
*
* If 'command' is given as -2, 'string' may begin with a command name ("add",
* "modify", "delete", "modify_strict", or "delete_strict"). A missing command
* name is treated as "add".
*
* Returns NULL if successful, otherwise a malloc()'d string describing the
* error. The caller is responsible for freeing the returned string. */
char * OVS_WARN_UNUSED_RESULT
parse_ofp_flow_mod_str(struct ofputil_flow_mod *fm, const char *string,
uint16_t command,
int command,
enum ofputil_protocol *usable_protocols)
{
char *error = parse_ofp_str(fm, command, string, usable_protocols);
if (!error) {
/* Normalize a copy of the match. This ensures that non-normalized
* flows get logged but doesn't affect what gets sent to the switch, so
@@ -883,10 +915,14 @@ parse_ofp_table_mod(struct ofputil_table_mod *tm, const char *table_id,
* type (one of OFPFC_*). Stores each flow_mod in '*fm', an array allocated
* on the caller's behalf, and the number of flow_mods in '*n_fms'.
*
* If 'command' is given as -2, each line may start with a command name
* ("add", "modify", "delete", "modify_strict", or "delete_strict"). A missing
* command name is treated as "add".
*
* Returns NULL if successful, otherwise a malloc()'d string describing the
* error. The caller is responsible for freeing the returned string. */
char * OVS_WARN_UNUSED_RESULT
parse_ofp_flow_mod_file(const char *file_name, uint16_t command,
parse_ofp_flow_mod_file(const char *file_name, int command,
struct ofputil_flow_mod **fms, size_t *n_fms,
enum ofputil_protocol *usable_protocols)
{