Skip to content

net: fib_rules: RTNL-less RTM_NEWRULE and RTM_DELRULE.

Kuniyuki Iwashima netdev 1 version Applied

Status from this message: This series was applied to netdev/net-next.git (main)

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest10 patches 4 repliesApplied 10/10

Patches in v1 All 10 applied

#Subject and filesSizeRepliesApplied
1/10net: fib_rules: Make fib_rules_ops.delete() return void.include/net/fib_rules.h net/core/fib_rules.c net/ipv4/fib_rules.c +1 more+5 -120 repliesApplied
2/10ipv4: fib_rules: Make the need for fib_unmerge() explicit.net/ipv4/fib_rules.c+6 -40 repliesApplied
3/10ipv4: fib: Protect fib_new_table() with spinlock.include/net/netns/ipv4.h net/ipv4/fib_frontend.c+22 -40 repliesApplied
4/10ipv4: fib: Drop RTNL annotation for net->ipv4.fib_table_hash[].include/net/ip_fib.h net/ipv4/fib_frontend.c net/ipv4/fib_trie.c+16 -130 repliesApplied
5/10net: fib_rules: Add fib_rules_ops.lock.include/net/fib_rules.h net/core/fib_rules.c+19 -20 repliesApplied
6/10net: fib_rules: Remove unnecessary EXPORT_SYMBOL.net/core/fib_rules.c+0 -70 repliesApplied
7/10net: fib_rules: Drop RTNL assertions.net/core/fib_rules.c+3 -61 replyApplied
8/10net: fib_rules: Use dev_get_by_name_rcu().net/core/fib_rules.c+14 -100 repliesApplied
9/10net: fib_rules: Only hold RTNL for the first IPv4 RTM_NEWRULE.include/net/fib_rules.h net/core/fib_rules.c net/ipv4/fib_rules.c+13 -90 repliesApplied
10/10ipv6: fib_rules: Convert fib6_rules_net_exit_rtnl() to ->exit().net/ipv6/fib6_rules.c+3 -101 replyApplied

Reviews trailers per patch

None of the 10 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchIdo Schimmel
SeriesR-b
1/10
2/10
3/10
4/10
5/10
6/10
7/10
8/10
9/10
10/10

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH v1 net-next 00/10] net: fib_rules: RTNL-less RTM_NEWRULE and RTM_DELRULE.

RTM_NEWRULE and RTM_DELRULE acquire rtnl_net_lock(), but this is only for fib_unmerge() in IPv4.

Since commit d954a67a7dfa ("ipv4: fib_rule: Move fib4_rules_exit() to ->exit()."), RTM_DELRULE no longer needs RTNL.

fib_unmerge() is one-time event for each netns, so we only need RTNL for the first IPv4 rule.

This series introduces per-fib_rules_ops mutex and drops RTNL from fib_rules code except for the first IPv4 RTM_NEWRULE.

The script below creates 1K rules in parallel in 4K netns, and it got 20x/30x faster for IPv4/IPv6.

#!/bin/bash
N=4096
F=rules.txt

for i in $(seq $N); do ip netns add ns-$i; done printf 'rule add from all table %d\n' {1..1024} > $F

  for v in 4 6; do
        echo "=== IPv${v} ==="
        time { for i in $(seq $N); do nsenter \
        --net=/var/run/netns/ns-$i ip -$v -batch $F & done; wait; }
  done

  for i in $(seq $N); do ip netns del ns-$i; done
  rm -f $F

Without this series:

  # ./test.sh
  === IPv4 ===
  real  0m22.752s
  user  0m7.834s
  sys   92m46.721s

=== IPv6 ===

  real  0m35.181s
  user  0m8.635s
  sys   142m30.479s

With this series:

  # ./test.sh
  === IPv4 ===
  real  0m0.918s
  user  0m5.675s
  sys   2m7.024s

=== IPv6 ===

  real  0m1.214s
  user  0m7.917s
  sys   4m19.489s

Kuniyuki Iwashima (10):
net: fib_rules: Make fib_rules_ops.delete() return void.
ipv4: fib_rules: Make the need for fib_unmerge() explicit.
ipv4: fib: Protect fib_new_table() with spinlock.
ipv4: fib: Drop RTNL annotation for net->ipv4.fib_table_hash[].
net: fib_rules: Add fib_rules_ops.lock.
net: fib_rules: Remove unnecessary EXPORT_SYMBOL.
net: fib_rules: Drop RTNL assertions.
net: fib_rules: Use dev_get_by_name_rcu().
net: fib_rules: Only hold RTNL for the first IPv4 RTM_NEWRULE.
ipv6: fib_rules: Convert fib6_rules_net_exit_rtnl() to ->exit().

 include/net/fib_rules.h  |  4 +-
 include/net/ip_fib.h     |  3 +-
 include/net/netns/ipv4.h |  1 +
 net/core/fib_rules.c     | 82 +++++++++++++++++++++-------------------
 net/ipv4/fib_frontend.c  | 48 ++++++++++++++++-------
 net/ipv4/fib_rules.c     | 20 ++++++----
 net/ipv4/fib_trie.c      |  3 +-
 net/ipv6/fib6_rules.c    | 17 ++-------
 8 files changed, 101 insertions(+), 77 deletions(-)
Signature · 1 line
2.55.0.rc0.799.gd6f94ed593-goog