ipv6: No RTNL for IPv6 routing table.
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 · linked by author and title
- v3 Latest15 patches 6 repliesApplied 15/15
- v2 posting 2/214 patches 25 repliesSuperseded
- v2 posting 1/214 patches 5 repliesSuperseded
Earlier versions · 1
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v1 | 13 patches | 2 replies | Superseded |
Changes in v3 from the cover letter
* Add patch 10
* Patch 2
* Add a note that fib6_get_table() does not require RCU
* Patch 4
* Explain the checks do not require RCU.
* Patch 6
* Update changelog s/everything as possible/as much as possible/
* Patch 7
* Explain alloc_percpu_gfp() is still needed when called via ipv6_stub.
* Patch 14
* Bundle critical section for rt->nh as fib6_add_rt2node_nh()
* Patch 15
* Add a note about lwtunnel_valid_encap_type()
Patches in v3 All 15 applied
Reviews trailers per patch
6 of 15 patches have a Reviewed-by or Acked-by.
| Patch | Paolo Abeni |
|---|---|
| 1/15 | |
| 2/15 | |
| 3/15 | A-b |
| 4/15 | |
| 5/15 | A-b |
| 6/15 | A-b |
| 7/15 | |
| 8/15 | |
| 9/15 | A-b |
| 10/15 | |
| 11/15 | |
| 12/15 | A-b |
| 13/15 | A-b |
| 14/15 | |
| 15/15 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v3 net-next 00/15] ipv6: No RTNL for IPv6 routing table.
IPv6 routing tables are protected by each table's lock and work in the interrupt context, which means we basically don't need RTNL to modify an IPv6 routing table itself.
Currently, the control paths require RTNL because we may need to perform device and nexthop lookups; we must prevent dev/nexthop from going away from the netns.
This, however, can be achieved by RCU as well.
If we are in the RCU critical section while adding an IPv6 route, synchronize_net() in __dev_change_net_namespace() and unregister_netdevice_many_notify() guarantee that the dev will not be moved to another netns or removed.
Also, nexthop is guaranteed not to be freed during the RCU grace period.
If we care about a race between nexthop removal and IPv6 route addition, we can get rid of RTNL from the control paths.
Patch 1 moves a validation for RTA_MULTIPATH earlier. Patch 2 removes RTNL for SIOCDELRT and RTM_DELROUTE. Patch 3 ~ 11 moves validation and memory allocation earlier. Patch 12 prevents a race between two requests for the same table. Patch 13 & 14 prevents the nexthop race mentioned above. Patch 15 removes RTNL for SIOCADDRT and RTM_NEWROUTE.
Test:
The script [0] lets each CPU-X create 100000 routes on table-X in a batch.
On c7a.metal-48xl EC2 instance with 192 CPUs,
without this series:
$ sudo ./route_test.sh start adding routes added 19200000 routes (100000 routes * 192 tables). total routes: 19200006 Time elapsed: 191577 milliseconds.
with this series:
$ sudo ./route_test.sh start adding routes added 19200000 routes (100000 routes * 192 tables). total routes: 19200006 Time elapsed: 62854 milliseconds.
I changed the number of routes (1000 ~ 100000 per CPU/table) and consistently saw it finish 3x faster with this series.
[0]
#!/bin/bash
mkdir tmp
NS="test"
ip netns add $NS
ip -n $NS link add veth0 type veth peer veth1
ip -n $NS link set veth0 up
ip -n $NS link set veth1 up
TABLES=()
for i in $(seq $(nproc)); do
TABLES+=("$i")done
ROUTES=()
for i in {1..100}; do
for j in {1..1000}; do
ROUTES+=("2001:$i:$j::/64")
donedone
for TABLE in "${TABLES[@]}"; do
(
FILE="./tmp/batch-table-$TABLE.txt"
> $FILE
for ROUTE in "${ROUTES[@]}"; do
echo "route add $ROUTE dev veth0 table $TABLE" >> $FILE
done
) &done
wait
echo "start adding routes"
START_TIME=$(date +%s%3N)
for TABLE in "${TABLES[@]}"; do
ip -n $NS -6 -batch "./tmp/batch-table-$TABLE.txt" &
done
wait
END_TIME=$(date +%s%3N)
ELAPSED_TIME=$((END_TIME - START_TIME))
echo "added $((${#ROUTES[@]} * ${#TABLES[@]})) routes (${#ROUTES[@]} routes * ${#TABLES[@]} tables)." echo "total routes: $(ip -n $NS -6 route show table all | wc -l)" # Just for debug echo "Time elapsed: ${ELAPSED_TIME} milliseconds."
ip netns del $NS
rm -fr ./tmp/
Changes:
v3:
* Add patch 10
* Patch 2
* Add a note that fib6_get_table() does not require RCU
* Patch 4
* Explain the checks do not require RCU.
* Patch 6
* Update changelog s/everything as possible/as much as possible/
* Patch 7
* Explain alloc_percpu_gfp() is still needed when called via ipv6_stub.
* Patch 14
* Bundle critical section for rt->nh as fib6_add_rt2node_nh()
* Patch 15
* Add a note about lwtunnel_valid_encap_type()
v2 (RESEND) : https://lore.kernel.org/netdev/[email protected]/
v2: https://lore.kernel.org/netdev/[email protected]/
* Add Patch 12
* Patch 2
* Call __ip6_del_rt() under RCU
v1: https://lore.kernel.org/netdev/[email protected]/
Kuniyuki Iwashima (15):
ipv6: Validate RTA_GATEWAY of RTA_MULTIPATH in rtm_to_fib6_config().
ipv6: Get rid of RTNL for SIOCDELRT and RTM_DELROUTE.
ipv6: Move some validation from ip6_route_info_create() to
rtm_to_fib6_config().
ipv6: Check GATEWAY in rtm_to_fib6_multipath_config().
ipv6: Move nexthop_find_by_id() after fib6_info_alloc().
ipv6: Split ip6_route_info_create().
ipv6: Preallocate rt->fib6_nh->rt6i_pcpu in ip6_route_info_create().
ipv6: Preallocate nhc_pcpu_rth_output in ip6_route_info_create().
ipv6: Don't pass net to ip6_route_info_append().
ipv6: Rename rt6_nh.next to rt6_nh.list.
ipv6: Factorise ip6_route_multipath_add().
ipv6: Protect fib6_link_table() with spinlock.
ipv6: Defer fib6_purge_rt() in fib6_add_rt2node() to fib6_add().
ipv6: Protect nh->f6i_list with spinlock and flag.
ipv6: Get rid of RTNL for SIOCADDRT and RTM_NEWROUTE.
include/net/ip6_fib.h | 1 + include/net/netns/ipv6.h | 1 + include/net/nexthop.h | 2 + net/ipv4/fib_semantics.c | 10 +- net/ipv4/nexthop.c | 22 +- net/ipv6/ip6_fib.c | 84 ++++-- net/ipv6/route.c | 577 ++++++++++++++++++++++++--------------- 7 files changed, 452 insertions(+), 245 deletions(-)
Signature · 1 line
2.49.0