Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3835243ybb; Mon, 6 Apr 2020 17:08:36 -0700 (PDT) X-Google-Smtp-Source: APiQypKiAdpaJgbukqCSbWvVWSPxe9CgCcNEdE5g3Hab9OxB3BpZb2arg2HVQK1+N5e6Sumvd1qu X-Received: by 2002:a9d:6ad2:: with SMTP id m18mr1497282otq.28.1586218116450; Mon, 06 Apr 2020 17:08:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586218116; cv=none; d=google.com; s=arc-20160816; b=c9XZbEc9Ytya6sp3fdCJWiRRbVb9FEMRmEdopPS+RtGhKGWeMj7hvMSDi7BjvlCFuR x7ote6jXkNuN9/qZB+j10O2GnncBCHDoawZu0t4aHAio0cdtzoDzjd9Qk3/u/vES5H5d 1+mXZ49r7Xryx/xiVBznpv1JDmvnhFrsZoE16kthRfCsbmx+4GREqglp9z0iF4kDqGZ1 smebD8F0jOz+PT6O2XLHETwzXATIS5axw9bEly3lSrBzo2kLv+AgvLpA8bPe7rJVckGI T2BVXecVGeXlYC9hv690xIF5rpDThbOl+FBOIcbTX9GPmr0jTFUlGPofcgRFlrTn8KHk T39w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LfPNjuO5xiGtfspHYf08ASiSgk1UQdcHwzhvJxcqTfI=; b=HAHfe0+YinXanIm9rlXdNZWkwvi3G3uacwKbJf5HzNreN42ZqPhIQUsFssWXOYzW34 CbDMv8dOq2SYiczhNi+9N++eywz1Jz1yuhXMq0+Pb2AvjlCMr+HEMYrLhwqhmJRmKpRP Cqb0vOBKjCuYM7EvlXX39LcrE+qAfXCDUzMUT2/Jir+RuOTV3f8U4whDAoX7Otl+Wi9h Q1SbPHLx27rWewY98BdsUyai5uUDRqX6yMTeZgVhcPWuGvt0mV5Owbh9yEIAL2qYEjRj k+reUcbgT1VJYBGTYXBaM3wZdV65OdV/7V/KDC4PcwWbUoowaSh9JPei/BSUhcrIUrNx jWNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SfSnBUMe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g1si522486otn.200.2020.04.06.17.08.24; Mon, 06 Apr 2020 17:08:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SfSnBUMe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727327AbgDGABl (ORCPT + 99 others); Mon, 6 Apr 2020 20:01:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:34776 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727003AbgDGABf (ORCPT ); Mon, 6 Apr 2020 20:01:35 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A4FF72082D; Tue, 7 Apr 2020 00:01:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586217694; bh=0NmjDoUM5gYgsEDS4Q8qgD6YSor5H2823HhLNhDpAmA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SfSnBUMeNxI/5WQBDs0fClS2fxoTKBZ+dTlcmZofcbtgUmKv8JV6e646+x57yMszl vO1vzawGhmhWmx9QcMX9UQUoi7e+DY1IVxcgAKJPN1xZOaj1jfELFpZQ1C7/cnebGY CSplo3hSBeRsER50KuoclQfpTvDlq/K1+KYJ9+wY= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Stefano Brivio , Pablo Neira Ayuso , Sasha Levin , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.5 28/35] netfilter: nft_set_rbtree: Introduce and use nft_rbtree_interval_start() Date: Mon, 6 Apr 2020 20:00:50 -0400 Message-Id: <20200407000058.16423-28-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200407000058.16423-1-sashal@kernel.org> References: <20200407000058.16423-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 a9f804f7a04ac..95fcba34bfd35 100644 --- a/net/netfilter/nft_set_rbtree.c +++ b/net/netfilter/nft_set_rbtree.c @@ -33,6 +33,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) { @@ -64,7 +69,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) @@ -89,7 +94,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; } @@ -224,9 +229,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)) { @@ -317,10 +322,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