mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-11 16:39:33 +00:00
bgpd: Abstract bgp_table retrieving/setting from info pointer
Convert the set/get of bgp_table's from the info pointer. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
6f94b685d0
commit
67009e2200
@ -2134,7 +2134,7 @@ static int delete_global_type2_routes(struct bgp *bgp, struct bgpevpn *vpn)
|
||||
|
||||
rdrn = bgp_node_lookup(bgp->rib[afi][safi], (struct prefix *)&vpn->prd);
|
||||
if (rdrn && bgp_node_has_bgp_path_info_data(rdrn)) {
|
||||
table = (struct bgp_table *)rdrn->info;
|
||||
table = bgp_node_get_bgp_table_info(rdrn);
|
||||
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
|
||||
struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p;
|
||||
|
||||
@ -2908,7 +2908,7 @@ static int install_uninstall_routes_for_es(struct bgp *bgp,
|
||||
*/
|
||||
for (rd_rn = bgp_table_top(bgp->rib[afi][safi]); rd_rn;
|
||||
rd_rn = bgp_route_next(rd_rn)) {
|
||||
table = (struct bgp_table *)(rd_rn->info);
|
||||
table = bgp_node_get_bgp_table_info(rd_rn);
|
||||
if (!table)
|
||||
continue;
|
||||
|
||||
@ -2981,7 +2981,7 @@ static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf, int install)
|
||||
*/
|
||||
for (rd_rn = bgp_table_top(bgp_def->rib[afi][safi]); rd_rn;
|
||||
rd_rn = bgp_route_next(rd_rn)) {
|
||||
table = (struct bgp_table *)(rd_rn->info);
|
||||
table = bgp_node_get_bgp_table_info(rd_rn);
|
||||
if (!table)
|
||||
continue;
|
||||
|
||||
@ -3065,7 +3065,7 @@ static int install_uninstall_routes_for_vni(struct bgp *bgp,
|
||||
/* EVPN routes are a 2-level table. */
|
||||
for (rd_rn = bgp_table_top(bgp->rib[afi][safi]); rd_rn;
|
||||
rd_rn = bgp_route_next(rd_rn)) {
|
||||
table = (struct bgp_table *)(rd_rn->info);
|
||||
table = bgp_node_get_bgp_table_info(rd_rn);
|
||||
if (!table)
|
||||
continue;
|
||||
|
||||
@ -5230,7 +5230,7 @@ int bgp_filter_evpn_routes_upon_martian_nh_change(struct bgp *bgp)
|
||||
/* EVPN routes are a 2-level table. */
|
||||
for (rd_rn = bgp_table_top(bgp->rib[afi][safi]); rd_rn;
|
||||
rd_rn = bgp_route_next(rd_rn)) {
|
||||
table = (struct bgp_table *)(rd_rn->info);
|
||||
table = bgp_node_get_bgp_table_info(rd_rn);
|
||||
if (!table)
|
||||
continue;
|
||||
|
||||
|
@ -1041,7 +1041,8 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
|
||||
if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0)
|
||||
continue;
|
||||
|
||||
if ((table = rn->info) == NULL)
|
||||
table = bgp_node_get_bgp_table_info(rn);
|
||||
if (!table)
|
||||
continue;
|
||||
|
||||
rd_header = 1;
|
||||
@ -2039,7 +2040,7 @@ static void evpn_show_route_vni_multicast(struct vty *vty, struct bgp *bgp,
|
||||
/* See if route exists. */
|
||||
build_evpn_type3_prefix(&p, orig_ip);
|
||||
rn = bgp_node_lookup(vpn->route_table, (struct prefix *)&p);
|
||||
if (!rn || !rn->info) {
|
||||
if (!rn || !bgp_node_has_bgp_path_info_data(rn)) {
|
||||
if (!json)
|
||||
vty_out(vty, "%% Network not in table\n");
|
||||
return;
|
||||
@ -2109,7 +2110,7 @@ static void evpn_show_route_vni_macip(struct vty *vty, struct bgp *bgp,
|
||||
/* See if route exists. Look for both non-sticky and sticky. */
|
||||
build_evpn_type2_prefix(&p, mac, ip);
|
||||
rn = bgp_node_lookup(vpn->route_table, (struct prefix *)&p);
|
||||
if (!rn || !rn->info) {
|
||||
if (!rn || !bgp_node_has_bgp_path_info_data(rn)) {
|
||||
if (!json)
|
||||
vty_out(vty, "%% Network not in table\n");
|
||||
return;
|
||||
@ -2213,7 +2214,7 @@ static void evpn_show_route_rd_macip(struct vty *vty, struct bgp *bgp,
|
||||
build_evpn_type2_prefix(&p, mac, ip);
|
||||
rn = bgp_afi_node_lookup(bgp->rib[afi][safi], afi, safi,
|
||||
(struct prefix *)&p, prd);
|
||||
if (!rn || !rn->info) {
|
||||
if (!rn || !bgp_node_has_bgp_path_info_data(rn)) {
|
||||
if (!json)
|
||||
vty_out(vty, "%% Network not in table\n");
|
||||
return;
|
||||
@ -2284,7 +2285,7 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
|
||||
if (!rd_rn)
|
||||
return;
|
||||
|
||||
table = (struct bgp_table *)rd_rn->info;
|
||||
table = bgp_node_get_bgp_table_info(rd_rn);
|
||||
if (table == NULL)
|
||||
return;
|
||||
|
||||
@ -2408,7 +2409,7 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
|
||||
int add_rd_to_json = 0;
|
||||
uint64_t tbl_ver;
|
||||
|
||||
table = (struct bgp_table *)rd_rn->info;
|
||||
table = bgp_node_get_bgp_table_info(rd_rn);
|
||||
if (table == NULL)
|
||||
continue;
|
||||
|
||||
|
@ -961,7 +961,7 @@ void vpn_leak_from_vrf_withdraw_all(struct bgp *bgp_vpn, /* to */
|
||||
struct bgp_path_info *bpi;
|
||||
|
||||
/* This is the per-RD table of prefixes */
|
||||
table = prn->info;
|
||||
table = bgp_node_get_bgp_table_info(prn);
|
||||
|
||||
if (!table)
|
||||
continue;
|
||||
@ -1381,7 +1381,7 @@ void vpn_leak_to_vrf_update_all(struct bgp *bgp_vrf, /* to */
|
||||
memcpy(prd.val, prn->p.u.val, 8);
|
||||
|
||||
/* This is the per-RD table of prefixes */
|
||||
table = prn->info;
|
||||
table = bgp_node_get_bgp_table_info(prn);
|
||||
|
||||
if (!table)
|
||||
continue;
|
||||
|
134
bgpd/bgp_route.c
134
bgpd/bgp_route.c
@ -120,11 +120,12 @@ struct bgp_node *bgp_afi_node_get(struct bgp_table *table, afi_t afi,
|
||||
|| (safi == SAFI_EVPN)) {
|
||||
prn = bgp_node_get(table, (struct prefix *)prd);
|
||||
|
||||
if (prn->info == NULL)
|
||||
prn->info = bgp_table_init(table->bgp, afi, safi);
|
||||
if (!bgp_node_has_bgp_path_info_data(prn))
|
||||
bgp_node_set_bgp_table_info(
|
||||
prn, bgp_table_init(table->bgp, afi, safi));
|
||||
else
|
||||
bgp_unlock_node(prn);
|
||||
table = prn->info;
|
||||
table = bgp_node_get_bgp_table_info(prn);
|
||||
}
|
||||
|
||||
rn = bgp_node_get(table, p);
|
||||
@ -157,7 +158,7 @@ struct bgp_node *bgp_afi_node_lookup(struct bgp_table *table, afi_t afi,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
table = prn->info;
|
||||
table = bgp_node_get_bgp_table_info(prn);
|
||||
}
|
||||
|
||||
rn = bgp_node_lookup(table, p);
|
||||
@ -2743,8 +2744,8 @@ static void bgp_rib_withdraw(struct bgp_node *rn, struct bgp_path_info *pi,
|
||||
|
||||
prn = bgp_node_get(peer->bgp->rib[afi][safi],
|
||||
(struct prefix *)prd);
|
||||
if (prn->info) {
|
||||
table = (struct bgp_table *)(prn->info);
|
||||
if (bgp_node_has_bgp_path_info_data(prn)) {
|
||||
table = bgp_node_get_bgp_table_info(prn);
|
||||
|
||||
vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
|
||||
peer->bgp, prd, table, &rn->p, pi);
|
||||
@ -3174,8 +3175,8 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id,
|
||||
|
||||
prn = bgp_node_get(bgp->rib[afi][safi],
|
||||
(struct prefix *)prd);
|
||||
if (prn->info) {
|
||||
table = (struct bgp_table *)(prn->info);
|
||||
if (bgp_node_has_bgp_path_info_data(prn)) {
|
||||
table = bgp_node_get_bgp_table_info(prn);
|
||||
|
||||
vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
|
||||
bgp, prd, table, p, pi);
|
||||
@ -3324,8 +3325,8 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id,
|
||||
|
||||
prn = bgp_node_get(bgp->rib[afi][safi],
|
||||
(struct prefix *)prd);
|
||||
if (prn->info) {
|
||||
table = (struct bgp_table *)(prn->info);
|
||||
if (bgp_node_has_bgp_path_info_data(prn)) {
|
||||
table = bgp_node_get_bgp_table_info(prn);
|
||||
|
||||
vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
|
||||
bgp, prd, table, p, pi);
|
||||
@ -3461,8 +3462,8 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id,
|
||||
struct bgp_table *table = NULL;
|
||||
|
||||
prn = bgp_node_get(bgp->rib[afi][safi], (struct prefix *)prd);
|
||||
if (prn->info) {
|
||||
table = (struct bgp_table *)(prn->info);
|
||||
if (bgp_node_has_bgp_path_info_data(prn)) {
|
||||
table = bgp_node_get_bgp_table_info(prn);
|
||||
|
||||
vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
|
||||
bgp, prd, table, p, new);
|
||||
@ -3802,9 +3803,11 @@ void bgp_soft_reconfig_in(struct peer *peer, afi_t afi, safi_t safi)
|
||||
bgp_soft_reconfig_table(peer, afi, safi, NULL, NULL);
|
||||
else
|
||||
for (rn = bgp_table_top(peer->bgp->rib[afi][safi]); rn;
|
||||
rn = bgp_route_next(rn))
|
||||
if ((table = rn->info) != NULL) {
|
||||
rn = bgp_route_next(rn)) {
|
||||
table = bgp_node_get_bgp_table_info(rn);
|
||||
if (table != NULL) {
|
||||
struct prefix_rd prd;
|
||||
|
||||
prd.family = AF_UNSPEC;
|
||||
prd.prefixlen = 64;
|
||||
memcpy(&prd.val, rn->p.u.val, 8);
|
||||
@ -3813,6 +3816,7 @@ void bgp_soft_reconfig_in(struct peer *peer, afi_t afi, safi_t safi)
|
||||
&prd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct bgp_clear_node_queue {
|
||||
@ -4031,9 +4035,13 @@ void bgp_clear_route(struct peer *peer, afi_t afi, safi_t safi)
|
||||
bgp_clear_route_table(peer, afi, safi, NULL);
|
||||
else
|
||||
for (rn = bgp_table_top(peer->bgp->rib[afi][safi]); rn;
|
||||
rn = bgp_route_next(rn))
|
||||
if ((table = rn->info) != NULL)
|
||||
rn = bgp_route_next(rn)) {
|
||||
table = bgp_node_get_bgp_table_info(rn);
|
||||
if (!table)
|
||||
continue;
|
||||
|
||||
bgp_clear_route_table(peer, afi, safi, table);
|
||||
}
|
||||
|
||||
/* unlock if no nodes got added to the clear-node-queue. */
|
||||
if (!peer->clear_node_queue->thread)
|
||||
@ -4093,7 +4101,8 @@ void bgp_clear_stale_route(struct peer *peer, afi_t afi, safi_t safi)
|
||||
struct bgp_node *rm;
|
||||
|
||||
/* look for neighbor in tables */
|
||||
if ((table = rn->info) == NULL)
|
||||
table = bgp_node_get_bgp_table_info(rn);
|
||||
if (!table)
|
||||
continue;
|
||||
|
||||
for (rm = bgp_table_top(table); rm;
|
||||
@ -4154,6 +4163,7 @@ void bgp_cleanup_routes(struct bgp *bgp)
|
||||
{
|
||||
afi_t afi;
|
||||
struct bgp_node *rn;
|
||||
struct bgp_table *table;
|
||||
|
||||
for (afi = AFI_IP; afi < AFI_MAX; ++afi) {
|
||||
if (afi == AFI_L2VPN)
|
||||
@ -4168,26 +4178,22 @@ void bgp_cleanup_routes(struct bgp *bgp)
|
||||
safi = SAFI_MPLS_VPN;
|
||||
for (rn = bgp_table_top(bgp->rib[afi][safi]); rn;
|
||||
rn = bgp_route_next(rn)) {
|
||||
if (rn->info) {
|
||||
bgp_cleanup_table(bgp,
|
||||
(struct bgp_table *)(rn->info),
|
||||
safi);
|
||||
bgp_table_finish((struct bgp_table **)&(
|
||||
rn->info));
|
||||
rn->info = NULL;
|
||||
table = bgp_node_get_bgp_table_info(rn);
|
||||
if (table != NULL) {
|
||||
bgp_cleanup_table(bgp, table, safi);
|
||||
bgp_table_finish(&table);
|
||||
bgp_node_set_bgp_table_info(rn, NULL);
|
||||
bgp_unlock_node(rn);
|
||||
}
|
||||
}
|
||||
safi = SAFI_ENCAP;
|
||||
for (rn = bgp_table_top(bgp->rib[afi][safi]); rn;
|
||||
rn = bgp_route_next(rn)) {
|
||||
if (rn->info) {
|
||||
bgp_cleanup_table(bgp,
|
||||
(struct bgp_table *)(rn->info),
|
||||
safi);
|
||||
bgp_table_finish((struct bgp_table **)&(
|
||||
rn->info));
|
||||
rn->info = NULL;
|
||||
table = bgp_node_get_bgp_table_info(rn);
|
||||
if (table != NULL) {
|
||||
bgp_cleanup_table(bgp, table, safi);
|
||||
bgp_table_finish(&table);
|
||||
bgp_node_set_bgp_table_info(rn, NULL);
|
||||
bgp_unlock_node(rn);
|
||||
}
|
||||
}
|
||||
@ -4195,12 +4201,11 @@ void bgp_cleanup_routes(struct bgp *bgp)
|
||||
}
|
||||
for (rn = bgp_table_top(bgp->rib[AFI_L2VPN][SAFI_EVPN]); rn;
|
||||
rn = bgp_route_next(rn)) {
|
||||
if (rn->info) {
|
||||
bgp_cleanup_table(bgp,
|
||||
(struct bgp_table *)(rn->info),
|
||||
SAFI_EVPN);
|
||||
bgp_table_finish((struct bgp_table **)&(rn->info));
|
||||
rn->info = NULL;
|
||||
table = bgp_node_get_bgp_table_info(rn);
|
||||
if (table != NULL) {
|
||||
bgp_cleanup_table(bgp, table, SAFI_EVPN);
|
||||
bgp_table_finish(&table);
|
||||
bgp_node_set_bgp_table_info(rn, NULL);
|
||||
bgp_unlock_node(rn);
|
||||
}
|
||||
}
|
||||
@ -5007,12 +5012,12 @@ void bgp_static_add(struct bgp *bgp)
|
||||
FOREACH_AFI_SAFI (afi, safi)
|
||||
for (rn = bgp_table_top(bgp->route[afi][safi]); rn;
|
||||
rn = bgp_route_next(rn)) {
|
||||
if (rn->info == NULL)
|
||||
if (!bgp_node_has_bgp_path_info_data(rn))
|
||||
continue;
|
||||
|
||||
if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)
|
||||
|| (safi == SAFI_EVPN)) {
|
||||
table = rn->info;
|
||||
table = bgp_node_get_bgp_table_info(rn);
|
||||
|
||||
for (rm = bgp_table_top(table); rm;
|
||||
rm = bgp_route_next(rm)) {
|
||||
@ -5044,12 +5049,12 @@ void bgp_static_delete(struct bgp *bgp)
|
||||
FOREACH_AFI_SAFI (afi, safi)
|
||||
for (rn = bgp_table_top(bgp->route[afi][safi]); rn;
|
||||
rn = bgp_route_next(rn)) {
|
||||
if (rn->info == NULL)
|
||||
if (!bgp_node_has_bgp_path_info_data(rn))
|
||||
continue;
|
||||
|
||||
if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)
|
||||
|| (safi == SAFI_EVPN)) {
|
||||
table = rn->info;
|
||||
table = bgp_node_get_bgp_table_info(rn);
|
||||
|
||||
for (rm = bgp_table_top(table); rm;
|
||||
rm = bgp_route_next(rm)) {
|
||||
@ -5086,12 +5091,12 @@ void bgp_static_redo_import_check(struct bgp *bgp)
|
||||
FOREACH_AFI_SAFI (afi, safi) {
|
||||
for (rn = bgp_table_top(bgp->route[afi][safi]); rn;
|
||||
rn = bgp_route_next(rn)) {
|
||||
if (rn->info == NULL)
|
||||
if (!bgp_node_has_bgp_path_info_data(rn))
|
||||
continue;
|
||||
|
||||
if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)
|
||||
|| (safi == SAFI_EVPN)) {
|
||||
table = rn->info;
|
||||
table = bgp_node_get_bgp_table_info(rn);
|
||||
|
||||
for (rm = bgp_table_top(table); rm;
|
||||
rm = bgp_route_next(rm)) {
|
||||
@ -5227,15 +5232,16 @@ int bgp_static_set_safi(afi_t afi, safi_t safi, struct vty *vty,
|
||||
}
|
||||
}
|
||||
prn = bgp_node_get(bgp->route[afi][safi], (struct prefix *)&prd);
|
||||
if (prn->info == NULL)
|
||||
prn->info = bgp_table_init(bgp, afi, safi);
|
||||
if (!bgp_node_has_bgp_path_info_data(prn))
|
||||
bgp_node_set_bgp_table_info(prn,
|
||||
bgp_table_init(bgp, afi, safi));
|
||||
else
|
||||
bgp_unlock_node(prn);
|
||||
table = prn->info;
|
||||
table = bgp_node_get_bgp_table_info(prn);
|
||||
|
||||
rn = bgp_node_get(table, &p);
|
||||
|
||||
if (rn->info) {
|
||||
if (bgp_node_has_bgp_path_info_data(rn)) {
|
||||
vty_out(vty, "%% Same network configuration exists\n");
|
||||
bgp_unlock_node(rn);
|
||||
} else {
|
||||
@ -5325,11 +5331,12 @@ int bgp_static_unset_safi(afi_t afi, safi_t safi, struct vty *vty,
|
||||
}
|
||||
|
||||
prn = bgp_node_get(bgp->route[afi][safi], (struct prefix *)&prd);
|
||||
if (prn->info == NULL)
|
||||
prn->info = bgp_table_init(bgp, afi, safi);
|
||||
if (!bgp_node_has_bgp_path_info_data(prn))
|
||||
bgp_node_set_bgp_table_info(prn,
|
||||
bgp_table_init(bgp, afi, safi));
|
||||
else
|
||||
bgp_unlock_node(prn);
|
||||
table = prn->info;
|
||||
table = bgp_node_get_bgp_table_info(prn);
|
||||
|
||||
rn = bgp_node_lookup(table, &p);
|
||||
|
||||
@ -6020,7 +6027,7 @@ static int bgp_aggregate_set(struct vty *vty, const char *prefix_str, afi_t afi,
|
||||
/* Old configuration check. */
|
||||
rn = bgp_node_get(bgp->aggregate[afi][safi], &p);
|
||||
|
||||
if (rn->info) {
|
||||
if (bgp_node_has_bgp_path_info_data(rn)) {
|
||||
vty_out(vty, "There is already same aggregate network.\n");
|
||||
/* try to remove the old entry */
|
||||
ret = bgp_aggregate_unset(vty, prefix_str, afi, safi);
|
||||
@ -8722,6 +8729,7 @@ int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi,
|
||||
unsigned long output_cum = 0;
|
||||
unsigned long total_cum = 0;
|
||||
unsigned long json_header_depth = 0;
|
||||
struct bgp_table *itable;
|
||||
bool show_msg;
|
||||
|
||||
show_msg = (!use_json && type == bgp_show_type_normal);
|
||||
@ -8730,16 +8738,17 @@ int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi,
|
||||
next = bgp_route_next(rn);
|
||||
if (prd_match && memcmp(rn->p.u.val, prd_match->val, 8) != 0)
|
||||
continue;
|
||||
if (rn->info != NULL) {
|
||||
|
||||
itable = bgp_node_get_bgp_table_info(rn);
|
||||
if (itable != NULL) {
|
||||
struct prefix_rd prd;
|
||||
char rd[RD_ADDRSTRLEN];
|
||||
|
||||
memcpy(&prd, &(rn->p), sizeof(struct prefix_rd));
|
||||
prefix_rd2str(&prd, rd, sizeof(rd));
|
||||
bgp_show_table(vty, bgp, safi, rn->info, type,
|
||||
output_arg, use_json, rd, next == NULL,
|
||||
&output_cum, &total_cum,
|
||||
&json_header_depth);
|
||||
bgp_show_table(vty, bgp, safi, itable, type, output_arg,
|
||||
use_json, rd, next == NULL, &output_cum,
|
||||
&total_cum, &json_header_depth);
|
||||
if (next == NULL)
|
||||
show_msg = false;
|
||||
}
|
||||
@ -9068,8 +9077,8 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp,
|
||||
for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) {
|
||||
if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0)
|
||||
continue;
|
||||
|
||||
if ((table = rn->info) == NULL)
|
||||
table = bgp_node_get_bgp_table_info(rn);
|
||||
if (!table)
|
||||
continue;
|
||||
|
||||
header = 1;
|
||||
@ -11428,7 +11437,8 @@ static int bgp_clear_damp_route(struct vty *vty, const char *view_name,
|
||||
rn = bgp_route_next(rn)) {
|
||||
if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0)
|
||||
continue;
|
||||
if ((table = rn->info) == NULL)
|
||||
table = bgp_node_get_bgp_table_info(rn);
|
||||
if (!table)
|
||||
continue;
|
||||
if ((rm = bgp_node_match(table, &match)) == NULL)
|
||||
continue;
|
||||
@ -11588,7 +11598,8 @@ static void bgp_config_write_network_vpn(struct vty *vty, struct bgp *bgp,
|
||||
/* Network configuration. */
|
||||
for (prn = bgp_table_top(bgp->route[afi][safi]); prn;
|
||||
prn = bgp_route_next(prn)) {
|
||||
if ((table = prn->info) == NULL)
|
||||
table = bgp_node_get_bgp_table_info(prn);
|
||||
if (!table)
|
||||
continue;
|
||||
|
||||
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
|
||||
@ -11638,7 +11649,8 @@ static void bgp_config_write_network_evpn(struct vty *vty, struct bgp *bgp,
|
||||
/* Network configuration. */
|
||||
for (prn = bgp_table_top(bgp->route[afi][safi]); prn;
|
||||
prn = bgp_route_next(prn)) {
|
||||
if ((table = prn->info) == NULL)
|
||||
table = bgp_node_get_bgp_table_info(prn);
|
||||
if (!table)
|
||||
continue;
|
||||
|
||||
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
|
||||
|
@ -388,6 +388,18 @@ static inline void bgp_node_set_bgp_path_info(struct bgp_node *node,
|
||||
node->info = bi;
|
||||
}
|
||||
|
||||
static inline struct bgp_table *
|
||||
bgp_node_get_bgp_table_info(struct bgp_node *node)
|
||||
{
|
||||
return node->info;
|
||||
}
|
||||
|
||||
static inline void bgp_node_set_bgp_table_info(struct bgp_node *node,
|
||||
struct bgp_table *table)
|
||||
{
|
||||
node->info = table;
|
||||
}
|
||||
|
||||
static inline bool bgp_node_has_bgp_path_info_data(struct bgp_node *node)
|
||||
{
|
||||
return !!node->info;
|
||||
|
@ -690,10 +690,13 @@ void subgroup_announce_route(struct update_subgroup *subgrp)
|
||||
subgroup_announce_table(subgrp, NULL);
|
||||
else
|
||||
for (rn = bgp_table_top(update_subgroup_rib(subgrp)); rn;
|
||||
rn = bgp_route_next(rn))
|
||||
if ((table = (rn->info)) != NULL)
|
||||
rn = bgp_route_next(rn)) {
|
||||
table = bgp_node_get_bgp_table_info(rn);
|
||||
if (!table)
|
||||
continue;
|
||||
subgroup_announce_table(subgrp, table);
|
||||
}
|
||||
}
|
||||
|
||||
void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
|
||||
{
|
||||
|
@ -79,7 +79,8 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
|
||||
if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0)
|
||||
continue;
|
||||
|
||||
if ((table = rn->info) != NULL) {
|
||||
table = bgp_node_get_bgp_table_info(rn);
|
||||
if (table != NULL) {
|
||||
if (use_json)
|
||||
json_array = json_object_new_array();
|
||||
else
|
||||
|
@ -7209,7 +7209,9 @@ static int bgp_clear_prefix(struct vty *vty, const char *view_name,
|
||||
if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0)
|
||||
continue;
|
||||
|
||||
if ((table = rn->info) != NULL) {
|
||||
table = bgp_node_get_bgp_table_info(rn);
|
||||
if (table != NULL) {
|
||||
|
||||
if ((rm = bgp_node_match(table, &match))
|
||||
!= NULL) {
|
||||
if (rm->p.prefixlen
|
||||
|
@ -1432,16 +1432,17 @@ static void bgp_recalculate_afi_safi_bestpaths(struct bgp *bgp, afi_t afi,
|
||||
safi_t safi)
|
||||
{
|
||||
struct bgp_node *rn, *nrn;
|
||||
struct bgp_table *table;
|
||||
|
||||
for (rn = bgp_table_top(bgp->rib[afi][safi]); rn;
|
||||
rn = bgp_route_next(rn)) {
|
||||
if (rn->info != NULL) {
|
||||
table = bgp_node_get_bgp_table_info(rn);
|
||||
if (table != NULL) {
|
||||
/* Special handling for 2-level routing
|
||||
* tables. */
|
||||
if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP
|
||||
|| safi == SAFI_EVPN) {
|
||||
for (nrn = bgp_table_top(
|
||||
(struct bgp_table *)(rn->info));
|
||||
for (nrn = bgp_table_top(table);
|
||||
nrn; nrn = bgp_route_next(nrn))
|
||||
bgp_process(bgp, nrn, afi, safi);
|
||||
} else
|
||||
@ -3319,7 +3320,7 @@ void bgp_free(struct bgp *bgp)
|
||||
|| safi == SAFI_EVPN) {
|
||||
for (rn = bgp_table_top(bgp->rib[afi][safi]); rn;
|
||||
rn = bgp_route_next(rn)) {
|
||||
table = (struct bgp_table *)rn->info;
|
||||
table = bgp_node_get_bgp_table_info(rn);
|
||||
bgp_table_finish(&table);
|
||||
}
|
||||
}
|
||||
|
@ -472,12 +472,10 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
|
||||
|
||||
prn = bgp_node_get(bgp->rib[afi][safi],
|
||||
(struct prefix *)prd);
|
||||
if (prn->info) {
|
||||
table = (struct bgp_table *)(prn->info);
|
||||
|
||||
table = bgp_node_get_bgp_table_info(prn);
|
||||
if (table)
|
||||
vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
|
||||
bgp, prd, table, p, bpi);
|
||||
}
|
||||
bgp_unlock_node(prn);
|
||||
}
|
||||
|
||||
@ -1018,12 +1016,10 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
|
||||
|
||||
prn = bgp_node_get(bgp->rib[afi][safi],
|
||||
(struct prefix *)prd);
|
||||
if (prn->info) {
|
||||
table = (struct bgp_table *)(prn->info);
|
||||
|
||||
table = bgp_node_get_bgp_table_info(prn);
|
||||
if (table)
|
||||
vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
|
||||
bgp, prd, table, p, bpi);
|
||||
}
|
||||
bgp_unlock_node(prn);
|
||||
}
|
||||
|
||||
@ -1043,12 +1039,10 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
|
||||
|
||||
prn = bgp_node_get(bgp->rib[afi][safi],
|
||||
(struct prefix *)prd);
|
||||
if (prn->info) {
|
||||
table = (struct bgp_table *)(prn->info);
|
||||
|
||||
table = bgp_node_get_bgp_table_info(prn);
|
||||
if (table)
|
||||
vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
|
||||
bgp, prd, table, p, bpi);
|
||||
}
|
||||
bgp_unlock_node(prn);
|
||||
}
|
||||
|
||||
@ -1094,12 +1088,10 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
|
||||
struct bgp_table *table = NULL;
|
||||
|
||||
prn = bgp_node_get(bgp->rib[afi][safi], (struct prefix *)prd);
|
||||
if (prn->info) {
|
||||
table = (struct bgp_table *)(prn->info);
|
||||
|
||||
table = bgp_node_get_bgp_table_info(prn);
|
||||
if (table)
|
||||
vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
|
||||
bgp, prd, table, p, new);
|
||||
}
|
||||
bgp_unlock_node(prn);
|
||||
encode_label(label_val, &bn->local_label);
|
||||
}
|
||||
@ -3697,10 +3689,13 @@ static void rfapi_print_exported(struct bgp *bgp)
|
||||
|
||||
for (rdn = bgp_table_top(bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rdn;
|
||||
rdn = bgp_route_next(rdn)) {
|
||||
if (!rdn->info)
|
||||
struct bgp_table *table;
|
||||
|
||||
table = bgp_node_get_bgp_table_info(rdn);
|
||||
if (!table)
|
||||
continue;
|
||||
fprintf(stderr, "%s: vpn rdn=%p\n", __func__, rdn);
|
||||
for (rn = bgp_table_top(rdn->info); rn;
|
||||
for (rn = bgp_table_top(table); rn;
|
||||
rn = bgp_route_next(rn)) {
|
||||
bpi = bgp_node_get_bgp_path_info(rn);
|
||||
|
||||
@ -3714,10 +3709,13 @@ static void rfapi_print_exported(struct bgp *bgp)
|
||||
}
|
||||
for (rdn = bgp_table_top(bgp->rib[AFI_IP][SAFI_ENCAP]); rdn;
|
||||
rdn = bgp_route_next(rdn)) {
|
||||
if (!rdn->info)
|
||||
struct bgp_table *table;
|
||||
|
||||
table = bgp_node_get_bgp_table_info(rdn);
|
||||
if (!table)
|
||||
continue;
|
||||
fprintf(stderr, "%s: encap rdn=%p\n", __func__, rdn);
|
||||
for (rn = bgp_table_top(rdn->info); rn;
|
||||
for (rn = bgp_table_top(table)); rn;
|
||||
rn = bgp_route_next(rn)) {
|
||||
bpi = bgp_node_get_bgp_path_info(rn);
|
||||
if (!bpi)
|
||||
|
@ -4246,7 +4246,7 @@ static void rfapiBgpTableFilteredImport(struct bgp *bgp,
|
||||
|
||||
if (bgp_node_has_bgp_path_info_data(rn1)) {
|
||||
|
||||
for (rn2 = bgp_table_top(rn1->info); rn2;
|
||||
for (rn2 = bgp_table_top(bgp_node_get_bgp_table_info(rn1)); rn2;
|
||||
rn2 = bgp_route_next(rn2)) {
|
||||
|
||||
struct bgp_path_info *bpi;
|
||||
|
@ -1847,7 +1847,7 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
|
||||
memcpy(prd.val, prn->p.u.val, 8);
|
||||
|
||||
/* This is the per-RD table of prefixes */
|
||||
table = prn->info;
|
||||
table = bgp_node_get_bgp_table_info(prn);
|
||||
|
||||
if (!table)
|
||||
continue;
|
||||
|
@ -676,7 +676,7 @@ static void vnc_import_bgp_add_route_mode_resolve_nve(
|
||||
|
||||
struct bgp_table *table;
|
||||
|
||||
table = (struct bgp_table *)(bnp->info);
|
||||
table = bgp_node_get_bgp_table_info(bnp);
|
||||
|
||||
if (!table)
|
||||
continue;
|
||||
@ -1377,7 +1377,7 @@ vnc_import_bgp_del_route_mode_resolve_nve(struct bgp *bgp, afi_t afi,
|
||||
|
||||
struct bgp_table *table;
|
||||
|
||||
table = (struct bgp_table *)(bnp->info);
|
||||
table = bgp_node_get_bgp_table_info(bnp);
|
||||
|
||||
if (!table)
|
||||
continue;
|
||||
@ -2907,8 +2907,9 @@ void vnc_import_bgp_redist_disable(struct bgp *bgp, afi_t afi)
|
||||
|
||||
if (bgp_node_has_bgp_path_info_data(rn1)) {
|
||||
|
||||
for (rn2 = bgp_table_top(rn1->info); rn2;
|
||||
rn2 = bgp_route_next(rn2)) {
|
||||
for (rn2 = bgp_table_top(
|
||||
bgp_node_get_bgp_table_info(rn1));
|
||||
rn2; rn2 = bgp_route_next(rn2)) {
|
||||
|
||||
struct bgp_path_info *bpi;
|
||||
struct bgp_path_info *nextbpi;
|
||||
|
@ -312,7 +312,7 @@ static void vnc_redistribute_withdraw(struct bgp *bgp, afi_t afi, uint8_t type)
|
||||
memcpy(prd.val, prn->p.u.val, 8);
|
||||
|
||||
/* This is the per-RD table of prefixes */
|
||||
table = prn->info;
|
||||
table = bgp_node_get_bgp_table_info(prn);
|
||||
if (!table)
|
||||
continue;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user