Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2967285ybk; Mon, 18 May 2020 12:19:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcx82tri4JjyM3brQwjVOntD87WGPPA21r9XzSsSPdcoiC25RQNC9KYnXGPZ9OW/BTIhPN X-Received: by 2002:a50:abe3:: with SMTP id u90mr15132542edc.278.1589829568332; Mon, 18 May 2020 12:19:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589829568; cv=none; d=google.com; s=arc-20160816; b=LLRjleuwDTyW+f7dwM8pYmo/4o/TpApUI7vxFwczgwIH76S7HrSjwCAHJhnNeltIJv gq23jtFe4sW+c/RW9muzqnqSNU2r2eXHha8VD4TE4RXHREJdB5aTI+Re8z4rikMPO7F6 gnqdE9rWFT4STfKmhIUkqtpQZUTgLBqCBCAQDHLsOsfNKE98cCiZQ00KMkqRUeHIXCZ6 dnVc92ep3JVgIZFCycy1rGnfwMBKd5zHP08ICCp8ePclPK9DbtbhxklU6nTC3jJH1mW3 Bg+lkrQ9CtF2DMzoH6ksfqyg1mC6bzOrFzFDtL1+829tkMb64Wuc28Ucs+kOzchDWxfR K7/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mh58B7YF2uBHgrKBy36FxV9YQ0S+js9cFD984Cjm+Rc=; b=id7ASEFEW0uOAWrIYdqI1vxKdT4vGxPMBoM3xQFn2pKZOA/b2ixj+gKDbsEJzPdH6S k0T33BLmDjKMsSP4W1CrSVyGZUAWWnYGQhY8vw40Qlr9Og9WgBq+CgAI0SIcMU/zCdw7 ne9cRvUeve/cR8AIhIhtBJ3Fnab984+I6a/elzOSaGwVMFyCNVCcE0PMew1rlfLCy/Yy 22rqI5IoXa78Va9JIsTHB5Ig8jmhKtp2FSLDExrS8+GY2GxKTQMuvz+3wSCFjKMLKy1E YbWJB4vjqUTs6R2n7v+qIbJnIkl8t1Q7zs8g8F746NvyJEaXEg9wS3/OS8wki5XP9Mu5 HRnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Mr1akdaB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i14si1881059ejp.246.2020.05.18.12.19.04; Mon, 18 May 2020 12:19:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Mr1akdaB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730898AbgERRvy (ORCPT + 99 others); Mon, 18 May 2020 13:51:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:54816 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730761AbgERRvu (ORCPT ); Mon, 18 May 2020 13:51:50 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 265FB207F5; Mon, 18 May 2020 17:51:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589824309; bh=ewKaz7VLHOf9HNs60KfzVpxH3IxyiCDrULONC5NIVjA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mr1akdaB6yrUfGWd6n+sLrOCWPboZJsPrZv+qJVdj1G7rurCmuSdZUODzMwoH86Zk E2iwbrAmX3EeNW3TMMcV1DoKLVUe51WfXHRsTYzWPWZwnuRQje9KYOqGaZIs5GLwJK NwPPlsyezz9374io3gcgWQRMhDdRMsqFbT+wBBXM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stefano Brivio , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 4.19 41/80] netfilter: nft_set_rbtree: Introduce and use nft_rbtree_interval_start() Date: Mon, 18 May 2020 19:36:59 +0200 Message-Id: <20200518173458.612903024@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200518173450.097837707@linuxfoundation.org> References: <20200518173450.097837707@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefano Brivio [ Upstream commit 6f7c9caf017be8ab0fe3b99509580d0793bf0833 ] Replace negations of nft_rbtree_interval_end() with a new helper, nft_rbtree_interval_start(), wherever this helps to visualise the problem at hand, that is, for all the occurrences except for the comparison against given flags in __nft_rbtree_get(). This gets especially useful in the next patch. Signed-off-by: Stefano Brivio Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nft_set_rbtree.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/net/netfilter/nft_set_rbtree.c b/net/netfilter/nft_set_rbtree.c index 0221510328d4f..84d317418d184 100644 --- a/net/netfilter/nft_set_rbtree.c +++ b/net/netfilter/nft_set_rbtree.c @@ -36,6 +36,11 @@ static bool nft_rbtree_interval_end(const struct nft_rbtree_elem *rbe) (*nft_set_ext_flags(&rbe->ext) & NFT_SET_ELEM_INTERVAL_END); } +static bool nft_rbtree_interval_start(const struct nft_rbtree_elem *rbe) +{ + return !nft_rbtree_interval_end(rbe); +} + static bool nft_rbtree_equal(const struct nft_set *set, const void *this, const struct nft_rbtree_elem *interval) { @@ -67,7 +72,7 @@ static bool __nft_rbtree_lookup(const struct net *net, const struct nft_set *set if (interval && nft_rbtree_equal(set, this, interval) && nft_rbtree_interval_end(rbe) && - !nft_rbtree_interval_end(interval)) + nft_rbtree_interval_start(interval)) continue; interval = rbe; } else if (d > 0) @@ -92,7 +97,7 @@ static bool __nft_rbtree_lookup(const struct net *net, const struct nft_set *set if (set->flags & NFT_SET_INTERVAL && interval != NULL && nft_set_elem_active(&interval->ext, genmask) && - !nft_rbtree_interval_end(interval)) { + nft_rbtree_interval_start(interval)) { *ext = &interval->ext; return true; } @@ -221,9 +226,9 @@ static int __nft_rbtree_insert(const struct net *net, const struct nft_set *set, p = &parent->rb_right; else { if (nft_rbtree_interval_end(rbe) && - !nft_rbtree_interval_end(new)) { + nft_rbtree_interval_start(new)) { p = &parent->rb_left; - } else if (!nft_rbtree_interval_end(rbe) && + } else if (nft_rbtree_interval_start(rbe) && nft_rbtree_interval_end(new)) { p = &parent->rb_right; } else if (nft_set_elem_active(&rbe->ext, genmask)) { @@ -314,10 +319,10 @@ static void *nft_rbtree_deactivate(const struct net *net, parent = parent->rb_right; else { if (nft_rbtree_interval_end(rbe) && - !nft_rbtree_interval_end(this)) { + nft_rbtree_interval_start(this)) { parent = parent->rb_left; continue; - } else if (!nft_rbtree_interval_end(rbe) && + } else if (nft_rbtree_interval_start(rbe) && nft_rbtree_interval_end(this)) { parent = parent->rb_right; continue; -- 2.20.1