net: mpls: Fix notifications when deleting a device
authorBenjamin Poirier <bpoirier@nvidia.com>
Mon, 29 Nov 2021 06:15:05 +0000 (15:15 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 Dec 2021 07:46:55 +0000 (08:46 +0100)
commitb0ff618f2b3fdccde8da541f53ac72f8e547ee8a
tree02c9485b60b1e64476a5bdc21816db8b487b66ab
parent550658a2d61e4eaf522c8ebc7fad76dc376bfb45
net: mpls: Fix notifications when deleting a device

commit 7d4741eacdefa5f0475431645b56baf00784df1f upstream.

There are various problems related to netlink notifications for mpls route
changes in response to interfaces being deleted:
* delete interface of only nexthop
DELROUTE notification is missing RTA_OIF attribute
* delete interface of non-last nexthop
NEWROUTE notification is missing entirely
* delete interface of last nexthop
DELROUTE notification is missing nexthop

All of these problems stem from the fact that existing routes are modified
in-place before sending a notification. Restructure mpls_ifdown() to avoid
changing the route in the DELROUTE cases and to create a copy in the
NEWROUTE case.

Fixes: f8efb73c97e2 ("mpls: multipath route support")
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/mpls/af_mpls.c