From patchwork Fri Oct 9 11:44:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Lui0uum5jw==?= X-Patchwork-Id: 1379130 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=bytedance-com.20150623.gappssmtp.com header.i=@bytedance-com.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=Ii1J5WKF; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C75nr2nv6z9sTR for ; Fri, 9 Oct 2020 22:44:16 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 85C4787701; Fri, 9 Oct 2020 11:44:14 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QTXSKQrPl8bd; Fri, 9 Oct 2020 11:44:13 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 98780876BD; Fri, 9 Oct 2020 11:44:13 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6AA0AC07FF; Fri, 9 Oct 2020 11:44:13 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id E240FC0051 for ; Fri, 9 Oct 2020 11:44:11 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id D6DA9876F8 for ; Fri, 9 Oct 2020 11:44:11 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XrWBabw7wGfj for ; Fri, 9 Oct 2020 11:44:09 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by hemlock.osuosl.org (Postfix) with ESMTPS id 6F850876BD for ; Fri, 9 Oct 2020 11:44:09 +0000 (UTC) Received: by mail-pl1-f170.google.com with SMTP id c6so4331708plr.9 for ; Fri, 09 Oct 2020 04:44:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Eml/EmHGGS7nFe3CehyxyqKq/Sl+O0shwsh/cJyDU1Y=; b=Ii1J5WKFLImYDdkzmIh3XIYkTHJIt2LuDijlqHLmnvS8owJECkiWdDYn1gyWp3RXqd aXyJnjLy/9HvQ03YvAuCaCHxwnuaDJh4xc17mDm/tYOWXJF+Nzz/eU62vEMz+g8ZcQLd x24nX6F7WAy48A+czYyLSb0vJEUqoeTiHuL4zhKzWeIaEpuVtbdfxcSWnB9MaxXWBMPc wRL2jtNGtoq/AN/bzvqH4Pi4YzYF39thSZHpf4gNsa/t5dbFAFwyGxOwws84Iv4StFfh DYJTLWM60CBqn4HBUc754n9seH2Ghe9KAjzVMtLZ6Dyzu5jFYmOPc0zUO4DKjJDmAkg4 weMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Eml/EmHGGS7nFe3CehyxyqKq/Sl+O0shwsh/cJyDU1Y=; b=IchK2F+I8b+OnY6sUxuLUaKCyREe2qhL2S4aYVEsZ2USkAVx4WufcO6z/ChTHdjT2K 3pxsmVjS5OKij/94HV/JyaHOZzsvkFKkLBS3aJYQZxC7AB9U2IR8KLnbrdLKVW42brBa iqjbIE4FxHLB6Co26iBkS2E62NWH7Y9QNvhT7E5y7mS1M0Eb2EOaEdVx2rcWTb/sliPP kGRBjPHZDIlv5Dc4P/8N2ADaxQ+0sy/ncjBU1MIdI8jFreiQUCEWKwVxU8J2CrohUAY2 h7fx7Y6XFWQEUaTJoY/dwn39CXXexaDWjPog6MTciwswPDbie5y34p1E9pVQwEl+2Ym4 uu3Q== X-Gm-Message-State: AOAM532GCs8M2i38IfF6XvSUJYw+m+GaQFRN2KyAAEne5wuFlc6x45I6 bTqgyX7X3CVccA4Wj8/wybC07pDhB3IXpRro X-Google-Smtp-Source: ABdhPJx9ulnULp8LGQdAxQtlasGpdCI1lYgYJ+vNV9ja7tLbjCnXIJwf1JljCTxvfBPoLX6kCYd8xg== X-Received: by 2002:a17:902:9890:b029:d2:2f2a:584e with SMTP id s16-20020a1709029890b02900d22f2a584emr12054519plp.29.1602243848527; Fri, 09 Oct 2020 04:44:08 -0700 (PDT) Received: from localhost ([61.120.150.71]) by smtp.gmail.com with ESMTPSA id b11sm10379017pfd.33.2020.10.09.04.44.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Oct 2020 04:44:07 -0700 (PDT) From: "hepeng.0320" To: dev@openvswitch.org Date: Fri, 9 Oct 2020 19:44:05 +0800 Message-Id: <20201009114405.41964-1-hepeng.0320@bytedance.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Cc: i.maximets@ovn.org Subject: [ovs-dev] [ovs-dev v1] ofproto-dpif-xlate: ovs-tcpdump cannot capture incomming vxlan packets X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" when running ovs-tcpdump -i ethX and the port is used as the incomming port for a vxlan port. The callstack for the upcall: mirror_ingress_packet mirror_packet output_normal compose_output_action compose_output_action__ terminate_native_tunnel will xlate the action into a tnl_pop action, not an output action to the mirror port. So eventually the translated actions will be 'tnl_pop(x), tnl_pop(x)'. However, the right action should be '(mirror port), tnl_pop(x)' This patch adds a flag in xlate_ctx indicating the current output_normal is used by mirroring. Note that we cannot use ctx->mirrors as the indicator as in the mirror code, the ctx->mirrors will not be cleared after mirror action finished. Signed-off-by: hepeng.0320 --- ofproto/ofproto-dpif-xlate.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index e0ede2cab..c83225c79 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -269,6 +269,7 @@ struct xlate_ctx { bool exit; /* No further actions should be processed. */ mirror_mask_t mirrors; /* Bitmap of associated mirrors. */ int mirror_snaplen; /* Max size of a mirror packet in byte. */ + bool in_mirror_output; /* Freezing Translation * ==================== @@ -2154,7 +2155,9 @@ mirror_packet(struct xlate_ctx *ctx, struct xbundle *xbundle, if (out) { struct xbundle *out_xbundle = xbundle_lookup(ctx->xcfg, out); if (out_xbundle) { + ctx->in_mirror_output = true; output_normal(ctx, out_xbundle, &xvlan); + ctx->in_mirror_output = false; } } else if (xvlan.v[0].vid != out_vlan && !eth_addr_is_reserved(ctx->xin->flow.dl_dst)) { @@ -2165,7 +2168,9 @@ mirror_packet(struct xlate_ctx *ctx, struct xbundle *xbundle, LIST_FOR_EACH (xb, list_node, &xbridge->xbundles) { if (xbundle_includes_vlan(xb, &xvlan) && !xbundle_mirror_out(xbridge, xb)) { + ctx->in_mirror_output = true; output_normal(ctx, xb, &xvlan); + ctx->in_mirror_output = false; } } xvlan.v[0].vid = old_vid; @@ -4241,7 +4246,7 @@ 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, flow, wc, + } else if (!ctx->in_mirror_output && terminate_native_tunnel(ctx, 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, @@ -7505,6 +7510,7 @@ xlate_actions(struct xlate_in *xin, struct xlate_out *xout) .exit = false, .error = XLATE_OK, .mirrors = 0, + .in_mirror_output = false, .freezing = false, .recirc_update_dp_hash = false,