From patchwork Fri May 22 09:02:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng He X-Patchwork-Id: 1296059 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.137; helo=fraxinus.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=Zcr5DhqE; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49T0r71cZXz9sSw for ; Fri, 22 May 2020 19:02:46 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 83781877A8; Fri, 22 May 2020 09:02:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PeCdB-JbGRc9; Fri, 22 May 2020 09:02:43 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id E41DF877B7; Fri, 22 May 2020 09:02:43 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A66BBC0863; Fri, 22 May 2020 09:02:43 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 63FD8C0176 for ; Fri, 22 May 2020 09:02:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 31FB12042A for ; Fri, 22 May 2020 09:02:42 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id f45xtntgT3lG for ; Fri, 22 May 2020 09:02:41 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by silver.osuosl.org (Postfix) with ESMTPS id 075502034C for ; Fri, 22 May 2020 09:02:40 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id q16so4158319plr.2 for ; Fri, 22 May 2020 02:02:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pd4UdcdqdDSYYLEApTMQ84fIzyLl+3yxauGCDUXv4uo=; b=Zcr5DhqEKtekVGqgHt4S4cBb2U4VblW3j1ylSbFHznyJ3/Dcw0c7IBFmnw5AbUa3Ls 28r7fSLQkUK56AKy84OgIKkmb1GAu68vk4/7yjxWYNSjCo9S3V8SU0GXSmNJyR7C0epG y6y87bDqSVqvVb70wiUIW4p+VobCsihSTDhhXN6GjwEBPSxzDg0/tmGozITVbyiXQSgL Wv6jiOQvMdvoCmxZpUsrHcpD2SUFN2o2w0LpEgPKsSeEiMUlxuqkLp6wLKtPPjJcOMkq b8OJCzgyDIvvxvwslwS7Xjdyf6778rJ+pNWKvcPVFHzuoZdc1BP0sKWs4X7zY3n4aZ/4 v7wg== 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=pd4UdcdqdDSYYLEApTMQ84fIzyLl+3yxauGCDUXv4uo=; b=VJ1msgW5GpFHeRLwIkWJtj61ssTUIWZ8HN97359uwvImd1fMK15XimGyhdxy3uiKmt y5arAG4KgswLyKkOzkUbdtXjDcRHYvTxOJbjSE6QU8/elRfqkvA7+2LZDnQ7ZMaHz/FA tkcg1VqzOOMCNCRR5x3fpymWy8B7fsCyphx6otiM9sbSJOm7tMXtWA5PusNA8ZDOSHhF 1ozM6JSc+BlSQG+Bfa4jq5ub+kNbgqK/qbZWvMbjF8Q4X5BIjZ9gESy7u35ZFQyXDceB KgZe/YKa45NPIqFYoFJ8pUyo/UrZmkR+b7ca2JQPlTy8Swke1p1YzhTsMjXKfTflrcwy 85uQ== X-Gm-Message-State: AOAM530psJQRd0F4QrntYz692S9LGjESkM7u5IWEBi6dFaL+dkV48Sw6 vwtZ0JUjnbBYj1fw7/8v4u4ONEP750A= X-Google-Smtp-Source: ABdhPJyk4Ym7GXVUz1ezjQA+qzyrSoYSTRk9edxD+8BIBdPIdfxmD6gINEzhKPThUzXG0jWbL15UNQ== X-Received: by 2002:a17:90a:2e17:: with SMTP id q23mr3152717pjd.43.1590138158797; Fri, 22 May 2020 02:02:38 -0700 (PDT) Received: from localhost ([103.136.220.69]) by smtp.gmail.com with ESMTPSA id d2sm6316590pfa.164.2020.05.22.02.02.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 02:02:38 -0700 (PDT) From: "hepeng.0320" X-Google-Original-From: "hepeng.0320" To: dev@openvswitch.org Date: Fri, 22 May 2020 17:02:34 +0800 Message-Id: <20200522090234.35857-1-hepeng.0320@bytedance.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Subject: [ovs-dev] [PATCH] 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. --- 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 80fba84cb..03f370a0a 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; @@ -4231,7 +4236,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, @@ -7492,6 +7497,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,