Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp3040420ybx; Fri, 8 Nov 2019 13:08:24 -0800 (PST) X-Google-Smtp-Source: APXvYqz+lk2k0z6aeHKZsARJ6DGOUXvvzGMYip9yRvlm13Ezkj6nnUnJjyoe0IelseVd0IGRv2dz X-Received: by 2002:aa7:d496:: with SMTP id b22mr12762591edr.122.1573247304117; Fri, 08 Nov 2019 13:08:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573247304; cv=none; d=google.com; s=arc-20160816; b=RVtmh8wKa+DlqDlpq8z1TqV1CW7TupCLnwyqk12PT9MZRkYLdkUheXVkSJbPqyRiPa a0IzAW4UN7kXg+yycoxsR/10DvlGuVM+opJtW3LysfM1jOK3WhwnfTgLo/+hPg/Hrk71 +SskZiyyckBDtEYD2te4zdbzFWeMx7niTf4R16P6v1GFaPUZoy7KPwV6SdYqgBV9ieYt m+62yvKa3pV3rlyH341YFovET8jbFmaCtFP2hGj8qwLWBEqr2K7vy7sbOMSJb2rmAmA3 EHMW9sBQASO63X/27j2rxsVrgoOJk3hHbY7FL+Wce9/n2/CG+XVZDf7o2rXEDCuXkEXC SNZQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=MBWevgYefE/oENuuV+xMUbOS2g9VAZuCifeLUildEZE=; b=bZ3XB5sevv/Q2xNO745hfOnF2ihbyKJf1yoe/ct2wgVbzbK5XO7VGjhRqqGVuSVEOa IHdOAZuC46izy0j+NhQ5XYQ66IyzZ1RiWpZ96mi8HlhsIwn0gsPdLx5CjkkMork0X28w OxA0/VZZ5q/RejFyKBIiGT8MofNKRiooC7EJniBWY1FrSA7QXsKL31d6/Otev7lXJHX3 Bg884b/IKnt2cSMYrkl9BQkWbxulj+czlhOw6DuEVACx08KgzWVzXLB9q3+NkhNChK4V ZT+L6fpKEj5fKoez5MQI1k9wxcJyRrjRgHpHcZ1sGkl72TMniWiHAvPUyPiwo0JNNnJb 68dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="AjXxWqX/"; 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 w21si4489856eja.324.2019.11.08.13.08.01; Fri, 08 Nov 2019 13:08:24 -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="AjXxWqX/"; 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 S1732164AbfKHVHX (ORCPT + 99 others); Fri, 8 Nov 2019 16:07:23 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:53530 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732051AbfKHVHX (ORCPT ); Fri, 8 Nov 2019 16:07:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573247242; 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; bh=MBWevgYefE/oENuuV+xMUbOS2g9VAZuCifeLUildEZE=; b=AjXxWqX/xWcGQ7uIncyNikrExrRSaVJVdayi8CqKPofhhOxq39D5E2Q1oTbie3qHzMqXgS V5MD7Gm0VuiW53UekzWHCTkeuCNzcPKSMJvQTv5PN7+BRAHoOHKwl449XbaSl65xc2NK7z PyTbe+kHRaGx37Z/TcC9hlJXi6HJtQE= 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-76-IRg7_hqAPOSlzW8cZognoA-1; Fri, 08 Nov 2019 16:07:18 -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 19EFB800686; Fri, 8 Nov 2019 21:07:17 +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 719D03DA3; Fri, 8 Nov 2019 21:07:15 +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 1/2] openvswitch: support asymmetric conntrack Date: Fri, 8 Nov 2019 16:07:13 -0500 Message-Id: <20191108210714.12426-1-aconole@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: IRg7_hqAPOSlzW8cZognoA-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 openvswitch 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 openvswitch module doesn't have such capability. Like netfilter hook infrastructure, we should run through NAT twice to keep the symmetry. Fixes: 05752523e565 ("openvswitch: Interface with NAT.") Signed-off-by: Aaron Conole --- net/openvswitch/conntrack.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c index 05249eb45082..283e8f9a5fd2 100644 --- a/net/openvswitch/conntrack.c +++ b/net/openvswitch/conntrack.c @@ -903,6 +903,17 @@ static int ovs_ct_nat(struct net *net, struct sw_flow_= key *key, =09} =09err =3D ovs_ct_nat_execute(skb, ct, ctinfo, &info->range, maniptype); =20 +=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 ovs_ct_nat_execute(skb, ct, ctinfo, &info->range, +=09=09=09=09=09 maniptype); +=09} + =09/* Mark NAT done if successful and update the flow key. */ =09if (err =3D=3D NF_ACCEPT) =09=09ovs_nat_update_key(key, skb, maniptype); --=20 2.21.0