From: Ben Pfaff Date: Fri, 9 Nov 2012 17:57:57 +0000 (-0800) Subject: ofp-util: Ignore invalid bitmaps in ofputil_decode_hello_bitmap(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0935de410ce518f6abe60c8bce35f67171e3059a;p=openvswitch ofp-util: Ignore invalid bitmaps in ofputil_decode_hello_bitmap(). 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 --- diff --git a/lib/ofp-util.c b/lib/ofp-util.c index 5703f8cc..14ac7c13 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -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; }