Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1078827ybl; Wed, 14 Aug 2019 10:20:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0pq1qLY5dtzuGP2xhbhxwCDjZlj8dOz0C8ERQLe5E7cooHjdhpmZa7xu/e2xsAMHr7Nr8 X-Received: by 2002:a17:90a:bd0b:: with SMTP id y11mr685337pjr.141.1565803257675; Wed, 14 Aug 2019 10:20:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565803257; cv=none; d=google.com; s=arc-20160816; b=ziH+BxvUlkPkBvyZ3lH6y8MDtSyKbTQYYnDBoOPrbesYIlHLw0Aw7E1NqKoVaF4rLg IDbHydFUakxvtoaBUi3Zb67V7WWEVugQjfBaLhZ546to17qbfE+C0yXue5Tmm8BzBNgA CzNlGe3jZO0vjhcKRuLHqBjmgW+P733XW2AtRYPjpWnY0f1LuTjtjPNjPw2g8HV2vgPY XetfSIqPZAPad735O7Q6FsWHNh4zqfGK6o0PBhUSUYPVUxZmGHoYMoifDhCo9SXLiURb wURPFlRcqVOHcEad2hJdO43NZX6SAiRerRyOLVSvkUhbVvVui4woBn3Pq0lvRZkuruIO o45A== 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=/O9Df2RgFXrlxGXvGqTlDyMz4EUkmYsBY1cnVCbxc9I=; b=rNrXsVZNUYqfXIrxcsnuZJ9NLAelDGzGCvAGUZaVtSQlVNvShvw21ojfO0WG6jTZnT eHnwb9TOgw6EG1Aoj9KMxshKGI6d1wSIvU/bnBOmMgRHO1Bw7mmNRKOATPBkQhYLpeSq cni/roRkWSlP/XZEe3HHKgYHzdG7TMy7ddJ4oiog7B8W1tZbAxWxoNH15i8Fn9vQludo shJVWlJuV7Aqhs3PhSBtIMdyTa9RaqagYozjm8d4p+vSdcyXhAZV60DFkfdP1MOlnUmO aCRCPkOefYa4Fmmr/jATRr1UOMHjtqPM/i8TeST/n6ZAHbN6r/Eqfdasn7wELMYy7nev dqBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UJeqtW1k; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j12si64316pfe.188.2019.08.14.10.20.41; Wed, 14 Aug 2019 10:20:57 -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=UJeqtW1k; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730537AbfHNRKy (ORCPT + 99 others); Wed, 14 Aug 2019 13:10:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:33794 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730507AbfHNRKr (ORCPT ); Wed, 14 Aug 2019 13:10:47 -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 07FF2214DA; Wed, 14 Aug 2019 17:10:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802646; bh=zguiC8HP/MFooApydEOtzHjcprr/7Fmez4iab1u41pM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UJeqtW1kyawAwUizZsX4nV68roHre98XkeUon5WD+mFUgWhbHkgzns3x0LNDrHt+q XYf2lS5XIMx4dQib0ecBZL7JbqUpoSesoEEC5RMaU9vTYuxLUKhsU04i79UYl/gZBF Q3DL0ViXmaSCg26RIPTrxAMr068EzB+gCXSi00SM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Laura Garcia Liebana , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 4.19 37/91] netfilter: nft_hash: fix symhash with modulus one Date: Wed, 14 Aug 2019 19:01:00 +0200 Message-Id: <20190814165751.247450065@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165748.991235624@linuxfoundation.org> References: <20190814165748.991235624@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 [ Upstream commit 28b1d6ef53e3303b90ca8924bb78f31fa527cafb ] The rule below doesn't work as the kernel raises -ERANGE. nft add rule netdev nftlb lb01 ip daddr set \ symhash mod 1 map { 0 : 192.168.0.10 } fwd to "eth0" This patch allows to use the symhash modulus with one element, in the same way that the other types of hashes and algorithms that uses the modulus parameter. Signed-off-by: Laura Garcia Liebana Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nft_hash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netfilter/nft_hash.c b/net/netfilter/nft_hash.c index c2d237144f747..b8f23f75aea6c 100644 --- a/net/netfilter/nft_hash.c +++ b/net/netfilter/nft_hash.c @@ -196,7 +196,7 @@ static int nft_symhash_init(const struct nft_ctx *ctx, priv->dreg = nft_parse_register(tb[NFTA_HASH_DREG]); priv->modulus = ntohl(nla_get_be32(tb[NFTA_HASH_MODULUS])); - if (priv->modulus <= 1) + if (priv->modulus < 1) return -ERANGE; if (priv->offset + priv->modulus - 1 < priv->offset) -- 2.20.1