ofp-util: Issue error when OFPGC_DELETE command includes buckets.
authorBen Pfaff <blp@nicira.com>
Fri, 30 Jan 2015 22:20:52 +0000 (14:20 -0800)
committerBen Pfaff <blp@nicira.com>
Tue, 3 Feb 2015 23:25:10 +0000 (15:25 -0800)
An OFPGC_DELETE command deletes a whole group, including all of its
buckets, and so it doesn't make sense for the command itself to include any
specification of buckets.

ONF-JIRA: EXT-510
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/ofp-util.c

index bf55fb2..a503818 100644 (file)
@@ -7992,6 +7992,7 @@ ofputil_pull_ofp11_group_mod(struct ofpbuf *msg, enum ofp_version ofp_version,
                              struct ofputil_group_mod *gm)
 {
     const struct ofp11_group_mod *ogm;
+    enum ofperr error;
 
     ogm = ofpbuf_pull(msg, sizeof *ogm);
     gm->command = ntohs(ogm->command);
@@ -7999,8 +8000,18 @@ ofputil_pull_ofp11_group_mod(struct ofpbuf *msg, enum ofp_version ofp_version,
     gm->group_id = ntohl(ogm->group_id);
     gm->command_bucket_id = OFPG15_BUCKET_ALL;
 
-    return ofputil_pull_ofp11_buckets(msg, ofpbuf_size(msg), ofp_version,
-                                      &gm->buckets);
+    error = ofputil_pull_ofp11_buckets(msg, ofpbuf_size(msg), ofp_version,
+                                       &gm->buckets);
+
+    /* OF1.3.5+ prescribes an error when an OFPGC_DELETE includes buckets. */
+    if (!error
+        && ofp_version >= OFP13_VERSION
+        && gm->command == OFPGC11_DELETE
+        && !list_is_empty(&gm->buckets)) {
+        error = OFPERR_OFPGMFC_INVALID_GROUP;
+    }
+
+    return error;
 }
 
 static enum ofperr