From patchwork Wed Mar 15 23:31:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarno Rajahalme X-Patchwork-Id: 739489 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 3vk7Rh6k8Lz9ryk for ; Thu, 16 Mar 2017 10:41:52 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id BD252C49; Wed, 15 Mar 2017 23:32:44 +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 7761BC3F for ; Wed, 15 Mar 2017 23:32:41 +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 C40621DAA8 for ; Wed, 15 Mar 2017 23:32:40 +0000 (UTC) Received: from mfilter17-d.gandi.net (mfilter17-d.gandi.net [217.70.178.145]) by relay3-d.mail.gandi.net (Postfix) with ESMTP id 6FF2AA80C1; Thu, 16 Mar 2017 00:32:39 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter17-d.gandi.net Received: from relay3-d.mail.gandi.net ([IPv6:::ffff:217.70.183.195]) by mfilter17-d.gandi.net (mfilter17-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id DEtfkyhJOpMn; Thu, 16 Mar 2017 00:32:37 +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 36B91A80C6; Thu, 16 Mar 2017 00:32:36 +0100 (CET) From: Jarno Rajahalme To: dev@openvswitch.org Date: Wed, 15 Mar 2017 16:31:26 -0700 Message-Id: <1489620689-122370-23-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 22/25] ofp-util: Ignore unknown fields in ofputil_decode_packet_in2(). 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 The decoder of packet_in messages should not fail on encountering unknown metadata fields. This allows the switch to add new features without breaking controllers. The controllers should, however, copy the metadata fields from the packet_int to packet_out so that the switch gets back the full metadata. OVN is already doing this. Signed-off-by: Jarno Rajahalme Acked-by: Joe Stringer --- lib/nx-match.c | 25 ++++++++++++++++--------- lib/nx-match.h | 4 ++-- lib/ofp-util.c | 5 +++-- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/lib/nx-match.c b/lib/nx-match.c index 91401e2..2e62e99 100644 --- a/lib/nx-match.c +++ b/lib/nx-match.c @@ -504,6 +504,9 @@ nx_pull_match_entry(struct ofpbuf *b, bool allow_cookie, return 0; } +/* Prerequisites will only be checked when 'strict' is 'true'. This allows + * decoding conntrack original direction 5-tuple IP addresses without the + * ethertype being present, when decoding metadata only. */ static enum ofperr nx_pull_raw(const uint8_t *p, unsigned int match_len, bool strict, struct match *match, ovs_be64 *cookie, ovs_be64 *cookie_mask, @@ -539,7 +542,7 @@ nx_pull_raw(const uint8_t *p, unsigned int match_len, bool strict, *cookie = value.be64; *cookie_mask = mask.be64; } - } else if (!mf_are_prereqs_ok(field, &match->flow, NULL)) { + } else if (strict && !mf_are_prereqs_ok(field, &match->flow, NULL)) { error = OFPERR_OFPBMC_BAD_PREREQ; } else if (!mf_is_all_wild(field, &match->wc)) { error = OFPERR_OFPBMC_DUP_FIELD; @@ -607,7 +610,8 @@ nx_pull_match(struct ofpbuf *b, unsigned int match_len, struct match *match, } /* Behaves the same as nx_pull_match(), but skips over unknown NXM headers, - * instead of failing with an error. */ + * instead of failing with an error, and does not check for field + * prerequisities. */ enum ofperr nx_pull_match_loose(struct ofpbuf *b, unsigned int match_len, struct match *match, @@ -664,8 +668,9 @@ oxm_pull_match(struct ofpbuf *b, const struct tun_table *tun_table, return oxm_pull_match__(b, true, tun_table, match); } -/* Behaves the same as oxm_pull_match() with one exception. Skips over unknown - * OXM headers instead of failing with an error when they are encountered. */ +/* Behaves the same as oxm_pull_match() with two exceptions. Skips over + * unknown OXM headers instead of failing with an error when they are + * encountered, and does not check for field prerequisities. */ enum ofperr oxm_pull_match_loose(struct ofpbuf *b, const struct tun_table *tun_table, struct match *match) @@ -676,14 +681,16 @@ oxm_pull_match_loose(struct ofpbuf *b, const struct tun_table *tun_table, /* Parses the OXM match description in the 'oxm_len' bytes in 'oxm'. Stores * the result in 'match'. * - * Fails with an error when encountering unknown OXM headers. + * Returns 0 if successful, otherwise an OpenFlow error code. * - * Returns 0 if successful, otherwise an OpenFlow error code. */ + * 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, - const struct tun_table *tun_table, struct match *match) +oxm_decode_match_loose(const void *oxm, size_t oxm_len, + 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, false, 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 5dca24a..cee9e65 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_loose(const void *, size_t, + 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 0c9343e..9e8d4d2 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -3397,8 +3397,9 @@ 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); + error = oxm_decode_match_loose(payload.msg, + ofpbuf_msgsize(&payload), + tun_table, &pin->flow_metadata); break; case NXPINT_USERDATA: