From patchwork Wed Mar 15 23:31:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarno Rajahalme X-Patchwork-Id: 739490 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 3vk7S85mFkz9s03 for ; Thu, 16 Mar 2017 10:42:16 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 9EC09C4D; Wed, 15 Mar 2017 23:32:45 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp2.linuxfoundation.org (smtp2.linux-foundation.org [172.17.192.36]) by mail.linuxfoundation.org (Postfix) with ESMTPS id DC8D4C13 for ; Wed, 15 Mar 2017 23:32:42 +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 smtp2.linuxfoundation.org (Postfix) with ESMTPS id 6D7481DAA8 for ; Wed, 15 Mar 2017 23:32:42 +0000 (UTC) Received: from mfilter10-d.gandi.net (mfilter10-d.gandi.net [217.70.178.139]) by relay3-d.mail.gandi.net (Postfix) with ESMTP id 1693DA80C6; Thu, 16 Mar 2017 00:32:41 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter10-d.gandi.net Received: from relay3-d.mail.gandi.net ([IPv6:::ffff:217.70.183.195]) by mfilter10-d.gandi.net (mfilter10-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id mWUaVONgP7fi; Thu, 16 Mar 2017 00:32:39 +0100 (CET) X-Originating-IP: 208.91.1.34 Received: from sc9-mailhost1.vmware.com (unknown [208.91.1.34]) (Authenticated sender: jarno@ovn.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 56643A80BE; Thu, 16 Mar 2017 00:32:38 +0100 (CET) From: Jarno Rajahalme To: dev@openvswitch.org Date: Wed, 15 Mar 2017 16:31:27 -0700 Message-Id: <1489620689-122370-24-git-send-email-jarno@ovn.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1489620689-122370-1-git-send-email-jarno@ovn.org> References: <1489620689-122370-1-git-send-email-jarno@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 smtp2.linux-foundation.org Subject: [ovs-dev] [PATCH branch-2.7 23/25] 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. Therefore, change oxm_decode_loose() to oxm_decode() that takes an extra argument to indicate whether we want strict or loose match. Fixes: 7befb20d0f70 ("ofp-util: Ignore unknown fields in ofputil_decode_packet_in2()") Signed-off-by: Yi-Hung Wei Signed-off-by: Joe Stringer Signed-off-by: Jarno Rajahalme --- lib/nx-match.c | 10 +++++----- lib/nx-match.h | 4 ++-- lib/ofp-util.c | 5 ++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/nx-match.c b/lib/nx-match.c index 2e62e99..43672cb 100644 --- a/lib/nx-match.c +++ b/lib/nx-match.c @@ -683,14 +683,14 @@ oxm_pull_match_loose(struct ofpbuf *b, const struct tun_table *tun_table, * * Returns 0 if successful, otherwise an OpenFlow error code. * - * Encountering unknown OXM headers or missing field prerequisites are not - * considered as error conditions. + * If 'loose' is true, encountering unknown OXM headers or missing field + * prerequisites are not considered as error conditions. */ enum ofperr -oxm_decode_match_loose(const void *oxm, size_t oxm_len, - const struct tun_table *tun_table, struct match *match) +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, false, 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 cee9e65..e103dd5 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_loose(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 9e8d4d2..d315337 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -3397,9 +3397,8 @@ decode_nx_packet_in2(const struct ofp_header *oh, bool loose, } case NXPINT_METADATA: - error = oxm_decode_match_loose(payload.msg, - ofpbuf_msgsize(&payload), - tun_table, &pin->flow_metadata); + error = oxm_decode_match(payload.msg, ofpbuf_msgsize(&payload), + loose, tun_table, &pin->flow_metadata); break; case NXPINT_USERDATA: