From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9513214010 for ; Mon, 18 Sep 2023 12:00:46 +0000 (UTC) Received: from ganesha.gnumonks.org (ganesha.gnumonks.org [IPv6:2001:780:45:1d:225:90ff:fe52:c662]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC258133 for ; Mon, 18 Sep 2023 04:59:55 -0700 (PDT) Received: from [78.30.34.192] (port=34322 helo=gnumonks.org) by ganesha.gnumonks.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qiCuq-009r2A-JV; Mon, 18 Sep 2023 13:59:50 +0200 Date: Mon, 18 Sep 2023 13:59:47 +0200 From: Pablo Neira Ayuso To: Herbert Xu Cc: Alexander Aring , Network Development , kadlec@netfilter.org, fw@strlen.de, gfs2@lists.linux.dev, David Teigland , tgraf@suug.ch Subject: Re: nft_rhash_walk, rhashtable and resize event Message-ID: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Score: -1.9 (-) X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Hi Herbert, On Sat, Sep 16, 2023 at 11:37:51AM +0800, Herbert Xu wrote: > On Fri, Sep 15, 2023 at 10:05:06AM -0400, Alexander Aring wrote: > > > > My question is here? Is that allowed to do because a resize event may > > change the order how to iterate over a rhashtable. > > Walking over an rhashtable should be a last resort. There is > no guarantee of stability. > > If you skip entries after a resize then you may miss entries. One more question: this walk might miss entries but may it also duplicate the same entries? > If you want a stable walk, allocate an extra 8 bytes and use > a linked list. I will work on a patch to update netfilter clients for this code to use a rcu linked list. Thanks.