From patchwork Mon Jun 12 22:28:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 774869 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 3wmnpj24m3z9s06 for ; Tue, 13 Jun 2017 08:37:49 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4A4ABC9E; Mon, 12 Jun 2017 22:29:39 +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 EE19AB79 for ; Mon, 12 Jun 2017 22:29:35 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by smtp2.linuxfoundation.org (Postfix) with ESMTPS id 268351DD47 for ; Mon, 12 Jun 2017 22:29:35 +0000 (UTC) Received: from mfilter15-d.gandi.net (mfilter15-d.gandi.net [217.70.178.143]) by relay6-d.mail.gandi.net (Postfix) with ESMTP id B9908FB8AC; Tue, 13 Jun 2017 00:29:33 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter15-d.gandi.net Received: from relay6-d.mail.gandi.net ([IPv6:::ffff:217.70.183.198]) by mfilter15-d.gandi.net (mfilter15-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id szAI_E9zoKo0; Tue, 13 Jun 2017 00:29:32 +0200 (CEST) X-Originating-IP: 208.91.2.3 Received: from sigabrt.benpfaff.org (unknown [208.91.2.3]) (Authenticated sender: blp@ovn.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id D4749FB88B; Tue, 13 Jun 2017 00:29:30 +0200 (CEST) From: Ben Pfaff To: dev@openvswitch.org Date: Mon, 12 Jun 2017 15:28:42 -0700 Message-Id: <20170612222856.14108-18-blp@ovn.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170612222856.14108-1-blp@ovn.org> References: <20170612222856.14108-1-blp@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 Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 17/31] userspace: Handling of versatile tunnel ports 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: Jan Scheurich In netdev_gre_build_header(), GRE protocol and VXLAN next_potocol is set based on packet_type of flow. If it's about an Ethernet packet, it is set to ETP_TYPE_TEB. Otherwise, if the name space is OFPHTN_ETHERNET, it is set according to the name space type. Signed-off-by: Jan Scheurich Signed-off-by: Ben Pfaff --- lib/netdev-native-tnl.c | 20 ++++++++++++++------ ofproto/ofproto-dpif-xlate.c | 2 +- ofproto/tunnel.c | 24 ++++++++++++++++++++---- ofproto/tunnel.h | 2 +- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c index c7a29934537e..658c871015f9 100644 --- a/lib/netdev-native-tnl.c +++ b/lib/netdev-native-tnl.c @@ -463,10 +463,12 @@ netdev_gre_build_header(const struct netdev *netdev, greh = netdev_tnl_ip_build_header(data, params, IPPROTO_GRE); - if (tnl_cfg->is_layer3) { - greh->protocol = params->flow->dl_type; - } else { + if (params->flow->packet_type == htonl(PT_ETH)) { greh->protocol = htons(ETH_TYPE_TEB); + } else if (pt_ns(params->flow->packet_type) == OFPHTN_ETHERTYPE) { + greh->protocol = pt_ns_type_be(params->flow->packet_type); + } else { + return 1; } greh->flags = 0; @@ -575,8 +577,10 @@ netdev_vxlan_build_header(const struct netdev *netdev, put_16aligned_be32(&vxh->vx_flags, htonl(VXLAN_FLAGS | VXLAN_HF_GPE)); put_16aligned_be32(&vxh->vx_vni, htonl(ntohll(params->flow->tunnel.tun_id) << 8)); - if (tnl_cfg->is_layer3) { - switch (ntohs(params->flow->dl_type)) { + if (params->flow->packet_type == htonl(PT_ETH)) { + vxh->vx_gpe.next_protocol = VXLAN_GPE_NP_ETHERNET; + } else if (pt_ns(params->flow->packet_type) == OFPHTN_ETHERTYPE){ + switch (pt_ns_type(params->flow->packet_type)) { case ETH_TYPE_IP: vxh->vx_gpe.next_protocol = VXLAN_GPE_NP_IPV4; break; @@ -586,9 +590,13 @@ netdev_vxlan_build_header(const struct netdev *netdev, case ETH_TYPE_TEB: vxh->vx_gpe.next_protocol = VXLAN_GPE_NP_ETHERNET; break; + default: + /* Drop packet. */ + return 1; + break; } } else { - vxh->vx_gpe.next_protocol = VXLAN_GPE_NP_ETHERNET; + return 1; } } else { put_16aligned_be32(&vxh->vx_flags, htonl(VXLAN_FLAGS)); diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index d18d58c87c20..623b7a0ee6c5 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -6154,7 +6154,7 @@ xlate_wc_init(struct xlate_ctx *ctx) netflow_mask_wc(&ctx->xin->flow, ctx->wc); } - tnl_wc_init(&ctx->xin->flow, ctx->wc); + tnl_wc_init(&ctx->xin->flow, ctx->wc, ctx->xbridge->packet_type_aware); } static void diff --git a/ofproto/tunnel.c b/ofproto/tunnel.c index e27a9fb75d08..caf01be5f14b 100644 --- a/ofproto/tunnel.c +++ b/ofproto/tunnel.c @@ -361,7 +361,8 @@ tnl_process_ecn(struct flow *flow) } void -tnl_wc_init(struct flow *flow, struct flow_wildcards *wc) +tnl_wc_init(struct flow *flow, struct flow_wildcards *wc, + bool packet_type_aware) { if (tnl_port_should_receive(flow)) { wc->masks.tunnel.tun_id = OVS_BE64_MAX; @@ -386,8 +387,10 @@ tnl_wc_init(struct flow *flow, struct flow_wildcards *wc) && IP_ECN_is_ce(flow->tunnel.ip_tos)) { wc->masks.nw_tos |= IP_ECN_MASK; } - /* Match on packet_type for tunneled packets.*/ - wc->masks.packet_type = OVS_BE32_MAX; + if (!packet_type_aware) { + /* Match on packet_type for tunneled packets.*/ + wc->masks.packet_type = OVS_BE32_MAX; + } } } @@ -566,8 +569,21 @@ tnl_find(const struct flow *flow) OVS_REQ_RDLOCK(rwlock) match.in_key_flow = in_key_flow; match.ip_dst_flow = ip_dst_flow; match.ip_src_flow = ip_src == IP_SRC_FLOW; - match.is_layer3 = flow->packet_type != htonl(PT_ETH); + /* If it's about a Non-ethernet packet then we look for a + * layer3 tunnel port first, as it would be attached to a + * non-PTAP bridge. Then for a versatile tunnel port as it + * would be attached to a PTAP bridge. */ + if (pt_ns(flow->packet_type) == OFPHTN_ETHERTYPE) { + /* Try to find a layer3 port first. */ + match.is_layer3 = true; + tnl_port = tnl_find_exact(&match, map); + if (tnl_port) { + return tnl_port; + } + } + /* Check for a non-layer3 or versatile tunnel port. */ + match.is_layer3 = false; tnl_port = tnl_find_exact(&match, map); if (tnl_port) { return tnl_port; diff --git a/ofproto/tunnel.h b/ofproto/tunnel.h index b0ec67c2bd74..dc004cc18b66 100644 --- a/ofproto/tunnel.h +++ b/ofproto/tunnel.h @@ -39,7 +39,7 @@ int tnl_port_add(const struct ofport_dpif *, const struct netdev *, void tnl_port_del(const struct ofport_dpif *); const struct ofport_dpif *tnl_port_receive(const struct flow *); -void tnl_wc_init(struct flow *, struct flow_wildcards *); +void tnl_wc_init(struct flow *, struct flow_wildcards *, bool); bool tnl_process_ecn(struct flow *); odp_port_t tnl_port_send(const struct ofport_dpif *, struct flow *, struct flow_wildcards *wc);