bgpd: Convert bgp_addpath_encode_[tr]x() to bool from int

Rename addpath_encode[d] to addpath_capable to be consistent.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
This commit is contained in:
Donatas Abraitis 2022-01-27 09:51:59 +02:00
parent 23ad8186e5
commit be92fc9f1a
17 changed files with 86 additions and 101 deletions

View File

@ -151,7 +151,7 @@ bool bgp_adj_out_lookup(struct peer *peer, struct bgp_dest *dest,
struct peer_af *paf;
afi_t afi;
safi_t safi;
int addpath_capable;
bool addpath_capable;
RB_FOREACH (adj, bgp_adj_out_rb, &dest->adj_out)
SUBGRP_FOREACH_PEER (adj->subgroup, paf)

View File

@ -3728,11 +3728,11 @@ size_t bgp_packet_mpattr_start(struct stream *s, struct peer *peer, afi_t afi,
void bgp_packet_mpattr_prefix(struct stream *s, afi_t afi, safi_t safi,
const struct prefix *p,
const struct prefix_rd *prd, mpls_label_t *label,
uint32_t num_labels, int addpath_encode,
uint32_t num_labels, bool addpath_capable,
uint32_t addpath_tx_id, struct attr *attr)
{
if (safi == SAFI_MPLS_VPN) {
if (addpath_encode)
if (addpath_capable)
stream_putl(s, addpath_tx_id);
/* Label, RD, Prefix write. */
stream_putc(s, p->prefixlen + 88);
@ -3742,17 +3742,17 @@ void bgp_packet_mpattr_prefix(struct stream *s, afi_t afi, safi_t safi,
} else if (afi == AFI_L2VPN && safi == SAFI_EVPN) {
/* EVPN prefix - contents depend on type */
bgp_evpn_encode_prefix(s, p, prd, label, num_labels, attr,
addpath_encode, addpath_tx_id);
addpath_capable, addpath_tx_id);
} else if (safi == SAFI_LABELED_UNICAST) {
/* Prefix write with label. */
stream_put_labeled_prefix(s, p, label, addpath_encode,
stream_put_labeled_prefix(s, p, label, addpath_capable,
addpath_tx_id);
} else if (safi == SAFI_FLOWSPEC) {
stream_putc(s, p->u.prefix_flowspec.prefixlen);
stream_put(s, (const void *)p->u.prefix_flowspec.ptr,
p->u.prefix_flowspec.prefixlen);
} else
stream_put_prefix_addpath(s, p, addpath_encode, addpath_tx_id);
stream_put_prefix_addpath(s, p, addpath_capable, addpath_tx_id);
}
size_t bgp_packet_mpattr_prefix_size(afi_t afi, safi_t safi,
@ -3896,7 +3896,7 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
struct prefix *p, afi_t afi, safi_t safi,
struct peer *from, struct prefix_rd *prd,
mpls_label_t *label, uint32_t num_labels,
int addpath_encode, uint32_t addpath_tx_id)
bool addpath_capable, uint32_t addpath_tx_id)
{
size_t cp;
size_t aspath_sizep;
@ -3920,7 +3920,7 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
mpattrlen_pos = bgp_packet_mpattr_start(s, peer, afi, safi,
vecarr, attr);
bgp_packet_mpattr_prefix(s, afi, safi, p, prd, label,
num_labels, addpath_encode,
num_labels, addpath_capable,
addpath_tx_id, attr);
bgp_packet_mpattr_end(s, mpattrlen_pos);
}
@ -4419,7 +4419,7 @@ void bgp_packet_mpunreach_prefix(struct stream *s, const struct prefix *p,
afi_t afi, safi_t safi,
const struct prefix_rd *prd,
mpls_label_t *label, uint32_t num_labels,
int addpath_encode, uint32_t addpath_tx_id,
bool addpath_capable, uint32_t addpath_tx_id,
struct attr *attr)
{
uint8_t wlabel[3] = {0x80, 0x00, 0x00};
@ -4430,7 +4430,7 @@ void bgp_packet_mpunreach_prefix(struct stream *s, const struct prefix *p,
}
bgp_packet_mpattr_prefix(s, afi, safi, p, prd, label, num_labels,
addpath_encode, addpath_tx_id, attr);
addpath_capable, addpath_tx_id, attr);
}
void bgp_packet_mpunreach_end(struct stream *s, size_t attrlen_pnt)
@ -4473,7 +4473,7 @@ void bgp_dump_routes_attr(struct stream *s, struct attr *attr,
unsigned long len;
size_t aspath_lenp;
struct aspath *aspath;
int addpath_encode = 0;
bool addpath_capable = false;
uint32_t addpath_tx_id = 0;
/* Remember current pointer. */
@ -4602,7 +4602,7 @@ void bgp_dump_routes_attr(struct stream *s, struct attr *attr,
stream_putc(s, 0);
/* Prefix */
stream_put_prefix_addpath(s, prefix, addpath_encode,
stream_put_prefix_addpath(s, prefix, addpath_capable,
addpath_tx_id);
/* Set MP attribute length. */

View File

@ -400,12 +400,14 @@ extern struct attr *bgp_attr_aggregate_intern(
struct community *community, struct ecommunity *ecommunity,
struct lcommunity *lcommunity, struct bgp_aggregate *aggregate,
uint8_t atomic_aggregate, const struct prefix *p);
extern bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *,
struct stream *, struct attr *,
extern bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
struct stream *s, struct attr *attr,
struct bpacket_attr_vec_arr *vecarr,
struct prefix *, afi_t, safi_t,
struct peer *, struct prefix_rd *,
mpls_label_t *, uint32_t, int, uint32_t);
struct prefix *p, afi_t afi, safi_t safi,
struct peer *from, struct prefix_rd *prd,
mpls_label_t *label, uint32_t num_labels,
bool addpath_capable,
uint32_t addpath_tx_id);
extern void bgp_dump_routes_attr(struct stream *s, struct attr *attr,
const struct prefix *p);
extern bool attrhash_cmp(const void *arg1, const void *arg2);
@ -456,8 +458,8 @@ extern void bgp_packet_mpattr_prefix(struct stream *s, afi_t afi, safi_t safi,
const struct prefix *p,
const struct prefix_rd *prd,
mpls_label_t *label, uint32_t num_labels,
int addpath_encode, uint32_t addpath_tx_id,
struct attr *);
bool addpath_capable,
uint32_t addpath_tx_id, struct attr *);
extern size_t bgp_packet_mpattr_prefix_size(afi_t afi, safi_t safi,
const struct prefix *p);
extern void bgp_packet_mpattr_end(struct stream *s, size_t sizep);
@ -467,7 +469,7 @@ extern size_t bgp_packet_mpunreach_start(struct stream *s, afi_t afi,
extern void bgp_packet_mpunreach_prefix(
struct stream *s, const struct prefix *p, afi_t afi, safi_t safi,
const struct prefix_rd *prd, mpls_label_t *label, uint32_t num_labels,
int addpath_encode, uint32_t addpath_tx_id, struct attr *attr);
bool addpath_capable, uint32_t addpath_tx_id, struct attr *attr);
extern void bgp_packet_mpunreach_end(struct stream *s, size_t attrlen_pnt);
extern bgp_attr_parse_ret_t bgp_attr_nexthop_valid(struct peer *peer,

View File

@ -75,7 +75,7 @@ static void bgp_conditional_adv_routes(struct peer *peer, afi_t afi,
struct route_map *rmap,
enum update_type update_type)
{
int addpath_capable;
bool addpath_capable;
struct bgp_dest *dest;
struct bgp_path_info *pi;
struct bgp_path_info path;

View File

@ -298,14 +298,6 @@ static void bgp_dump_routes_index_table(struct bgp *bgp)
fflush(bgp_dump_routes.fp);
}
static int bgp_addpath_encode_rx(struct peer *peer, afi_t afi, safi_t safi)
{
return (CHECK_FLAG(peer->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV)
&& CHECK_FLAG(peer->af_cap[afi][safi],
PEER_CAP_ADDPATH_AF_TX_RCV));
}
static struct bgp_path_info *
bgp_dump_route_node_record(int afi, struct bgp_dest *dest,
struct bgp_path_info *path, unsigned int seq)
@ -313,16 +305,16 @@ bgp_dump_route_node_record(int afi, struct bgp_dest *dest,
struct stream *obuf;
size_t sizep;
size_t endp;
int addpath_encoded;
bool addpath_capable;
const struct prefix *p = bgp_dest_get_prefix(dest);
obuf = bgp_dump_obuf;
stream_reset(obuf);
addpath_encoded = bgp_addpath_encode_rx(path->peer, afi, SAFI_UNICAST);
addpath_capable = bgp_addpath_encode_rx(path->peer, afi, SAFI_UNICAST);
/* MRT header */
if (afi == AFI_IP && addpath_encoded)
if (afi == AFI_IP && addpath_capable)
bgp_dump_header(obuf, MSG_TABLE_DUMP_V2,
TABLE_DUMP_V2_RIB_IPV4_UNICAST_ADDPATH,
BGP_DUMP_ROUTES);
@ -330,7 +322,7 @@ bgp_dump_route_node_record(int afi, struct bgp_dest *dest,
bgp_dump_header(obuf, MSG_TABLE_DUMP_V2,
TABLE_DUMP_V2_RIB_IPV4_UNICAST,
BGP_DUMP_ROUTES);
else if (afi == AFI_IP6 && addpath_encoded)
else if (afi == AFI_IP6 && addpath_capable)
bgp_dump_header(obuf, MSG_TABLE_DUMP_V2,
TABLE_DUMP_V2_RIB_IPV6_UNICAST_ADDPATH,
BGP_DUMP_ROUTES);
@ -378,7 +370,7 @@ bgp_dump_route_node_record(int afi, struct bgp_dest *dest,
stream_putl(obuf, time(NULL) - (bgp_clock() - path->uptime));
/*Path Identifier*/
if (addpath_encoded) {
if (addpath_capable) {
stream_putl(obuf, path->addpath_rx_id);
}
@ -549,15 +541,15 @@ static void bgp_dump_packet_func(struct bgp_dump *bgp_dump, struct peer *peer,
struct stream *packet)
{
struct stream *obuf;
int addpath_encoded = 0;
bool addpath_capable = false;
/* If dump file pointer is disabled return immediately. */
if (bgp_dump->fp == NULL)
return;
if (peer->su.sa.sa_family == AF_INET) {
addpath_encoded =
addpath_capable =
bgp_addpath_encode_rx(peer, AFI_IP, SAFI_UNICAST);
} else if (peer->su.sa.sa_family == AF_INET6) {
addpath_encoded =
addpath_capable =
bgp_addpath_encode_rx(peer, AFI_IP6, SAFI_UNICAST);
}
@ -566,13 +558,13 @@ static void bgp_dump_packet_func(struct bgp_dump *bgp_dump, struct peer *peer,
stream_reset(obuf);
/* Dump header and common part. */
if (CHECK_FLAG(peer->cap, PEER_CAP_AS4_RCV) && addpath_encoded) {
if (CHECK_FLAG(peer->cap, PEER_CAP_AS4_RCV) && addpath_capable) {
bgp_dump_header(obuf, MSG_PROTOCOL_BGP4MP,
BGP4MP_MESSAGE_AS4_ADDPATH, bgp_dump->type);
} else if (CHECK_FLAG(peer->cap, PEER_CAP_AS4_RCV)) {
bgp_dump_header(obuf, MSG_PROTOCOL_BGP4MP, BGP4MP_MESSAGE_AS4,
bgp_dump->type);
} else if (addpath_encoded) {
} else if (addpath_capable) {
bgp_dump_header(obuf, MSG_PROTOCOL_BGP4MP,
BGP4MP_MESSAGE_ADDPATH, bgp_dump->type);
} else {

View File

@ -4903,12 +4903,12 @@ void bgp_evpn_route2json(const struct prefix_evpn *p, json_object *json)
void bgp_evpn_encode_prefix(struct stream *s, const struct prefix *p,
const struct prefix_rd *prd, mpls_label_t *label,
uint32_t num_labels, struct attr *attr,
int addpath_encode, uint32_t addpath_tx_id)
bool addpath_capable, uint32_t addpath_tx_id)
{
struct prefix_evpn *evp = (struct prefix_evpn *)p;
int len, ipa_len = 0;
if (addpath_encode)
if (addpath_capable)
stream_putl(s, addpath_tx_id);
/* Route type */
@ -4990,7 +4990,7 @@ int bgp_nlri_parse_evpn(struct peer *peer, struct attr *attr,
afi_t afi;
safi_t safi;
uint32_t addpath_id;
int addpath_encoded;
bool addpath_capable;
int psize = 0;
uint8_t rtype;
struct prefix p;
@ -5002,17 +5002,14 @@ int bgp_nlri_parse_evpn(struct peer *peer, struct attr *attr,
safi = packet->safi;
addpath_id = 0;
addpath_encoded =
(CHECK_FLAG(peer->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV)
&& CHECK_FLAG(peer->af_cap[afi][safi],
PEER_CAP_ADDPATH_AF_TX_RCV));
addpath_capable = bgp_addpath_encode_rx(peer, afi, safi);
for (; pnt < lim; pnt += psize) {
/* Clear prefix structure. */
memset(&p, 0, sizeof(struct prefix));
/* Deal with path-id if AddPath is supported. */
if (addpath_encoded) {
if (addpath_capable) {
/* When packet overflow occurs return immediately. */
if (pnt + BGP_ADDPATH_ID_LEN > lim)
return BGP_NLRI_PARSE_ERROR_PACKET_OVERFLOW;

View File

@ -183,7 +183,7 @@ extern void bgp_evpn_route2json(const struct prefix_evpn *p, json_object *json);
extern void bgp_evpn_encode_prefix(struct stream *s, const struct prefix *p,
const struct prefix_rd *prd,
mpls_label_t *label, uint32_t num_labels,
struct attr *attr, int addpath_encode,
struct attr *attr, bool addpath_capable,
uint32_t addpath_tx_id);
extern int bgp_nlri_parse_evpn(struct peer *peer, struct attr *attr,
struct bgp_nlri *packet, int withdraw);

View File

@ -335,7 +335,7 @@ int bgp_nlri_parse_label(struct peer *peer, struct attr *attr,
int prefixlen;
afi_t afi;
safi_t safi;
int addpath_encoded;
bool addpath_capable;
uint32_t addpath_id;
mpls_label_t label = MPLS_INVALID_LABEL;
uint8_t llen;
@ -346,16 +346,13 @@ int bgp_nlri_parse_label(struct peer *peer, struct attr *attr,
safi = packet->safi;
addpath_id = 0;
addpath_encoded =
(CHECK_FLAG(peer->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV)
&& CHECK_FLAG(peer->af_cap[afi][safi],
PEER_CAP_ADDPATH_AF_TX_RCV));
addpath_capable = bgp_addpath_encode_rx(peer, afi, safi);
for (; pnt < lim; pnt += psize) {
/* Clear prefix structure. */
memset(&p, 0, sizeof(struct prefix));
if (addpath_encoded) {
if (addpath_capable) {
/* When packet overflow occurs return immediately. */
if (pnt + BGP_ADDPATH_ID_LEN > lim)

View File

@ -112,7 +112,7 @@ int bgp_nlri_parse_vpn(struct peer *peer, struct attr *attr,
mpls_label_t label = {0};
afi_t afi;
safi_t safi;
int addpath_encoded;
bool addpath_capable;
uint32_t addpath_id;
int ret = 0;
@ -126,17 +126,14 @@ int bgp_nlri_parse_vpn(struct peer *peer, struct attr *attr,
safi = packet->safi;
addpath_id = 0;
addpath_encoded =
(CHECK_FLAG(peer->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV)
&& CHECK_FLAG(peer->af_cap[afi][safi],
PEER_CAP_ADDPATH_AF_TX_RCV));
addpath_capable = bgp_addpath_encode_rx(peer, afi, safi);
#define VPN_PREFIXLEN_MIN_BYTES (3 + 8) /* label + RD */
while (STREAM_READABLE(data) > 0) {
/* Clear prefix structure. */
memset(&p, 0, sizeof(struct prefix));
if (addpath_encoded) {
if (addpath_capable) {
STREAM_GET(&addpath_id, data, BGP_ADDPATH_ID_LEN);
addpath_id = ntohl(addpath_id);
}

View File

@ -5599,7 +5599,7 @@ void bgp_reset(void)
prefix_list_reset();
}
static int bgp_addpath_encode_rx(struct peer *peer, afi_t afi, safi_t safi)
bool bgp_addpath_encode_rx(struct peer *peer, afi_t afi, safi_t safi)
{
return (CHECK_FLAG(peer->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV)
&& CHECK_FLAG(peer->af_cap[afi][safi],
@ -5618,7 +5618,7 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr,
int ret;
afi_t afi;
safi_t safi;
int addpath_encoded;
bool addpath_capable;
uint32_t addpath_id;
pnt = packet->nlri;
@ -5626,7 +5626,7 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr,
afi = packet->afi;
safi = packet->safi;
addpath_id = 0;
addpath_encoded = bgp_addpath_encode_rx(peer, afi, safi);
addpath_capable = bgp_addpath_encode_rx(peer, afi, safi);
/* RFC4771 6.3 The NLRI field in the UPDATE message is checked for
syntactic validity. If the field is syntactically incorrect,
@ -5635,7 +5635,7 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr,
/* Clear prefix structure. */
memset(&p, 0, sizeof(struct prefix));
if (addpath_encoded) {
if (addpath_capable) {
/* When packet overflow occurs return immediately. */
if (pnt + BGP_ADDPATH_ID_LEN >= lim)
@ -9841,7 +9841,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
int first = 0;
struct listnode *node, *nnode;
struct peer *peer;
int addpath_capable;
bool addpath_capable;
int has_adj;
unsigned int first_as;
bool nexthop_self =

View File

@ -838,4 +838,5 @@ extern void bgp_aggregate_toggle_suppressed(struct bgp_aggregate *aggregate,
extern void subgroup_announce_reset_nhop(uint8_t family, struct attr *attr);
const char *
bgp_path_selection_reason2str(enum bgp_path_selection_reason reason);
extern bool bgp_addpath_encode_rx(struct peer *peer, afi_t afi, safi_t safi);
#endif /* _QUAGGA_BGP_ROUTE_H */

View File

@ -1925,7 +1925,7 @@ int update_group_clear_update_dbg(struct update_group *updgrp, void *arg)
}
/* Return true if we should addpath encode NLRI to this peer */
int bgp_addpath_encode_tx(struct peer *peer, afi_t afi, safi_t safi)
bool bgp_addpath_encode_tx(struct peer *peer, afi_t afi, safi_t safi)
{
return (CHECK_FLAG(peer->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV)
&& CHECK_FLAG(peer->af_cap[afi][safi],

View File

@ -461,7 +461,7 @@ extern int update_group_clear_update_dbg(struct update_group *updgrp,
void *arg);
extern void update_bgp_group_free(struct bgp *bgp);
extern int bgp_addpath_encode_tx(struct peer *peer, afi_t afi, safi_t safi);
extern bool bgp_addpath_encode_tx(struct peer *peer, afi_t afi, safi_t safi);
/*
* Inline functions

View File

@ -145,7 +145,7 @@ static int group_announce_route_walkcb(struct update_group *updgrp, void *arg)
safi_t safi;
struct peer *peer;
struct bgp_adj_out *adj, *adj_next;
int addpath_capable;
bool addpath_capable;
afi = UPDGRP_AFI(updgrp);
safi = UPDGRP_SAFI(updgrp);
@ -655,7 +655,7 @@ void subgroup_announce_table(struct update_subgroup *subgrp,
struct peer *peer;
afi_t afi;
safi_t safi;
int addpath_capable;
bool addpath_capable;
struct bgp *bgp;
bool advertise;

View File

@ -672,7 +672,7 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
char send_attr_str[BUFSIZ];
int send_attr_printed = 0;
int num_pfx = 0;
int addpath_encode = 0;
bool addpath_capable = false;
int addpath_overhead = 0;
uint32_t addpath_tx_id = 0;
struct prefix_rd *prd = NULL;
@ -695,8 +695,8 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
bpacket_attr_vec_arr_reset(&vecarr);
addpath_encode = bgp_addpath_encode_tx(peer, afi, safi);
addpath_overhead = addpath_encode ? BGP_ADDPATH_ID_LEN : 0;
addpath_capable = bgp_addpath_encode_tx(peer, afi, safi);
addpath_overhead = addpath_capable ? BGP_ADDPATH_ID_LEN : 0;
adv = bgp_adv_fifo_first(&subgrp->sync->update);
while (adv) {
@ -788,7 +788,7 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
if ((afi == AFI_IP && safi == SAFI_UNICAST)
&& !peer_cap_enhe(peer, afi, safi))
stream_put_prefix_addpath(s, dest_p, addpath_encode,
stream_put_prefix_addpath(s, dest_p, addpath_capable,
addpath_tx_id);
else {
/* Encode the prefix in MP_REACH_NLRI attribute */
@ -813,7 +813,7 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
bgp_packet_mpattr_prefix(snlri, afi, safi, dest_p, prd,
label_pnt, num_labels,
addpath_encode, addpath_tx_id,
addpath_capable, addpath_tx_id,
adv->baa->attr);
}
@ -846,7 +846,7 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
bgp_debug_rdpfxpath2str(afi, safi, prd, dest_p,
label_pnt, num_labels,
addpath_encode, addpath_tx_id,
addpath_capable, addpath_tx_id,
&adv->baa->attr->evpn_overlay,
pfx_buf, sizeof(pfx_buf));
zlog_debug("u%" PRIu64 ":s%" PRIu64 " send UPDATE %s",
@ -924,7 +924,7 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
int space_remaining = 0;
int space_needed = 0;
int num_pfx = 0;
int addpath_encode = 0;
bool addpath_capable = false;
int addpath_overhead = 0;
uint32_t addpath_tx_id = 0;
const struct prefix_rd *prd = NULL;
@ -941,8 +941,8 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
safi = SUBGRP_SAFI(subgrp);
s = subgrp->work;
stream_reset(s);
addpath_encode = bgp_addpath_encode_tx(peer, afi, safi);
addpath_overhead = addpath_encode ? BGP_ADDPATH_ID_LEN : 0;
addpath_capable = bgp_addpath_encode_tx(peer, afi, safi);
addpath_overhead = addpath_capable ? BGP_ADDPATH_ID_LEN : 0;
while ((adv = bgp_adv_fifo_first(&subgrp->sync->withdraw)) != NULL) {
const struct prefix *dest_p;
@ -970,7 +970,7 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
if (afi == AFI_IP && safi == SAFI_UNICAST
&& !peer_cap_enhe(peer, afi, safi))
stream_put_prefix_addpath(s, dest_p, addpath_encode,
stream_put_prefix_addpath(s, dest_p, addpath_capable,
addpath_tx_id);
else {
if (dest->pdest)
@ -1005,7 +1005,7 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
}
bgp_packet_mpunreach_prefix(s, dest_p, afi, safi, prd,
NULL, 0, addpath_encode,
NULL, 0, addpath_capable,
addpath_tx_id, NULL);
}
@ -1015,7 +1015,7 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
char pfx_buf[BGP_PRD_PATH_STRLEN];
bgp_debug_rdpfxpath2str(afi, safi, prd, dest_p, NULL, 0,
addpath_encode, addpath_tx_id,
addpath_capable, addpath_tx_id,
NULL, pfx_buf, sizeof(pfx_buf));
zlog_debug("u%" PRIu64 ":s%" PRIu64" send UPDATE %s -- unreachable",
subgrp->update_group->id, subgrp->id,
@ -1068,7 +1068,7 @@ void subgroup_default_update_packet(struct update_subgroup *subgrp,
afi_t afi;
safi_t safi;
struct bpacket_attr_vec_arr vecarr;
int addpath_encode = 0;
bool addpath_capable = false;
if (DISABLE_BGP_ANNOUNCE)
return;
@ -1080,7 +1080,7 @@ void subgroup_default_update_packet(struct update_subgroup *subgrp,
afi = SUBGRP_AFI(subgrp);
safi = SUBGRP_SAFI(subgrp);
bpacket_attr_vec_arr_reset(&vecarr);
addpath_encode = bgp_addpath_encode_tx(peer, afi, safi);
addpath_capable = bgp_addpath_encode_tx(peer, afi, safi);
memset(&p, 0, sizeof(p));
p.family = afi2family(afi);
@ -1100,7 +1100,7 @@ void subgroup_default_update_packet(struct update_subgroup *subgrp,
bgp_dump_attr(attr, attrstr, sizeof(attrstr));
if (addpath_encode)
if (addpath_capable)
snprintf(tx_id_buf, sizeof(tx_id_buf),
" with addpath ID %u",
BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE);
@ -1125,7 +1125,7 @@ void subgroup_default_update_packet(struct update_subgroup *subgrp,
stream_putw(s, 0);
total_attr_len = bgp_packet_attribute(
NULL, peer, s, attr, &vecarr, &p, afi, safi, from, NULL, NULL,
0, addpath_encode, BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE);
0, addpath_capable, BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE);
/* Set Total Path Attribute Length. */
stream_putw_at(s, pos, total_attr_len);
@ -1134,7 +1134,7 @@ void subgroup_default_update_packet(struct update_subgroup *subgrp,
if (p.family == AF_INET && safi == SAFI_UNICAST
&& !peer_cap_enhe(peer, afi, safi))
stream_put_prefix_addpath(
s, &p, addpath_encode,
s, &p, addpath_capable,
BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE);
/* Set size. */
@ -1158,7 +1158,7 @@ void subgroup_default_withdraw_packet(struct update_subgroup *subgrp)
size_t mplen_pos = 0;
afi_t afi;
safi_t safi;
int addpath_encode = 0;
bool addpath_capable = false;
if (DISABLE_BGP_ANNOUNCE)
return;
@ -1166,7 +1166,7 @@ void subgroup_default_withdraw_packet(struct update_subgroup *subgrp)
peer = SUBGRP_PEER(subgrp);
afi = SUBGRP_AFI(subgrp);
safi = SUBGRP_SAFI(subgrp);
addpath_encode = bgp_addpath_encode_tx(peer, afi, safi);
addpath_capable = bgp_addpath_encode_tx(peer, afi, safi);
memset(&p, 0, sizeof(p));
p.family = afi2family(afi);
@ -1180,7 +1180,7 @@ void subgroup_default_withdraw_packet(struct update_subgroup *subgrp)
* ============================ 29 */
char tx_id_buf[30];
if (addpath_encode)
if (addpath_capable)
snprintf(tx_id_buf, sizeof(tx_id_buf),
" with addpath ID %u",
BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE);
@ -1204,7 +1204,7 @@ void subgroup_default_withdraw_packet(struct update_subgroup *subgrp)
if (p.family == AF_INET && safi == SAFI_UNICAST
&& !peer_cap_enhe(peer, afi, safi)) {
stream_put_prefix_addpath(
s, &p, addpath_encode,
s, &p, addpath_capable,
BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE);
unfeasible_len = stream_get_endp(s) - cp - 2;
@ -1220,7 +1220,7 @@ void subgroup_default_withdraw_packet(struct update_subgroup *subgrp)
mp_start = stream_get_endp(s);
mplen_pos = bgp_packet_mpunreach_start(s, afi, safi);
bgp_packet_mpunreach_prefix(
s, &p, afi, safi, NULL, NULL, 0, addpath_encode,
s, &p, afi, safi, NULL, NULL, 0, addpath_capable,
BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE, NULL);
/* Set the mp_unreach attr's length */

View File

@ -990,7 +990,7 @@ int stream_put_in6_addr_at(struct stream *s, size_t putp,
/* Put prefix by nlri type format. */
int stream_put_prefix_addpath(struct stream *s, const struct prefix *p,
int addpath_encode, uint32_t addpath_tx_id)
bool addpath_capable, uint32_t addpath_tx_id)
{
size_t psize;
size_t psize_with_addpath;
@ -999,7 +999,7 @@ int stream_put_prefix_addpath(struct stream *s, const struct prefix *p,
psize = PSIZE(p->prefixlen);
if (addpath_encode)
if (addpath_capable)
psize_with_addpath = psize + 4;
else
psize_with_addpath = psize;
@ -1009,7 +1009,7 @@ int stream_put_prefix_addpath(struct stream *s, const struct prefix *p,
return 0;
}
if (addpath_encode) {
if (addpath_capable) {
s->data[s->endp++] = (uint8_t)(addpath_tx_id >> 24);
s->data[s->endp++] = (uint8_t)(addpath_tx_id >> 16);
s->data[s->endp++] = (uint8_t)(addpath_tx_id >> 8);
@ -1030,7 +1030,7 @@ int stream_put_prefix(struct stream *s, const struct prefix *p)
/* Put NLRI with label */
int stream_put_labeled_prefix(struct stream *s, const struct prefix *p,
mpls_label_t *label, int addpath_encode,
mpls_label_t *label, bool addpath_capable,
uint32_t addpath_tx_id)
{
size_t psize;
@ -1040,14 +1040,14 @@ int stream_put_labeled_prefix(struct stream *s, const struct prefix *p,
STREAM_VERIFY_SANE(s);
psize = PSIZE(p->prefixlen);
psize_with_addpath = psize + (addpath_encode ? 4 : 0);
psize_with_addpath = psize + (addpath_capable ? 4 : 0);
if (STREAM_WRITEABLE(s) < (psize_with_addpath + 3)) {
STREAM_BOUND_WARN(s, "put");
return 0;
}
if (addpath_encode) {
if (addpath_capable) {
s->data[s->endp++] = (uint8_t)(addpath_tx_id >> 24);
s->data[s->endp++] = (uint8_t)(addpath_tx_id >> 16);
s->data[s->endp++] = (uint8_t)(addpath_tx_id >> 8);

View File

@ -197,13 +197,12 @@ extern int stream_put_in_addr_at(struct stream *s, size_t putp,
const struct in_addr *addr);
extern int stream_put_in6_addr_at(struct stream *s, size_t putp,
const struct in6_addr *addr);
extern int stream_put_prefix_addpath(struct stream *s,
const struct prefix *p,
int addpath_encode,
extern int stream_put_prefix_addpath(struct stream *s, const struct prefix *p,
bool addpath_capable,
uint32_t addpath_tx_id);
extern int stream_put_prefix(struct stream *s, const struct prefix *p);
extern int stream_put_labeled_prefix(struct stream *, const struct prefix *,
mpls_label_t *, int addpath_encode,
mpls_label_t *, bool addpath_capable,
uint32_t addpath_tx_id);
extern void stream_get(void *, struct stream *, size_t);
extern bool stream_get2(void *data, struct stream *s, size_t size);