diff options
author | Neale Ranns <nranns@cisco.com> | 2017-11-25 15:20:26 -0800 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2017-11-26 19:16:30 +0000 |
commit | 84517cfd1508f6da24937f310f7fffe752f22584 (patch) | |
tree | d26e98ec23ddf2cdcc573b39650a49c890ca2bd7 /src/vnet/fib/fib_entry_src.h | |
parent | 630b9741659b9a4b68c64ebbeb675761c6f26842 (diff) |
FIB: optimise for src memory allocations
Most FIB entries will only ever have one source providing forwarding
information. Currently the source infom is stored in a vector of sources
on the FIB entry. Change this to a union of one source inline and a vector.
This saves the need to alloc a vector of sources for each FIB entry.
before:
vpp# ip route add count 1500000 1.0.0.1/32 via 10.10.10.2 loop0
4.392857e5 routes/sec
vpp# ip route del count 1500000 1.0.0.1/32 via 10.10.10.2 loop0
9.175464e5 routes/sec
vpp# ip route add count 1500000 1.0.0.1/32 via 10.10.10.2 loop0
5.193375e5 routes/sec
vpp# sh fib mem
FIB memory
Name Size in-use /allocated totals
Entry 72 1500011/ 1500011 108000792/108000792
Entry Source 32 1500011/ 1500011 48000352/48000352
after:
vpp# ip route add count 1500000 1.0.0.1/32 via 10.10.10.2 loop0
4.726560e5 routes/sec
vpp# ip route del count 1500000 1.0.0.1/32 via 10.10.10.2 loop0
1.041629e6 routes/sec
vpp# ip route add count 1500000 1.0.0.1/32 via 10.10.10.2 loop0
5.702895e5 routes/sec
vpp# sh fib mem
FIB memory
Name Size in-use /allocated totals
Entry 96 1500011/ 1500011 144001056/144001056
Entry Source 32 0 / 0 0/0
Change-Id: Ic71e413eaff1ec152656beda3b94186f7894ea49
Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/fib/fib_entry_src.h')
-rw-r--r-- | src/vnet/fib/fib_entry_src.h | 70 |
1 files changed, 48 insertions, 22 deletions
diff --git a/src/vnet/fib/fib_entry_src.h b/src/vnet/fib/fib_entry_src.h index 35c43936a1f..a19fae10a1c 100644 --- a/src/vnet/fib/fib_entry_src.h +++ b/src/vnet/fib/fib_entry_src.h @@ -105,15 +105,6 @@ typedef fib_entry_src_cover_res_t (*fib_entry_src_cover_update_t)( const fib_entry_t *fib_entry); /** - * Forwarding updated. Notification that the forwarding information for the - * entry has been updated. This notification is sent to all sources, not just - * the active best. - */ -typedef void (*fib_entry_src_fwd_update_t)(fib_entry_src_t *src, - const fib_entry_t *fib_entry, - fib_source_t best_source); - -/** * Installed. Notification that the source is now installed as * the entry's forwarding source. */ @@ -182,22 +173,56 @@ typedef struct fib_entry_src_vft_t_ { fib_entry_src_cover_update_t fesv_cover_update; fib_entry_src_format_t fesv_format; fib_entry_src_installed_t fesv_installed; - fib_entry_src_fwd_update_t fesv_fwd_update; fib_entry_src_get_data_t fesv_get_data; fib_entry_src_set_data_t fesv_set_data; } fib_entry_src_vft_t; -#define FOR_EACH_SRC_ADDED(_entry, _src, _source, action) \ -{ \ - vec_foreach(_src, _entry->fe_srcs) \ - { \ - if (_src->fes_flags & FIB_ENTRY_SRC_FLAG_ADDED) { \ - _source = _src->fes_src; \ - do { \ - action; \ - } while(0); \ - } \ - } \ +#define FOR_EACH_SRC_ADDED(_entry, _src, _source, action) \ +{ \ + if (fib_entry_has_multiple_srcs(_entry)) \ + { \ + vec_foreach(_src, _entry->fe_u_src.fe_srcs) \ + { \ + if (_src->fes_flags & FIB_ENTRY_SRC_FLAG_ADDED) { \ + _source = _src->fes_src; \ + do { \ + action; \ + } while(0); \ + } \ + } \ + } \ + else \ + { \ + _src = &_entry->fe_u_src.fe_src; \ + if (_src->fes_flags & FIB_ENTRY_SRC_FLAG_ADDED) { \ + _source = _src->fes_src; \ + do { \ + action; \ + } while(0); \ + } \ + } \ +} + +#define FOR_EACH_SRC(_entry, _src, _source, action) \ +{ \ + if (fib_entry_has_multiple_srcs(_entry)) \ + { \ + vec_foreach(_src, _entry->fe_u_src.fe_srcs) \ + { \ + _source = _src->fes_src; \ + do { \ + action; \ + } while(0); \ + } \ + } \ + else \ + { \ + _src = &_entry->fe_u_src.fe_src; \ + _source = _src->fes_src; \ + do { \ + action; \ + } while(0); \ + } \ } extern u8* fib_entry_src_format(fib_entry_t *entry, @@ -260,7 +285,7 @@ extern fib_entry_src_flag_t fib_entry_src_action_path_remove(fib_entry_t *fib_en fib_source_t source, const fib_route_path_t *path); -extern void fib_entry_src_action_installed(const fib_entry_t *fib_entry, +extern void fib_entry_src_action_installed(fib_entry_t *fib_entry, fib_source_t source); extern fib_forward_chain_type_t fib_entry_get_default_chain_type( @@ -279,6 +304,7 @@ extern void fib_entry_src_mk_lb (fib_entry_t *fib_entry, extern fib_protocol_t fib_entry_get_proto(const fib_entry_t * fib_entry); extern dpo_proto_t fib_entry_get_dpo_proto(const fib_entry_t * fib_entry); +extern u32 fib_entry_has_multiple_srcs(const fib_entry_t * fib_entry); /* * Per-source registration. declared here so we save a separate .h file for each |