From patchwork Wed Jun 19 11:14:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuseppe Longo X-Patchwork-Id: 252554 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 1BE182C02C2 for ; Wed, 19 Jun 2013 21:14:28 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933991Ab3FSLO0 (ORCPT ); Wed, 19 Jun 2013 07:14:26 -0400 Received: from mail-we0-f178.google.com ([74.125.82.178]:32888 "EHLO mail-we0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933666Ab3FSLO0 (ORCPT ); Wed, 19 Jun 2013 07:14:26 -0400 Received: by mail-we0-f178.google.com with SMTP id u53so4244381wes.23 for ; Wed, 19 Jun 2013 04:14:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:from:date:message-id:user-agent:mime-version :content-type:content-transfer-encoding; bh=6bZoVc6lr55GiQ/onBEw1Kw9DMmHfrGEA+VCyXcGQWY=; b=PkRhJDYlCCwiEQQAyAZJ8rDfPimeb+mwRAHh1T88E7z8qgiuPpbKxZoWSDmSmkIcyG PVv0WWR/ngtZ8YODgESGYeQr01D3qTD7Gp/4x9ShWTPDnvs4eQwHR6QU5VOqqT4vUnZj bNNjPu9+x9pWbmz1nuGLHaZ+l5VbbGj+hNWptSppZXa6Z2zzqk2RNTMLBF+RpGvDgP9+ VTZIAn5lzTSnqaYxwS3KQeGL2C23Go7OnUdbC0MIFBuKViu5H2YLD1Jf2J/hicpQZktp FAHVv8U7f4MllkGfm4B/udVWIr7I19TomT6VTUjB2WB5xtxM6QGeM5UiwzrsVFTCHSFs up0w== X-Received: by 10.180.187.17 with SMTP id fo17mr1665491wic.60.1371640464670; Wed, 19 Jun 2013 04:14:24 -0700 (PDT) Received: from [127.0.0.1] ([46.182.90.24]) by mx.google.com with ESMTPSA id fv11sm8439498wic.11.2013.06.19.04.14.22 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 19 Jun 2013 04:14:23 -0700 (PDT) Subject: [PATCH] nft: loop optimization To: netfilter-devel@vger.kernel.org From: Giuseppe Longo Date: Wed, 19 Jun 2013 13:14:23 +0200 Message-ID: <20130619111423.7135.60976.stgit@localhost> User-Agent: StGit/0.16 MIME-Version: 1.0 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org This patch prevent in some functions to continue looping after the chain is found. Signed-off-by: Giuseppe Longo --- iptables/nft.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/iptables/nft.c b/iptables/nft.c index d51f2f3..42bf50f 100644 --- a/iptables/nft.c +++ b/iptables/nft.c @@ -1275,6 +1275,8 @@ int nft_rule_flush(struct nft_handle *h, const char *chain, const char *table) __nft_rule_flush(h, table_name, chain_name); + if (chain != NULL) + break; next: c = nft_chain_list_iter_next(iter); } @@ -1390,6 +1392,9 @@ int nft_chain_user_del(struct nft_handle *h, const char *chain, const char *tabl break; deleted_ctr++; + + if (chain != NULL) + break; next: c = nft_chain_list_iter_next(iter); } @@ -2893,6 +2898,8 @@ int nft_chain_zero_counters(struct nft_handle *h, const char *chain, if (ret < 0) perror("mnl_talk:nft_chain_zero_counters"); + if (chain != NULL) + break; next: c = nft_chain_list_iter_next(iter); }