diff mbox series

[ovs-dev] ovs:group: support to insert bucket with weight value for select type

Message ID 4f04d061-199e-185a-9c92-63532946050c@gmail.com
State Superseded
Headers show
Series [ovs-dev] ovs:group: support to insert bucket with weight value for select type | expand

Commit Message

solomon Nov. 22, 2018, 9:43 a.m. UTC
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: LiWei <liwei.solomon@gmail.com>
---
 lib/ofp-group.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

Comments

0-day Robot Nov. 22, 2018, 9:56 a.m. UTC | #1
Bleep bloop.  Greetings solomon, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


checkpatch:
ERROR: Author solomon <liwei.solomon@gmail.com> needs to sign off.
WARNING: Unexpected sign-offs from developers who are not authors or co-authors or committers: LiWei <liwei.solomon@gmail.com>
WARNING: Line is 99 characters long (recommended limit is 79)
#34 FILE: lib/ofp-group.c:1046:
        if (gm->command != OFPGC15_INSERT_BUCKET && gm->type != OFPGT11_SELECT && bucket->weight) {

WARNING: Line is 81 characters long (recommended limit is 79)
#54 FILE: lib/ofp-group.c:1193:
    if (group_type == OFPGT11_SELECT || group_command == OFPGC15_INSERT_BUCKET) {

WARNING: Line is 91 characters long (recommended limit is 79)
#72 FILE: lib/ofp-group.c:2069:
        ofputil_put_ofp15_bucket(bucket, bucket_id, gm->type, b, ofp_version, gm->command);

Lines checked: 89, Warnings: 4, Errors: 1


Please check this out.  If you feel there has been an error, please email aconole@bytheb.org

Thanks,
0-day Robot
diff mbox series

Patch

diff --git a/lib/ofp-group.c b/lib/ofp-group.c
index c9e95ad4c..a4677310a 100644
--- a/lib/ofp-group.c
+++ b/lib/ofp-group.c
@@ -1043,7 +1043,7 @@  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 +1176,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 +1189,7 @@  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 +1266,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 +2066,7 @@  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 +2251,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;
         }