diff options
| author | Donatas Abraitis <donatas.abraitis@gmail.com> | 2022-01-27 10:12:59 +0200 | 
|---|---|---|
| committer | Donatas Abraitis <donatas.abraitis@gmail.com> | 2022-02-01 13:31:29 +0200 | 
| commit | b1dd7180785ef92d5a17f230cb7b607c98e51f63 (patch) | |
| tree | 08bf76b7f8976fc41c8c7a4e59674a1583bfe6d5 | |
| parent | be92fc9f1aae0f59e3d9f35bf9a557180b8ee7c6 (diff) | |
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>
| -rw-r--r-- | bgpd/bgp_conditional_adv.c | 8 | ||||
| -rw-r--r-- | bgpd/bgp_updgrp.c | 9 | ||||
| -rw-r--r-- | bgpd/bgp_updgrp.h | 2 | ||||
| -rw-r--r-- | bgpd/bgp_updgrp_adv.c | 7 | 
4 files changed, 15 insertions, 11 deletions
diff --git a/bgpd/bgp_conditional_adv.c b/bgpd/bgp_conditional_adv.c index 6f72985876..c0dd3d6f81 100644 --- a/bgpd/bgp_conditional_adv.c +++ b/bgpd/bgp_conditional_adv.c @@ -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. diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c index 79433d6a5b..bfcb4810d1 100644 --- a/bgpd/bgp_updgrp.c +++ b/bgpd/bgp_updgrp.c @@ -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))); +} diff --git a/bgpd/bgp_updgrp.h b/bgpd/bgp_updgrp.h index f00853fc6f..5a9bebf8fe 100644 --- a/bgpd/bgp_updgrp.h +++ b/bgpd/bgp_updgrp.h @@ -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 diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c index 806abbeba1..2110dcb8bc 100644 --- a/bgpd/bgp_updgrp_adv.c +++ b/bgpd/bgp_updgrp_adv.c @@ -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)) {  | 
