mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-17 02:22:17 +00:00
Merge pull request #5379 from pogojotz/fix-bgp-neighbors-prefix-count-segfault
bgpd: Special handling for 2-level routing tables
This commit is contained in:
commit
b332774896
@ -10921,18 +10921,16 @@ struct peer_pcounts {
|
|||||||
unsigned int count[PCOUNT_MAX];
|
unsigned int count[PCOUNT_MAX];
|
||||||
const struct peer *peer;
|
const struct peer *peer;
|
||||||
const struct bgp_table *table;
|
const struct bgp_table *table;
|
||||||
|
safi_t safi;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int bgp_peer_count_walker(struct thread *t)
|
static void bgp_peer_count_proc(struct bgp_node *rn,
|
||||||
|
struct peer_pcounts *pc)
|
||||||
{
|
{
|
||||||
struct bgp_node *rn;
|
const struct bgp_adj_in *ain;
|
||||||
struct peer_pcounts *pc = THREAD_ARG(t);
|
const struct bgp_path_info *pi;
|
||||||
const struct peer *peer = pc->peer;
|
const struct peer *peer = pc->peer;
|
||||||
|
|
||||||
for (rn = bgp_table_top(pc->table); rn; rn = bgp_route_next(rn)) {
|
|
||||||
struct bgp_adj_in *ain;
|
|
||||||
struct bgp_path_info *pi;
|
|
||||||
|
|
||||||
for (ain = rn->adj_in; ain; ain = ain->next)
|
for (ain = rn->adj_in; ain; ain = ain->next)
|
||||||
if (ain->peer == peer)
|
if (ain->peer == peer)
|
||||||
pc->count[PCOUNT_ADJ_IN]++;
|
pc->count[PCOUNT_ADJ_IN]++;
|
||||||
@ -10971,6 +10969,28 @@ static int bgp_peer_count_walker(struct thread *t)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int bgp_peer_count_walker(struct thread *t)
|
||||||
|
{
|
||||||
|
struct bgp_node *rn, *rm;
|
||||||
|
const struct bgp_table *table;
|
||||||
|
struct peer_pcounts *pc = THREAD_ARG(t);
|
||||||
|
|
||||||
|
if (pc->safi == SAFI_MPLS_VPN || pc->safi == SAFI_ENCAP
|
||||||
|
|| pc->safi == SAFI_EVPN) {
|
||||||
|
/* Special handling for 2-level routing tables. */
|
||||||
|
for (rn = bgp_table_top(pc->table); rn;
|
||||||
|
rn = bgp_route_next(rn)) {
|
||||||
|
table = bgp_node_get_bgp_table_info(rn);
|
||||||
|
if (table != NULL)
|
||||||
|
for (rm = bgp_table_top(table); rm;
|
||||||
|
rm = bgp_route_next(rm))
|
||||||
|
bgp_peer_count_proc(rm, pc);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
for (rn = bgp_table_top(pc->table); rn; rn = bgp_route_next(rn))
|
||||||
|
bgp_peer_count_proc(rn, pc);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -11004,6 +11024,7 @@ static int bgp_peer_counts(struct vty *vty, struct peer *peer, afi_t afi,
|
|||||||
memset(&pcounts, 0, sizeof(pcounts));
|
memset(&pcounts, 0, sizeof(pcounts));
|
||||||
pcounts.peer = peer;
|
pcounts.peer = peer;
|
||||||
pcounts.table = peer->bgp->rib[afi][safi];
|
pcounts.table = peer->bgp->rib[afi][safi];
|
||||||
|
pcounts.safi = safi;
|
||||||
|
|
||||||
/* in-place call via thread subsystem so as to record execution time
|
/* in-place call via thread subsystem so as to record execution time
|
||||||
* stats for the thread-walk (i.e. ensure this can't be blamed on
|
* stats for the thread-walk (i.e. ensure this can't be blamed on
|
||||||
|
Loading…
Reference in New Issue
Block a user