FreeBSD kernel IPv4 code
|
#include <sys/cdefs.h>
#include "opt_inet.h"
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/ctype.h>
#include <sys/epoch.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <sys/syslog.h>
#include <vm/uma.h>
#include <netinet/in.h>
#include <netinet/in_fib.h>
#include <net/route.h>
#include <net/route/route_ctl.h>
#include <net/route/fib_algo.h>
Go to the source code of this file.
Data Structures | |
struct | direct_entry |
struct | range_entry_long |
struct | range_entry_short |
struct | heap_entry |
struct | chunk_desc |
struct | trie_desc |
struct | dxr_aux |
struct | dxr |
Functions | |
__FBSDID ("$FreeBSD$") | |
CTASSERT (DXR_TRIE_BITS >=16 &&DXR_TRIE_BITS<=24) | |
static | MALLOC_DEFINE (M_DXRLPM, "dxr", "DXR LPM") |
static | MALLOC_DEFINE (M_DXRAUX, "dxr aux", "DXR auxiliary") |
VNET_DEFINE_STATIC (int, frag_limit) | |
static int | range_lookup (struct range_entry_long *rt, struct direct_entry de, uint32_t dst) |
static int | dxr_lookup (struct dxr *dxr, uint32_t dst) |
static void | initheap (struct dxr_aux *da, uint32_t dst_u32, uint32_t chunk) |
static uint32_t | chunk_size (struct dxr_aux *da, struct direct_entry *fdesc) |
static uint32_t | chunk_hash (struct dxr_aux *da, struct direct_entry *fdesc) |
static int | chunk_ref (struct dxr_aux *da, uint32_t chunk) |
static void | chunk_unref (struct dxr_aux *da, uint32_t chunk) |
static uint32_t | trie_hash (struct dxr_aux *da, uint32_t dxr_x, uint32_t index) |
static int | trie_ref (struct dxr_aux *da, uint32_t index) |
static void | trie_unref (struct dxr_aux *da, uint32_t index) |
static void | heap_inject (struct dxr_aux *da, uint32_t start, uint32_t end, uint32_t preflen, uint32_t nh) |
static int | dxr_walk (struct rtentry *rt, void *arg) |
static int | update_chunk (struct dxr_aux *da, uint32_t chunk) |
static void | dxr_build (struct dxr *dxr) |
static struct nhop_object * | dxr_fib_lookup (void *algo_data, const struct flm_lookup_key key, uint32_t scopeid) |
static enum flm_op_result | dxr_init (uint32_t fibnum, struct fib_data *fd, void *old_data, void **data) |
static void | dxr_destroy (void *data) |
static void | epoch_dxr_destroy (epoch_context_t ctx) |
static void * | choose_lookup_fn (struct dxr_aux *da) |
static enum flm_op_result | dxr_dump_end (void *data, struct fib_dp *dp) |
static enum flm_op_result | dxr_dump_rib_item (struct rtentry *rt, void *data) |
static enum flm_op_result | dxr_change_rib_item (struct rib_head *rnh, struct rib_cmd_info *rc, void *data) |
static enum flm_op_result | dxr_change_rib_batch (struct rib_head *rnh, struct fib_change_queue *q, void *data) |
static uint8_t | dxr_get_pref (const struct rib_rtable_info *rinfo) |
SYSCTL_DECL (_net_route_algo) | |
SYSCTL_NODE (_net_route_algo, OID_AUTO, dxr, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "DXR tunables") | |
static int | sysctl_dxr_frag_limit (SYSCTL_HANDLER_ARGS) |
SYSCTL_PROC (_net_route_algo_dxr, OID_AUTO, frag_limit, CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_VNET, 0, 0, sysctl_dxr_frag_limit, "A", "Fragmentation threshold to full rebuild") | |
static int | dxr_modevent (module_t mod, int type, void *unused) |
DECLARE_MODULE (fib_dxr, dxr_mod, SI_SUB_PSEUDO, SI_ORDER_ANY) | |
MODULE_VERSION (fib_dxr, 1) | |
Variables | |
uma_zone_t | chunk_zone |
uma_zone_t | trie_zone |
static struct fib_lookup_module | fib_dxr_mod |
static moduledata_t | dxr_mod = {"fib_dxr", dxr_modevent, 0} |
#define BASE_MAX ((1 << DESC_BASE_BITS) - 1) |
Definition at line 89 of file in_fib_dxr.c.
#define CHUNK_HASH_BITS 16 |
Definition at line 108 of file in_fib_dxr.c.
#define CHUNK_HASH_MASK (CHUNK_HASH_SIZE - 1) |
Definition at line 110 of file in_fib_dxr.c.
#define CHUNK_HASH_SIZE (1 << CHUNK_HASH_BITS) |
Definition at line 109 of file in_fib_dxr.c.
#define D_TBL_SIZE (1 << DXR_D) |
Definition at line 82 of file in_fib_dxr.c.
#define DESC_BASE_BITS 22 |
Definition at line 87 of file in_fib_dxr.c.
#define DESC_FRAGMENTS_BITS (32 - DESC_BASE_BITS) |
Definition at line 88 of file in_fib_dxr.c.
#define DIRECT_TBL_SIZE (1 << DXR_TRIE_BITS) |
Definition at line 83 of file in_fib_dxr.c.
#define DXR2 |
Definition at line 74 of file in_fib_dxr.c.
#define DXR_D 16 |
Definition at line 77 of file in_fib_dxr.c.
#define DXR_LOOKUP_DEFINE | ( | D | ) |
Definition at line 296 of file in_fib_dxr.c.
#define DXR_LOOKUP_STAGE |
Definition at line 238 of file in_fib_dxr.c.
#define DXR_RANGE_MASK (0xffffffffU >> DXR_TRIE_BITS) |
Definition at line 84 of file in_fib_dxr.c.
#define DXR_RANGE_SHIFT (32 - DXR_TRIE_BITS) |
Definition at line 85 of file in_fib_dxr.c.
#define DXR_TRIE_BITS 20 |
Definition at line 69 of file in_fib_dxr.c.
#define FRAGS_MARK_HIT (FRAGS_PREF_SHORT - 2) |
Definition at line 100 of file in_fib_dxr.c.
#define FRAGS_MARK_XL (FRAGS_PREF_SHORT - 1) |
Definition at line 99 of file in_fib_dxr.c.
#define FRAGS_MASK_SHORT ((1 << (23 - DXR_TRIE_BITS)) - 1) |
Definition at line 93 of file in_fib_dxr.c.
#define FRAGS_PREF_SHORT |
Definition at line 97 of file in_fib_dxr.c.
#define IS_LONG_FORMAT | ( | x | ) | ((x & FRAGS_PREF_SHORT) != FRAGS_PREF_SHORT) |
Definition at line 103 of file in_fib_dxr.c.
#define IS_SHORT_FORMAT | ( | x | ) | ((x & FRAGS_PREF_SHORT) == FRAGS_PREF_SHORT) |
Definition at line 102 of file in_fib_dxr.c.
#define IS_XL_FORMAT | ( | x | ) | (x == FRAGS_MARK_XL) |
Definition at line 104 of file in_fib_dxr.c.
#define RE_SHORT_MAX_NH ((1 << (DXR_TRIE_BITS - 8)) - 1) |
Definition at line 106 of file in_fib_dxr.c.
#define RTBL_SIZE_INCR (BASE_MAX / 64) |
Definition at line 90 of file in_fib_dxr.c.
#define TRIE_HASH_BITS 16 |
Definition at line 112 of file in_fib_dxr.c.
#define TRIE_HASH_MASK (TRIE_HASH_SIZE - 1) |
Definition at line 114 of file in_fib_dxr.c.
#define TRIE_HASH_SIZE (1 << TRIE_HASH_BITS) |
Definition at line 113 of file in_fib_dxr.c.
#define UNUSED_BUCKETS 8 |
Definition at line 118 of file in_fib_dxr.c.
#define V_frag_limit VNET(frag_limit) |
Definition at line 235 of file in_fib_dxr.c.
#define XTBL_SIZE_INCR (DIRECT_TBL_SIZE / 16) |
Definition at line 116 of file in_fib_dxr.c.
__FBSDID | ( | "$FreeBSD$" | ) |
|
static |
Definition at line 1181 of file in_fib_dxr.c.
References dxr_fib_lookup().
Referenced by dxr_change_rib_batch(), and dxr_dump_end().
|
static |
Definition at line 395 of file in_fib_dxr.c.
References direct_entry::base, chunk_size(), direct_entry::fragments, and dxr_aux::range_tbl.
Referenced by chunk_ref(), and chunk_unref().
Definition at line 409 of file in_fib_dxr.c.
References direct_entry::base, BASE_MAX, chunk_hash(), CHUNK_HASH_MASK, chunk_size(), chunk_zone, dxr_aux::direct_tbl, dxr_aux::fd, FRAGS_PREF_SHORT, dxr_aux::range_tbl, RTBL_SIZE_INCR, and UNUSED_BUCKETS.
Referenced by update_chunk().
|
static |
Definition at line 383 of file in_fib_dxr.c.
References direct_entry::base, direct_entry::fragments, dxr_aux::fragments, FRAGS_MASK_SHORT, IS_SHORT_FORMAT, IS_XL_FORMAT, and dxr_aux::range_tbl.
Referenced by chunk_hash(), chunk_ref(), and chunk_unref().
Definition at line 510 of file in_fib_dxr.c.
References direct_entry::base, chunk_hash(), CHUNK_HASH_MASK, chunk_size(), chunk_zone, dxr_aux::direct_tbl, dxr_aux::range_tbl, and UNUSED_BUCKETS.
Referenced by update_chunk().
CTASSERT | ( | DXR_TRIE_BITS >=16 &&DXR_TRIE_BITS<= | 24 | ) |
DECLARE_MODULE | ( | fib_dxr | , |
dxr_mod | , | ||
SI_SUB_PSEUDO | , | ||
SI_ORDER_ANY | |||
) |
|
static |
Definition at line 858 of file in_fib_dxr.c.
References dxr::aux, direct_entry::base, chunk_zone, dxr::d, dxr::d_shift, dxr_aux::d_tbl, dxr_aux::direct_tbl, DIRECT_TBL_SIZE, DXR_D, DXR_TRIE_BITS, dxr_aux::fd, dxr::fd, dxr_aux::fibnum, dxr::fibnum, direct_entry::fragments, FRAGS_MARK_HIT, FRAGS_PREF_SHORT, dxr::nh_tbl, dxr::r, dxr_aux::range_tbl, dxr_aux::refcnt, RTBL_SIZE_INCR, trie_ref(), trie_unref(), trie_zone, dxr_aux::trietbl, UNUSED_BUCKETS, update_chunk(), dxr_aux::updates_mask, V_frag_limit, dxr::x, dxr::x_mask, dxr::x_shift, dxr_aux::x_tbl, and XTBL_SIZE_INCR.
Referenced by dxr_change_rib_batch(), and dxr_dump_end().
|
static |
Definition at line 1251 of file in_fib_dxr.c.
References dxr::aux, BASE_MAX, choose_lookup_fn(), dxr::d, dxr_build(), dxr_destroy(), dxr_init(), DXR_RANGE_SHIFT, dxr::epoch_ctx, epoch_dxr_destroy(), dxr_aux::fd, dxr::fd, and dxr_aux::updates_mask.
|
static |
Definition at line 1243 of file in_fib_dxr.c.
|
static |
Definition at line 1142 of file in_fib_dxr.c.
References dxr::aux, chunk_zone, dxr::d, dxr_aux::range_tbl, dxr_aux::refcnt, trie_zone, and dxr_aux::x_tbl.
Referenced by dxr_change_rib_batch(), and epoch_dxr_destroy().
|
static |
Definition at line 1210 of file in_fib_dxr.c.
References dxr::aux, BASE_MAX, choose_lookup_fn(), dxr::d, and dxr_build().
|
static |
Definition at line 1236 of file in_fib_dxr.c.
|
static |
Definition at line 1107 of file in_fib_dxr.c.
References dxr_lookup(), and dxr::nh_tbl.
Referenced by choose_lookup_fn().
|
static |
Definition at line 1339 of file in_fib_dxr.c.
|
static |
Definition at line 1116 of file in_fib_dxr.c.
References dxr::aux, dxr::d, dxr::fd, dxr::fibnum, and dxr_aux::refcnt.
Referenced by dxr_change_rib_batch().
Definition at line 336 of file in_fib_dxr.c.
References direct_entry::base, dxr::d, dxr::d_shift, DXR_RANGE_SHIFT, direct_entry::fragments, FRAGS_MARK_HIT, dxr::r, range_lookup(), dxr::x, dxr::x_mask, and dxr::x_shift.
Referenced by dxr_fib_lookup().
|
static |
Definition at line 1399 of file in_fib_dxr.c.
References chunk_zone, fib_dxr_mod, and trie_zone.
|
static |
Definition at line 700 of file in_fib_dxr.c.
References DXR_RANGE_MASK, DXR_RANGE_SHIFT, heap_entry::end, dxr_aux::fd, heap_inject(), initheap(), range_entry_long::nexthop, heap_entry::nexthop, heap_entry::preflen, dxr_aux::range_tbl, dxr_aux::re, in_addr::s_addr, range_entry_long::start, and heap_entry::start.
Referenced by update_chunk().
|
static |
Definition at line 1173 of file in_fib_dxr.c.
References dxr_destroy(), and dxr::epoch_ctx.
Referenced by dxr_change_rib_batch().
|
static |
Definition at line 676 of file in_fib_dxr.c.
References heap_entry::end, heap_entry::nexthop, heap_entry::preflen, and heap_entry::start.
Referenced by dxr_walk().
Definition at line 356 of file in_fib_dxr.c.
References heap_entry::end, dxr_aux::fd, fib4_lookup_rt(), dxr_aux::fibnum, heap_entry::nexthop, heap_entry::preflen, in_addr::s_addr, and heap_entry::start.
Referenced by dxr_walk(), and update_chunk().
|
static |
|
static |
MODULE_VERSION | ( | fib_dxr | , |
1 | |||
) |
|
static |
Definition at line 252 of file in_fib_dxr.c.
References direct_entry::base, DXR_LOOKUP_STAGE, DXR_RANGE_MASK, direct_entry::fragments, FRAGS_MASK_SHORT, IS_SHORT_FORMAT, and IS_XL_FORMAT.
Referenced by dxr_lookup().
SYSCTL_DECL | ( | _net_route_algo | ) |
|
static |
Definition at line 1351 of file in_fib_dxr.c.
References V_frag_limit.
SYSCTL_NODE | ( | _net_route_algo | , |
OID_AUTO | , | ||
dxr | , | ||
CTLFLAG_RW| | CTLFLAG_MPSAFE, | ||
0 | , | ||
"DXR tunables" | |||
) |
SYSCTL_PROC | ( | _net_route_algo_dxr | , |
OID_AUTO | , | ||
frag_limit | , | ||
CTLTYPE_STRING|CTLFLAG_RW| | CTLFLAG_VNET, | ||
0 | , | ||
0 | , | ||
sysctl_dxr_frag_limit | , | ||
"A" | , | ||
"Fragmentation threshold to full rebuild" | |||
) |
Definition at line 579 of file in_fib_dxr.c.
References dxr_aux::direct_tbl.
Referenced by trie_ref().
Definition at line 596 of file in_fib_dxr.c.
References dxr_aux::direct_tbl, DXR_TRIE_BITS, trie_hash(), TRIE_HASH_MASK, trie_zone, dxr_aux::trietbl, dxr_aux::x_tbl, and XTBL_SIZE_INCR.
Referenced by dxr_build().
Definition at line 644 of file in_fib_dxr.c.
References trie_zone, and dxr_aux::trietbl.
Referenced by dxr_build().
Definition at line 762 of file in_fib_dxr.c.
References direct_entry::base, chunk_ref(), chunk_unref(), dxr_aux::direct_tbl, DXR_RANGE_MASK, DXR_RANGE_SHIFT, DXR_TRIE_BITS, dxr_walk(), heap_entry::end, dxr_aux::fibnum, direct_entry::fragments, dxr_aux::fragments, FRAGS_MARK_HIT, FRAGS_MARK_XL, FRAGS_PREF_SHORT, initheap(), range_entry_long::nexthop, range_entry_short::nexthop, heap_entry::nexthop, heap_entry::preflen, dxr_aux::range_tbl, dxr_aux::re, RE_SHORT_MAX_NH, range_entry_long::start, range_entry_short::start, and heap_entry::start.
Referenced by dxr_build().
VNET_DEFINE_STATIC | ( | int | , |
frag_limit | |||
) |
uma_zone_t chunk_zone |
Definition at line 231 of file in_fib_dxr.c.
Referenced by chunk_ref(), chunk_unref(), dxr_build(), dxr_destroy(), and dxr_modevent().
|
static |
Definition at line 1423 of file in_fib_dxr.c.
|
static |
Definition at line 1386 of file in_fib_dxr.c.
Referenced by dxr_modevent().
uma_zone_t trie_zone |
Definition at line 232 of file in_fib_dxr.c.
Referenced by dxr_build(), dxr_destroy(), dxr_modevent(), trie_ref(), and trie_unref().