Page MenuHomeFreeBSD

route/fib_algo: Fix nexthop index collision across families
Needs ReviewPublic

Authored by pouria on Wed, Sep 9, 10:32 PM.
Tags
None
Referenced Files
F171268111: D59552.id186311.diff
Thu, Sep 10, 12:03 AM
F171268086: D59552.id186312.diff
Thu, Sep 10, 12:03 AM
F171267839: D59552.diff
Thu, Sep 10, 12:00 AM
Subscribers

Details

Reviewers
melifaro
glebius
markj
Group Reviewers
network
Summary

fib_algo indexes its idx->nhop array by the nexthop index with
assumption of its uniqueness. Which is true except for IPv4 over
IPv6 nexthops.
Give each index space its own segment within the same array and
offset the index by the segment base. Segments are created on demand
and sized independently, so the rib's own family keeps base 0 and
tables without cross-family nexthops index exactly as before.

MFC after: 2 weeks

Test Plan

Before this patch you can trigger this panic under INVARIANTS by using overlapping idx across families

panic: index table contains whong nh
# netstat -on4
Nexthop data

Internet:
Idx   IFA                Gateway            Flags         Netif  Refcnt
1     127.0.0.1          lo0/resolve        H               lo0     2
2     172.23.1.101       vtnet0/resolve                  vtnet0     2
3     127.0.0.1          lo0/resolve        HS              lo0     2
4     172.23.1.101       172.23.1.1         GS           vtnet0     2
# netstat -on6
Nexthop data

Internet6:
Idx   IFA                           Gateway                       Flags         Netif  Refcnt
1     ::1                           lo0/resolve                   HS              lo0     2
2     fe80::1%lo0                   lo0/resolve                   HS              lo0     2
3     fe80::1%lo0                   lo0/resolve                                   lo0     2
4     ::1                           lo0/resolve                   HS              lo0     3
5     fdb5:c59b:114e::a             vtnet0/resolve                             vtnet0     8
6     ::1                           lo0/resolve                   RS              lo0     5
# route -n4 add -net 192.0.2.0/24 -gateway 172.23.1.102
add net 192.0.2.0: gateway 172.23.1.102 fib 0
# route -n4 add -net 192.0.3.0/24 -gateway 172.23.1.103
add net 192.0.3.0: gateway 172.23.1.103 fib 0
# route -n4 add -net 192.0.4.0/24 -gateway 172.23.1.104
add net 192.0.4.0: gateway 172.23.1.104 fib 0
# route -n4 add -net 192.0.5.0/24 -inet6 -gateway fdb5:c59b:114e::a
add net 192.0.5.0: gateway fdb5:c59b:114e::a fib 0

## Delete the same index in another family, try multiple time to find the right time.
# route -n4 del -net 192.0.4.0/24 -gateway 172.23.1.104
panic: index table contains whong nh
cpuid = 5
time = 1788995613
KDB: stack backtrace:
#0 0xffffffff80ca0745 at kdb_backtrace+0x75
#1 0xffffffff80c4ab59 at vpanic+0x149
#2 0xffffffff80c4aa03 at panic+0x43
#3 0xffffffff80dd935b at fib_unref_nhop+0x13b
#4 0xffffffff80ddf080 at rib_notify+0x50
#5 0xffffffff80ddb1f6 at rt_delete_conditional+0xf6
#6 0xffffffff80ddaed9 at rib_del_route_px+0x1e9
#7 0xffffffff80f00a64 at rtnl_handle_delroute+0x124
#8 0xffffffff80ef73dd at rtnl_handle_message+0x13d
#9 0xffffffff80ef5c0a at nl_receive_message+0x12a
#10 0xffffffff80ef5545 at nl_taskqueue_handler+0x3f5
#11 0xffffffff80cbaa5b at taskqueue_run_locked+0x1bb
#12 0xffffffff80cbba93 at taskqueue_thread_loop+0xd3
#13 0xffffffff80bf7352 at fork_exit+0x82
#14 0xffffffff811afece at fork_trampoline+0xe
KDB: enter: panic

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 76722
Build 73605: arc lint + arc unit