From patchwork Wed Mar 15 23:01:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 739462 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vk6Z91K2Rz9rxl for ; Thu, 16 Mar 2017 10:02:25 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4952B9FA; Wed, 15 Mar 2017 23:01:55 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 52565941 for ; Wed, 15 Mar 2017 23:01:54 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id C1223A1 for ; Wed, 15 Mar 2017 23:01:53 +0000 (UTC) Received: from mfilter24-d.gandi.net (mfilter24-d.gandi.net [217.70.178.152]) by relay3-d.mail.gandi.net (Postfix) with ESMTP id 9433EA80C2; Thu, 16 Mar 2017 00:01:52 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter24-d.gandi.net Received: from relay3-d.mail.gandi.net ([IPv6:::ffff:217.70.183.195]) by mfilter24-d.gandi.net (mfilter24-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id G84h6l6W4Py3; Thu, 16 Mar 2017 00:01:51 +0100 (CET) X-Originating-IP: 208.91.1.34 Received: from carno.eng.vmware.com (unknown [208.91.1.34]) (Authenticated sender: joe@ovn.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 85D73A80C6; Thu, 16 Mar 2017 00:01:49 +0100 (CET) From: Joe Stringer To: dev@openvswitch.org Date: Wed, 15 Mar 2017 16:01:38 -0700 Message-Id: <20170315230141.32414-2-joe@ovn.org> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170315230141.32414-1-joe@ovn.org> References: <20170315230141.32414-1-joe@ovn.org> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [branch-2.7 1/4] nx-match: Fix oxm decode. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Yi-Hung Wei decode_nx_packet_in2() may be used by the switch to parse NXT_RESUME messages, where we need exact match on the oxm header. It's also used by OVN to parse NXT_PACKET_IN2 messages. For the switch, strict prerequisites should be applied but for the controller, this should not be the case. Pass the 'loose' parameter down to oxm_decode() to apply these restrictions correctly based on which code is performing decode. Signed-off-by: Yi-Hung Wei Signed-off-by: Joe Stringer --- lib/nx-match.c | 8 +++++--- lib/nx-match.h | 4 ++-- lib/ofp-util.c | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/nx-match.c b/lib/nx-match.c index 91401e2201c6..c258869eec80 100644 --- a/lib/nx-match.c +++ b/lib/nx-match.c @@ -678,12 +678,14 @@ oxm_pull_match_loose(struct ofpbuf *b, const struct tun_table *tun_table, * * Fails with an error when encountering unknown OXM headers. * - * Returns 0 if successful, otherwise an OpenFlow error code. */ + * If 'loose' is true, encountering unknown OXM headers or missing field + * prerequisites are not considered as error conditions. + */ enum ofperr -oxm_decode_match(const void *oxm, size_t oxm_len, +oxm_decode_match(const void *oxm, size_t oxm_len, bool loose, const struct tun_table *tun_table, struct match *match) { - return nx_pull_raw(oxm, oxm_len, true, match, NULL, NULL, tun_table); + return nx_pull_raw(oxm, oxm_len, !loose, match, NULL, NULL, tun_table); } /* Verify an array of OXM TLVs treating value of each TLV as a mask, diff --git a/lib/nx-match.h b/lib/nx-match.h index 5dca24a01a49..e103dd5fa74d 100644 --- a/lib/nx-match.h +++ b/lib/nx-match.h @@ -61,8 +61,8 @@ enum ofperr oxm_pull_match(struct ofpbuf *, const struct tun_table *, struct match *); enum ofperr oxm_pull_match_loose(struct ofpbuf *, const struct tun_table *, struct match *); -enum ofperr oxm_decode_match(const void *, size_t, const struct tun_table *, - struct match *); +enum ofperr oxm_decode_match(const void *, size_t, bool, + const struct tun_table *, struct match *); enum ofperr oxm_pull_field_array(const void *, size_t fields_len, struct field_array *); diff --git a/lib/ofp-util.c b/lib/ofp-util.c index 0c9343ec400b..d3153370f2e6 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -3398,7 +3398,7 @@ decode_nx_packet_in2(const struct ofp_header *oh, bool loose, case NXPINT_METADATA: error = oxm_decode_match(payload.msg, ofpbuf_msgsize(&payload), - tun_table, &pin->flow_metadata); + loose, tun_table, &pin->flow_metadata); break; case NXPINT_USERDATA: