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-26 14:04:12 +0100
commit5902e72d968db7e6f4b730adbd01483da0aa06f9 (patch)
treeca62339952df76251f4251b974ac13086f480aae
parent0b057727b410e626829bddb34f142dde96512174 (diff)
downloadopenvswitch-5902e72d968db7e6f4b730adbd01483da0aa06f9.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> Signed-off-by: Simon Horman <simon.horman@netronome.com>
-rw-r--r--lib/ofp-group.c8
-rw-r--r--tests/ofproto.at14
2 files changed, 19 insertions, 3 deletions
diff --git a/lib/ofp-group.c b/lib/ofp-group.c
index c9e95ad4c..6857164f0 100644
--- a/lib/ofp-group.c
+++ b/lib/ofp-group.c
@@ -1043,7 +1043,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;
}
@@ -1189,7 +1190,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) {
@@ -2251,7 +2252,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 1570a53fe..c5cebd9fe 100644
--- a/tests/ofproto.at
+++ b/tests/ofproto.at
@@ -678,6 +678,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