From patchwork Fri Oct 16 10:50:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 531215 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (li376-54.members.linode.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 1414E1402BF for ; Fri, 16 Oct 2015 21:52:33 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 2E76810C8F; Fri, 16 Oct 2015 03:52:32 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e4.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id C5F9F10C8E for ; Fri, 16 Oct 2015 03:52:30 -0700 (PDT) Received: from bar5.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id 080D11E011C for ; Fri, 16 Oct 2015 04:52:30 -0600 (MDT) X-ASG-Debug-ID: 1444992749-09eadd080e35380001-byXFYA Received: from mx1-pf1.cudamail.com ([192.168.24.1]) by bar5.cudamail.com with ESMTP id 1p4JzaQgpLIpIp1Z (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 16 Oct 2015 04:52:29 -0600 (MDT) X-Barracuda-Envelope-From: simon.horman@netronome.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.1 Received: from unknown (HELO mail-pa0-f46.google.com) (209.85.220.46) by mx1-pf1.cudamail.com with ESMTPS (RC4-SHA encrypted); 16 Oct 2015 10:52:28 -0000 Received-SPF: none (mx1-pf1.cudamail.com: domain at netronome.com does not designate permitted sender hosts) X-Barracuda-Apparent-Source-IP: 209.85.220.46 X-Barracuda-RBL-IP: 209.85.220.46 Received: by pabrc13 with SMTP id rc13so117920834pab.0 for ; Fri, 16 Oct 2015 03:52:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LbAp8cUEJMAPhgu80l5bx89ttrqPUnHdiKZG/tmA9j4=; b=ji8Kogl+J4375OwpVDVOiAzWtQULw7dnSieIuk8xdPgD9NmP4MKysOzwgZtnNfeUSC ZOMEB/LiNhFukl3Ezgqw/gCePrUp2dloSCVFDOtPO4iSoSDwypQt87OF3iWO5nXUxC89 a7rsgumRz3hgzNUU3jKAY/r5XczDsS+sPbCEKbDb1bgx4RKxh0WkmsKp/p6eKDs/JNL0 zA8BKgThtAkr1Jde59IczhpfFRzBZJrzfoCBv0d5HIJiXHH9WptRFHjYg+fe1Sc6HU3C +E9lY8DVoEfr1K7/wuusfJF2baklKxcqWmEMVD1u+1ipY6/ktXHpICVR37Eg6cshonEN CG+g== X-Gm-Message-State: ALoCoQkfTb8Vc0AEuZl7ZJYU1loewPFRFpSHEdoFnle+qp9+OOmjezsJXMCSVs+2Q5HTI+o9jvEm X-Received: by 10.68.57.129 with SMTP id i1mr15589327pbq.51.1444992748076; Fri, 16 Oct 2015 03:52:28 -0700 (PDT) Received: from penelope.isobedori.kobe.vergenet.net (g1-27-253-251-7.bmobile.ne.jp. [27.253.251.7]) by smtp.gmail.com with ESMTPSA id bo5sm20525555pbb.76.2015.10.16.03.52.18 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Oct 2015 03:52:26 -0700 (PDT) X-CudaMail-Envelope-Sender: simon.horman@netronome.com From: Simon Horman To: dev@openvswitch.org X-CudaMail-MID: CM-E1-1015008826 X-CudaMail-DTE: 101615 X-CudaMail-Originating-IP: 209.85.220.46 Date: Fri, 16 Oct 2015 19:50:47 +0900 X-ASG-Orig-Subj: [##CM-E1-1015008826##][PATCH 1/2] ofproto: correct encoding and decoding of group desc properties Message-Id: <1444992648-27107-2-git-send-email-simon.horman@netronome.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1444992648-27107-1-git-send-email-simon.horman@netronome.com> References: <1444992648-27107-1-git-send-email-simon.horman@netronome.com> X-GBUdb-Analysis: 0, 209.85.220.46, Ugly c=0.495056 p=-0.622951 Source Normal X-MessageSniffer-Rules: 0-0-0-10673-c X-Barracuda-Connect: UNKNOWN[192.168.24.1] X-Barracuda-Start-Time: 1444992749 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.60 X-Barracuda-Spam-Status: No, SCORE=0.60 using per-user scores of TAG_LEVEL=3.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=3.0 tests=BSF_SC5_MJ1963, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.23542 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 Cc: Simon Horman Subject: [ovs-dev] [PATCH 1/2] ofproto: correct encoding and decoding of group desc properties X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" * encode: if properties are present include their length in value of the length field of the group desc * decode: use the value of the length field to calculate the length of properties rather than assuming that the rest of the message is properties. This assumption is not correct as a message may contain multiple group descs. Fixes: 18ac06d3546e ("ofp-util: Encoding and decoding of (draft) OpenFlow 1.5 group messages.") Signed-off-by: Simon Horman --- lib/ofp-util.c | 4 ++-- tests/ofp-print.at | 2 +- tests/ofproto.at | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/ofp-util.c b/lib/ofp-util.c index 97b5449f62fb..342be5409ece 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -7783,7 +7783,6 @@ ofputil_append_ofp15_group_desc_reply(const struct ofputil_group_desc *gds, gds->type, reply, version); } ogds = ofpbuf_at_assert(reply, start_ogds, sizeof *ogds); - ogds->length = htons(reply->size - start_ogds); ogds->type = gds->type; ogds->group_id = htonl(gds->group_id); ogds->bucket_list_len = htons(reply->size - start_buckets); @@ -7793,6 +7792,7 @@ ofputil_append_ofp15_group_desc_reply(const struct ofputil_group_desc *gds, ofputil_put_group_prop_ntr_selection_method(version, &gds->props, reply); } + ogds->length = htons(reply->size - start_ogds); ofpmp_postappend(replies, start_ogds); } @@ -8338,7 +8338,7 @@ ofputil_decode_ofp15_group_desc_reply(struct ofputil_group_desc *gd, * claim that the group mod command is OFPGC15_ADD to * satisfy the check in parse_group_prop_ntr_selection_method() */ return parse_ofp15_group_properties(msg, gd->type, OFPGC15_ADD, &gd->props, - msg->size); + length - sizeof *ogds - bucket_list_len); } /* Converts a group description reply in 'msg' into an abstract diff --git a/tests/ofp-print.at b/tests/ofp-print.at index 8cdceade0244..25cf950c685b 100644 --- a/tests/ofp-print.at +++ b/tests/ofp-print.at @@ -2026,7 +2026,7 @@ AT_SETUP([OFPST_GROUP_DESC reply - OF1.5]) AT_KEYWORDS([ofp-print OFPT_STATS_REPLY]) AT_CHECK([ovs-ofctl ofp-print "\ 06 13 00 d8 00 00 00 02 00 07 00 00 00 00 00 00 \ -00 88 01 00 00 00 20 00 00 78 00 00 00 00 00 00 \ +00 c8 01 00 00 00 20 00 00 78 00 00 00 00 00 00 \ 00 28 00 10 00 00 00 00 00 00 00 10 00 00 00 01 \ 00 00 00 00 00 00 00 00 00 00 00 08 00 64 00 00 \ 00 01 00 08 00 00 00 01 \ diff --git a/tests/ofproto.at b/tests/ofproto.at index 5e4441c7e1d7..8699c4a29ed9 100644 --- a/tests/ofproto.at +++ b/tests/ofproto.at @@ -343,6 +343,7 @@ dnl Actions definition listed in both supported formats (w/ actions=) AT_SETUP([ofproto - del group (OpenFlow 1.5)]) OVS_VSWITCHD_START AT_DATA([groups.txt], [dnl +group_id=1233,type=select,selection_method=hash,bucket=output:10,bucket=output:11 group_id=1234,type=select,selection_method=hash,bucket=output:10,bucket=output:11 group_id=1235,type=all,bucket=actions=output:12,bucket=bucket_id:0,actions=output:10,bucket=bucket_id:1,actions=output:11 ]) @@ -357,12 +358,14 @@ AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout]) AT_CHECK([STRIP_XIDS stdout], [0], [dnl OFPST_GROUP_DESC reply (OF1.5): group_id=1235,type=all,bucket=bucket_id:2,actions=output:12,bucket=bucket_id:0,actions=output:10,bucket=bucket_id:1,actions=output:11 + group_id=1233,type=select,selection_method=hash,bucket=bucket_id:0,actions=output:10,bucket=bucket_id:1,actions=output:11 ]) AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn del-groups br0 group_id=1234]) AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout]) AT_CHECK([STRIP_XIDS stdout], [0], [dnl OFPST_GROUP_DESC reply (OF1.5): group_id=1235,type=all,bucket=bucket_id:2,actions=output:12,bucket=bucket_id:0,actions=output:10,bucket=bucket_id:1,actions=output:11 + group_id=1233,type=select,selection_method=hash,bucket=bucket_id:0,actions=output:10,bucket=bucket_id:1,actions=output:11 ]) AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn del-groups br0], [0]) AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])