Skip to content

Commit

Permalink
ofp-util: Add missing 'break;' in bad_group_cmd().
Browse files Browse the repository at this point in the history
Otherwise you get an assertion failure in place of a helpful error message.

Also fix typo where the "remove-bucket" command was output as
"insert-bucket".

Also fix a nearby style violation and add a pair of tests to prevent
regression.

Found by LLVM scan-build.

Reported-by: Kevin Lo <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
Acked-by: Andy Zhou <[email protected]>
  • Loading branch information
blp committed Apr 22, 2015
1 parent 966904d commit 9dd30b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/ofp-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -8170,7 +8170,8 @@ ofputil_encode_ofp15_group_mod(enum ofp_version ofp_version,
}

static void
bad_group_cmd(enum ofp15_group_mod_command cmd) {
bad_group_cmd(enum ofp15_group_mod_command cmd)
{
const char *opt_version;
const char *version;
const char *cmd_str;
Expand All @@ -8187,6 +8188,7 @@ bad_group_cmd(enum ofp15_group_mod_command cmd) {
case OFPGC15_REMOVE_BUCKET:
version = "1.5";
opt_version = "15";
break;

default:
OVS_NOT_REACHED();
Expand All @@ -8210,7 +8212,7 @@ bad_group_cmd(enum ofp15_group_mod_command cmd) {
break;

case OFPGC15_REMOVE_BUCKET:
cmd_str = "insert-bucket";
cmd_str = "remove-bucket";
break;

default:
Expand Down
9 changes: 8 additions & 1 deletion tests/ofproto.at
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,13 @@ OFPST_GROUP_DESC reply (OF1.5):
group_id=1234,type=all,bucket=bucket_id:0,actions=output:0,bucket=bucket_id:1,actions=output:1,bucket=bucket_id:10,actions=output:10,bucket=bucket_id:11,actions=output:11,bucket=bucket_id:12,actions=output:12,bucket=bucket_id:13,actions=output:13,bucket=bucket_id:14,actions=output:14,bucket=bucket_id:15,actions=output:15,bucket=bucket_id:20,actions=output:20,bucket=bucket_id:21,actions=output:21
])

# Negative test.
# Negative tests.
AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn insert-buckets br0 group_id=1234,command_bucket_id=0xffffff01,bucket=bucket_id:0,actions=output:0,bucket=bucket_id:1,actions=output:1], [1], [],
[ovs-ofctl: invalid command bucket id 4294967041
])
AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn insert-buckets br0 group_id=1234,command_bucket_id=first,bucket=bucket_id:0,actions=output:0,bucket=bucket_id:1,actions=output:1], [1], [],
[ovs-ofctl: insert-bucket needs OpenFlow 1.5 or later ('-O OpenFlow15')
])
OVS_VSWITCHD_STOP
AT_CLEANUP

Expand Down Expand Up @@ -512,6 +515,10 @@ OFPT_ERROR (OF1.5): OFPGMFC_UNKNOWN_BUCKET
OFPT_GROUP_MOD (OF1.5):
REMOVE_BUCKET command_bucket_id:1,group_id=1234
])
# Negative test.
AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn remove-buckets br0 group_id=1234,command_bucket_id=last], [1], [],
[ovs-ofctl: remove-bucket needs OpenFlow 1.5 or later ('-O OpenFlow15')
])
OVS_VSWITCHD_STOP
AT_CLEANUP

Expand Down

0 comments on commit 9dd30b0

Please sign in to comment.