summaryrefslogtreecommitdiff
path: root/bgpd/bgp_mplsvpn.h
diff options
context:
space:
mode:
authorValerian_He <1826906282@qq.com>2023-08-08 10:47:29 +0000
committerValerian_He <1826906282@qq.com>2023-08-08 10:48:07 +0000
commit98efa5bc6bac9e3917afe2fa206ec795ddf86b87 (patch)
treebec88bbb7b364d234860c17efe23aa73776bce69 /bgpd/bgp_mplsvpn.h
parent49f04841131b917ac6218ecba933af36f51a7f91 (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_mplsvpn.h')
-rw-r--r--bgpd/bgp_mplsvpn.h7
1 files changed, 3 insertions, 4 deletions
diff --git a/bgpd/bgp_mplsvpn.h b/bgpd/bgp_mplsvpn.h
index dcde42146c..62748a9e56 100644
--- a/bgpd/bgp_mplsvpn.h
+++ b/bgpd/bgp_mplsvpn.h
@@ -298,12 +298,11 @@ static inline bool is_route_injectable_into_vpn(struct bgp_path_info *pi)
struct bgp_table *table;
struct bgp_dest *dest;
- if (pi->sub_type != BGP_ROUTE_IMPORTED ||
- !pi->extra ||
- !pi->extra->parent)
+ if (pi->sub_type != BGP_ROUTE_IMPORTED || !pi->extra ||
+ !pi->extra->vrfleak || !pi->extra->vrfleak->parent)
return true;
- parent_pi = (struct bgp_path_info *)pi->extra->parent;
+ parent_pi = (struct bgp_path_info *)pi->extra->vrfleak->parent;
dest = parent_pi->net;
if (!dest)
return true;