From: David Ahern <dahe…@nvidia.com>
When rt6_get_pcpu_route() finds that a pcpu dst of a route using a
nexthop object has been invalidated, it takes the dst out of its slot
and calls dst_dev_put() on it. That points the dst at the blackhole
device and makes its output a discard, although the dst may still be
held: by a socket, a tunnel dst_cache, an xfrm bundle, or an skb that
has not reached dst_output() yet (a queued or NFQUEUE reinjected
packet, async crypto). Those packets are dropped, where the holder
would have noticed that the dst is stale at its next check and looked
the route up again.
The dst does have to be detached from its device when the device is
unregistered: it is no longer reachable from the FIB, and a holder
such as an idle socket can keep it indefinitely, which would hold the
device. Put it on the uncached list instead. It keeps working until its
holders let go, and rt6_uncached_list_flush_dev() detaches it on
unregister like any other uncached dst.
Fixes: 8f34e53b60b3 ("ipv6: Use global sernum for dst validation with nexthop objects")
Reported-by: Ralf Lici <ra…@mandelbit.com>
Signed-off-by: David Ahern <dahe…@nvidia.com>
---
net/ipv6/route.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index c41c5ca23fe1..31ebcf665216 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1483,7 +1483,13 @@ static struct rt6_info *rt6_get_pcpu_route(const struct fib6_result *res)
/* Paired with READ_ONCE() in __fib6_drop_pcpu_from() */
prev = xchg(p, NULL);
if (prev) {
- dst_dev_put(&prev->dst);
+ /* Holders may still be using it until they notice it
+ * is stale, so keep it working rather than dst_dev_put()
+ * it, which would turn the packets of anyone who has
+ * not rechecked yet into drops. Device unregister
+ * detaches it like any other uncached dst.
+ */
+ rt6_uncached_list_add(prev);
dst_release(&prev->dst);
}
--
2.54.0 (Apple Git-157)