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.

v1-->v2:
1. fix warning from 0-day robot.

Signed-off-by: solomon <[email protected]>
---
 lib/ofp-group.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/lib/ofp-group.c b/lib/ofp-group.c
index c9e95ad4c..6ba15fd82 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;
         }
@@ -1176,7 +1177,8 @@ ofputil_put_ofp11_bucket(const struct ofputil_bucket 
*bucket,
 static void
 ofputil_put_ofp15_bucket(const struct ofputil_bucket *bucket,
                          uint32_t bucket_id, enum ofp11_group_type group_type,
-                         struct ofpbuf *openflow, enum ofp_version ofp_version)
+                         struct ofpbuf *openflow, enum ofp_version ofp_version,
+                         int group_command)
 {
     struct ofp15_bucket *ob;
     size_t start, actions_start, actions_len;
@@ -1188,8 +1190,8 @@ ofputil_put_ofp15_bucket(const struct ofputil_bucket 
*bucket,
     ofpacts_put_openflow_actions(bucket->ofpacts, bucket->ofpacts_len,
                                  openflow, ofp_version);
     actions_len = openflow->size - actions_start;
-
-    if (group_type == OFPGT11_SELECT) {
+    if (group_type == OFPGT11_SELECT 
+        || group_command == OFPGC15_INSERT_BUCKET) {
         ofpprop_put_u16(openflow, OFPGBPT15_WEIGHT, bucket->weight);
     }
     if (bucket->watch_port != OFPP_ANY) {
@@ -1266,7 +1268,7 @@ ofputil_append_ofp15_group_desc_reply(const struct 
ofputil_group_desc *gds,
     start_buckets = reply->size;
     LIST_FOR_EACH (bucket, list_node, buckets) {
         ofputil_put_ofp15_bucket(bucket, bucket->bucket_id,
-                                 gds->type, reply, version);
+                                 gds->type, reply, version, -1);
     }
     ogds = ofpbuf_at_assert(reply, start_ogds, sizeof *ogds);
     ogds->type = gds->type;
@@ -2066,7 +2068,8 @@ ofputil_encode_ofp15_group_mod(enum ofp_version 
ofp_version,
             bucket_id = bucket->bucket_id;
         }
 
-        ofputil_put_ofp15_bucket(bucket, bucket_id, gm->type, b, ofp_version);
+        ofputil_put_ofp15_bucket(bucket, bucket_id, gm->type, b, ofp_version,
+                                 gm->command);
     }
     ogm = ofpbuf_at_assert(b, start_ogm, sizeof *ogm);
     ogm->command = htons(gm->command != OFPGC11_ADD_OR_MOD || group_existed < 0
@@ -2251,7 +2254,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;
         }
 
-- 
2.17.2 (Apple Git-113)

-- 

Thanks
Solomon
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to