Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2457865imd; Fri, 2 Nov 2018 11:44:43 -0700 (PDT) X-Google-Smtp-Source: AJdET5d13uWsBeef8shwECQq1MCqi3GKCbD5njwxX42wvCJ87Q28Yltvvg5Wp+JUC387popATERp X-Received: by 2002:a62:29c4:: with SMTP id p187-v6mr3278095pfp.62.1541184283698; Fri, 02 Nov 2018 11:44:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541184283; cv=none; d=google.com; s=arc-20160816; b=tbcX3ko+a4qaYmah5yCnA5t4gBPJNlBasayewOfrFgsBDR3tDqX2fU0Jn36pY+dh13 OWadmKLpmKu1/h7GN2KkzpLgfjraWMv2+ek0P8yDtV5bnwDGOTc2zYzUKFJhxm88FyDU SYMzvwMpQWyEbG6DYs6LMusfofLtzuvsa2mnoxwo3QDNRwFJKP1QuCARGM5Xs0m9RzPB szcH+S9YT3krqS6S8AK4qElnxjruTjCoEzqB+dYGqFwgaCTVmUDnj17fb5/XJjp7wAPU lS/dod47ErEKKwlDTRZmlZIJNzOxIMe0ShpZZY+uytrj+F5X+YVpvovXlPcE7aXcs9d8 as5Q== 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=je0ml8POHNiJjIy6ZnZpSCpf6ZbSTPeBA/b67CFmMb0=; b=CrThr4lBBMsmBnLgPvJQI4rX8T3T0RIwqrizgfzl6zon/J5m3yrdUslYvvFwI0zOSz Ynk9mWPWsvH9cbc3K1CPfYQa4XptBxUi6bpj9wzzc/Yp6WUCQYwMhJwsz5o7SkojZSRw xE9jVg/eGsj92M2FKCsfU8DA1hlsHtS5OANyWMKwv8cJATs3zabQiC70jHuS7BCiIjwW 9f/o/RIy9GqxaLLMdvpXZgkEqBaTgr8UjoT7vghaN78tMqeEb3tt4vvpa5h3OD2RDpzs 6YNNdu4hNGRjgPeRdSVZZK8Tialw9GlvaHInM32wa5g8bb3mn7q+97pfs6DK2C+74Kxn rSMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YdGCpChE; 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 g9-v6si31283503pgp.488.2018.11.02.11.44.28; Fri, 02 Nov 2018 11:44:43 -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=YdGCpChE; 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 S1729933AbeKCDvh (ORCPT + 99 others); Fri, 2 Nov 2018 23:51:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:46808 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728961AbeKCDvg (ORCPT ); Fri, 2 Nov 2018 23:51:36 -0400 Received: from localhost (5356596B.cm-6-7b.dynamic.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 F24CF20847; Fri, 2 Nov 2018 18:43:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541184203; bh=SCWD+HAQxy1i03z8Sgw91ivvLmuJLUSarS938PYECUc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YdGCpChEWWL8sdtYEjvYkR9kbtRiSS8z0cg9xH5g2aaJPzifaO2H2CP36ESVuBou+ FnZXID7U8LjIwPZ06nFdgRvV1ThMfJ2+awknKTOy7tAG5WQSEuvUzunfr6quKIkvwE p6xwPH9UnlgQ+2tUk9SZN40jkh0fs5Q4Y5A+l4dg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sabrina Dubroca , Stefano Brivio , "David S. Miller" Subject: [PATCH 4.18 106/150] ipv6: rate-limit probes for neighbourless routes Date: Fri, 2 Nov 2018 19:34:28 +0100 Message-Id: <20181102182910.664214711@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181102182902.250560510@linuxfoundation.org> References: <20181102182902.250560510@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sabrina Dubroca [ Upstream commit f547fac624be53ad8b07e9ebca7654a7827ba61b ] When commit 270972554c91 ("[IPV6]: ROUTE: Add Router Reachability Probing (RFC4191).") introduced router probing, the rt6_probe() function required that a neighbour entry existed. This neighbour entry is used to record the timestamp of the last probe via the ->updated field. Later, commit 2152caea7196 ("ipv6: Do not depend on rt->n in rt6_probe().") removed the requirement for a neighbour entry. Neighbourless routes skip the interval check and are not rate-limited. This patch adds rate-limiting for neighbourless routes, by recording the timestamp of the last probe in the fib6_info itself. Fixes: 2152caea7196 ("ipv6: Do not depend on rt->n in rt6_probe().") Signed-off-by: Sabrina Dubroca Reviewed-by: Stefano Brivio Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- include/net/ip6_fib.h | 4 ++++ net/ipv6/route.c | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) --- a/include/net/ip6_fib.h +++ b/include/net/ip6_fib.h @@ -159,6 +159,10 @@ struct fib6_info { struct rt6_info * __percpu *rt6i_pcpu; struct rt6_exception_bucket __rcu *rt6i_exception_bucket; +#ifdef CONFIG_IPV6_ROUTER_PREF + unsigned long last_probe; +#endif + u32 fib6_metric; u8 fib6_protocol; u8 fib6_type; --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -517,10 +517,11 @@ static void rt6_probe_deferred(struct wo static void rt6_probe(struct fib6_info *rt) { - struct __rt6_probe_work *work; + struct __rt6_probe_work *work = NULL; const struct in6_addr *nh_gw; struct neighbour *neigh; struct net_device *dev; + struct inet6_dev *idev; /* * Okay, this does not seem to be appropriate @@ -536,15 +537,12 @@ static void rt6_probe(struct fib6_info * nh_gw = &rt->fib6_nh.nh_gw; dev = rt->fib6_nh.nh_dev; rcu_read_lock_bh(); + idev = __in6_dev_get(dev); neigh = __ipv6_neigh_lookup_noref(dev, nh_gw); if (neigh) { - struct inet6_dev *idev; - if (neigh->nud_state & NUD_VALID) goto out; - idev = __in6_dev_get(dev); - work = NULL; write_lock(&neigh->lock); if (!(neigh->nud_state & NUD_VALID) && time_after(jiffies, @@ -554,11 +552,13 @@ static void rt6_probe(struct fib6_info * __neigh_set_probe_once(neigh); } write_unlock(&neigh->lock); - } else { + } else if (time_after(jiffies, rt->last_probe + + idev->cnf.rtr_probe_interval)) { work = kmalloc(sizeof(*work), GFP_ATOMIC); } if (work) { + rt->last_probe = jiffies; INIT_WORK(&work->work, rt6_probe_deferred); work->target = *nh_gw; dev_hold(dev);