[ovs-dev] [PATCH v2] ofp-parse: Correctly parse actions= in group bucket

Thomas Graf tgraf at noironetworks.com
Tue Jun 24 18:29:30 UTC 2014


Make the parser compatible with how we print group buckets and allow
actions= to be specified, e.g.:

 group_id=1,type=all,bucket=actions=output:2,bucket=actions=output:3

Also, better document the supported syntax in the manual page and
cover both syntax formats in the unit test.

Signed-off-by: Thomas Graf <tgraf at noironetworks.com>
---
v2: Add unit test upon suggestion of Ben Pfaff <blp at nicira.com>

 lib/ofp-parse.c          | 6 ++++++
 tests/ofproto.at         | 3 ++-
 utilities/ovs-ofctl.8.in | 6 ++++--
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c
index 93bdbea..ff7b9ce 100644
--- a/lib/ofp-parse.c
+++ b/lib/ofp-parse.c
@@ -2121,6 +2121,12 @@ parse_bucket_str(struct ofputil_bucket *bucket, char *str_,
                 error = xasprintf("invalid watch_group id %"PRIu32,
                                   bucket->watch_group);
             }
+        } else if (!strcasecmp(act, "actions")) {
+            if (ofputil_parse_key_value(&arg, &act, &arg)) {
+                error = str_to_ofpact__(pos, act, arg, &ofpacts, n_actions,
+                                        usable_protocols);
+                n_actions++;
+            }
         } else {
             error = str_to_ofpact__(pos, act, arg, &ofpacts, n_actions,
                                     usable_protocols);
diff --git a/tests/ofproto.at b/tests/ofproto.at
index c6c090b..729ef7b 100644
--- a/tests/ofproto.at
+++ b/tests/ofproto.at
@@ -263,11 +263,12 @@ AT_CLEANUP
 
 dnl This is really bare-bones.
 dnl It at least checks request and reply serialization and deserialization.
+dnl Actions definition listed in both supported formats (w/ actions=)
 AT_SETUP([ofproto - del group])
 OVS_VSWITCHD_START
 AT_DATA([groups.txt], [dnl
 group_id=1234,type=all,bucket=output:10
-group_id=1235,type=all,bucket=output:10
+group_id=1235,type=all,bucket=actions=output:10
 ])
 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-groups br0 groups.txt])
 AT_CHECK([ovs-ofctl -F OXM-OpenFlow15 -O OpenFlow15 -vwarn dump-groups br0 1234], [0], [stdout])
diff --git a/utilities/ovs-ofctl.8.in b/utilities/ovs-ofctl.8.in
index 4ebaa18..61a0e0d 100644
--- a/utilities/ovs-ofctl.8.in
+++ b/utilities/ovs-ofctl.8.in
@@ -1899,11 +1899,13 @@ be specified.
 \fIbucket_parameters\fR consists of a list of \fIfield\fB=\fIvalue\fR
 assignments, separated by commas or white space followed by a
 comma-separated list of actions.
-The syntax of actions are same
-to \fBactions=\fR field described in \fBFlow Syntax\fR above.
 The fields for \fIbucket_parameters\fR are:
 .
 .RS
+.IP \fBactions=\fR[\fIaction\fR][\fB,\fIaction\fR...]\fR
+The syntax of actions are identical to the \fBactions=\fR field described in
+\fBFlow Syntax\fR above. Specyfing \fBactions=\fR is optional, any unknown
+bucket parameter will be interpreted as an action.
 .IP \fBweight=\fIvalue\fR
 The relative weight of the bucket as an integer. This may be used by the switch
 during bucket select for groups whose \fBtype\fR is \fBselect\fR.
-- 
1.9.3




More information about the dev mailing list