bgpd: Add bgp_check_selected() helper for abstraction

Just check if the path is selected to be advertised: best path or addpath
capable.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
This commit is contained in:
Donatas Abraitis 2022-01-27 10:12:59 +02:00
parent a08e5c529c
commit 5cb526136a
4 changed files with 15 additions and 11 deletions

View File

@ -124,12 +124,8 @@ static void bgp_conditional_adv_routes(struct peer *peer, afi_t afi,
if (ret != RMAP_PERMITMATCH)
continue;
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)
|| (addpath_capable
&& bgp_addpath_tx_path(
peer->addpath_type[afi][safi],
pi))) {
if (bgp_check_selected(pi, peer, addpath_capable, afi,
safi)) {
/* Skip route-map checks in
* subgroup_announce_check while executing from
* the conditional advertise scanner process.

View File

@ -49,6 +49,7 @@
#include "bgpd/bgp_debug.h"
#include "bgpd/bgp_errors.h"
#include "bgpd/bgp_fsm.h"
#include "bgpd/bgp_addpath.h"
#include "bgpd/bgp_advertise.h"
#include "bgpd/bgp_packet.h"
#include "bgpd/bgp_updgrp.h"
@ -1931,3 +1932,11 @@ bool bgp_addpath_encode_tx(struct peer *peer, afi_t afi, safi_t safi)
&& CHECK_FLAG(peer->af_cap[afi][safi],
PEER_CAP_ADDPATH_AF_RX_RCV));
}
bool bgp_check_selected(struct bgp_path_info *bpi, struct peer *peer,
bool addpath_capable, afi_t afi, safi_t safi)
{
return (CHECK_FLAG(bpi->flags, BGP_PATH_SELECTED) ||
(addpath_capable &&
bgp_addpath_tx_path(peer->addpath_type[afi][safi], bpi)));
}

View File

@ -462,6 +462,8 @@ extern int update_group_clear_update_dbg(struct update_group *updgrp,
extern void update_bgp_group_free(struct bgp *bgp);
extern bool bgp_addpath_encode_tx(struct peer *peer, afi_t afi, safi_t safi);
extern bool bgp_check_selected(struct bgp_path_info *bpi, struct peer *peer,
bool addpath_capable, afi_t afi, safi_t safi);
/*
* Inline functions

View File

@ -687,11 +687,8 @@ void subgroup_announce_table(struct update_subgroup *subgrp,
for (ri = bgp_dest_get_bgp_path_info(dest); ri; ri = ri->next)
if (CHECK_FLAG(ri->flags, BGP_PATH_SELECTED)
|| (addpath_capable
&& bgp_addpath_tx_path(
peer->addpath_type[afi][safi],
ri))) {
if (bgp_check_selected(ri, peer, addpath_capable, afi,
safi)) {
if (subgroup_announce_check(dest, ri, subgrp,
dest_p, &attr,
false)) {