From patchwork Fri Jul 26 12:18:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Li X-Patchwork-Id: 1137416 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=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=139.com 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 45w7RT4d7Zz9s4Y for ; Fri, 26 Jul 2019 22:19:00 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id E29EFBE7; Fri, 26 Jul 2019 12:18:57 +0000 (UTC) X-Original-To: ovs-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 BEA6986D for ; Fri, 26 Jul 2019 12:18:56 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from n9-30.mail.139.com (n9-30.mail.139.com [221.176.9.30]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id 189A47C for ; Fri, 26 Jul 2019 12:18:54 +0000 (UTC) X-RM-TagInfo: emlType=0 X-RM-SPAM: X-RM-SPAM-FLAG: 00000000 Received: from B000000115533A.internal.baidu.com (unknown[61.135.169.81]) by rmsmtp-rmapp-11-12027 (RichMail) with SMTP id 2efb5d3aefa8d79-58b21; Fri, 26 Jul 2019 20:18:49 +0800 (CST) X-RM-TRANSID: 2efb5d3aefa8d79-58b21 From: Wang Li To: ovs-dev@openvswitch.org Date: Fri, 26 Jul 2019 20:18:39 +0800 Message-Id: <20190726121839.92497-1-wang.li@139.com> X-Mailer: git-send-email 2.15.2 (Apple Git-101.1) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE 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] [PATCH] ofproto-dpif-xlate: Check mirror port before do terminate_native_tunnel 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: Wang Li The problem is the ovs-tcpdump can not capture the ingress vxlan traffics when it listens on the dpdk port, and the following dump-flows described the details: ovs-tcpdump stopped: recirc_id(0),in_port(2),packet_type(ns=0,id=0),eth(),eth_type(0x0800),ipv4(), udp(dst=4789), packets:6, bytes:888, used:0.188s, actions:tnl_pop(6) ovs-tcpdump started: recirc_id(0),in_port(2),packet_type(ns=0,id=0),eth(),eth_type(0x0800),ipv4(), udp(dst=4789), packets:17, bytes:2516, used:0.038s,actions:tnl_pop(6),tnl_pop(6) There are two tnl_pop actions here, and the ovs-tcpdump app can not capture any ingress vxlan traffics, in the meantime the side effect is the VM got duplicate packets that looks like this: 64 bytes from 172.16.0.37: icmp_seq=1 ttl=64 time=0.132 ms 64 bytes from 172.16.0.37: icmp_seq=1 ttl=64 time=0.132 ms (DUP!) 64 bytes from 172.16.0.37: icmp_seq=2 ttl=64 time=0.115 ms 64 bytes from 172.16.0.37: icmp_seq=2 ttl=64 time=0.115 ms (DUP!) ovs-tcpdump started with this fix: recirc_id(0),in_port(2),packet_type(ns=0,id=0),eth(),eth_type(0x0800),ipv4(), udp(dst=4789), packets:29, bytes:4292, used:0.330s, actions:7,tnl_pop(6) The root cause is the duplicate tnl_pop actions, so this fix will check if the ingress vxlan traffics are mirrored to the specified mirror port, in that case we should deliver the origin vxlan packets to mirror port without tnl_pop. Signed-off-by: Wang Li --- ofproto/ofproto-dpif-xlate.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 28a7fdd84..93536df11 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -153,6 +153,7 @@ struct xbundle { /* Use 802.1p tag for frames in VLAN 0? */ bool floodable; /* No port has OFPUTIL_PC_NO_FLOOD set? */ bool protected; /* Protected port mode */ + bool is_mirror; /* True if it is mirror port */ }; struct xport { @@ -184,6 +185,7 @@ struct xport { bool may_enable; /* May be enabled in bonds. */ bool is_tunnel; /* Is a tunnel port. */ + bool is_mirror; /* Is a mirror port. */ enum netdev_pt_mode pt_mode; /* packet_type handling. */ struct cfm *cfm; /* CFM handle or null. */ @@ -2124,6 +2126,7 @@ mirror_packet(struct xlate_ctx *ctx, struct xbundle *xbundle, if (out) { struct xbundle *out_xbundle = xbundle_lookup(ctx->xcfg, out); if (out_xbundle) { + out_xbundle->is_mirror = true; output_normal(ctx, out_xbundle, &xvlan); } } else if (xvlan.v[0].vid != out_vlan @@ -2458,6 +2461,7 @@ output_normal(struct xlate_ctx *ctx, const struct xbundle *out_xbundle, memcpy(&old_vlans, &ctx->xin->flow.vlans, sizeof(old_vlans)); xvlan_put(&ctx->xin->flow, &out_xvlan, out_xbundle->use_priority_tags); + xport->is_mirror = out_xbundle->is_mirror; compose_output_action(ctx, xport->ofp_port, use_recirc ? &xr : NULL, false, false); memcpy(&ctx->xin->flow.vlans, &old_vlans, sizeof(old_vlans)); @@ -4151,8 +4155,8 @@ compose_output_action__(struct xlate_ctx *ctx, ofp_port_t ofp_port, native_tunnel_output(ctx, xport, flow, odp_port, truncate); flow->tunnel = flow_tnl; /* Restore tunnel metadata */ - } else if (terminate_native_tunnel(ctx, ofp_port, flow, wc, - &odp_tnl_port)) { + } else if (!xport->is_mirror && terminate_native_tunnel(ctx, ofp_port, + flow, wc, &odp_tnl_port)) { /* Intercept packet to be received on native tunnel port. */ nl_msg_put_odp_port(ctx->odp_actions, OVS_ACTION_ATTR_TUNNEL_POP, odp_tnl_port);