Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3922151pxj; Mon, 21 Jun 2021 09:26:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxi3xbofWJINDiE2pJNLfePWEGDSfV2oauG2K+Cfjj2BLwumYZRrRdRqJTqCeZ5Oxc8xJ53 X-Received: by 2002:a6b:c984:: with SMTP id z126mr21080743iof.94.1624292760592; Mon, 21 Jun 2021 09:26:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624292760; cv=none; d=google.com; s=arc-20160816; b=tyz1zwPI9Ucxxm6vOIylrDLhNHi1p1YCzhqImc3cvfaGjl2W/pWnqwQu3yJmbVqDkl LDmG4H9US3c1tj8z9NQEXGLG0omI9fsLyDnOgSFSu3+3LYm9682LRx4tr4MRQz/jNFi3 wdcLU0vDlg0e1J5mklSRvUGInZG5/mAFS/0XX26ar8zVvyJkWG1wR+0SElkSiyqI7CBf 7YDvncD/HpJAHwgEYf/a/vYQ43Cw4elcOmUMFQsh9IZv+aeFmoMov9+DKmCMS7hpKcXv SxSWQ4buu8frzLQXt03kKvkbPAweX3sp8gUXQnIMBa9nVM+o2duLOoLiDFGf2LCPojFB ycBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Vwa4VHINX5hLnE4VNGgxEipsggUHM7ptx77mCESJOk4=; b=ztjTUWqgMCeVevs4jTFWEhwZJuAVYRA70G7kGMUujSxJyjL2MBdgURN9FLqSYg2QxK nTVljYqfQK1bD12l5ziGwkVHNwDS8ujxa9MswB7sQjiwy0nD3xn1EKL5TQYCHzPkWnaH qj7238klaZRfRV9qMd8GbSSsO6iuLAFqzR28EtZHhCv7678A2nEu+HnHyNbOKo+OJNSc ydTK4sfGmdzybJrAkvOr01vidFyUSkmKhToJgROzfbjdpLOkS1bL5mVv90fDHeehJ8pA 6FhpZQVzK5OkDzPZHn/hVsaV3ZyTsz4nRcIBhpZwxHVLH+661XX5laikIMrcO7N0buUl LeXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sa2lShYH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i13si15211923ilm.45.2021.06.21.09.25.47; Mon, 21 Jun 2021 09:26:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sa2lShYH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231514AbhFUQ1d (ORCPT + 99 others); Mon, 21 Jun 2021 12:27:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:42544 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232203AbhFUQZk (ORCPT ); Mon, 21 Jun 2021 12:25:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E566A613B3; Mon, 21 Jun 2021 16:21:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624292513; bh=TSxMnFp0YdvzQE0zM5wiWnge1FLRpeiMZNyFb7UoRw4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sa2lShYHpmdChrNNswIpd6AHqkeeM6l/hdV4+KCMgqschThdyvjqGRas2jke1DN89 5ryNYbhL2JOuHqyE98WSGGQh4EZSX4s4wPLf6dB3euR3UyrLsAU7WGLNS8xAdtP1GT 9a9sKdtefCIp8ZnP706FQUeI2NU2MpFhbqwGiryo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marcelo Ricardo Leitner , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 027/146] net/sched: act_ct: handle DNAT tuple collision Date: Mon, 21 Jun 2021 18:14:17 +0200 Message-Id: <20210621154912.201597488@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154911.244649123@linuxfoundation.org> References: <20210621154911.244649123@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marcelo Ricardo Leitner [ Upstream commit 13c62f5371e3eb4fc3400cfa26e64ca75f888008 ] This this the counterpart of 8aa7b526dc0b ("openvswitch: handle DNAT tuple collision") for act_ct. From that commit changelog: """ With multiple DNAT rules it's possible that after destination translation the resulting tuples collide. ... Netfilter handles this case by allocating a null binding for SNAT at egress by default. Perform the same operation in openvswitch for DNAT if no explicit SNAT is requested by the user and allocate a null binding for SNAT for packets in the "original" direction. """ Fixes: 95219afbb980 ("act_ct: support asymmetric conntrack") Signed-off-by: Marcelo Ricardo Leitner Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/sched/act_ct.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c index 315a5b2f3add..7ef074c6dd16 100644 --- a/net/sched/act_ct.c +++ b/net/sched/act_ct.c @@ -900,14 +900,19 @@ static int tcf_ct_act_nat(struct sk_buff *skb, } err = ct_nat_execute(skb, ct, ctinfo, range, maniptype); - if (err == NF_ACCEPT && - ct->status & IPS_SRC_NAT && ct->status & IPS_DST_NAT) { - if (maniptype == NF_NAT_MANIP_SRC) - maniptype = NF_NAT_MANIP_DST; - else - maniptype = NF_NAT_MANIP_SRC; - - err = ct_nat_execute(skb, ct, ctinfo, range, maniptype); + if (err == NF_ACCEPT && ct->status & IPS_DST_NAT) { + if (ct->status & IPS_SRC_NAT) { + if (maniptype == NF_NAT_MANIP_SRC) + maniptype = NF_NAT_MANIP_DST; + else + maniptype = NF_NAT_MANIP_SRC; + + err = ct_nat_execute(skb, ct, ctinfo, range, + maniptype); + } else if (CTINFO2DIR(ctinfo) == IP_CT_DIR_ORIGINAL) { + err = ct_nat_execute(skb, ct, ctinfo, NULL, + NF_NAT_MANIP_SRC); + } } return err; #else -- 2.30.2