Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.2/patches/805050/?format=api
{ "id": 805050, "url": "http://patchwork.ozlabs.org/api/1.2/patches/805050/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netfilter-devel/patch/20170823152627.19865-4-fw@strlen.de/", "project": { "id": 26, "url": "http://patchwork.ozlabs.org/api/1.2/projects/26/?format=api", "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": "<20170823152627.19865-4-fw@strlen.de>", "list_archive_url": null, "date": "2017-08-23T15:26:27", "name": "[nf-next,3/3] netfilter: core: batch nf_unregister_net_hooks synchronize_net calls", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "1a886bb7506bc299736c9779128118a2846be2c9", "submitter": { "id": 1025, "url": "http://patchwork.ozlabs.org/api/1.2/people/1025/?format=api", "name": "Florian Westphal", "email": "fw@strlen.de" }, "delegate": { "id": 6139, "url": "http://patchwork.ozlabs.org/api/1.2/users/6139/?format=api", "username": "pablo", "first_name": "Pablo", "last_name": "Neira", "email": "pablo@netfilter.org" }, "mbox": "http://patchwork.ozlabs.org/project/netfilter-devel/patch/20170823152627.19865-4-fw@strlen.de/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/805050/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/805050/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 3xcrqd5bPrz9s8V\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 24 Aug 2017 01:26:21 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S932338AbdHWP0U (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tWed, 23 Aug 2017 11:26:20 -0400", "from Chamillionaire.breakpoint.cc ([146.0.238.67]:58172 \"EHLO\n\tChamillionaire.breakpoint.cc\" rhost-flags-OK-OK-OK-OK)\n\tby vger.kernel.org with ESMTP id S932337AbdHWP0T (ORCPT\n\t<rfc822;netfilter-devel@vger.kernel.org>);\n\tWed, 23 Aug 2017 11:26:19 -0400", "from fw by Chamillionaire.breakpoint.cc with local (Exim 4.84_2)\n\t(envelope-from <fw@breakpoint.cc>)\n\tid 1dkXVR-0002SL-PG; Wed, 23 Aug 2017 17:23:45 +0200" ], "From": "Florian Westphal <fw@strlen.de>", "To": "<netfilter-devel@vger.kernel.org>", "Cc": "aconole@bytheb.org, Florian Westphal <fw@strlen.de>", "Subject": "[PATCH nf-next 3/3] netfilter: core: batch nf_unregister_net_hooks\n\tsynchronize_net calls", "Date": "Wed, 23 Aug 2017 17:26:27 +0200", "Message-Id": "<20170823152627.19865-4-fw@strlen.de>", "X-Mailer": "git-send-email 2.13.0", "In-Reply-To": "<20170823152627.19865-1-fw@strlen.de>", "References": "<20170823152627.19865-1-fw@strlen.de>", "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": "re-add batching in nf_unregister_net_hooks().\n\nSimilar as before, just store an array with to-be-free'd rule arrays\non stack, then call synchronize_net once per batch.\n\nSigned-off-by: Florian Westphal <fw@strlen.de>\n---\n net/netfilter/core.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++---\n 1 file changed, 56 insertions(+), 3 deletions(-)", "diff": "diff --git a/net/netfilter/core.c b/net/netfilter/core.c\nindex 8ca26729430b..db0b4195e0fe 100644\n--- a/net/netfilter/core.c\n+++ b/net/netfilter/core.c\n@@ -397,10 +397,63 @@ EXPORT_SYMBOL(nf_register_net_hooks);\n void nf_unregister_net_hooks(struct net *net, const struct nf_hook_ops *reg,\n \t\t\t unsigned int hookcount)\n {\n-\tunsigned int i;\n+\tstruct nf_hook_entries *to_free[16], *p;\n+\tstruct nf_hook_entries __rcu **pp;\n+\tunsigned int i, j, n;\n+\n+\tmutex_lock(&nf_hook_mutex);\n+\tfor (i = 0; i < hookcount; i++) {\n+\t\tpp = nf_hook_entry_head(net, ®[i]);\n+\t\tif (!pp)\n+\t\t\tcontinue;\n+\n+\t\tp = nf_entry_dereference(*pp);\n+\t\tif (WARN_ON_ONCE(!p))\n+\t\t\tcontinue;\n+\t\t__nf_unregister_net_hook(p, ®[i]);\n+\t}\n+\tmutex_unlock(&nf_hook_mutex);\n+\n+\tdo {\n+\t\tn = min_t(unsigned int, hookcount, ARRAY_SIZE(to_free));\n+\n+\t\tmutex_lock(&nf_hook_mutex);\n+\n+\t\tfor (i = 0, j = 0; i < hookcount && j < n; i++) {\n+\t\t\tpp = nf_hook_entry_head(net, ®[i]);\n+\t\t\tif (!pp)\n+\t\t\t\tcontinue;\n+\n+\t\t\tp = nf_entry_dereference(*pp);\n+\t\t\tif (!p)\n+\t\t\t\tcontinue;\n+\n+\t\t\tto_free[j] = __nf_hook_entries_try_shrink(pp);\n+\t\t\tif (to_free[j])\n+\t\t\t\t++j;\n+\t\t}\n+\n+\t\tmutex_unlock(&nf_hook_mutex);\n+\n+\t\tif (j) {\n+\t\t\tunsigned int nfq;\n+\n+\t\t\tsynchronize_net();\n+\n+\t\t\t/* need 2nd synchronize_net() if nfqueue is used, skb\n+\t\t\t * can get reinjected right before nf_queue_hook_drop()\n+\t\t\t */\n+\t\t\tnfq = nf_queue_nf_hook_drop(net);\n+\t\t\tif (nfq)\n+\t\t\t\tsynchronize_net();\n+\n+\t\t\tfor (i = 0; i < j; i++)\n+\t\t\t\tkvfree(to_free[i]);\n+\t\t}\n \n-\tfor (i = 0; i < hookcount; i++)\n-\t\tnf_unregister_net_hook(net, ®[i]);\n+\t\treg += n;\n+\t\thookcount -= n;\n+\t} while (hookcount > 0);\n }\n EXPORT_SYMBOL(nf_unregister_net_hooks);\n \n", "prefixes": [ "nf-next", "3/3" ] }