Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2875443pxp; Tue, 22 Mar 2022 07:41:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5qRTux+NkXNHGJmdMix+MdW4MJPcT9drrxj86y8VibvoSSaypPbVqzSX9WhNJDVYAyvPL X-Received: by 2002:a17:906:2f97:b0:6ce:3ef6:94be with SMTP id w23-20020a1709062f9700b006ce3ef694bemr26400292eji.136.1647960087912; Tue, 22 Mar 2022 07:41:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647960087; cv=none; d=google.com; s=arc-20160816; b=wRa3OB41XbgSLJKsXg9uxUqeLUGn8FwZSc1eS+9x3XWuVOqlXA0Lybgpx+oZTqeRsO xWMlmU8PiTkSSftqI44w1Cy3JTYmC5pYFEsWF9BI58QjIGeZrqlHd6bpJafAFPvwCSw4 /7qM7U4pVBSqOwGYHibVh2i6xqIRAMHEUcqziqjKsy5pRxH66/vCWOCXXYZ9PHt/fBim TKG7sUUYXaDTuDDUpz5iDWK7QL8qVvmGIZC91Ksu/MT5rV7JWQz7huQcHnBiVX7NvQZI JYNHyqJo/2EyV5pk3xCYoH6XO3lMDqBIL7AiCV8IO4RsipTxzXTjMXyA+9zWbp9uRuFp ORNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=6eTie8pN9DOlF868bn+y4zBjLnv2GLhQ4xR2n+oPB4o=; b=ugLy0tSpdrqcgqWP38AXoltHyrV9nxg8FAaXb2urOT5PBk2dd93NM9El13/43on36t ZfKsgVM9t/qSbtGa3KgyiuINsueP3CRnl8lg6oFuJs/Tdnn+0eWxKYRfVOxANpnnhCX5 queIa36SRoJAiSspBh0X2WcrcsLqz8z/UbpVJ+bTtMiOHO4uIMO+OQM7/9pIgsMm8jMI q0dHVGL8vuoHrNVcOawWOGJK+9NvM999HjF+pzUey7MydthxPHaG4fV8NeW+l2vWqoDl vAn3mia74HUevX1kH4MT13BROITxuZ3NZBAiBavRHvEJKc4/Mktx1cvFIe+hu7O5Sz7P 0xFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=QzvTPalS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg28-20020a170907971c00b006dfd7e71edcsi9733576ejc.381.2022.03.22.07.41.01; Tue, 22 Mar 2022 07:41:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=QzvTPalS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233767AbiCVLAV (ORCPT + 99 others); Tue, 22 Mar 2022 07:00:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231140AbiCVLAU (ORCPT ); Tue, 22 Mar 2022 07:00:20 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 531D657163; Tue, 22 Mar 2022 03:58:53 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id bi12so35403728ejb.3; Tue, 22 Mar 2022 03:58:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6eTie8pN9DOlF868bn+y4zBjLnv2GLhQ4xR2n+oPB4o=; b=QzvTPalSltc1H2yWkF7TA/9e8Udp1ApWJdjNySe8TcsiL2zt3+USc7xlja6WIms09q j7Oac21kyr1Ue9ryUmmWZXJUwmgEjcfqOsczHxYoJrErWgb31lsHM0N/jlrR2Kkv3HE3 ugKYnoHgOte8xlT3opFPTr39L/c24oQp8YHr7oojZPCXf4Phj3PX8a/LEathe2YlnxGD 7D2dC5en8o51c6mBvB38CkZJZD/HwHvMjPLGCDEr8I51RpTYvQwRlE2xSQDwRxRVbC/R 8Ma/wmPsDJM9xvdx1Galp5ZxfHuyYmfAdOJx33Dq0TkNs1vv1ViIPVC+kKhdbMO4JeM3 1/dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6eTie8pN9DOlF868bn+y4zBjLnv2GLhQ4xR2n+oPB4o=; b=guSRRA2HDYsjQvhsqAhUE1V7+NrvQiXH/R6YCfjCqpsHJ6rdEbRJiFKgere2WnMq1r q2B+Xf5IZmZvkzOZCx7OjBiHa7Lh/jkqdDxs9QuJd1mgCVAaUnrhXqLtAHqlZD8fQIRq xFLPscVd6zRAcr1ZKrBvPl/1tB3dDLynGLfM1bXkkhGaSo1llgyh85cdwnwCirytBmAA +rIwJMA828Q1IOnPVwmIWAk/xWKEpjN5CQZnS38diNeFiUODnjETby6/3vtbcaAKtuDf yVqP64+XpaAmH9NtV5QGhAt8UlgrBDrP2s0vrfzq2Q5cRhOZlotPsyg2KnPmIYhg7NMS TOyQ== X-Gm-Message-State: AOAM530OS6P3uQhp823rMrQopA7FmfSzFhRAPaFXEWaA9ikYUJHKYoch SXDZuihTNcaLQVwWXPiKV0jWriE0c+Y= X-Received: by 2002:a17:906:e87:b0:6df:8602:5801 with SMTP id p7-20020a1709060e8700b006df86025801mr25367980ejf.140.1647946731535; Tue, 22 Mar 2022 03:58:51 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id da19-20020a056402177300b00413583e0996sm9227623edb.14.2022.03.22.03.58.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Mar 2022 03:58:51 -0700 (PDT) From: Jakob Koschel To: Pablo Neira Ayuso Cc: Jakob Koschel , linux-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, Jozsef Kadlecsik , Florian Westphal , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." Subject: [PATCH v2] netfilter: nf_tables: replace unnecessary use of list_for_each_entry_continue() Date: Tue, 22 Mar 2022 11:56:44 +0100 Message-Id: <20220322105645.3667322-1-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since there is no way for list_for_each_entry_continue() to start interating in the middle of the list they can be replaced with a call to list_for_each_entry(). In preparation to limit the scope of the list iterator to the list traversal loop, the list iterator variable 'rule' should not be used past the loop. v1->v2: - also replace first usage of list_for_each_entry_continue() (Florian Westphal) Signed-off-by: Jakob Koschel --- net/netfilter/nf_tables_api.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index d71a33ae39b3..6a8239b25a66 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -8279,10 +8279,8 @@ static int nf_tables_commit_chain_prepare(struct net *net, struct nft_chain *cha if (chain->blob_next || !nft_is_active_next(net, chain)) return 0; - rule = list_entry(&chain->rules, struct nft_rule, list); - data_size = 0; - list_for_each_entry_continue(rule, &chain->rules, list) { + list_for_each_entry(rule, &chain->rules, list) { if (nft_is_active_next(net, rule)) { data_size += sizeof(*prule) + rule->dlen; if (data_size > INT_MAX) @@ -8299,7 +8297,7 @@ static int nf_tables_commit_chain_prepare(struct net *net, struct nft_chain *cha data_boundary = data + data_size; size = 0; - list_for_each_entry_continue(rule, &chain->rules, list) { + list_for_each_entry(rule, &chain->rules, list) { if (!nft_is_active_next(net, rule)) continue; base-commit: f443e374ae131c168a065ea1748feac6b2e76613 -- 2.25.1