From patchwork Sat Jan 30 14:56:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 1433703 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; 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=Sdjpc8kC; 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 4DScjv2ccHz9t1C for ; Sun, 31 Jan 2021 01:56:48 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id AA06A8715F; Sat, 30 Jan 2021 14:56:46 +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 pAQK-iJ1sAhY; Sat, 30 Jan 2021 14:56:46 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id F19B8870F8; Sat, 30 Jan 2021 14:56:45 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D3275C0FA7; Sat, 30 Jan 2021 14:56:45 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id A2624C013A for ; Sat, 30 Jan 2021 14:56:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 8A1A185EF3 for ; Sat, 30 Jan 2021 14:56: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 UqwW0Qml3e-F for ; Sat, 30 Jan 2021 14:56:44 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 0142C85A76 for ; Sat, 30 Jan 2021 14:56:43 +0000 (UTC) Received: by mail-pj1-f42.google.com with SMTP id a20so7310769pjs.1 for ; Sat, 30 Jan 2021 06:56:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=iGUh60gEQkgM3PFOuWlSjFkU4GfLuKq6tPBiHLh+WyQ=; b=Sdjpc8kC/5xvmCgNsEYm6eILY5+w9G+w48XyDhM9lO1xmuCC5ONuWh+vakK3pwmNbU ARGcUKnZlgzYSctr4ikQlsvCGGtBiA61TMGE5Gw53hplc9N2YroJPu/R805xIiz60768 mGve5PBcTDQ3gTP/CsSoCMDSqVyQxCSGrB74/728D2jCg3yBGrDCKEtMsCgK1GrDczHt rYUaWzWkFhfELJW0rOs8EeevVfJQMhOv1SsPLbXBcVAM41BDSO1zQBaDZP9eQU9LOqLY GmAZ3jZUSZa9COaOHBHIPWmTzqAEeydO39pSkD9jVaoz3wpczqQKth335Z93B+UhZMFL UzSg== 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; bh=iGUh60gEQkgM3PFOuWlSjFkU4GfLuKq6tPBiHLh+WyQ=; b=NxTl0i+l6KdpJUX3r4Fsh+nDmiGQ1NDOLi3deatFpZzM1LrZSf+kK+BOvR+QmEK4NL o2Qbq4Z1fqTa/PxwvpjDmafjtYrGdlDDWk6qrAu6jrYlm043wq4BOfP59XFcrj64kg2/ cwk6llkjNY7wzegz9BZM2LmQgq0fzwuZ+CKySNMVMXZEfQoOLWydwzcs9tQ1qaGN5unM IXlHk8vQjbYj++cT1TqagYMDJsG/q63KYcZikQrvDw1YP6pqW5IxOKKDTlXdMHHMryJd xOPg3ZPh2Sta7R1/N714jEDxWs8Qq96up7QULDEBz7eW5ympVlxzLjb/PBwl0MWgbhmT zPsA== X-Gm-Message-State: AOAM533moLOWo55tahmCx/dAdEZBsUIPQiiL8cIvqbUWMEuxQrXLw402 ksMiV2PE6Gln99TLl9a4uHs= X-Google-Smtp-Source: ABdhPJzL680s2KGPbuf0uvTRhlSgWXur7xgCWahRv1gTwTSfgvGVik1rDbKYAtV+A4V2AhaJiY03TQ== X-Received: by 2002:a17:902:7596:b029:da:b7a3:cdd0 with SMTP id j22-20020a1709027596b02900dab7a3cdd0mr10259467pll.14.1612018603517; Sat, 30 Jan 2021 06:56:43 -0800 (PST) Received: from localhost.localdomain ([106.39.151.61]) by smtp.gmail.com with ESMTPSA id ob6sm9755049pjb.30.2021.01.30.06.56.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Jan 2021 06:56:42 -0800 (PST) From: xiangxia.m.yue@gmail.com To: i.maximets@ovn.org, blp@ovn.org Date: Sat, 30 Jan 2021 22:56:11 +0800 Message-Id: <20210130145611.78958-1-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 2.15.0 Cc: dev@openvswitch.org Subject: [ovs-dev] [PATCH ovs] ofproto-dpif-xlate: Allow specific tunnel packets sent outside. 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: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Tonghao Zhang This patch adds more strict limitation to tunnel packets. If the source and destination address are the local address. the tunnel packets will be sent to outside. This is useful, for example, if we upgrade the openvswitch: One OvS may send these packets outside, and the physical switch can send that packets back in hairpin mode, then other OvS may process them. Signed-off-by: Tonghao Zhang --- ofproto/ofproto-dpif-xlate.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 7108c8a30138..80c631993f05 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -4101,7 +4101,15 @@ terminate_native_tunnel(struct xlate_ctx *ctx, struct flow *flow, } } - return *tnl_port != ODPP_NONE; + /* Allow tunnel packets which source, and destination address + * are the local address to be sent outside. */ + if (*tnl_port != ODPP_NONE && + (flow->nw_src != flow->nw_dst || + !ipv6_addr_equals(&flow->ipv6_src, &flow->ipv6_dst))) { + return true; + } + + return false; } static void