netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH net-next 0/2] Mitigate the Issue of Expired Routes in Linux IPv6 Routing Tables
@ 2023-05-17  4:27 Kui-Feng Lee
  2023-05-17  4:27 ` [RFC PATCH net-next 1/2] net: Remove expired routes with separated timers Kui-Feng Lee
  2023-05-17  4:27 ` [RFC PATCH net-next 2/2] net: Remove unused code and variables Kui-Feng Lee
  0 siblings, 2 replies; 6+ messages in thread
From: Kui-Feng Lee @ 2023-05-17  4:27 UTC (permalink / raw)
  To: netdev, ast, martin.lau, kernel-team; +Cc: Kui-Feng Lee

The size of a Linux IPv6 routing table can become a big problem if not
managed appropriately.  Now, Linux has a garbage collector to remove
expired routes periodically.  However, this may lead to a situation in
which the routing path is blocked for a long period due to an
excessive number of routes.

For example, years ago, there is a commit about "ICMPv6 Packet too big
messages".  The root cause is that malicious ICMPv6 packets were sent
back for every small packet sent to them. These packets have to
lookup/insert a new route, putting hosts under high stress due to
contention on a spinlock while one is stuck in fib6_run_gc().

Why Route Expires
=================

Users can add IPv6 routes with an expiration time manually. However,
the Neighbor Discovery protocol may also generate routes that can
expire.  For example, Router Advertisement (RA) messages may create a
default route with an expiration time. [RFC 4861] For IPv4, it is not
possible to set an expiration time for a route, and there is no RA, so
there is no need to worry about such issues.

Create Routes with Expires
==========================

You can create routes with expires with the  command.

For example,

    ip -6 route add 2001:b000:591::3 via fe80::5054:ff:fe12:3457 \ 
        dev enp0s3 expires 30

The route that has been generated will be deleted automatically in 30
seconds.

GC of FIB6
==========

The function called fib6_run_gc() is responsible for performing
garbage collection (GC) for the Linux IPv6 stack. It checks for the
expiration of every route by traversing the tries of routing
tables. The time taken to traverse a routing table increases with its
size. Holding the routing table lock during traversal is particularly
undesirable. Therefore, it is preferable to keep the lock for the
shortest possible duration.

Solution
========

The cause of the issue is keeping the routing table locked during the
traversal of large tries. To address this, the patchset eliminates
garbage collection that does the tries traversal and introduces
individual timers for each route that eventually expires.  Walking
trials are no longer necessary with the timers. Additionally, the time
required to handle a timer is consistent.

If the expiration time is long, the timer becomes less precise. The
drawback is that the longer the expiration time, the less accurate the
timer.

Kui-Feng Lee (2):
  net: Remove expired routes with separated timers.
  net: Remove unused code and variables.

 include/net/ip6_fib.h    |  21 ++---
 include/net/ip6_route.h  |   2 -
 include/net/netns/ipv6.h |   6 --
 net/ipv6/addrconf.c      |   8 +-
 net/ipv6/ip6_fib.c       | 160 ++++++++++++++++++---------------------
 net/ipv6/ndisc.c         |   4 +-
 net/ipv6/route.c         | 119 ++---------------------------
 7 files changed, 95 insertions(+), 225 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-05-17 17:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-17  4:27 [RFC PATCH net-next 0/2] Mitigate the Issue of Expired Routes in Linux IPv6 Routing Tables Kui-Feng Lee
2023-05-17  4:27 ` [RFC PATCH net-next 1/2] net: Remove expired routes with separated timers Kui-Feng Lee
2023-05-17 15:26   ` Jakub Kicinski
2023-05-17  4:27 ` [RFC PATCH net-next 2/2] net: Remove unused code and variables Kui-Feng Lee
2023-05-17 14:56   ` Simon Horman
     [not found]     ` <CAFVMQ6SX=CES2EpovCbB5eSZjZuSbxAmoACbNdLCGWdU8kf=PQ@mail.gmail.com>
2023-05-17 17:34       ` Fwd: " Kui-Feng Lee

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).