mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-29 15:07:51 +00:00
bgpd: [7.1] add addpath ID to adj_out tree sort (#5691)
bgpd: [7.1] add addpath ID to adj_out tree sort
This commit is contained in:
commit
c3996e08c5
@ -64,6 +64,12 @@ static int bgp_adj_out_compare(const struct bgp_adj_out *o1,
|
|||||||
if (o1->subgroup > o2->subgroup)
|
if (o1->subgroup > o2->subgroup)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
if (o1->addpath_tx_id < o2->addpath_tx_id)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (o1->addpath_tx_id > o2->addpath_tx_id)
|
||||||
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
RB_GENERATE(bgp_adj_out_rb, bgp_adj_out, adj_entry, bgp_adj_out_compare);
|
RB_GENERATE(bgp_adj_out_rb, bgp_adj_out, adj_entry, bgp_adj_out_compare);
|
||||||
@ -72,32 +78,17 @@ static inline struct bgp_adj_out *adj_lookup(struct bgp_node *rn,
|
|||||||
struct update_subgroup *subgrp,
|
struct update_subgroup *subgrp,
|
||||||
uint32_t addpath_tx_id)
|
uint32_t addpath_tx_id)
|
||||||
{
|
{
|
||||||
struct bgp_adj_out *adj, lookup;
|
struct bgp_adj_out lookup;
|
||||||
struct peer *peer;
|
|
||||||
afi_t afi;
|
|
||||||
safi_t safi;
|
|
||||||
int addpath_capable;
|
|
||||||
|
|
||||||
if (!rn || !subgrp)
|
if (!rn || !subgrp)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
peer = SUBGRP_PEER(subgrp);
|
|
||||||
afi = SUBGRP_AFI(subgrp);
|
|
||||||
safi = SUBGRP_SAFI(subgrp);
|
|
||||||
addpath_capable = bgp_addpath_encode_tx(peer, afi, safi);
|
|
||||||
|
|
||||||
/* update-groups that do not support addpath will pass 0 for
|
/* update-groups that do not support addpath will pass 0 for
|
||||||
* addpath_tx_id so do not both matching against it */
|
* addpath_tx_id. */
|
||||||
lookup.subgroup = subgrp;
|
lookup.subgroup = subgrp;
|
||||||
adj = RB_FIND(bgp_adj_out_rb, &rn->adj_out, &lookup);
|
lookup.addpath_tx_id = addpath_tx_id;
|
||||||
if (adj) {
|
|
||||||
if (addpath_capable) {
|
return RB_FIND(bgp_adj_out_rb, &rn->adj_out, &lookup);
|
||||||
if (adj->addpath_tx_id == addpath_tx_id)
|
|
||||||
return adj;
|
|
||||||
} else
|
|
||||||
return adj;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void adj_free(struct bgp_adj_out *adj)
|
static void adj_free(struct bgp_adj_out *adj)
|
||||||
@ -402,13 +393,14 @@ struct bgp_adj_out *bgp_adj_out_alloc(struct update_subgroup *subgrp,
|
|||||||
|
|
||||||
adj = XCALLOC(MTYPE_BGP_ADJ_OUT, sizeof(struct bgp_adj_out));
|
adj = XCALLOC(MTYPE_BGP_ADJ_OUT, sizeof(struct bgp_adj_out));
|
||||||
adj->subgroup = subgrp;
|
adj->subgroup = subgrp;
|
||||||
|
adj->addpath_tx_id = addpath_tx_id;
|
||||||
|
|
||||||
if (rn) {
|
if (rn) {
|
||||||
RB_INSERT(bgp_adj_out_rb, &rn->adj_out, adj);
|
RB_INSERT(bgp_adj_out_rb, &rn->adj_out, adj);
|
||||||
bgp_lock_node(rn);
|
bgp_lock_node(rn);
|
||||||
adj->rn = rn;
|
adj->rn = rn;
|
||||||
}
|
}
|
||||||
|
|
||||||
adj->addpath_tx_id = addpath_tx_id;
|
|
||||||
TAILQ_INSERT_TAIL(&(subgrp->adjq), adj, subgrp_adj_train);
|
TAILQ_INSERT_TAIL(&(subgrp->adjq), adj, subgrp_adj_train);
|
||||||
SUBGRP_INCR_STAT(subgrp, adj_count);
|
SUBGRP_INCR_STAT(subgrp, adj_count);
|
||||||
return adj;
|
return adj;
|
||||||
|
Loading…
Reference in New Issue
Block a user