Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp3043400ybx; Fri, 8 Nov 2019 13:11:07 -0800 (PST) X-Google-Smtp-Source: APXvYqwtgZDUkSHbGgVRDzHztI/tZScAUaNH6ws886x/qSJyaUqo591Y+BhFHlgOEKeaeZWSr6V/ X-Received: by 2002:a50:becf:: with SMTP id e15mr12641668edk.135.1573247467039; Fri, 08 Nov 2019 13:11:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573247467; cv=none; d=google.com; s=arc-20160816; b=lg3qQ7j7o3SyH0wMiO8A4gwNK64BjQYvun804g9kAvYIJ8lV+GlyAjkjC+aMh95fgb hvJJVHAPlOfaJ/YjjI6XqDBXHOTqt1l3VsLixjT+xFNmzUDFBH3910Ws7lOfXTZBCieM e4VQTNkfj8V21gGa/60WpMR2UftB5m902C2Nznfj4qvah5qZOWt9WRDEjz/BwVczO9OA rVwD/l7cBWooelRwm+fHyDKCCOYAHgjfiKlBJNH/caf5upZW/Bice6OBmR535x7+11r1 mnbPU4tjyoVZnfh4gGrynT1CIwvy0lQWlM7j8gFOswu9O1MjmdXrPZCOn88LvO511mvB y9iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=g+C4Ygst36NalU5H7g0gFh5wyAlvafm4eB3mjWDqmsI=; b=c8VC2hFh6BMXEdcHp4BO2pAUYw74uK9G0Z6kNVm7kwm2rxhQDZuFW8ylAHo6PklxZV FIeIKePIxlVZ0P0PXcogj/+rr/p7ZClAFipyCSCGcff9EqhtX4aNUMvB5hxXmzg99SQw mlDv6ItZ71BZE/BogCPLqpSCJ8/LkwPnJofxnTm+Z3yu6wunx9iJPSbOAzig35od9YUH cIz0oqNntosowkyJkbRxa/G/Onq6QBrbTr8khnN2LFD3gWvf8gOwMRb+EYyusrt/yVDQ /z1ceK2vtq0B1Iy6KDx4Yo1QWfk0ZDxDnHAaBzyI0R0JyOrqlvhoI/kPAWvDbqZhAvs1 vD6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZubWkVXL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h19si4679996ejx.34.2019.11.08.13.10.43; Fri, 08 Nov 2019 13:11:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZubWkVXL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732246AbfKHVH0 (ORCPT + 99 others); Fri, 8 Nov 2019 16:07:26 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:26677 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732051AbfKHVHY (ORCPT ); Fri, 8 Nov 2019 16:07:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573247243; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g+C4Ygst36NalU5H7g0gFh5wyAlvafm4eB3mjWDqmsI=; b=ZubWkVXLIc1hO+zFPaEZqM8r4l6Jf/ooYL1GAv2tv9m1CUGC90PoqI6XkYRRRoTIktl3uQ nUuUQmA1NFg13sUCBeWPIiYFAjA7FYRmfWEVsM5Oud+CLo7xJPI1ASXrMtidii+gt5O8nl 7rtm/eHZcxwkfufiq39vkrMkZBKcSB8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-42-MIR5xOepMjK9mOApVWCbAQ-1; Fri, 08 Nov 2019 16:07:19 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 39C388017DD; Fri, 8 Nov 2019 21:07:18 +0000 (UTC) Received: from dhcp-25.97.bos.redhat.com (ovpn-123-109.rdu2.redhat.com [10.10.123.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 40BED19757; Fri, 8 Nov 2019 21:07:17 +0000 (UTC) From: Aaron Conole To: netdev@vger.kernel.org Cc: Pravin B Shelar , "David S . Miller" , Jamal Hadi Salim , Cong Wang , Jiri Pirko , dev@openvswitch.org, linux-kernel@vger.kernel.org Subject: [PATCH net 2/2] act_ct: support asymmetric conntrack Date: Fri, 8 Nov 2019 16:07:14 -0500 Message-Id: <20191108210714.12426-2-aconole@redhat.com> In-Reply-To: <20191108210714.12426-1-aconole@redhat.com> References: <20191108210714.12426-1-aconole@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: MIR5xOepMjK9mOApVWCbAQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The act_ct TC module shares a common conntrack and NAT infrastructure exposed via netfilter. It's possible that a packet needs both SNAT and DNAT manipulation, due to e.g. tuple collision. Netfilter can support this because it runs through the NAT table twice - once on ingress and again after egress. The act_ct action doesn't have such capability. Like netfilter hook infrastructure, we should run through NAT twice to keep the symmetry. Fixes: b57dc7c13ea9 ("net/sched: Introduce action ct") Signed-off-by: Aaron Conole --- net/sched/act_ct.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c index fcc46025e790..f3232a00970f 100644 --- a/net/sched/act_ct.c +++ b/net/sched/act_ct.c @@ -329,6 +329,7 @@ static int tcf_ct_act_nat(struct sk_buff *skb, =09=09=09 bool commit) { #if IS_ENABLED(CONFIG_NF_NAT) +=09int err; =09enum nf_nat_manip_type maniptype; =20 =09if (!(ct_action & TCA_CT_ACT_NAT)) @@ -359,7 +360,17 @@ static int tcf_ct_act_nat(struct sk_buff *skb, =09=09return NF_ACCEPT; =09} =20 -=09return ct_nat_execute(skb, ct, ctinfo, range, maniptype); +=09err =3D ct_nat_execute(skb, ct, ctinfo, range, maniptype); +=09if (err =3D=3D NF_ACCEPT && +=09 ct->status & IPS_SRC_NAT && ct->status & IPS_DST_NAT) { +=09=09if (maniptype =3D=3D NF_NAT_MANIP_SRC) +=09=09=09maniptype =3D NF_NAT_MANIP_DST; +=09=09else +=09=09=09maniptype =3D NF_NAT_MANIP_SRC; + +=09=09err =3D ct_nat_execute(skb, ct, ctinfo, range, maniptype); +=09} +=09return err; #else =09return NF_ACCEPT; #endif --=20 2.21.0