Introduce DXR as an IPv4 longest prefix matching / FIB module

DXR maintains compressed lookup structures with a trivial search
procedure.  A two-stage trie is indexed by the more significant bits of
the search key (IPv4 address), while the remaining bits are used for
finding the next hop in a sorted array.  The tradeoff between memory
footprint and search speed depends on the split between the trie and
the remaining binary search.  The default of 20 bits of the key being
used for trie indexing yields good performance (see below) with
footprints of around 2.5 Bytes per prefix with current BGP snapshots.

Rebuilding lookup structures takes some time, which is compensated for by
batching several RIB change requests into a single FIB update, i.e. FIB
synchronization with the RIB may be delayed for a fraction of a second.
RIB to FIB synchronization, next-hop table housekeeping, and lockless
lookup capability is provided by the FIB_ALGO infrastructure.

DXR works well on modern CPUs with several MBytes of caches, especially
in VMs, where is outperforms other currently available IPv4 FIB
algorithms by a large margin.

Reviewed by:	melifaro
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D29821

(cherry picked from commit 2aca58e16f)
This commit is contained in:
Marko Zec 2021-05-05 13:45:52 +02:00
parent 7da8312f7b
commit 4715d948c5
3 changed files with 1266 additions and 0 deletions

View file

@ -120,6 +120,7 @@ SUBDIR= \
fdc \
fdescfs \
${_ffec} \
${_fib_dxr} \
filemon \
firewire \
firmware \
@ -476,6 +477,7 @@ _ipfilter= ipfilter
.if ${MK_INET_SUPPORT} != "no" && ${KERN_OPTS:MFIB_ALGO}
_dpdk_lpm4= dpdk_lpm4
_fib_dxr= fib_dxr
.endif
.if ${MK_INET6_SUPPORT} != "no" && ${KERN_OPTS:MFIB_ALGO}

View file

@ -0,0 +1,11 @@
# $FreeBSD$
SYSDIR?=${SRCTOP}/sys
.include "${SYSDIR}/conf/kern.opts.mk"
.PATH: ${SYSDIR}/netinet
KMOD= fib_dxr
SRCS= in_fib_dxr.c opt_inet.h
.include <bsd.kmod.mk>

1253
sys/netinet/in_fib_dxr.c Normal file

File diff suppressed because it is too large Load diff