* [PATCH net-next 1/2] net: mpls: Don't show nexthop if device has been deleted
2017-03-24 22:21 [PATCH net-next 0/2] net: mpls: multipath route cleanups David Ahern
@ 2017-03-24 22:21 ` David Ahern
2017-03-26 17:20 ` Roopa Prabhu
2017-03-24 22:21 ` [PATCH net-next 2/2] net: mpls: Delete route when all nexthops have " David Ahern
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: David Ahern @ 2017-03-24 22:21 UTC (permalink / raw)
To: netdev; +Cc: rshearma, roopa, David Ahern
If the device for a nexthop in a multipath route is deleted, the nexthop
is effectively removed from the route. Currently, a route dump still
returns the nexhop though without the device set:
$ ip -f mpls ro ls
100
nexthopvia inet 10.11.1.2 dev br0
nexthopvia inet 10.100.3.1 dev eth3
$ ip li del br0
$ ip -f mpls ro ls
100
nexthopvia inet 10.11.1.2 dev * dead linkdown
nexthopvia inet 10.100.3.1 dev eth3
Since the nexthop is effectively deleted, drop the hop from the route
dump.
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
---
net/mpls/af_mpls.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index cd8be8d5e4ad..3861f8dfa9c1 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -1769,13 +1769,15 @@ static int mpls_dump_route(struct sk_buff *skb, u32 portid, u32 seq, int event,
goto nla_put_failure;
for_nexthops(rt) {
+ dev = rtnl_dereference(nh->nh_dev);
+ if (!dev)
+ continue;
+
rtnh = nla_reserve_nohdr(skb, sizeof(*rtnh));
if (!rtnh)
goto nla_put_failure;
- dev = rtnl_dereference(nh->nh_dev);
- if (dev)
- rtnh->rtnh_ifindex = dev->ifindex;
+ rtnh->rtnh_ifindex = dev->ifindex;
if (nh->nh_flags & RTNH_F_LINKDOWN) {
rtnh->rtnh_flags |= RTNH_F_LINKDOWN;
linkdown++;
--
2.1.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 1/2] net: mpls: Don't show nexthop if device has been deleted
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
0 siblings, 0 replies; 7+ messages in thread
From: Roopa Prabhu @ 2017-03-26 17:20 UTC (permalink / raw)
To: David Ahern; +Cc: netdev, rshearma
On 3/24/17, 3:21 PM, David Ahern wrote:
> If the device for a nexthop in a multipath route is deleted, the nexthop
> is effectively removed from the route. Currently, a route dump still
> returns the nexhop though without the device set:
>
> $ ip -f mpls ro ls
> 100
> nexthopvia inet 10.11.1.2 dev br0
> nexthopvia inet 10.100.3.1 dev eth3
> $ ip li del br0
> $ ip -f mpls ro ls
> 100
> nexthopvia inet 10.11.1.2 dev * dead linkdown
> nexthopvia inet 10.100.3.1 dev eth3
>
> Since the nexthop is effectively deleted, drop the hop from the route
> dump.
>
> Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
> ---
> net/mpls/af_mpls.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
> index cd8be8d5e4ad..3861f8dfa9c1 100644
> --- a/net/mpls/af_mpls.c
> +++ b/net/mpls/af_mpls.c
> @@ -1769,13 +1769,15 @@ static int mpls_dump_route(struct sk_buff *skb, u32 portid, u32 seq, int event,
> goto nla_put_failure;
>
> for_nexthops(rt) {
> + dev = rtnl_dereference(nh->nh_dev);
> + if (!dev)
> + continue;
> +
size calculation may have to account for this too ?.
> rtnh = nla_reserve_nohdr(skb, sizeof(*rtnh));
> if (!rtnh)
> goto nla_put_failure;
>
> - dev = rtnl_dereference(nh->nh_dev);
> - if (dev)
> - rtnh->rtnh_ifindex = dev->ifindex;
> + rtnh->rtnh_ifindex = dev->ifindex;
> if (nh->nh_flags & RTNH_F_LINKDOWN) {
> rtnh->rtnh_flags |= RTNH_F_LINKDOWN;
> linkdown++;
Acked-by: Roopa Prabhu <roopa@cumulusnetworks.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net-next 2/2] net: mpls: Delete route when all nexthops have been deleted
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-24 22:21 ` David Ahern
2017-03-26 17:26 ` 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
3 siblings, 1 reply; 7+ messages in thread
From: David Ahern @ 2017-03-24 22:21 UTC (permalink / raw)
To: netdev; +Cc: rshearma, roopa, David Ahern
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 0/2] net: mpls: multipath route cleanups
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-24 22:21 ` [PATCH net-next 2/2] net: mpls: Delete route when all nexthops have " David Ahern
@ 2017-03-27 10:17 ` Robert Shearman
2017-03-27 21:12 ` David Miller
3 siblings, 0 replies; 7+ messages in thread
From: Robert Shearman @ 2017-03-27 10:17 UTC (permalink / raw)
To: David Ahern, netdev; +Cc: roopa
On 24/03/17 22:21, David Ahern wrote:
> When a device associated with a nexthop is deleted, the nexthop in
> the route is effectively removed, so remove it from the route dump.
>
> Further, when all nexhops have been deleted the route is effectively
> done, so remove the route.
>
> David Ahern (2):
> mpls: Don't show nexthop if device has been deleted
> mpls: Delete route when all nexthops have been deleted
>
> net/mpls/af_mpls.c | 17 +++++++++++++----
> 1 file changed, 13 insertions(+), 4 deletions(-)
>
Acked-by: Robert Shearman <rshearma@brocade.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 0/2] net: mpls: multipath route cleanups
2017-03-24 22:21 [PATCH net-next 0/2] net: mpls: multipath route cleanups David Ahern
` (2 preceding siblings ...)
2017-03-27 10:17 ` [PATCH net-next 0/2] net: mpls: multipath route cleanups Robert Shearman
@ 2017-03-27 21:12 ` David Miller
3 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2017-03-27 21:12 UTC (permalink / raw)
To: dsa; +Cc: netdev, rshearma, roopa
From: David Ahern <dsa@cumulusnetworks.com>
Date: Fri, 24 Mar 2017 15:21:55 -0700
> When a device associated with a nexthop is deleted, the nexthop in
> the route is effectively removed, so remove it from the route dump.
>
> Further, when all nexhops have been deleted the route is effectively
> done, so remove the route.
Series applied, but I agree with Roopa that you need to add that nexthop
NULL device check to lfib_nlmsg_size() too.
^ permalink raw reply [flat|nested] 7+ messages in thread