summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsolomon <liwei.solomon@gmail.com>2019-01-06 17:17:34 +0800
committerSimon Horman <simon.horman@netronome.com>2019-03-27 09:45:48 +0100
commit6d3fd2ed72d0ba02374027276e192d1ab86c162e (patch)
tree65d59f6aab1d5f0a38b61eb4c77eae3877727672
parent030cad7989ed1640216145ddaae66f44c2e63ff6 (diff)
downloadopenvswitch-6d3fd2ed72d0ba02374027276e192d1ab86c162e.tar.gz
ofp-group: support to insert bucket with weight value for select type
After creating a group with hash select type,then we need to insert a new bucket with weight, But,it fails. Commands are as following: # ovs-ofctl -O OpenFlow15 add-group br0 "group_id=10, type=select, selection_method=hash,fields=tcp_src, bucket=bucket_id=10,weight:99,actions=output:1, bucket=bucket_id=20,weight:199,actions=output:1 " # ovs-ofctl -O OpenFlow15 insert-buckets br0 "group_id=10,type=select command_bucket_id=last,bucket=bucket_id=3,weight=100,actions=output:1" ovs-ofctl: type is not needed # ovs-ofctl -O OpenFlow15 insert-buckets br0 "group_id=10 command_bucket_id=last,bucket=bucket_id=3,weight=100,actions=output:1" ovs-ofctl: Only select groups can have bucket weights. This patch can help us. However, for other types that are not select, the check of the parameters is not strict, but it does not affect their function, because other types do not use this weight parameter. Signed-off-by: solomon <liwei.solomon@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org> [simon: rebased] Signed-off-by: Simon Horman <simon.horman@netronome.com>
-rw-r--r--lib/ofp-parse.c3
-rw-r--r--lib/ofp-util.c5
-rw-r--r--tests/ofproto.at14
3 files changed, 19 insertions, 3 deletions
diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c
index 448fa03ca..02e0ef7a7 100644
--- a/lib/ofp-parse.c
+++ b/lib/ofp-parse.c
@@ -1769,7 +1769,8 @@ parse_ofp_group_mod_str__(struct ofputil_group_mod *gm, int command,
}
ovs_list_push_back(&gm->buckets, &bucket->list_node);
- if (gm->type != OFPGT11_SELECT && bucket->weight) {
+ if (gm->command != OFPGC15_INSERT_BUCKET
+ && gm->type != OFPGT11_SELECT && bucket->weight) {
error = xstrdup("Only select groups can have bucket weights.");
goto out;
}
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index b96123058..786b9b9c8 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -8581,7 +8581,7 @@ ofputil_put_ofp15_bucket(const struct ofputil_bucket *bucket,
openflow, ofp_version);
actions_len = openflow->size - actions_start;
- if (group_type == OFPGT11_SELECT) {
+ if (group_type == OFPGT11_SELECT || bucket->weight) {
ofpprop_put_u16(openflow, OFPGBPT15_WEIGHT, bucket->weight);
}
if (bucket->watch_port != OFPP_ANY) {
@@ -9481,7 +9481,8 @@ ofputil_check_group_mod(const struct ofputil_group_mod *gm)
struct ofputil_bucket *bucket;
LIST_FOR_EACH (bucket, list_node, &gm->buckets) {
- if (bucket->weight && gm->type != OFPGT11_SELECT) {
+ if (bucket->weight && gm->type != OFPGT11_SELECT
+ && gm->command != OFPGC15_INSERT_BUCKET) {
return OFPERR_OFPGMFC_INVALID_GROUP;
}
diff --git a/tests/ofproto.at b/tests/ofproto.at
index 1324d6d97..6ac5a70a7 100644
--- a/tests/ofproto.at
+++ b/tests/ofproto.at
@@ -619,6 +619,20 @@ AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn insert-buckets br0 group_id=1234,comman
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')
])
+
+# Verify insert-buckets command to insert bucket with weight value for select group.
+AT_CHECK([ovs-ofctl -O OpenFlow15 --strict del-groups br0 group_id=1234])
+AT_DATA([groups.txt], [dnl
+group_id=1234,type=select,selection_method=hash,bucket=bucket_id=1,weight:100,output:11
+])
+AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn add-groups br0 groups.txt])
+AT_CHECK([ovs-ofctl -O OpenFlow15 insert-buckets br0 group_id=1234,command_bucket_id=last,bucket=bucket_id=2,weight=100,actions=output:11])
+AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])
+AT_CHECK([strip_xids < stdout], [0], [dnl
+OFPST_GROUP_DESC reply (OF1.5):
+ group_id=1234,type=select,selection_method=hash,bucket=bucket_id:1,weight:100,actions=output:11,bucket=bucket_id:2,weight:100,actions=output:11
+])
+
OVS_VSWITCHD_STOP
AT_CLEANUP