Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2989356ybk; Mon, 18 May 2020 12:58:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEjgsizqwW3cBNY5ZWJUG/zQ29SajsssFFI1QcQnxi8rIbxEISsX81Sw0O/8lTAlatEkGh X-Received: by 2002:a17:906:6088:: with SMTP id t8mr14797849ejj.110.1589831921706; Mon, 18 May 2020 12:58:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589831921; cv=none; d=google.com; s=arc-20160816; b=f47i8a2lK/JgXaFJ8jBYPnx9WWAXtcbeZib5OSMFOVSWtU9iYHf/bpMiM5RKiDl1d6 BHE7KqKc9291jKJDBWsJdVBhQkoN8oYFx/aum8AHbA57oiEaC93WynwwTE2/f4ZrjoDh XCf7IEG4PpbWEB9e+/7MImHFWrELqb6AbJZlpmLfrFJ05siAEpMxkuIk+Kp6y4rnTLwo 8dQZ7kOopd/LiRDLxnrC4MZ4KY0TkKbBRWQMWn78Va5LIGgV/wXSuek7LcN4AWfME5pg vPqc3/Kdqdg/tOluZBTfqOVoSf6GkoLnT/G/u7HBi7cqYgdBReRy+acM6SKeKq7Pe7Lq CCcQ== 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=3Xdt1EzxuZdwMMyx7WtEmTiZ77nDMMJVirb7TuWLTjk=; b=D4/2uHxmiwcAA6iB1nNEPcRIbzyMFptOunQ3stwWiIy6AkUd1R1eaBuhTt6XvCWV+i Fk1/I1A00NomP9+lEG0viePXLbJtHos3JE/IdaWfvPcYMI76LBrcmzRQ9muuijh9Egbd biyAjbEr0oaLqBy8TwnGmCSoyVNr86NNR3VuHELrAqgmSOAioRrLYph2O3RQVAFAW2Im rUv40UXz/THFCeAvD9oG1zvRjdb6TY4cI5Imz7wMoYBVSfFVaU4JUCXFimgoKr6cL1UG uq5On8jJNX6OIEruEBiANjjW9j0sYE5DxwQ83SlU6vw0L8W+Vd/adWDTXqLwOkJAccxJ QVPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a1Gx3ZTN; 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 t14si882103ejj.344.2020.05.18.12.58.18; Mon, 18 May 2020 12:58:41 -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=a1Gx3ZTN; 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 S1732537AbgERS0W (ORCPT + 99 others); Mon, 18 May 2020 14:26:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:44578 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729973AbgERRph (ORCPT ); Mon, 18 May 2020 13:45:37 -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 DE6E620671; Mon, 18 May 2020 17:45:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589823937; bh=YNrWYBeTxYdb0O+DbcPxCij4hDjcu6RrXCU7kSPbevw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a1Gx3ZTN8SWf5lSY2NQjFYWsL00GpXLCSVb+W5oD80LjIyLz+mr6hqKH2jlAS6Tpx zgRyaz8e7QgZaXgf0h3QCd57O0Tf6Ihi4/hOfghxh1px44phYQsSSe6hKq9JHLMXZ1 vAyLUmSw6SU0/EyhyIO9LdZ2NKoRJ3OUkJ5lN4IM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paolo Abeni , Jakub Kicinski , Colin Walters Subject: [PATCH 4.9 71/90] net: ipv4: really enforce backoff for redirects Date: Mon, 18 May 2020 19:36:49 +0200 Message-Id: <20200518173505.712038047@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200518173450.930655662@linuxfoundation.org> References: <20200518173450.930655662@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: Paolo Abeni [ Upstream commit 57644431a6c2faac5d754ebd35780cf43a531b1a ] In commit b406472b5ad7 ("net: ipv4: avoid mixed n_redirects and rate_tokens usage") I missed the fact that a 0 'rate_tokens' will bypass the backoff algorithm. Since rate_tokens is cleared after a redirect silence, and never incremented on redirects, if the host keeps receiving packets requiring redirect it will reply ignoring the backoff. Additionally, the 'rate_last' field will be updated with the cadence of the ingress packet requiring redirect. If that rate is high enough, that will prevent the host from generating any other kind of ICMP messages The check for a zero 'rate_tokens' value was likely a shortcut to avoid the more complex backoff algorithm after a redirect silence period. Address the issue checking for 'n_redirects' instead, which is incremented on successful redirect, and does not interfere with other ICMP replies. Fixes: b406472b5ad7 ("net: ipv4: avoid mixed n_redirects and rate_tokens usage") Reported-and-tested-by: Colin Walters Signed-off-by: Paolo Abeni Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/ipv4/route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -898,7 +898,7 @@ void ip_rt_send_redirect(struct sk_buff /* Check for load limit; set rate_last to the latest sent * redirect. */ - if (peer->rate_tokens == 0 || + if (peer->n_redirects == 0 || time_after(jiffies, (peer->rate_last + (ip_rt_redirect_load << peer->n_redirects)))) {