From: David Ahern <dsa@cumulusnetworks.com>
To: netdev@vger.kernel.org
Cc: rshearma@brocade.com, roopa@cumulusnetworks.com,
David Ahern <dsa@cumulusnetworks.com>
Subject: [PATCH net-next 2/2] net: mpls: Delete route when all nexthops have been deleted
Date: Fri, 24 Mar 2017 15:21:57 -0700 [thread overview]
Message-ID: <1490394117-19268-3-git-send-email-dsa@cumulusnetworks.com> (raw)
In-Reply-To: <1490394117-19268-1-git-send-email-dsa@cumulusnetworks.com>
When all devices for all nexthops in a route have been deleted, the
route is effectively dead, so remove it.
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
---
net/mpls/af_mpls.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index 3861f8dfa9c1..74755920c689 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -1299,7 +1299,7 @@ static void mpls_ifdown(struct net_device *dev, int event)
struct mpls_route __rcu **platform_label;
struct net *net = dev_net(dev);
unsigned int nh_flags = RTNH_F_DEAD | RTNH_F_LINKDOWN;
- unsigned int alive;
+ unsigned int alive, deleted;
unsigned index;
platform_label = rtnl_dereference(net->mpls.platform_label);
@@ -1310,6 +1310,7 @@ static void mpls_ifdown(struct net_device *dev, int event)
continue;
alive = 0;
+ deleted = 0;
change_nexthops(rt) {
if (rtnl_dereference(nh->nh_dev) != dev)
goto next;
@@ -1328,9 +1329,15 @@ static void mpls_ifdown(struct net_device *dev, int event)
next:
if (!(nh->nh_flags & nh_flags))
alive++;
+ if (!rtnl_dereference(nh->nh_dev))
+ deleted++;
} endfor_nexthops(rt);
WRITE_ONCE(rt->rt_nhn_alive, alive);
+
+ /* if there are no more nexthops, delete the route */
+ if (event == NETDEV_UNREGISTER && deleted == rt->rt_nhn)
+ mpls_route_update(net, index, NULL, NULL);
}
}
--
2.1.4
next prev parent reply other threads:[~2017-03-24 22:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-24 22:21 [PATCH net-next 0/2] net: mpls: multipath route cleanups David Ahern
2017-03-24 22:21 ` [PATCH net-next 1/2] net: mpls: Don't show nexthop if device has been deleted David Ahern
2017-03-26 17:20 ` Roopa Prabhu
2017-03-24 22:21 ` David Ahern [this message]
2017-03-26 17:26 ` [PATCH net-next 2/2] net: mpls: Delete route when all nexthops have " Roopa Prabhu
2017-03-27 10:17 ` [PATCH net-next 0/2] net: mpls: multipath route cleanups Robert Shearman
2017-03-27 21:12 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1490394117-19268-3-git-send-email-dsa@cumulusnetworks.com \
--to=dsa@cumulusnetworks.com \
--cc=netdev@vger.kernel.org \
--cc=roopa@cumulusnetworks.com \
--cc=rshearma@brocade.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).