summaryrefslogtreecommitdiff
path: root/bgpd/bgp_evpn_mh.c
diff options
context:
space:
mode:
authorYuqing Zhao <xiaopanghu99@163.com>2023-07-31 20:34:48 +0800
committerYuqing Zhao <xiaopanghu99@163.com>2023-08-22 09:35:46 +0800
commit6e7f305e54f4828d58cb4b2e4c815d82a4cbe560 (patch)
tree4c01b7351f468d2139053b3cc5095e4bde67c6bd /bgpd/bgp_evpn_mh.c
parent451fb24b17cb9272981d3809f755985d9ce52f79 (diff)
bgpd: Convert from struct bgp_node to struct bgp_dest
This is based on @donaldsharp's work The current code base is the struct bgp_node data structure. The problem with this is that it creates a bunch of extra data per route_node. The table structure generates ‘holder’ nodes that are never going to receive bgp routes, and now the memory of those nodes is allocated as if they are a full bgp_node. After splitting up the bgp_node into bgp_dest and route_node, the memory of ‘holder’ node which does not have any bgp data will be allocated as the route_node, not the bgp_node, and the memory usage is reduced. The memory usage of BGP node will be reduced from 200B to 96B. The total memory usage optimization of this part is ~16.00%. Signed-off-by: Donald Sharp <sharpd@nvidia.com> Signed-off-by: Yuqing Zhao <xiaopanghu99@163.com>
Diffstat (limited to 'bgpd/bgp_evpn_mh.c')
-rw-r--r--bgpd/bgp_evpn_mh.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/bgpd/bgp_evpn_mh.c b/bgpd/bgp_evpn_mh.c
index 36bf752d48..91db9a061a 100644
--- a/bgpd/bgp_evpn_mh.c
+++ b/bgpd/bgp_evpn_mh.c
@@ -527,7 +527,7 @@ int delete_global_ead_evi_routes(struct bgp *bgp, struct bgpevpn *vpn)
{
afi_t afi;
safi_t safi;
- struct bgp_dest *rdrn, *rn;
+ struct bgp_dest *rdrn, *bd;
struct bgp_table *table;
struct bgp_path_info *pi;
@@ -543,15 +543,15 @@ int delete_global_ead_evi_routes(struct bgp *bgp, struct bgpevpn *vpn)
* Iterate over all the routes in this table and delete EAD/EVI
* routes
*/
- for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
- struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p;
+ for (bd = bgp_table_top(table); bd; bd = bgp_route_next(bd)) {
+ struct prefix_evpn *evp = (struct prefix_evpn *)&bd->rn->p;
if (evp->prefix.route_type != BGP_EVPN_AD_ROUTE)
continue;
- delete_evpn_route_entry(bgp, afi, safi, rn, &pi);
+ delete_evpn_route_entry(bgp, afi, safi, bd, &pi);
if (pi)
- bgp_process(bgp, rn, afi, safi);
+ bgp_process(bgp, bd, afi, safi);
}
}
@@ -1583,7 +1583,7 @@ static void bgp_evpn_path_es_unlink(struct bgp_path_es_info *es_info)
pi = es_info->pi;
if (BGP_DEBUG(evpn_mh, EVPN_MH_RT))
zlog_debug("vni %u path %pFX unlinked from es %s", es_info->vni,
- &pi->net->p, es->esi_str);
+ &pi->net->rn->p, es->esi_str);
if (es_info->vni)
list_delete_node(es->macip_evi_path_list,
@@ -1641,7 +1641,7 @@ void bgp_evpn_path_es_link(struct bgp_path_info *pi, vni_t vni, esi_t *esi)
bgp_evpn_path_es_unlink(es_info);
if (BGP_DEBUG(evpn_mh, EVPN_MH_RT))
- zlog_debug("vni %u path %pFX linked to es %s", vni, &pi->net->p,
+ zlog_debug("vni %u path %pFX linked to es %s", vni, &pi->net->rn->p,
es->esi_str);
/* link mac-ip path to the new destination ES */
@@ -1661,7 +1661,7 @@ static bool bgp_evpn_is_macip_path(struct bgp_path_info *pi)
* skipped) as these lists are maintained for managing
* host routes in the tenant VRF
*/
- evp = (struct prefix_evpn *)&pi->net->p;
+ evp = (struct prefix_evpn *)&pi->net->rn->p;
return is_evpn_prefix_ipaddr_v4(evp) || is_evpn_prefix_ipaddr_v6(evp);
}
@@ -1697,7 +1697,7 @@ bgp_evpn_es_path_update_on_es_vrf_chg(struct bgp_evpn_es_vrf *es_vrf,
if (BGP_DEBUG(evpn_mh, EVPN_MH_RT))
zlog_debug(
"update path %pFX linked to es %s on vrf chg",
- &pi->net->p, es->esi_str);
+ &pi->net->rn->p, es->esi_str);
bgp_evpn_route_entry_install_if_vrf_match(es_vrf->bgp_vrf, pi,
1);
}
@@ -2086,7 +2086,7 @@ static void bgp_evpn_mac_update_on_es_oper_chg(struct bgp_evpn_es *es)
if (BGP_DEBUG(evpn_mh, EVPN_MH_RT))
zlog_debug(
"update path %d %pFX linked to es %s on oper chg",
- es_info->vni, &pi->net->p, es->esi_str);
+ es_info->vni, &pi->net->rn->p, es->esi_str);
bgp_evpn_update_type2_route_entry(bgp, vpn, pi->net, pi,
__func__);
@@ -2135,7 +2135,7 @@ static void bgp_evpn_mac_update_on_es_local_chg(struct bgp_evpn_es *es,
if (BGP_DEBUG(evpn_mh, EVPN_MH_RT))
zlog_debug(
"update path %pFX linked to es %s on chg to %s",
- &pi->net->p, es->esi_str,
+ &pi->net->rn->p, es->esi_str,
is_local ? "local" : "non-local");
attr_tmp = *pi->attr;
@@ -3160,7 +3160,7 @@ bool bgp_evpn_path_es_use_nhg(struct bgp *bgp_vrf, struct bgp_path_info *pi,
esi_t *esi;
struct bgp_evpn_es_vrf *es_vrf = NULL;
struct bgp_path_info *parent_pi;
- struct bgp_node *rn;
+ struct bgp_dest *bd;
struct prefix_evpn *evp;
struct bgp_path_info *mpinfo;
bool use_l3nhg = false;
@@ -3176,11 +3176,11 @@ bool bgp_evpn_path_es_use_nhg(struct bgp *bgp_vrf, struct bgp_path_info *pi,
if (!parent_pi)
return false;
- rn = parent_pi->net;
- if (!rn)
+ bd = parent_pi->net;
+ if (!bd)
return false;
- evp = (struct prefix_evpn *)&rn->p;
+ evp = (struct prefix_evpn *)&bd->rn->p;
if (evp->prefix.route_type != BGP_EVPN_MAC_IP_ROUTE)
return false;
@@ -4706,7 +4706,7 @@ static void bgp_evpn_path_nh_unlink(struct bgp_path_evpn_nh_info *nh_info)
pi = nh_info->pi;
if (BGP_DEBUG(evpn_mh, EVPN_MH_RT))
zlog_debug("path %s unlinked from nh %s %s",
- pi->net ? prefix2str(&pi->net->p, prefix_buf,
+ pi->net ? prefix2str(&pi->net->rn->p, prefix_buf,
sizeof(prefix_buf))
: "",
nh->bgp_vrf->name_pretty, nh->nh_str);
@@ -4741,7 +4741,7 @@ static void bgp_evpn_path_nh_link(struct bgp *bgp_vrf, struct bgp_path_info *pi)
if (!bgp_vrf->evpn_nh_table) {
if (BGP_DEBUG(evpn_mh, EVPN_MH_RT))
zlog_debug("path %pFX linked to vrf %s failed",
- &pi->net->p, bgp_vrf->name_pretty);
+ &pi->net->rn->p, bgp_vrf->name_pretty);
return;
}
@@ -4764,7 +4764,7 @@ static void bgp_evpn_path_nh_link(struct bgp *bgp_vrf, struct bgp_path_info *pi)
/* find-create nh */
memset(&ip, 0, sizeof(ip));
- if (pi->net->p.family == AF_INET6) {
+ if (pi->net->rn->p.family == AF_INET6) {
SET_IPADDR_V6(&ip);
memcpy(&ip.ipaddr_v6, &pi->attr->mp_nexthop_global,
sizeof(ip.ipaddr_v6));
@@ -4788,7 +4788,7 @@ static void bgp_evpn_path_nh_link(struct bgp *bgp_vrf, struct bgp_path_info *pi)
bgp_evpn_path_nh_unlink(nh_info);
if (BGP_DEBUG(evpn_mh, EVPN_MH_RT))
- zlog_debug("path %pFX linked to nh %s %s", &pi->net->p,
+ zlog_debug("path %pFX linked to nh %s %s", &pi->net->rn->p,
nh->bgp_vrf->name_pretty, nh->nh_str);
/* link mac-ip path to the new nh */
@@ -4803,7 +4803,7 @@ static void bgp_evpn_path_nh_link(struct bgp *bgp_vrf, struct bgp_path_info *pi)
if (!nh->ref_pi)
zlog_debug(
"path %pFX linked to nh %s %s with no valid pi",
- &pi->net->p, nh->bgp_vrf->name_pretty,
+ &pi->net->rn->p, nh->bgp_vrf->name_pretty,
nh->nh_str);
}
}
@@ -4840,7 +4840,7 @@ static void bgp_evpn_nh_show_entry(struct bgp_evpn_nh *nh, struct vty *vty,
prefix_mac2str(&nh->rmac, mac_buf, sizeof(mac_buf));
if (nh->ref_pi && nh->ref_pi->net)
- prefix2str(&nh->ref_pi->net->p, prefix_buf, sizeof(prefix_buf));
+ prefix2str(&nh->ref_pi->net->rn->p, prefix_buf, sizeof(prefix_buf));
else
prefix_buf[0] = '\0';
if (json) {