Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.2/patches/809803/?format=api
{ "id": 809803, "url": "http://patchwork.ozlabs.org/api/1.2/patches/809803/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/1504555874-4168-13-git-send-email-pablo@netfilter.org/", "project": { "id": 7, "url": "http://patchwork.ozlabs.org/api/1.2/projects/7/?format=api", "name": "Linux network development", "link_name": "netdev", "list_id": "netdev.vger.kernel.org", "list_email": "netdev@vger.kernel.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<1504555874-4168-13-git-send-email-pablo@netfilter.org>", "list_archive_url": null, "date": "2017-09-04T20:11:14", "name": "[12/12] netfilter: nf_tables: support for recursive chain deletion", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "1d5291d01ee62e08a55f5fc6082c6207fd8cbd77", "submitter": { "id": 1315, "url": "http://patchwork.ozlabs.org/api/1.2/people/1315/?format=api", "name": "Pablo Neira Ayuso", "email": "pablo@netfilter.org" }, "delegate": { "id": 34, "url": "http://patchwork.ozlabs.org/api/1.2/users/34/?format=api", "username": "davem", "first_name": "David", "last_name": "Miller", "email": "davem@davemloft.net" }, "mbox": "http://patchwork.ozlabs.org/project/netdev/patch/1504555874-4168-13-git-send-email-pablo@netfilter.org/mbox/", "series": [ { "id": 1451, "url": "http://patchwork.ozlabs.org/api/1.2/series/1451/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=1451", "date": "2017-09-04T20:11:02", "name": "[01/12] netfilter: xt_hashlimit: add rate match mode", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/1451/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/809803/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/809803/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<netdev-owner@vger.kernel.org>", "X-Original-To": "patchwork-incoming@ozlabs.org", "Delivered-To": "patchwork-incoming@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=netdev-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 3xmLbM080pz9t2R\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 5 Sep 2017 06:11:43 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1754713AbdIDULk (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 4 Sep 2017 16:11:40 -0400", "from mail.us.es ([193.147.175.20]:42168 \"EHLO mail.us.es\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1754712AbdIDULf (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tMon, 4 Sep 2017 16:11:35 -0400", "from antivirus1-rhel7.int (unknown [192.168.2.11])\n\tby mail.us.es (Postfix) with ESMTP id A58C2532F86\n\tfor <netdev@vger.kernel.org>; Mon, 4 Sep 2017 22:11:07 +0200 (CEST)", "from antivirus1-rhel7.int (localhost [127.0.0.1])\n\tby antivirus1-rhel7.int (Postfix) with ESMTP id 96792B502D\n\tfor <netdev@vger.kernel.org>; Mon, 4 Sep 2017 22:11:07 +0200 (CEST)", "by antivirus1-rhel7.int (Postfix, from userid 99)\n\tid 8C202B502A; Mon, 4 Sep 2017 22:11:07 +0200 (CEST)", "from antivirus1-rhel7.int (localhost [127.0.0.1])\n\tby antivirus1-rhel7.int (Postfix) with ESMTP id 72A70B5026;\n\tMon, 4 Sep 2017 22:11:05 +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 22:11:05 +0200 (CEST)", "from salvia.here (129.166.216.87.static.jazztel.es\n\t[87.216.166.129]) (Authenticated sender: pneira@us.es)\n\tby entrada.int (Postfix) with ESMTPA id 191334265A20;\n\tMon, 4 Sep 2017 22:11:05 +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 12/12] netfilter: nf_tables: support for recursive chain\n\tdeletion", "Date": "Mon, 4 Sep 2017 22:11:14 +0200", "Message-Id": "<1504555874-4168-13-git-send-email-pablo@netfilter.org>", "X-Mailer": "git-send-email 2.1.4", "In-Reply-To": "<1504555874-4168-1-git-send-email-pablo@netfilter.org>", "References": "<1504555874-4168-1-git-send-email-pablo@netfilter.org>", "X-Virus-Scanned": "ClamAV using ClamSMTP", "Sender": "netdev-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<netdev.vger.kernel.org>", "X-Mailing-List": "netdev@vger.kernel.org" }, "content": "This patch sorts out an asymmetry in deletions. Currently, table and set\ndeletion commands come with an implicit content flush on deletion.\nHowever, chain deletion results in -EBUSY if there is content in this\nchain, so no implicit flush happens. So you have to send a flush command\nin first place to delete chains, this is inconsistent and it can be\nannoying in terms of user experience.\n\nThis patch uses the new NLM_F_NONREC flag to request non-recursive chain\ndeletion, ie. if the chain to be removed contains rules, then this\nreturns EBUSY. This problem was discussed during the NFWS'17 in Faro,\nPortugal. In iptables, you hit -EBUSY if you try to delete a chain that\ncontains rules, so you have to flush first before you can remove\nanything. Since iptables-compat uses the nf_tables netlink interface, it\nhas to use the NLM_F_NONREC flag from userspace to retain the original\niptables semantics, ie. bail out on removing chains that contain rules.\n\nSigned-off-by: Pablo Neira Ayuso <pablo@netfilter.org>\n---\n net/netfilter/nf_tables_api.c | 24 +++++++++++++++++++++++-\n 1 file changed, 23 insertions(+), 1 deletion(-)", "diff": "diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c\nindex 47fc7cd3f936..929927171426 100644\n--- a/net/netfilter/nf_tables_api.c\n+++ b/net/netfilter/nf_tables_api.c\n@@ -1617,8 +1617,11 @@ static int nf_tables_delchain(struct net *net, struct sock *nlsk,\n \tstruct nft_af_info *afi;\n \tstruct nft_table *table;\n \tstruct nft_chain *chain;\n+\tstruct nft_rule *rule;\n \tint family = nfmsg->nfgen_family;\n \tstruct nft_ctx ctx;\n+\tu32 use;\n+\tint err;\n \n \tafi = nf_tables_afinfo_lookup(net, family, false);\n \tif (IS_ERR(afi))\n@@ -1631,11 +1634,30 @@ static int nf_tables_delchain(struct net *net, struct sock *nlsk,\n \tchain = nf_tables_chain_lookup(table, nla[NFTA_CHAIN_NAME], genmask);\n \tif (IS_ERR(chain))\n \t\treturn PTR_ERR(chain);\n-\tif (chain->use > 0)\n+\n+\tif (nlh->nlmsg_flags & NLM_F_NONREC &&\n+\t chain->use > 0)\n \t\treturn -EBUSY;\n \n \tnft_ctx_init(&ctx, net, skb, nlh, afi, table, chain, nla);\n \n+\tuse = chain->use;\n+\tlist_for_each_entry(rule, &chain->rules, list) {\n+\t\tif (!nft_is_active_next(net, rule))\n+\t\t\tcontinue;\n+\t\tuse--;\n+\n+\t\terr = nft_delrule(&ctx, rule);\n+\t\tif (err < 0)\n+\t\t\treturn err;\n+\t}\n+\n+\t/* There are rules and elements that are still holding references to us,\n+\t * we cannot do a recursive removal in this case.\n+\t */\n+\tif (use > 0)\n+\t\treturn -EBUSY;\n+\n \treturn nft_delchain(&ctx);\n }\n \n", "prefixes": [ "12/12" ] }