ofp-util: Ignore invalid bitmaps in ofputil_decode_hello_bitmap().
authorBen Pfaff <blp@nicira.com>
Fri, 9 Nov 2012 17:57:57 +0000 (09:57 -0800)
committerBen Pfaff <blp@nicira.com>
Fri, 9 Nov 2012 18:01:42 +0000 (10:01 -0800)
This code has, until now, parsed and accepted invalid bitmaps.  It seems
better to simply ignore them, leaving the original set of allowed versions
from the version field in the ofp_header.

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

index 5703f8cc03cbf465514ca9d7427f6712d56a4a69..14ac7c13d1ad5076afaf911c611459b6895f2935 100644 (file)
@@ -1080,10 +1080,11 @@ ofputil_format_version_bitmap_names(struct ds *msg, uint32_t bitmap)
 
 static bool
 ofputil_decode_hello_bitmap(const struct ofp_hello_elem_header *oheh,
-                            uint32_t *allowed_versions)
+                            uint32_t *allowed_versionsp)
 {
     uint16_t bitmap_len = ntohs(oheh->length) - sizeof *oheh;
     const ovs_be32 *bitmap = (const ovs_be32 *) (oheh + 1);
+    uint32_t allowed_versions;
 
     if (!bitmap_len || bitmap_len % sizeof *bitmap) {
         return false;
@@ -1094,21 +1095,22 @@ ofputil_decode_hello_bitmap(const struct ofp_hello_elem_header *oheh,
      * should have no effect on session negotiation until Open vSwtich supports
      * wire-protocol versions greater than 31.
      */
-    *allowed_versions = ntohl(bitmap[0]);
+    allowed_versions = ntohl(bitmap[0]);
 
-    if (*allowed_versions & 1) {
+    if (allowed_versions & 1) {
         /* There's no OpenFlow version 0. */
         VLOG_WARN_RL(&bad_ofmsg_rl, "peer claims to support invalid OpenFlow "
                      "version 0x00");
-        *allowed_versions &= ~1u;
+        allowed_versions &= ~1u;
     }
 
-    if (!*allowed_versions) {
+    if (!allowed_versions) {
         VLOG_WARN_RL(&bad_ofmsg_rl, "peer does not support any OpenFlow "
                      "version (between 0x01 and 0x1f)");
         return false;
     }
 
+    *allowed_versionsp = allowed_versions;
     return true;
 }