From patchwork Fri Oct 9 12:15:03 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: 1379140 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.136; helo=silver.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=phzRKDfF; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C76c020V8z9sSn for ; Fri, 9 Oct 2020 23:20:48 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id A2B872E28C; Fri, 9 Oct 2020 12:20:44 +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 OJFrjYX4mBpk; Fri, 9 Oct 2020 12:20:38 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 371B6203DC; Fri, 9 Oct 2020 12:20:38 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 18E0CC016F; Fri, 9 Oct 2020 12:20:38 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id B363DC0051 for ; Fri, 9 Oct 2020 12:20:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 99138876B5 for ; Fri, 9 Oct 2020 12:20:36 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CCalIx6dvuot for ; Fri, 9 Oct 2020 12:20:34 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-io1-f67.google.com (mail-io1-f67.google.com [209.85.166.67]) by whitealder.osuosl.org (Postfix) with ESMTPS id 53FB6876A6 for ; Fri, 9 Oct 2020 12:20:34 +0000 (UTC) Received: by mail-io1-f67.google.com with SMTP id u19so9877313ion.3 for ; Fri, 09 Oct 2020 05:20:34 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=J1o2qavMQyJD5MV9ts1YGKisybn9dt2DmocqG/evpFw=; b=phzRKDfFw5BxFIY65OryBSbygAZC263NrniKyFuGT4EqbuKyv+lKCW8qh1i/f+5gXt k0Rx5vusl7oP8oHdwslcUWH/tFSpt1I2c7+buvkunDaWj0pKDzh1UiV/QMXi9rZoRVCB cxV5KR+Jb3c8EKq4rAeR5+uO4h4njAI4u8dUiCcDRvvncBfLzK9wlgTEQHRn3yzuoX2b ii4zsb/SVe+Ch85FKRlfgolacrFUWjbE6P9hbKFF5uUL6YVyH4nemJsnnGk/rQRjZXYA Vas7MS81H79jUunPJ1f2BUlC+EkXrbu6ijkD4nJZl8VSELxOu0IMLajyUejSCjLUOkOb b1Ow== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=J1o2qavMQyJD5MV9ts1YGKisybn9dt2DmocqG/evpFw=; b=orcW9i2TQZSHxXnPIlwDcQJL0IzlpmC4Z536+6GwjWYo7nnj29PtYYIVygAEjOdb7M 8Vg77ypD1YF2sCETCdXgAhNUgc8A9b7HuZ8l0+W033HUVWrNB7fD/Y5NVzNoi4q0qeIw 2e+3pAAHq7NrZoyiefsCJ+jTx9irRe6wOIwgTdbf5gZYtg1lJrNR8M5xSF7Yky/6neB2 /oD4UTET9JZOF6rHH+1/tybdhwRD0XQA38ALaiWeuyhU+6As//NCcDkS7Sida+pXpsIf c0DaNLpc6eVqndEhTuuwipt6XlIqwfLcWYUfM79kZSrxNgc77P9eEYSyItAKB5eq3jD3 nw7A== X-Gm-Message-State: AOAM5336lAzhxu2IkGLL7XBNGCNL0EVwm46b5gm8LjwBg0q5llYibdKS 7D+TcJ8XZIMFvkJKSlCLkIqNlb7KMtj3AC+2 X-Google-Smtp-Source: ABdhPJxbqXO28c4an6qItyj6cic798KJpbD2EXs5LEFHXc+9eUzOBG24CExTk8mpXVlp5fhldlFV1g== X-Received: by 2002:a65:6106:: with SMTP id z6mr3123181pgu.433.1602245706967; Fri, 09 Oct 2020 05:15:06 -0700 (PDT) Received: from localhost ([61.120.150.71]) by smtp.gmail.com with ESMTPSA id x4sm4155216pfj.114.2020.10.09.05.15.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Oct 2020 05:15:06 -0700 (PDT) From: "hepeng.0320" To: dev@openvswitch.org Date: Fri, 9 Oct 2020 20:15:03 +0800 Message-Id: <20201009121503.43893-1-hepeng.0320@bytedance.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20201009114405.41964-1-hepeng.0320@bytedance.com> References: <20201009114405.41964-1-hepeng.0320@bytedance.com> MIME-Version: 1.0 Cc: i.maximets@ovn.org Subject: [ovs-dev] [PATCH 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 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index e0ede2cab..169fd2761 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,8 +4246,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, flow, wc, - &odp_tnl_port)) { + } 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, odp_tnl_port); @@ -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,