uint32_t bgp_addpath_id_for_peer(struct peer *peer, afi_t afi, safi_t safi,
struct bgp_addpath_info_data *d)
{
+ if (safi == SAFI_LABELED_UNICAST)
+ safi = SAFI_UNICAST;
+
if (peer->addpath_type[afi][safi] < BGP_ADDPATH_MAX)
return d->addpath_tx_id[peer->addpath_type[afi][safi]];
else
{
struct bgp_path_info *pi;
+ if (safi == SAFI_LABELED_UNICAST)
+ safi = SAFI_UNICAST;
+
idalloc_drain_pool(
bgp->tx_addpath.id_allocators[afi][safi][addpath_type],
&(dest->tx_addpath.free_ids[addpath_type]));
{
struct bgp_dest *dest, *ndest;
+ if (safi == SAFI_LABELED_UNICAST)
+ safi = SAFI_UNICAST;
+
for (dest = bgp_table_top(bgp->rib[afi][safi]); dest;
dest = bgp_route_next(dest)) {
if (safi == SAFI_MPLS_VPN) {
* and afi/safi combination. Since we won't waste the time computing addpath IDs
* for unused strategies, the first time a peer is configured to use a strategy,
* we have to backfill the data.
+ * In labeled-unicast, addpath allocations SHOULD be done in unicast SAFI.
*/
static void bgp_addpath_populate_type(struct bgp *bgp, afi_t afi, safi_t safi,
enum bgp_addpath_strat addpath_type)
char buf[200];
struct id_alloc *allocator;
+ if (safi == SAFI_LABELED_UNICAST)
+ safi = SAFI_UNICAST;
+
snprintf(buf, sizeof(buf), "Addpath ID Allocator %s:%d/%d",
bgp_addpath_names(addpath_type)->config_name, (int)afi,
(int)safi);
enum bgp_addpath_strat addpath_type)
{
struct bgp *bgp = peer->bgp;
- enum bgp_addpath_strat old_type = peer->addpath_type[afi][safi];
+ enum bgp_addpath_strat old_type;
struct listnode *node, *nnode;
struct peer *tmp_peer;
struct peer_group *group;
+ if (safi == SAFI_LABELED_UNICAST)
+ safi = SAFI_UNICAST;
+
+ old_type = peer->addpath_type[afi][safi];
if (addpath_type == old_type)
return;
struct bgp_path_info *pi;
struct id_alloc_pool **pool_ptr;
+ if (safi == SAFI_LABELED_UNICAST)
+ safi = SAFI_UNICAST;
+
for (i = 0; i < BGP_ADDPATH_MAX; i++) {
struct id_alloc *alloc =
bgp->tx_addpath.id_allocators[afi][safi][i];
iana_safi_t pkt_safi = IANA_SAFI_UNICAST;
as_t local_as;
uint8_t afi_safi_count = 0;
- int adv_addpath_tx = 0;
+ bool adv_addpath_tx = false;
/* Non-Ext OP Len. */
cp = stream_get_endp(s);
* will use it is
* configured */
if (peer->addpath_type[afi][safi] != BGP_ADDPATH_NONE)
- adv_addpath_tx = 1;
+ adv_addpath_tx = true;
+
+ /* If we have enabled labeled unicast, we MUST check
+ * against unicast SAFI because addpath IDs are
+ * allocated under unicast SAFI, the same as the RIB
+ * is managed in unicast SAFI.
+ */
+ if (safi == SAFI_LABELED_UNICAST)
+ if (peer->addpath_type[afi][SAFI_UNICAST] !=
+ BGP_ADDPATH_NONE)
+ adv_addpath_tx = true;
}
}
SET_FLAG(flags, BGP_ADDPATH_TX);
SET_FLAG(peer->af_cap[afi][safi],
PEER_CAP_ADDPATH_AF_TX_ADV);
+ if (safi == SAFI_LABELED_UNICAST)
+ SET_FLAG(
+ peer->af_cap[afi][SAFI_UNICAST],
+ PEER_CAP_ADDPATH_AF_TX_ADV);
} else {
UNSET_FLAG(peer->af_cap[afi][safi],
PEER_CAP_ADDPATH_AF_TX_ADV);
/* If this is not the bestpath then check to see if there is an enabled
* addpath
* feature that requires us to advertise it */
- if (!CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)) {
- if (!bgp_addpath_tx_path(peer->addpath_type[afi][safi], pi)) {
+ if (!CHECK_FLAG(pi->flags, BGP_PATH_SELECTED))
+ if (!bgp_addpath_capable(pi, peer, afi, safi))
return false;
- }
- }
/* Aggregate-address suppress check. */
if (bgp_path_suppressed(pi) && !UNSUPPRESS_MAP_NAME(filter))
PEER_CAP_ADDPATH_AF_RX_RCV));
}
+bool bgp_addpath_capable(struct bgp_path_info *bpi, struct peer *peer,
+ afi_t afi, safi_t safi)
+{
+ return (bgp_addpath_tx_path(peer->addpath_type[afi][safi], bpi) ||
+ (safi == SAFI_LABELED_UNICAST &&
+ bgp_addpath_tx_path(peer->addpath_type[afi][SAFI_UNICAST],
+ bpi)));
+}
+
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)));
+ (addpath_capable && bgp_addpath_capable(bpi, peer, afi, safi)));
}
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);
+extern bool bgp_addpath_capable(struct bgp_path_info *bpi, struct peer *peer,
+ afi_t afi, safi_t safi);
/*
* Inline functions