mbox series

[v3,net-next,00/12] ipv4: fib: Convert RTM_NEWROUTE and RTM_DELROUTE to per-netns RTNL.

Message ID 20250228042328.96624-1-kuniyu@amazon.com (mailing list archive)
Headers show
Series ipv4: fib: Convert RTM_NEWROUTE and RTM_DELROUTE to per-netns RTNL. | expand

Message

Kuniyuki Iwashima Feb. 28, 2025, 4:23 a.m. UTC
Patch 1 is misc cleanup.
Patch 2 ~ 8 converts two fib_info hash tables to per-netns.
Patch 9 ~ 12 converts rtnl_lock() to rtnl_net_lcok().


Changes:
  v3:
    * Add Eric's and David's tags
    * Patch 2
      * Use kvcalloc() instead of kvmalloc_array(, __GFP_ZERO)

  v2: https://lore.kernel.org/netdev/20250226192556.21633-1-kuniyu@amazon.com/
    * Add Eric's tag except for patch 3 (due to a minor change for exit_batch())
    * Patch 3
      * Fix memleak by calling fib4_semantics_exit() properly
      * Move fib4_semantics_exit() to fib_net_exit_batch()

  v1: https://lore.kernel.org/netdev/20250225182250.74650-1-kuniyu@amazon.com/


Kuniyuki Iwashima (12):
  ipv4: fib: Use cached net in fib_inetaddr_event().
  ipv4: fib: Allocate fib_info_hash[] and fib_info_laddrhash[] by
    kvcalloc().
  ipv4: fib: Allocate fib_info_hash[] during netns initialisation.
  ipv4: fib: Make fib_info_hashfn() return struct hlist_head.
  ipv4: fib: Remove fib_info_laddrhash pointer.
  ipv4: fib: Remove fib_info_hash_size.
  ipv4: fib: Add fib_info_hash_grow().
  ipv4: fib: Namespacify fib_info hash tables.
  ipv4: fib: Hold rtnl_net_lock() for ip_fib_net_exit().
  ipv4: fib: Hold rtnl_net_lock() in ip_rt_ioctl().
  ipv4: fib: Move fib_valid_key_len() to rtm_to_fib_config().
  ipv4: fib: Convert RTM_NEWROUTE and RTM_DELROUTE to per-netns RTNL.

 include/net/ip_fib.h     |   2 +
 include/net/netns/ipv4.h |   3 +
 net/ipv4/fib_frontend.c  |  74 ++++++++++----
 net/ipv4/fib_semantics.c | 206 +++++++++++++++++++--------------------
 net/ipv4/fib_trie.c      |  22 -----
 5 files changed, 159 insertions(+), 148 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org March 3, 2025, 11:36 p.m. UTC | #1
Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 27 Feb 2025 20:23:16 -0800 you wrote:
> Patch 1 is misc cleanup.
> Patch 2 ~ 8 converts two fib_info hash tables to per-netns.
> Patch 9 ~ 12 converts rtnl_lock() to rtnl_net_lcok().
> 
> 
> Changes:
>   v3:
>     * Add Eric's and David's tags
>     * Patch 2
>       * Use kvcalloc() instead of kvmalloc_array(, __GFP_ZERO)
> 
> [...]

Here is the summary with links:
  - [v3,net-next,01/12] ipv4: fib: Use cached net in fib_inetaddr_event().
    https://git.kernel.org/netdev/net-next/c/e5bf1c39e894
  - [v3,net-next,02/12] ipv4: fib: Allocate fib_info_hash[] and fib_info_laddrhash[] by kvcalloc().
    https://git.kernel.org/netdev/net-next/c/fa336adc100e
  - [v3,net-next,03/12] ipv4: fib: Allocate fib_info_hash[] during netns initialisation.
    https://git.kernel.org/netdev/net-next/c/cfc47029fa12
  - [v3,net-next,04/12] ipv4: fib: Make fib_info_hashfn() return struct hlist_head.
    https://git.kernel.org/netdev/net-next/c/84c75e94ecee
  - [v3,net-next,05/12] ipv4: fib: Remove fib_info_laddrhash pointer.
    https://git.kernel.org/netdev/net-next/c/0dbca8c269ba
  - [v3,net-next,06/12] ipv4: fib: Remove fib_info_hash_size.
    https://git.kernel.org/netdev/net-next/c/d6306b9d9885
  - [v3,net-next,07/12] ipv4: fib: Add fib_info_hash_grow().
    https://git.kernel.org/netdev/net-next/c/b79bcaf7d952
  - [v3,net-next,08/12] ipv4: fib: Namespacify fib_info hash tables.
    https://git.kernel.org/netdev/net-next/c/9f7f3ebeba93
  - [v3,net-next,09/12] ipv4: fib: Hold rtnl_net_lock() for ip_fib_net_exit().
    https://git.kernel.org/netdev/net-next/c/af5cd2a8f078
  - [v3,net-next,10/12] ipv4: fib: Hold rtnl_net_lock() in ip_rt_ioctl().
    https://git.kernel.org/netdev/net-next/c/c0ebe1cdc2cf
  - [v3,net-next,11/12] ipv4: fib: Move fib_valid_key_len() to rtm_to_fib_config().
    https://git.kernel.org/netdev/net-next/c/254ba7e6032d
  - [v3,net-next,12/12] ipv4: fib: Convert RTM_NEWROUTE and RTM_DELROUTE to per-netns RTNL.
    https://git.kernel.org/netdev/net-next/c/1dd2af7963e9

