mbox series

[net-next,v2,00/10] Add notifications when route hardware flags change

Message ID 20210201194757.3463461-1-idosch@idosch.org (mailing list archive)
Headers show
Series Add notifications when route hardware flags change | expand

Message

Ido Schimmel Feb. 1, 2021, 7:47 p.m. UTC
From: Ido Schimmel <idosch@nvidia.com>

Routes installed to the kernel can be programmed to capable devices, in
which case they are marked with one of two flags. RTM_F_OFFLOAD for
routes that offload traffic from the kernel and RTM_F_TRAP for routes
that trap packets to the kernel for processing (e.g., host routes).

These flags are of interest to routing daemons since they would like to
delay advertisement of routes until they are installed in hardware. This
allows them to avoid packet loss or misrouted packets. Currently,
routing daemons do not receive any notifications when these flags are
changed, requiring them to poll the kernel tables for changes which is
inefficient.

This series addresses the issue by having the kernel emit RTM_NEWROUTE
notifications whenever these flags change. The behavior is controlled by
two sysctls (net.ipv4.fib_notify_on_flag_change and
net.ipv6.fib_notify_on_flag_change) that default to 0 (no
notifications).

Note that even if route installation in hardware is improved to be more
synchronous, these notifications are still of interest. For example, a
multipath route can change from RTM_F_OFFLOAD to RTM_F_TRAP if its
neighbours become invalid. A routing daemon can choose to withdraw /
replace the route in that case. In addition, the deletion of a route
from the kernel can prompt the installation of an identical route
(already in kernel, with an higher metric) to hardware.

For testing purposes, netdevsim is aligned to simulate a "real" driver
that programs routes to hardware.

Series overview:

Patches #1-#2 align netdevsim to perform route programming in a
non-atomic context

Patches #3-#5 add sysctl to control IPv4 notifications

Patches #6-#8 add sysctl to control IPv6 notifications

Patch #9 extends existing fib tests to set sysctls before running tests

Patch #10 adds test for fib notifications over netdevsim

v2:
* Patch #1: Use atomic64_sub() in nsim_nexthop_account()'s error path

Amit Cohen (10):
  netdevsim: fib: Convert the current occupancy to an atomic variable
  netdevsim: fib: Perform the route programming in a non-atomic context
  net: ipv4: Pass fib_rt_info as const to fib_dump_info()
  net: ipv4: Publish fib_nlmsg_size()
  net: ipv4: Emit notification when fib hardware flags are changed
  net: Pass 'net' struct as first argument to fib6_info_hw_flags_set()
  net: Do not call fib6_info_hw_flags_set() when IPv6 is disabled
  net: ipv6: Emit notification when fib hardware flags are changed
  selftests: Extend fib tests to run with and without flags
    notifications
  selftests: netdevsim: Add fib_notifications test

 Documentation/networking/ip-sysctl.rst        |  40 ++
 .../ethernet/mellanox/mlxsw/spectrum_router.c |  23 +-
 drivers/net/netdevsim/fib.c                   | 534 ++++++++++++------
 include/net/ip6_fib.h                         |   9 +-
 include/net/netns/ipv4.h                      |   2 +
 include/net/netns/ipv6.h                      |   1 +
 net/ipv4/af_inet.c                            |   2 +
 net/ipv4/fib_lookup.h                         |   3 +-
 net/ipv4/fib_semantics.c                      |   4 +-
 net/ipv4/fib_trie.c                           |  27 +
 net/ipv4/sysctl_net_ipv4.c                    |   9 +
 net/ipv6/af_inet6.c                           |   1 +
 net/ipv6/route.c                              |  44 ++
 net/ipv6/sysctl_net_ipv6.c                    |   9 +
 .../selftests/drivers/net/mlxsw/fib.sh        |  14 +
 .../selftests/drivers/net/netdevsim/fib.sh    |  14 +
 .../net/netdevsim/fib_notifications.sh        | 300 ++++++++++
 17 files changed, 854 insertions(+), 182 deletions(-)
 create mode 100755 tools/testing/selftests/drivers/net/netdevsim/fib_notifications.sh

Comments

patchwork-bot+netdevbpf@kernel.org Feb. 3, 2021, 2 a.m. UTC | #1
Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

On Mon,  1 Feb 2021 21:47:47 +0200 you wrote:
> From: Ido Schimmel <idosch@nvidia.com>
> 
> Routes installed to the kernel can be programmed to capable devices, in
> which case they are marked with one of two flags. RTM_F_OFFLOAD for
> routes that offload traffic from the kernel and RTM_F_TRAP for routes
> that trap packets to the kernel for processing (e.g., host routes).
> 
> [...]

Here is the summary with links:
  - [net-next,v2,01/10] netdevsim: fib: Convert the current occupancy to an atomic variable
    https://git.kernel.org/netdev/net-next/c/9e635a21cae0
  - [net-next,v2,02/10] netdevsim: fib: Perform the route programming in a non-atomic context
    https://git.kernel.org/netdev/net-next/c/0ae3eb7b4611
  - [net-next,v2,03/10] net: ipv4: Pass fib_rt_info as const to fib_dump_info()
    https://git.kernel.org/netdev/net-next/c/085547891de5
  - [net-next,v2,04/10] net: ipv4: Publish fib_nlmsg_size()
    https://git.kernel.org/netdev/net-next/c/1e7bdec6bbc7
  - [net-next,v2,05/10] net: ipv4: Emit notification when fib hardware flags are changed
    https://git.kernel.org/netdev/net-next/c/680aea08e78c
  - [net-next,v2,06/10] net: Pass 'net' struct as first argument to fib6_info_hw_flags_set()
    https://git.kernel.org/netdev/net-next/c/fbaca8f895a6
  - [net-next,v2,07/10] net: Do not call fib6_info_hw_flags_set() when IPv6 is disabled
    https://git.kernel.org/netdev/net-next/c/efc42879ec9e
  - [net-next,v2,08/10] net: ipv6: Emit notification when fib hardware flags are changed
    https://git.kernel.org/netdev/net-next/c/907eea486888
  - [net-next,v2,09/10] selftests: Extend fib tests to run with and without flags notifications
    https://git.kernel.org/netdev/net-next/c/d1a7a489287c
  - [net-next,v2,10/10] selftests: netdevsim: Add fib_notifications test
    https://git.kernel.org/netdev/net-next/c/19d36d2971e6

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html