From patchwork Tue Dec 6 23:31:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 1712964 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.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=20210112 header.b=cMPlWjws; dkim-atps=neutral Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NRcB81x3yz23ns for ; Wed, 7 Dec 2022 10:31:27 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 8E9B4408BF; Tue, 6 Dec 2022 23:31:25 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 8E9B4408BF Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=cMPlWjws X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rQUbdbRiPjb9; Tue, 6 Dec 2022 23:31:24 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 64D9B40890; Tue, 6 Dec 2022 23:31:23 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 64D9B40890 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1E47EC0032; Tue, 6 Dec 2022 23:31:23 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id DC8B5C002D for ; Tue, 6 Dec 2022 23:31:20 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id B0EF660E3C for ; Tue, 6 Dec 2022 23:31:20 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org B0EF660E3C Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=cMPlWjws X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id X8aqzujbar8O for ; Tue, 6 Dec 2022 23:31:20 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org DF0E860644 Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by smtp3.osuosl.org (Postfix) with ESMTPS id DF0E860644 for ; Tue, 6 Dec 2022 23:31:19 +0000 (UTC) Received: by mail-qt1-x82e.google.com with SMTP id h16so15054796qtu.2 for ; Tue, 06 Dec 2022 15:31:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=EQ22xCPp+0IvJx+qgjvPwxnaisUB/3g2Hwop58XpnMU=; b=cMPlWjwsrzmr+6tZkDhM8Frf1LegpIxQvFf7x6USnXS/qTfi5trTJA5NK6C3iHZOT+ i8NcOWDeEbhtX43xymHwEdVjmc2bc324jizao4WtraT2tev2i+aMNKC23DI/kCWWG1S6 tqAC2GIuM2aBQtyu7H3+jfFLg12TAxQn8M/D4noN+kkFhwM5mo4RS5eZHEyKsLhMWwkX sBR5b/6mnm9FJFe4acppVjBKY/cHbF43uRLRuQuxdbhbbzOGS4F7B+zibh9hjE/XMxI2 /uWfjncd/nDPc6JYDwKQPh7P4nelb7mUuVDvTEwx4FZsd4xaal969iJK78cCS8SApBZb KnVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EQ22xCPp+0IvJx+qgjvPwxnaisUB/3g2Hwop58XpnMU=; b=WbWBOivZ6/qW3VNvEQNmYbl4ybZSBEwRVm/qqPFcV7rSM/JhErPK4CH3TYfJGLt2xO cFWWzNxppgL6PhJgOAaY1slt3VU6+jNj6FKt8daPQ/8hGE5aFjH6hz41pi/yTrzN9Mfi QlBs03Fi3CsfYHgACBTsmxPa5Q+hYkJm860WtxHHVDUNKn4mM8MpEuQiG1pEaQzyhzzs jC1Syeyg23ze1pqK62y58K6SHswAwr7CaWtpjb5zlpLKeobi19xg6SJO3wTH9D9tIEhq DMWImSUhRR9JNPFkQIaonF0Qr8Vc3FmeH1/M8cWhK7Dz4zA2ckcr5nIPgBnFPYt2dnXe MK0w== X-Gm-Message-State: ANoB5pmjQ26jYzuB+3BtLthMZ3g32+iFMrNxotI7Fo0c3869ceMRkwfz UxnKWXnMYL/r/6X01piJHZvA4OWhqD4= X-Google-Smtp-Source: AA0mqf46CvXaC/EolTygpOtN4AOboQnv1dlf6Ev9JNtEHprlp2WIBewONbRY9TTJlJBN8Nq9UWiy1g== X-Received: by 2002:ac8:5e83:0:b0:39c:c7ba:4af4 with SMTP id r3-20020ac85e83000000b0039cc7ba4af4mr68188923qtx.99.1670369478375; Tue, 06 Dec 2022 15:31:18 -0800 (PST) Received: from wsfd-netdev15.ntdv.lab.eng.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id i21-20020a05620a405500b006f8665f483fsm16590231qko.85.2022.12.06.15.31.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 15:31:17 -0800 (PST) From: Xin Long To: network dev , dev@openvswitch.org Date: Tue, 6 Dec 2022 18:31:11 -0500 Message-Id: X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Cc: Marcelo Ricardo Leitner , Jiri Pirko , Paul Blakey , Davide Caratti , Florian Westphal , Jamal Hadi Salim , Ilya Maximets , Saeed Mahameed , Eric Dumazet , Cong Wang , kuba@kernel.org, Paolo Abeni , davem@davemloft.net, Pablo Neira Ayuso Subject: [ovs-dev] [PATCHv3 net-next 0/5] net: eliminate the duplicate code in the ct nat functions of ovs and tc 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" The changes in the patchset: "net: add helper support in tc act_ct for ovs offloading" had moved some common ct code used by both OVS and TC into netfilter. There are still some big functions pretty similar defined and used in each of OVS and TC. It is not good to maintain such big function in 2 places. This patchset is to extract the functions for NAT processing from OVS and TC to netfilter. To make this change clear and safe, this patchset gets the common code out of OVS and TC step by step: The patch 1-4 make some minor changes in OVS and TC to make the NAT code of them completely the same, then the patch 5 moves the common code to the netfilter and exports one function called by each of OVS and TC. v1->v2: - Create nf_nat_ovs.c to include the nat functions, as Pablo suggested. v2->v3: - Fix a typo in subject of patch 2/5, as Marcelo noticed. - Fix in openvswitch to keep OVS ct nat and TC ct nat consistent in patch 3/5 instead of in tc, as Marcelo noticed. - Use BIT(var) macro instead of (1 << var) in patch 5/5, as Marcelo suggested. - Use ifdef in netfilter/Makefile to build nf_nat_ovs only when OVS or TC ct action is enabled in patch 5/5, as Marcelo suggested. Xin Long (5): openvswitch: delete the unncessary skb_pull_rcsum call in ovs_ct_nat_execute openvswitch: return NF_ACCEPT when OVS_CT_NAT is not set in info nat openvswitch: return NF_DROP when fails to add nat ext in ovs_ct_nat net: sched: update the nat flag for icmp error packets in ct_nat_execute net: move the nat function to nf_nat_ovs for ovs and tc include/net/netfilter/nf_nat.h | 4 + net/netfilter/Makefile | 6 ++ net/netfilter/nf_nat_ovs.c | 135 ++++++++++++++++++++++++++++++ net/openvswitch/conntrack.c | 146 +++------------------------------ net/sched/act_ct.c | 136 +++--------------------------- 5 files changed, 169 insertions(+), 258 deletions(-) create mode 100644 net/netfilter/nf_nat_ovs.c