From patchwork Sat Jun 17 17:42:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Wang X-Patchwork-Id: 777362 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3wql4M54mtz9s76 for ; Sun, 18 Jun 2017 03:44:51 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="K2UhvxSB"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753089AbdFQRot (ORCPT ); Sat, 17 Jun 2017 13:44:49 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:34084 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752502AbdFQRni (ORCPT ); Sat, 17 Jun 2017 13:43:38 -0400 Received: by mail-pg0-f67.google.com with SMTP id j186so10593175pge.1 for ; Sat, 17 Jun 2017 10:43:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2yPqNUssJAXAg475rCQOG3t1ZhLv0LHfwvqizitLbZM=; b=K2UhvxSBD6dvdALCwY0dI0sz5GZUAKGJRNHgDtnZ9vQoKhH1SC+22UkoZTPvDwxh48 uSYzXhfSNY/rHLZ3/L0C7zrCJixpo7WSM9vnh2NNDMtASXGABWSldKrNaiAhEakp3nUD zZ8X/4PeAC0zoQ9fJCif+nzBhLIQtmPObt9mOh5wh9Dj6ixwED484CwfrFwtGBlVTC6Z A6c89RC7sG9+QyOgoiPcVlitW01j+6bmGDo6zYDt2cvev/plQOSX6M8sj8zGFIZyaOJI pOZXZ6HB08vCS0MQo6K5J6biCXFbeScT9jSu+Jqj9NuvJixpXuHXhuEHmv4hD/t4Wk2m 4Wuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2yPqNUssJAXAg475rCQOG3t1ZhLv0LHfwvqizitLbZM=; b=babl7/wbIZgRt0k0vyZryuAhQ5fjTI2WmCf0k78GXr4xt/ifpL7Ttb8TnlqrLv1BYo 5JpXRv1RQSVxr9cB0cDitFMzvEn5OHhzY9OeZ/fUD16RX5WZlBB/ZhomZLosSqg6DNKC 7cECPsd7SMiZTUqfUJh0qucQiBKqJ7ffk8B87T9+pQOAAiz+NHDofbVLko/yk1+dlLsc O4odIf7YLBHIXGVzXlJRkdsTmeJpSq9Qlx5FeLzyb/3RcxtrAiN/MFy3+KaNTFFaBebS y7U3XAQ1EopNxWhAjYB4JP359xK4nLy6rSMeISHxtkl0J036o6LDQYdMK9mOaaDb84z5 dScQ== X-Gm-Message-State: AKS2vOzqZfPSJ2N/mUh+CGaFLwcvV0bQlhrE5RAFr42XtxhyYrH6TRA1 q3k1Japsjn1GjnoWTOo= X-Received: by 10.98.29.7 with SMTP id d7mr17089487pfd.25.1497721418077; Sat, 17 Jun 2017 10:43:38 -0700 (PDT) Received: from weiwan0.mtv.corp.google.com ([100.123.230.66]) by smtp.gmail.com with ESMTPSA id h7sm11352777pfc.97.2017.06.17.10.43.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 17 Jun 2017 10:43:37 -0700 (PDT) From: Wei Wang To: David Miller , netdev@vger.kernel.org Cc: Eric Dumazet , Martin KaFai Lau , Wei Wang Subject: [PATCH v2 net-next 07/21] ipv4: call dst_dev_put() properly Date: Sat, 17 Jun 2017 10:42:30 -0700 Message-Id: <20170617174244.132862-8-tracywwnj@gmail.com> X-Mailer: git-send-email 2.13.1.518.g3df882009-goog In-Reply-To: <20170617174244.132862-1-tracywwnj@gmail.com> References: <20170617174244.132862-1-tracywwnj@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Wei Wang As the intend of this patch series is to completely remove dst gc, we need to call dst_dev_put() to release the reference to dst->dev when removing routes from fib because we won't keep the gc list anymore and will lose the dst pointer right after removing the routes. Without the gc list, there is no way to find all the dst's that have dst->dev pointing to the going-down dev. Hence, we are doing dst_dev_put() immediately before we lose the last reference of the dst from the routing code. The next dst_check() will trigger a route re-lookup to find another route (if there is any). Signed-off-by: Wei Wang Acked-by: Martin KaFai Lau --- net/ipv4/fib_semantics.c | 2 ++ net/ipv4/route.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index 53b3e9c2da4c..f163fa0a1164 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c @@ -152,6 +152,7 @@ static void rt_fibinfo_free(struct rtable __rcu **rtp) * free_fib_info_rcu() */ + dst_dev_put(&rt->dst); dst_release(&rt->dst); dst_free(&rt->dst); } @@ -196,6 +197,7 @@ static void rt_fibinfo_free_cpus(struct rtable __rcu * __percpu *rtp) rt = rcu_dereference_protected(*per_cpu_ptr(rtp, cpu), 1); if (rt) { + dst_dev_put(&rt->dst); dst_release(&rt->dst); dst_free(&rt->dst); } diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 3dee0043117e..d986d80258d2 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -603,12 +603,14 @@ static void fnhe_flush_routes(struct fib_nh_exception *fnhe) rt = rcu_dereference(fnhe->fnhe_rth_input); if (rt) { RCU_INIT_POINTER(fnhe->fnhe_rth_input, NULL); + dst_dev_put(&rt->dst); dst_release(&rt->dst); rt_free(rt); } rt = rcu_dereference(fnhe->fnhe_rth_output); if (rt) { RCU_INIT_POINTER(fnhe->fnhe_rth_output, NULL); + dst_dev_put(&rt->dst); dst_release(&rt->dst); rt_free(rt); } @@ -1337,6 +1339,7 @@ static bool rt_bind_exception(struct rtable *rt, struct fib_nh_exception *fnhe, dst_hold(&rt->dst); rcu_assign_pointer(*porig, rt); if (orig) { + dst_dev_put(&orig->dst); dst_release(&orig->dst); rt_free(orig); } @@ -1369,6 +1372,7 @@ static bool rt_cache_route(struct fib_nh *nh, struct rtable *rt) prev = cmpxchg(p, orig, rt); if (prev == orig) { if (orig) { + dst_dev_put(&orig->dst); dst_release(&orig->dst); rt_free(orig); }