{"id":809376,"url":"http://patchwork.ozlabs.org/api/patches/809376/?format=json","web_url":"http://patchwork.ozlabs.org/project/netfilter-devel/patch/1504477589-12045-10-git-send-email-pablo@netfilter.org/","project":{"id":26,"url":"http://patchwork.ozlabs.org/api/projects/26/?format=json","name":"Netfilter Development","link_name":"netfilter-devel","list_id":"netfilter-devel.vger.kernel.org","list_email":"netfilter-devel@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1504477589-12045-10-git-send-email-pablo@netfilter.org>","list_archive_url":null,"date":"2017-09-03T22:25:51","name":"[09/47] netfilter: add and use nf_ct_unconfirmed_destroy","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"3594b327e5b164ee4487559e2f18ca0fa12a96f7","submitter":{"id":1315,"url":"http://patchwork.ozlabs.org/api/people/1315/?format=json","name":"Pablo Neira Ayuso","email":"pablo@netfilter.org"},"delegate":{"id":6139,"url":"http://patchwork.ozlabs.org/api/users/6139/?format=json","username":"pablo","first_name":"Pablo","last_name":"Neira","email":"pablo@netfilter.org"},"mbox":"http://patchwork.ozlabs.org/project/netfilter-devel/patch/1504477589-12045-10-git-send-email-pablo@netfilter.org/mbox/","series":[{"id":1280,"url":"http://patchwork.ozlabs.org/api/series/1280/?format=json","web_url":"http://patchwork.ozlabs.org/project/netfilter-devel/list/?series=1280","date":"2017-09-03T22:25:42","name":"[01/47] netfilter: expect: add to hash table after expect init","version":1,"mbox":"http://patchwork.ozlabs.org/series/1280/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/809376/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/809376/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netfilter-devel-owner@vger.kernel.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netfilter-devel-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xlndx2Bxzz9s7M\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon,  4 Sep 2017 08:27:01 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1753182AbdICW0w (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tSun, 3 Sep 2017 18:26:52 -0400","from mail.us.es ([193.147.175.20]:50808 \"EHLO mail.us.es\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1753097AbdICW0p (ORCPT <rfc822; netfilter-devel@vger.kernel.org>);\n\tSun, 3 Sep 2017 18:26:45 -0400","from antivirus1-rhel7.int (unknown [192.168.2.11])\n\tby mail.us.es (Postfix) with ESMTP id 0C1B5190F61\n\tfor <netfilter-devel@vger.kernel.org>;\n\tMon,  4 Sep 2017 00:26:19 +0200 (CEST)","from antivirus1-rhel7.int (localhost [127.0.0.1])\n\tby antivirus1-rhel7.int (Postfix) with ESMTP id E7360B502E\n\tfor <netfilter-devel@vger.kernel.org>;\n\tMon,  4 Sep 2017 00:26:18 +0200 (CEST)","by antivirus1-rhel7.int (Postfix, from userid 99)\n\tid D73E9B5027; Mon,  4 Sep 2017 00:26:18 +0200 (CEST)","from antivirus1-rhel7.int (localhost [127.0.0.1])\n\tby antivirus1-rhel7.int (Postfix) with ESMTP id C5C69DA56C;\n\tMon,  4 Sep 2017 00:26:16 +0200 (CEST)","from 192.168.1.97 (192.168.1.97) by antivirus1-rhel7.int\n\t(F-Secure/fsigk_smtp/550/antivirus1-rhel7.int); \n\tMon, 04 Sep 2017 00:26:16 +0200 (CEST)","from salvia.here (unknown [31.4.193.113])\n\t(Authenticated sender: pneira@us.es)\n\tby entrada.int (Postfix) with ESMTPA id 6566D4265A22;\n\tMon,  4 Sep 2017 00:26:16 +0200 (CEST)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.1 (2015-04-28) on\n\tantivirus1-rhel7.int","X-Spam-Level":"","X-Spam-Status":"No, score=-108.2 required=7.5 tests=ALL_TRUSTED,BAYES_50,\n\tSMTPAUTH_US2,USER_IN_WHITELIST autolearn=disabled version=3.4.1","X-Virus-Status":"clean(F-Secure/fsigk_smtp/550/antivirus1-rhel7.int)","X-SMTPAUTHUS":"auth mail.us.es","From":"Pablo Neira Ayuso <pablo@netfilter.org>","To":"netfilter-devel@vger.kernel.org","Cc":"davem@davemloft.net, netdev@vger.kernel.org","Subject":"[PATCH 09/47] netfilter: add and use nf_ct_unconfirmed_destroy","Date":"Mon,  4 Sep 2017 00:25:51 +0200","Message-Id":"<1504477589-12045-10-git-send-email-pablo@netfilter.org>","X-Mailer":"git-send-email 2.1.4","In-Reply-To":"<1504477589-12045-1-git-send-email-pablo@netfilter.org>","References":"<1504477589-12045-1-git-send-email-pablo@netfilter.org>","X-Virus-Scanned":"ClamAV using ClamSMTP","Sender":"netfilter-devel-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netfilter-devel.vger.kernel.org>","X-Mailing-List":"netfilter-devel@vger.kernel.org"},"content":"From: Florian Westphal <fw@strlen.de>\n\nThis also removes __nf_ct_unconfirmed_destroy() call from\nnf_ct_iterate_cleanup_net, so that function can be used only\nwhen missing conntracks from unconfirmed list isn't a problem.\n\nSigned-off-by: Florian Westphal <fw@strlen.de>\nSigned-off-by: Pablo Neira Ayuso <pablo@netfilter.org>\n---\n include/net/netfilter/nf_conntrack.h |  3 +++\n net/netfilter/nf_conntrack_core.c    | 15 +++++++++++----\n net/netfilter/nfnetlink_cttimeout.c  |  1 +\n 3 files changed, 15 insertions(+), 4 deletions(-)","diff":"diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h\nindex 48407569585d..6e6f678aaac7 100644\n--- a/include/net/netfilter/nf_conntrack.h\n+++ b/include/net/netfilter/nf_conntrack.h\n@@ -224,6 +224,9 @@ extern s32 (*nf_ct_nat_offset)(const struct nf_conn *ct,\n \t\t\t       enum ip_conntrack_dir dir,\n \t\t\t       u32 seq);\n \n+/* Set all unconfirmed conntrack as dying */\n+void nf_ct_unconfirmed_destroy(struct net *);\n+\n /* Iterate over all conntracks: if iter returns true, it's deleted. */\n void nf_ct_iterate_cleanup_net(struct net *net,\n \t\t\t       int (*iter)(struct nf_conn *i, void *data),\ndiff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c\nindex c6f1cf0bff56..80ab4e937765 100644\n--- a/net/netfilter/nf_conntrack_core.c\n+++ b/net/netfilter/nf_conntrack_core.c\n@@ -1686,6 +1686,17 @@ __nf_ct_unconfirmed_destroy(struct net *net)\n \t}\n }\n \n+void nf_ct_unconfirmed_destroy(struct net *net)\n+{\n+\tmight_sleep();\n+\n+\tif (atomic_read(&net->ct.count) > 0) {\n+\t\t__nf_ct_unconfirmed_destroy(net);\n+\t\tsynchronize_net();\n+\t}\n+}\n+EXPORT_SYMBOL_GPL(nf_ct_unconfirmed_destroy);\n+\n void nf_ct_iterate_cleanup_net(struct net *net,\n \t\t\t       int (*iter)(struct nf_conn *i, void *data),\n \t\t\t       void *data, u32 portid, int report)\n@@ -1697,14 +1708,10 @@ void nf_ct_iterate_cleanup_net(struct net *net,\n \tif (atomic_read(&net->ct.count) == 0)\n \t\treturn;\n \n-\t__nf_ct_unconfirmed_destroy(net);\n-\n \td.iter = iter;\n \td.data = data;\n \td.net = net;\n \n-\tsynchronize_net();\n-\n \tnf_ct_iterate_cleanup(iter_net_only, &d, portid, report);\n }\n EXPORT_SYMBOL_GPL(nf_ct_iterate_cleanup_net);\ndiff --git a/net/netfilter/nfnetlink_cttimeout.c b/net/netfilter/nfnetlink_cttimeout.c\nindex 7ce9e86d374c..f4fb6d4dd0b9 100644\n--- a/net/netfilter/nfnetlink_cttimeout.c\n+++ b/net/netfilter/nfnetlink_cttimeout.c\n@@ -570,6 +570,7 @@ static void __net_exit cttimeout_net_exit(struct net *net)\n {\n \tstruct ctnl_timeout *cur, *tmp;\n \n+\tnf_ct_unconfirmed_destroy(net);\n \tctnl_untimeout(net, NULL);\n \n \tlist_for_each_entry_safe(cur, tmp, &net->nfct_timeout_list, head) {\n","prefixes":["09/47"]}