mbox series

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

Message ID 20250225182250.74650-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. 25, 2025, 6:22 p.m. UTC
Patch 1 is a misc cleanup.
Patch 2 ~ 8 converts two fib_info hash tables to per-netns.
Patch 9 ~ 12 converts rtnl_lock() to rtnl_net_lcok().


Kuniyuki Iwashima (12):
  ipv4: fib: Use cached net in fib_inetaddr_event().
  ipv4: fib: Allocate fib_info_hash[] and fib_info_laddrhash[] by
    kvmalloc_array().
  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  |  72 ++++++++++----
 net/ipv4/fib_semantics.c | 207 +++++++++++++++++++--------------------
 net/ipv4/fib_trie.c      |  22 -----
 5 files changed, 158 insertions(+), 148 deletions(-)

Comments

Jakub Kicinski Feb. 26, 2025, 12:24 a.m. UTC | #1
On Tue, 25 Feb 2025 10:22:38 -0800 Kuniyuki Iwashima wrote:
> Patch 1 is a misc cleanup.
> Patch 2 ~ 8 converts two fib_info hash tables to per-netns.
> Patch 9 ~ 12 converts rtnl_lock() to rtnl_net_lcok().

Breaks quite a few tests :(

unreferenced object 0xffff88800bfc6800 (size 256):
  comm "ip", pid 577, jiffies 4294699578
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace (crc 0):
    __kmalloc_node_noprof+0x35d/0x4a0
    fib4_semantics_init+0x25/0xf0
    fib_net_init+0x17e/0x340
    ops_init+0x189/0x550
    setup_net+0x189/0x750
    copy_net_ns+0x1f7/0x340
    create_new_namespaces+0x35f/0x920
    unshare_nsproxy_namespaces+0x8d/0x130
    ksys_unshare+0x2a9/0x660
    __x64_sys_unshare+0x31/0x40
    do_syscall_64+0xc1/0x1d0
    entry_SYSCALL_64_after_hwframe+0x77/0x7f
Kuniyuki Iwashima Feb. 26, 2025, 12:46 a.m. UTC | #2
From: Jakub Kicinski <kuba@kernel.org>
Date: Tue, 25 Feb 2025 16:24:48 -0800
> On Tue, 25 Feb 2025 10:22:38 -0800 Kuniyuki Iwashima wrote:
> > Patch 1 is a misc cleanup.
> > Patch 2 ~ 8 converts two fib_info hash tables to per-netns.
> > Patch 9 ~ 12 converts rtnl_lock() to rtnl_net_lcok().
> 
> Breaks quite a few tests :(

Oh, sorry... why I didn't notice this silly mistake :/
I enabled kmemleak on my debug config.
Will fix in v2.

---8<---
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index b9ead0257340..34cfea5c127b 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -1666,7 +1666,7 @@ static void __net_exit fib_net_exit(struct net *net)
 {
 	fib_proc_exit(net);
 	nl_fib_lookup_exit(net);
-	fib4_semantics_init(net);
+	fib4_semantics_exit(net);
 }
 
 static void __net_exit fib_net_exit_batch(struct list_head *net_list)
---8<---


> 
> unreferenced object 0xffff88800bfc6800 (size 256):
>   comm "ip", pid 577, jiffies 4294699578
>   hex dump (first 32 bytes):
>     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
>     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
>   backtrace (crc 0):
>     __kmalloc_node_noprof+0x35d/0x4a0
>     fib4_semantics_init+0x25/0xf0
>     fib_net_init+0x17e/0x340