diff options
author | Valerian_He <1826906282@qq.com> | 2023-08-08 12:47:29 +0200 |
---|---|---|
committer | Valerian_He <1826906282@qq.com> | 2023-08-08 12:48:07 +0200 |
commit | 98efa5bc6bac9e3917afe2fa206ec795ddf86b87 (patch) | |
tree | bec88bbb7b364d234860c17efe23aa73776bce69 /bgpd/bgp_zebra.h | |
parent | Merge pull request #14064 from donaldsharp/pim_cleanup (diff) | |
download | frr-98efa5bc6bac9e3917afe2fa206ec795ddf86b87.tar.xz frr-98efa5bc6bac9e3917afe2fa206ec795ddf86b87.zip |
bgpd: bgp_path_info_extra memory optimization
Even if some of the attributes in bgp_path_info_extra are
not used, their memory is still allocated every time. It
cause a waste of memory.
This commit code deletes all unnecessary attributes and
changes the optional attributes to pointer storage. Memory
will only be allocated when they are actually used. After
optimization, extra info related memory is reduced by about
half(~400B -> ~200B).
Signed-off-by: Valerian_He <1826906282@qq.com>
Diffstat (limited to 'bgpd/bgp_zebra.h')
-rw-r--r-- | bgpd/bgp_zebra.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/bgpd/bgp_zebra.h b/bgpd/bgp_zebra.h index a0f781946..ed2d5e669 100644 --- a/bgpd/bgp_zebra.h +++ b/bgpd/bgp_zebra.h @@ -10,9 +10,10 @@ /* Macro to update bgp_original based on bpg_path_info */ #define BGP_ORIGINAL_UPDATE(_bgp_orig, _mpinfo, _bgp) \ - ((_mpinfo->extra && _mpinfo->extra->bgp_orig \ - && _mpinfo->sub_type == BGP_ROUTE_IMPORTED) \ - ? (_bgp_orig = _mpinfo->extra->bgp_orig) \ + ((_mpinfo->extra && _mpinfo->extra->vrfleak && \ + _mpinfo->extra->vrfleak->bgp_orig && \ + _mpinfo->sub_type == BGP_ROUTE_IMPORTED) \ + ? (_bgp_orig = _mpinfo->extra->vrfleak->bgp_orig) \ : (_bgp_orig = _bgp)) /* Default weight for next hop, if doing weighted ECMP. */ |