You are awesome, thank you!
Jakub Kicinski March 4, 2025, 2:39 p.m. UTC | #2
On Thu, 27 Feb 2025 20:23:16 -0800 Kuniyuki Iwashima wrote:
> Patch 1 is misc cleanup.
> Patch 2 ~ 8 converts two fib_info hash tables to per-netns.
> Patch 9 ~ 12 converts rtnl_lock() to rtnl_net_lcok().

I think there's another leak. Not 100% reproducible but one of the runs
of the device csum test hit:

unreferenced object 0xffff888005c35440 (size 1576):
  comm "csum", pid 366, jiffies 4294693057
  hex dump (first 32 bytes):
    c0 00 02 01 c0 00 02 02 00 00 00 00 84 d0 ff 00  ................
    02 00 01 41 00 00 00 00 00 00 00 00 00 00 00 00  ...A............
  backtrace (crc 3c3950b5):
    kmem_cache_alloc_noprof+0x2ad/0x350
    sk_prot_alloc.constprop.0+0x4e/0x1b0
    sk_alloc+0x36/0x6c0
    inet_create.part.0.constprop.0+0x289/0xea0
    __sock_create+0x23c/0x6a0
    __sys_socket+0x11c/0x1e0
    __x64_sys_socket+0x72/0xb0
    do_syscall_64+0xc1/0x1d0
    entry_SYSCALL_64_after_hwframe+0x77/0x7f

https://netdev-3.bots.linux.dev/vmksft-drv-hw-dbg/results/17921/2-csum-py/stdout
Kuniyuki Iwashima March 4, 2025, 6:49 p.m. UTC | #3
From: Jakub Kicinski <kuba@kernel.org>
Date: Tue, 4 Mar 2025 06:39:28 -0800
> On Thu, 27 Feb 2025 20:23:16 -0800 Kuniyuki Iwashima wrote:
> > Patch 1 is misc cleanup.
> > Patch 2 ~ 8 converts two fib_info hash tables to per-netns.
> > Patch 9 ~ 12 converts rtnl_lock() to rtnl_net_lcok().
> 
> I think there's another leak. Not 100% reproducible but one of the runs
> of the device csum test hit:

Looks like v6 sk is also leaked...
Will try csum test.

Thanks!


> 
> unreferenced object 0xffff888005c35440 (size 1576):
>   comm "csum", pid 366, jiffies 4294693057
>   hex dump (first 32 bytes):
>     c0 00 02 01 c0 00 02 02 00 00 00 00 84 d0 ff 00  ................
>     02 00 01 41 00 00 00 00 00 00 00 00 00 00 00 00  ...A............
>   backtrace (crc 3c3950b5):
>     kmem_cache_alloc_noprof+0x2ad/0x350
>     sk_prot_alloc.constprop.0+0x4e/0x1b0
>     sk_alloc+0x36/0x6c0
>     inet_create.part.0.constprop.0+0x289/0xea0
>     __sock_create+0x23c/0x6a0
>     __sys_socket+0x11c/0x1e0
>     __x64_sys_socket+0x72/0xb0
>     do_syscall_64+0xc1/0x1d0
>     entry_SYSCALL_64_after_hwframe+0x77/0x7f
> 
> https://netdev-3.bots.linux.dev/vmksft-drv-hw-dbg/results/17921/2-csum-py/stdout