From patchwork Tue Sep 22 22:53:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Sutter X-Patchwork-Id: 1369395 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netfilter-devel-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nwl.cc Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4BwxCF4n2qz9sSn for ; Wed, 23 Sep 2020 08:42:33 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726662AbgIVWmc (ORCPT ); Tue, 22 Sep 2020 18:42:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726448AbgIVWmc (ORCPT ); Tue, 22 Sep 2020 18:42:32 -0400 Received: from orbyte.nwl.cc (orbyte.nwl.cc [IPv6:2001:41d0:e:133a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5223C061755 for ; Tue, 22 Sep 2020 15:42:32 -0700 (PDT) Received: from localhost ([::1]:52108 helo=tatos) by orbyte.nwl.cc with esmtp (Exim 4.94) (envelope-from ) id 1kKqzX-0007Wl-5M; Wed, 23 Sep 2020 00:42:31 +0200 From: Phil Sutter To: Pablo Neira Ayuso Cc: netfilter-devel@vger.kernel.org, Serhey Popovych Subject: [iptables PATCH 3/3] libxtables: Register multiple extensions in ascending order Date: Wed, 23 Sep 2020 00:53:41 +0200 Message-Id: <20200922225341.8976-4-phil@nwl.cc> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200922225341.8976-1-phil@nwl.cc> References: <20200922225341.8976-1-phil@nwl.cc> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org The newly introduced ordered insert algorithm in xtables_register_{match,target}() works best if extensions of same name are passed in ascending revisions. Since this is the case in about all extensions' arrays, iterate over them from beginning to end. Signed-off-by: Phil Sutter --- libxtables/xtables.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libxtables/xtables.c b/libxtables/xtables.c index de74d361a53af..90b1195c45a58 100644 --- a/libxtables/xtables.c +++ b/libxtables/xtables.c @@ -1139,9 +1139,10 @@ static bool xtables_fully_register_pending_match(struct xtables_match *me, void xtables_register_matches(struct xtables_match *match, unsigned int n) { - do { - xtables_register_match(&match[--n]); - } while (n > 0); + int i; + + for (i = 0; i < n; i++) + xtables_register_match(&match[i]); } void xtables_register_target(struct xtables_target *me) @@ -1264,9 +1265,10 @@ static bool xtables_fully_register_pending_target(struct xtables_target *me, void xtables_register_targets(struct xtables_target *target, unsigned int n) { - do { - xtables_register_target(&target[--n]); - } while (n > 0); + int i; + + for (i = 0; i < n; i++) + xtables_register_target(&target[i]); } /* receives a list of xtables_rule_match, release them */