diff options
| author | Valerian_He <1826906282@qq.com> | 2023-08-08 10:47:29 +0000 | 
|---|---|---|
| committer | Valerian_He <1826906282@qq.com> | 2023-08-08 10:48:07 +0000 | 
| commit | 98efa5bc6bac9e3917afe2fa206ec795ddf86b87 (patch) | |
| tree | bec88bbb7b364d234860c17efe23aa73776bce69 /bgpd/bgp_mpath.c | |
| parent | 49f04841131b917ac6218ecba933af36f51a7f91 (diff) | |
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_mpath.c')
| -rw-r--r-- | bgpd/bgp_mpath.c | 9 | 
1 files changed, 5 insertions, 4 deletions
diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c index e920d5753e..f2d1ee0bf3 100644 --- a/bgpd/bgp_mpath.c +++ b/bgpd/bgp_mpath.c @@ -173,10 +173,11 @@ int bgp_path_info_nexthop_cmp(struct bgp_path_info *bpi1,  	 * if they belong to same VRF  	 */  	if (!compare && bpi1->attr->nh_type != NEXTHOP_TYPE_BLACKHOLE) { -		if (bpi1->extra && bpi1->extra->bgp_orig && bpi2->extra -		    && bpi2->extra->bgp_orig) { -			if (bpi1->extra->bgp_orig->vrf_id -			    != bpi2->extra->bgp_orig->vrf_id) { +		if (bpi1->extra && bpi1->extra->vrfleak && +		    bpi1->extra->vrfleak->bgp_orig && bpi2->extra && +		    bpi2->extra->vrfleak && bpi2->extra->vrfleak->bgp_orig) { +			if (bpi1->extra->vrfleak->bgp_orig->vrf_id != +			    bpi2->extra->vrfleak->bgp_orig->vrf_id) {  				compare = 1;  			}  		}  | 
