diff options
| author | Donatas Abraitis <donatas@opensourcerouting.org> | 2023-06-07 22:15:43 +0300 | 
|---|---|---|
| committer | Donatas Abraitis <donatas@opensourcerouting.org> | 2023-06-07 22:27:29 +0300 | 
| commit | 78981a80c7457b96e73c108280577d4cbb8aee03 (patch) | |
| tree | 309c6632f4550a8b43c3a827d68f77d4db01a16f /bgpd/bgp_addpath.c | |
| parent | 0ec8b2d86983fce00875b3d8f8c966955ee11346 (diff) | |
bgpd: Implement `neighbor X addpath-tx-best-selected` command
When using `addpath-tx-all` BGP announces all known paths instead of announcing
only an arbitrary number of best paths.
With this new command we can send N best paths to the neighbor. That means, we
send the best path, then send the second best path excluding the previous one,
and so on. In other words, we run best path selection algorithm N times before
we finish.
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
Diffstat (limited to 'bgpd/bgp_addpath.c')
| -rw-r--r-- | bgpd/bgp_addpath.c | 23 | 
1 files changed, 17 insertions, 6 deletions
diff --git a/bgpd/bgp_addpath.c b/bgpd/bgp_addpath.c index 7f746541ff..de4b4a48af 100644 --- a/bgpd/bgp_addpath.c +++ b/bgpd/bgp_addpath.c @@ -25,7 +25,14 @@ static const struct bgp_addpath_strategy_names strat_names[BGP_ADDPATH_MAX] = {  		.human_description = "Advertise bestpath per AS via addpath",  		.type_json_name = "addpathTxBestpathPerAS",  		.id_json_name = "addpathTxIdBestPerAS" -	} +	}, +	{ +		.config_name = "addpath-tx-best-selected", +		.human_name = "Best-Selected", +		.human_description = "Advertise best N selected paths via addpath", +		.type_json_name = "addpathTxBestSelectedPaths", +		.id_json_name = "addpathTxIdBestSelected" +	},  };  static const struct bgp_addpath_strategy_names unknown_names = { @@ -161,6 +168,8 @@ bool bgp_addpath_tx_path(enum bgp_addpath_strat strat, struct bgp_path_info *pi)  			return true;  		else  			return false; +	case BGP_ADDPATH_BEST_SELECTED: +		return true;  	case BGP_ADDPATH_MAX:  		return false;  	} @@ -356,7 +365,8 @@ void bgp_addpath_type_changed(struct bgp *bgp)   * change take effect.   */  void bgp_addpath_set_peer_type(struct peer *peer, afi_t afi, safi_t safi, -			      enum bgp_addpath_strat addpath_type) +			       enum bgp_addpath_strat addpath_type, +			       uint8_t paths)  {  	struct bgp *bgp = peer->bgp;  	enum bgp_addpath_strat old_type; @@ -367,6 +377,8 @@ void bgp_addpath_set_peer_type(struct peer *peer, afi_t afi, safi_t safi,  	if (safi == SAFI_LABELED_UNICAST)  		safi = SAFI_UNICAST; +	peer->addpath_best_selected[afi][safi] = paths; +  	old_type = peer->addpath_type[afi][safi];  	if (addpath_type == old_type)  		return; @@ -411,10 +423,9 @@ void bgp_addpath_set_peer_type(struct peer *peer, afi_t afi, safi_t safi,  			     tmp_peer)) {  				if (tmp_peer->addpath_type[afi][safi] ==  				    old_type) { -					bgp_addpath_set_peer_type(tmp_peer, -								 afi, -								 safi, -								 addpath_type); +					bgp_addpath_set_peer_type( +						tmp_peer, afi, safi, +						addpath_type, paths);  				}  			}  		}  | 
