Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1072766ybl; Wed, 14 Aug 2019 10:15:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvaDqatk2QEOJnG6kquCQ6HmaN49oUPHBRmk0u8dSWwpvIH50yDimu7qp3HMpbMs0okxX7 X-Received: by 2002:a63:4612:: with SMTP id t18mr206734pga.85.1565802917372; Wed, 14 Aug 2019 10:15:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565802917; cv=none; d=google.com; s=arc-20160816; b=0tdnd+zYcp9EFCjmaG69qX3Y+2GIdgnHEysODlECCInKmsJJwQE7m2S4s+0ZaRl4A4 LDlihwTYcCtVGwdr75ieozKhiRrNB0lsjjiYbOsPjX1m7EWbYQIBn6V9aktkugIiHDeB 8Mp4sL2xj2bKunkUxLf39Ti/NDXfkE6kX1fJqkHQaTXvefwonInEOLK0a7D3RIpHtsr2 IYL6OQ9S2yFSJ1RMncCGgJpcGNWEeX5IlN42E9LgJ44kOR0le+BONgtzkRSRZveslaSa EF+kHDk7FEAkmipVJB5SGcU6x7pOHHRpkEx1OgdGWtfXGQ+ZfvRqGiGC6dSFKlz5NIIq wBqw== 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=G/ZXtfM9LuDcgsptvQaUejg4IPrOFpQhLAKkR6gTTeE=; b=avD8Tvb/wonye4Kg9BwOLJ5r7WEVCUAtF9kiQg9towZHFsM7iQTfjXtzB/gTa/5H2o Og658TxGbXXtsDU2Sna+hCQwfy9lO853eIfs+qCamVRS8FICt8nJQe7eF3LVsS+2wOUa zg/A3zUvl51bV4KJ3p9HEz8TuY17REqi5kMpgMB9QBOZdCaF36u7jyr23y4ZsjrLCdUi QkqCOihoCFpCDKPD8kOxW2Sel2bFWGayvFgM9NVCZfHhTxasIHMOVEdfBzvccTDTJUXX 99fD+cBzuq2PCk75On5IdusUu1UaZrK58Cmn/1CXAuQXfUQBue6+mC1TBPZwby/DFt4K bsHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qVXEol2d; 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 b13si159885pgr.460.2019.08.14.10.15.01; Wed, 14 Aug 2019 10:15:17 -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=qVXEol2d; 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 S1730492AbfHNRNP (ORCPT + 99 others); Wed, 14 Aug 2019 13:13:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:37404 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730828AbfHNRNM (ORCPT ); Wed, 14 Aug 2019 13:13:12 -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 F03632084D; Wed, 14 Aug 2019 17:13:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802792; bh=wvmpk6+fz8d+5hIrcn2Y0L+EjVGwztU49Pg1//2cPKM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qVXEol2dHgf+aTleqxLy9WE+Qe4WG7D86ClndSBvbmIIFs1HZ8OI4Nhcjv4nBpCuE cz9nier2yYZmlIf0Uob7PBt94IJ9tmy6dr+Deys47jk6+sLWf/D4oB6bd+wQ5zo2TI x2KFmOFHFWNO9dSut+DOFLvLX5BTtVTvr5HAgCW4= 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.14 28/69] netfilter: nft_hash: fix symhash with modulus one Date: Wed, 14 Aug 2019 19:01:26 +0200 Message-Id: <20190814165747.428288200@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165744.822314328@linuxfoundation.org> References: <20190814165744.822314328@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 24f2f7567ddb7..010a565b40001 100644 --- a/net/netfilter/nft_hash.c +++ b/net/netfilter/nft_hash.c @@ -131,7 +131,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