From patchwork Tue Jul 18 22:32:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 790672 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) 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 3xBw1528V1z9sxR for ; Wed, 19 Jul 2017 08:33:29 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 46759957; Tue, 18 Jul 2017 22:32:59 +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 634EE902 for ; Tue, 18 Jul 2017 22:32:57 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id A7C8912E for ; Tue, 18 Jul 2017 22:32:56 +0000 (UTC) Received: from mfilter11-d.gandi.net (mfilter11-d.gandi.net [217.70.178.131]) by relay5-d.mail.gandi.net (Postfix) with ESMTP id 75BE441C091; Wed, 19 Jul 2017 00:32:55 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter11-d.gandi.net Received: from relay5-d.mail.gandi.net ([IPv6:::ffff:217.70.183.197]) by mfilter11-d.gandi.net (mfilter11-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id b8qDgrzIcSRn; Wed, 19 Jul 2017 00:32:54 +0200 (CEST) X-Originating-IP: 208.91.1.34 Received: from carno.eng.vmware.com (unknown [208.91.1.34]) (Authenticated sender: joe@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 32AF441C08A; Wed, 19 Jul 2017 00:32:52 +0200 (CEST) From: Joe Stringer To: dev@openvswitch.org Date: Tue, 18 Jul 2017 15:32:44 -0700 Message-Id: <20170718223244.28449-2-joe@ovn.org> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170718223244.28449-1-joe@ovn.org> References: <20170718223244.28449-1-joe@ovn.org> MIME-Version: 1.0 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 Cc: e@erig.me Subject: [ovs-dev] [PATCH 2/2] dpif-netlink: For non-Ethernet, use Ethertype from packet_type. 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: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org For non-Ethernet flows, when fixing up the netlink message we need make sure to pass down a valid Ethertype. The kernel does not understand packet_type so it's implicitly encoded by the absence of _ETHERNET and exact match of _ETHERTYPE. Without this change match_validate in the kernel complains when trying to match packets from L3 tunnels. e.g.   openvswitch: netlink: Unexpected mask (mask=110088, allowed=3d9804c) The mask use to always be set in xlate_wc_init() and xlate_wc_finish(), but that changed for non-Ethernet frames with the commit listed below. Fixes: 3d4b2e6eb74e ("userspace: Add OXM field MFF_PACKET_TYPE") Signed-off-by: Joe Stringer Co-authored-by: Eric Garver Acked-by: Eric Garver --- lib/dpif-netlink.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c index 63ef3de5c7d1..55effd1f91a8 100644 --- a/lib/dpif-netlink.c +++ b/lib/dpif-netlink.c @@ -3434,8 +3434,9 @@ dpif_netlink_flow_from_ofpbuf(struct dpif_netlink_flow *flow, /* - * If PACKET_TYPE attribute is present in 'data', it filters PACKET_TYPE out, - * then puts 'data' to 'buf'. + * If PACKET_TYPE attribute is present in 'data', it filters PACKET_TYPE out. + * If the flow is not Ethernet, the OVS_KEY_ATTR_PACKET_TYPE is converted to + * OVS_KEY_ATTR_ETHERTYPE. Puts 'data' to 'buf'. */ static void put_exclude_packet_type(struct ofpbuf *buf, uint16_t type, @@ -3458,6 +3459,20 @@ put_exclude_packet_type(struct ofpbuf *buf, uint16_t type, ofs = nl_msg_start_nested(buf, type); nl_msg_put(buf, data, first_chunk_size); nl_msg_put(buf, next_attr, second_chunk_size); + if (!nl_attr_find__(data, data_len, OVS_KEY_ATTR_ETHERNET)) { + ovs_be16 pt = pt_ns_type_be(nl_attr_get_be32(packet_type)); + const struct nlattr *nla; + + nla = nl_attr_find(buf, NLA_HDRLEN, OVS_KEY_ATTR_ETHERTYPE); + if (nla) { + ovs_be16 *ethertype; + + ethertype = CONST_CAST(ovs_be16 *, nl_attr_get(nla)); + *ethertype = pt; + } else { + nl_msg_put_be16(buf, OVS_KEY_ATTR_ETHERTYPE, pt); + } + } nl_msg_end_nested(buf, ofs); } else { nl_msg_put_unspec(buf, type, data, data_len);