Merge pull request #6059 from ton31337/fix/int_to_bool

bgpd: Convert lots of int type functions to bool/void
This commit is contained in:
Donald Sharp 2020-03-21 12:39:30 -04:00 committed by GitHub
commit 2ecb6952ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 505 additions and 520 deletions

View File

@ -65,8 +65,8 @@ bgp_addpath_names(enum bgp_addpath_strat strat)
/* /*
* Returns if any peer is transmitting addpaths for a given afi/safi. * Returns if any peer is transmitting addpaths for a given afi/safi.
*/ */
int bgp_addpath_is_addpath_used(struct bgp_addpath_bgp_data *d, afi_t afi, bool bgp_addpath_is_addpath_used(struct bgp_addpath_bgp_data *d, afi_t afi,
safi_t safi) safi_t safi)
{ {
return d->total_peercount[afi][safi] > 0; return d->total_peercount[afi][safi] > 0;
} }
@ -123,15 +123,15 @@ uint32_t bgp_addpath_id_for_peer(struct peer *peer, afi_t afi, safi_t safi,
* Returns true if the path has an assigned addpath ID for any of the addpath * Returns true if the path has an assigned addpath ID for any of the addpath
* strategies. * strategies.
*/ */
int bgp_addpath_info_has_ids(struct bgp_addpath_info_data *d) bool bgp_addpath_info_has_ids(struct bgp_addpath_info_data *d)
{ {
int i; int i;
for (i = 0; i < BGP_ADDPATH_MAX; i++) for (i = 0; i < BGP_ADDPATH_MAX; i++)
if (d->addpath_tx_id[i] != 0) if (d->addpath_tx_id[i] != 0)
return 1; return true;
return 0; return false;
} }
/* /*
@ -152,7 +152,7 @@ void bgp_addpath_free_node_data(struct bgp_addpath_bgp_data *bd,
/* /*
* Check to see if the addpath strategy requires DMED to be configured to work. * Check to see if the addpath strategy requires DMED to be configured to work.
*/ */
int bgp_addpath_dmed_required(int strategy) bool bgp_addpath_dmed_required(int strategy)
{ {
return strategy == BGP_ADDPATH_BEST_PER_AS; return strategy == BGP_ADDPATH_BEST_PER_AS;
} }
@ -161,21 +161,20 @@ int bgp_addpath_dmed_required(int strategy)
* Return true if this is a path we should advertise due to a * Return true if this is a path we should advertise due to a
* configured addpath-tx knob * configured addpath-tx knob
*/ */
int bgp_addpath_tx_path(enum bgp_addpath_strat strat, bool bgp_addpath_tx_path(enum bgp_addpath_strat strat, struct bgp_path_info *pi)
struct bgp_path_info *pi)
{ {
switch (strat) { switch (strat) {
case BGP_ADDPATH_NONE: case BGP_ADDPATH_NONE:
return 0; return false;
case BGP_ADDPATH_ALL: case BGP_ADDPATH_ALL:
return 1; return true;
case BGP_ADDPATH_BEST_PER_AS: case BGP_ADDPATH_BEST_PER_AS:
if (CHECK_FLAG(pi->flags, BGP_PATH_DMED_SELECTED)) if (CHECK_FLAG(pi->flags, BGP_PATH_DMED_SELECTED))
return 1; return true;
else else
return 0; return false;
default: default:
return 0; return false;
} }
} }

View File

@ -32,8 +32,8 @@
void bgp_addpath_init_bgp_data(struct bgp_addpath_bgp_data *d); void bgp_addpath_init_bgp_data(struct bgp_addpath_bgp_data *d);
int bgp_addpath_is_addpath_used(struct bgp_addpath_bgp_data *d, afi_t afi, bool bgp_addpath_is_addpath_used(struct bgp_addpath_bgp_data *d, afi_t afi,
safi_t safi); safi_t safi);
void bgp_addpath_free_node_data(struct bgp_addpath_bgp_data *bd, void bgp_addpath_free_node_data(struct bgp_addpath_bgp_data *bd,
struct bgp_addpath_node_data *nd, struct bgp_addpath_node_data *nd,
@ -43,7 +43,7 @@ void bgp_addpath_free_info_data(struct bgp_addpath_info_data *d,
struct bgp_addpath_node_data *nd); struct bgp_addpath_node_data *nd);
int bgp_addpath_info_has_ids(struct bgp_addpath_info_data *d); bool bgp_addpath_info_has_ids(struct bgp_addpath_info_data *d);
uint32_t bgp_addpath_id_for_peer(struct peer *peer, afi_t afi, safi_t safi, uint32_t bgp_addpath_id_for_peer(struct peer *peer, afi_t afi, safi_t safi,
struct bgp_addpath_info_data *d); struct bgp_addpath_info_data *d);
@ -51,14 +51,14 @@ uint32_t bgp_addpath_id_for_peer(struct peer *peer, afi_t afi, safi_t safi,
const struct bgp_addpath_strategy_names * const struct bgp_addpath_strategy_names *
bgp_addpath_names(enum bgp_addpath_strat strat); bgp_addpath_names(enum bgp_addpath_strat strat);
int bgp_addpath_dmed_required(int strategy); bool bgp_addpath_dmed_required(int strategy);
/* /*
* Return true if this is a path we should advertise due to a configured * Return true if this is a path we should advertise due to a configured
* addpath-tx knob * addpath-tx knob
*/ */
int bgp_addpath_tx_path(enum bgp_addpath_strat strat, bool bgp_addpath_tx_path(enum bgp_addpath_strat strat,
struct bgp_path_info *pi); struct bgp_path_info *pi);
/* /*
* Change the type of addpath used for a peer. * Change the type of addpath used for a peer.
*/ */

View File

@ -144,8 +144,8 @@ void bgp_advertise_unintern(struct hash *hash, struct bgp_advertise_attr *baa)
} }
} }
int bgp_adj_out_lookup(struct peer *peer, struct bgp_node *rn, bool bgp_adj_out_lookup(struct peer *peer, struct bgp_node *rn,
uint32_t addpath_tx_id) uint32_t addpath_tx_id)
{ {
struct bgp_adj_out *adj; struct bgp_adj_out *adj;
struct peer_af *paf; struct peer_af *paf;
@ -169,11 +169,12 @@ int bgp_adj_out_lookup(struct peer *peer, struct bgp_node *rn,
&& adj->addpath_tx_id != addpath_tx_id) && adj->addpath_tx_id != addpath_tx_id)
continue; continue;
return (adj->adv ? (adj->adv->baa ? 1 : 0) return (adj->adv
: (adj->attr ? 1 : 0)); ? (adj->adv->baa ? true : false)
: (adj->attr ? true : false));
} }
return 0; return false;
} }
@ -208,8 +209,8 @@ void bgp_adj_in_remove(struct bgp_node *rn, struct bgp_adj_in *bai)
XFREE(MTYPE_BGP_ADJ_IN, bai); XFREE(MTYPE_BGP_ADJ_IN, bai);
} }
int bgp_adj_in_unset(struct bgp_node *rn, struct peer *peer, bool bgp_adj_in_unset(struct bgp_node *rn, struct peer *peer,
uint32_t addpath_id) uint32_t addpath_id)
{ {
struct bgp_adj_in *adj; struct bgp_adj_in *adj;
struct bgp_adj_in *adj_next; struct bgp_adj_in *adj_next;
@ -217,7 +218,7 @@ int bgp_adj_in_unset(struct bgp_node *rn, struct peer *peer,
adj = rn->adj_in; adj = rn->adj_in;
if (!adj) if (!adj)
return 0; return false;
while (adj) { while (adj) {
adj_next = adj->next; adj_next = adj->next;
@ -230,7 +231,7 @@ int bgp_adj_in_unset(struct bgp_node *rn, struct peer *peer,
adj = adj_next; adj = adj_next;
} }
return 1; return true;
} }
void bgp_sync_init(struct peer *peer) void bgp_sync_init(struct peer *peer)

View File

@ -139,10 +139,10 @@ struct bgp_synchronize {
#define BGP_ADJ_IN_DEL(N, A) BGP_PATH_INFO_DEL(N, A, adj_in) #define BGP_ADJ_IN_DEL(N, A) BGP_PATH_INFO_DEL(N, A, adj_in)
/* Prototypes. */ /* Prototypes. */
extern int bgp_adj_out_lookup(struct peer *, struct bgp_node *, uint32_t); extern bool bgp_adj_out_lookup(struct peer *, struct bgp_node *, uint32_t);
extern void bgp_adj_in_set(struct bgp_node *, struct peer *, struct attr *, extern void bgp_adj_in_set(struct bgp_node *, struct peer *, struct attr *,
uint32_t); uint32_t);
extern int bgp_adj_in_unset(struct bgp_node *, struct peer *, uint32_t); extern bool bgp_adj_in_unset(struct bgp_node *, struct peer *, uint32_t);
extern void bgp_adj_in_remove(struct bgp_node *, struct bgp_adj_in *); extern void bgp_adj_in_remove(struct bgp_node *, struct bgp_adj_in *);
extern void bgp_sync_init(struct peer *); extern void bgp_sync_init(struct peer *);

View File

@ -130,14 +130,14 @@ static struct cluster_list *cluster_parse(struct in_addr *pnt, int length)
return cluster; return cluster;
} }
int cluster_loop_check(struct cluster_list *cluster, struct in_addr originator) bool cluster_loop_check(struct cluster_list *cluster, struct in_addr originator)
{ {
int i; int i;
for (i = 0; i < cluster->length / 4; i++) for (i = 0; i < cluster->length / 4; i++)
if (cluster->list[i].s_addr == originator.s_addr) if (cluster->list[i].s_addr == originator.s_addr)
return 1; return true;
return 0; return false;
} }
static unsigned int cluster_hash_key_make(const void *p) static unsigned int cluster_hash_key_make(const void *p)
@ -263,16 +263,16 @@ void bgp_attr_flush_encap(struct attr *attr)
* *
* This algorithm could be made faster if needed * This algorithm could be made faster if needed
*/ */
static int encap_same(const struct bgp_attr_encap_subtlv *h1, static bool encap_same(const struct bgp_attr_encap_subtlv *h1,
const struct bgp_attr_encap_subtlv *h2) const struct bgp_attr_encap_subtlv *h2)
{ {
const struct bgp_attr_encap_subtlv *p; const struct bgp_attr_encap_subtlv *p;
const struct bgp_attr_encap_subtlv *q; const struct bgp_attr_encap_subtlv *q;
if (h1 == h2) if (h1 == h2)
return 1; return true;
if (h1 == NULL || h2 == NULL) if (h1 == NULL || h2 == NULL)
return 0; return false;
for (p = h1; p; p = p->next) { for (p = h1; p; p = p->next) {
for (q = h2; q; q = q->next) { for (q = h2; q; q = q->next) {
@ -283,7 +283,7 @@ static int encap_same(const struct bgp_attr_encap_subtlv *h1,
} }
} }
if (!q) if (!q)
return 0; return false;
} }
for (p = h2; p; p = p->next) { for (p = h2; p; p = p->next) {
@ -295,10 +295,10 @@ static int encap_same(const struct bgp_attr_encap_subtlv *h1,
} }
} }
if (!q) if (!q)
return 0; return false;
} }
return 1; return true;
} }
static void *encap_hash_alloc(void *p) static void *encap_hash_alloc(void *p)
@ -1274,7 +1274,7 @@ const uint8_t attr_flags_values[] = {
}; };
static const size_t attr_flags_values_max = array_size(attr_flags_values) - 1; static const size_t attr_flags_values_max = array_size(attr_flags_values) - 1;
static int bgp_attr_flag_invalid(struct bgp_attr_parser_args *args) static bool bgp_attr_flag_invalid(struct bgp_attr_parser_args *args)
{ {
uint8_t mask = BGP_ATTR_FLAG_EXTLEN; uint8_t mask = BGP_ATTR_FLAG_EXTLEN;
const uint8_t flags = args->flags; const uint8_t flags = args->flags;
@ -1282,9 +1282,9 @@ static int bgp_attr_flag_invalid(struct bgp_attr_parser_args *args)
/* there may be attributes we don't know about */ /* there may be attributes we don't know about */
if (attr_code > attr_flags_values_max) if (attr_code > attr_flags_values_max)
return 0; return false;
if (attr_flags_values[attr_code] == 0) if (attr_flags_values[attr_code] == 0)
return 0; return false;
/* RFC4271, "For well-known attributes, the Transitive bit MUST be set /* RFC4271, "For well-known attributes, the Transitive bit MUST be set
* to * to
@ -1296,7 +1296,7 @@ static int bgp_attr_flag_invalid(struct bgp_attr_parser_args *args)
EC_BGP_ATTR_FLAG, EC_BGP_ATTR_FLAG,
"%s well-known attributes must have transitive flag set (%x)", "%s well-known attributes must have transitive flag set (%x)",
lookup_msg(attr_str, attr_code, NULL), flags); lookup_msg(attr_str, attr_code, NULL), flags);
return 1; return true;
} }
/* "For well-known attributes and for optional non-transitive /* "For well-known attributes and for optional non-transitive
@ -1309,7 +1309,7 @@ static int bgp_attr_flag_invalid(struct bgp_attr_parser_args *args)
"%s well-known attribute " "%s well-known attribute "
"must NOT have the partial flag set (%x)", "must NOT have the partial flag set (%x)",
lookup_msg(attr_str, attr_code, NULL), flags); lookup_msg(attr_str, attr_code, NULL), flags);
return 1; return true;
} }
if (CHECK_FLAG(flags, BGP_ATTR_FLAG_OPTIONAL) if (CHECK_FLAG(flags, BGP_ATTR_FLAG_OPTIONAL)
&& !CHECK_FLAG(flags, BGP_ATTR_FLAG_TRANS)) { && !CHECK_FLAG(flags, BGP_ATTR_FLAG_TRANS)) {
@ -1317,7 +1317,7 @@ static int bgp_attr_flag_invalid(struct bgp_attr_parser_args *args)
"%s optional + transitive attribute " "%s optional + transitive attribute "
"must NOT have the partial flag set (%x)", "must NOT have the partial flag set (%x)",
lookup_msg(attr_str, attr_code, NULL), flags); lookup_msg(attr_str, attr_code, NULL), flags);
return 1; return true;
} }
} }
@ -1329,10 +1329,10 @@ static int bgp_attr_flag_invalid(struct bgp_attr_parser_args *args)
SET_FLAG(mask, BGP_ATTR_FLAG_PARTIAL); SET_FLAG(mask, BGP_ATTR_FLAG_PARTIAL);
if ((flags & ~mask) == attr_flags_values[attr_code]) if ((flags & ~mask) == attr_flags_values[attr_code])
return 0; return false;
bgp_attr_flags_diagnose(args, attr_flags_values[attr_code]); bgp_attr_flags_diagnose(args, attr_flags_values[attr_code]);
return 1; return true;
} }
/* Get origin attribute of the update message. */ /* Get origin attribute of the update message. */
@ -3562,7 +3562,7 @@ void bgp_packet_mpattr_end(struct stream *s, size_t sizep)
stream_putw_at(s, sizep, (stream_get_endp(s) - sizep) - 2); stream_putw_at(s, sizep, (stream_get_endp(s) - sizep) - 2);
} }
static int bgp_append_local_as(struct peer *peer, afi_t afi, safi_t safi) static bool bgp_append_local_as(struct peer *peer, afi_t afi, safi_t safi)
{ {
if (!BGP_AS_IS_PRIVATE(peer->local_as) if (!BGP_AS_IS_PRIVATE(peer->local_as)
|| (BGP_AS_IS_PRIVATE(peer->local_as) || (BGP_AS_IS_PRIVATE(peer->local_as)
@ -3574,8 +3574,8 @@ static int bgp_append_local_as(struct peer *peer, afi_t afi, safi_t safi)
PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE) PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)
&& !CHECK_FLAG(peer->af_flags[afi][safi], && !CHECK_FLAG(peer->af_flags[afi][safi],
PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE))) PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)))
return 1; return true;
return 0; return false;
} }
/* Make attribute packet. */ /* Make attribute packet. */

View File

@ -333,7 +333,7 @@ extern unsigned long int attr_count(void);
extern unsigned long int attr_unknown_count(void); extern unsigned long int attr_unknown_count(void);
/* Cluster list prototypes. */ /* Cluster list prototypes. */
extern int cluster_loop_check(struct cluster_list *, struct in_addr); extern bool cluster_loop_check(struct cluster_list *, struct in_addr);
extern void cluster_unintern(struct cluster_list *); extern void cluster_unintern(struct cluster_list *);
/* Below exported for unit-test purposes only */ /* Below exported for unit-test purposes only */

View File

@ -54,25 +54,25 @@ void bgp_add_routermac_ecom(struct attr *attr, struct ethaddr *routermac)
* format accepted: AA:BB:CC:DD:EE:FF:GG:HH:II:JJ * format accepted: AA:BB:CC:DD:EE:FF:GG:HH:II:JJ
* if id is null, check only is done * if id is null, check only is done
*/ */
int str2esi(const char *str, struct eth_segment_id *id) bool str2esi(const char *str, struct eth_segment_id *id)
{ {
unsigned int a[ESI_LEN]; unsigned int a[ESI_LEN];
int i; int i;
if (!str) if (!str)
return 0; return false;
if (sscanf(str, "%2x:%2x:%2x:%2x:%2x:%2x:%2x:%2x:%2x:%2x", a + 0, a + 1, if (sscanf(str, "%2x:%2x:%2x:%2x:%2x:%2x:%2x:%2x:%2x:%2x", a + 0, a + 1,
a + 2, a + 3, a + 4, a + 5, a + 6, a + 7, a + 8, a + 9) a + 2, a + 3, a + 4, a + 5, a + 6, a + 7, a + 8, a + 9)
!= ESI_LEN) { != ESI_LEN) {
/* error in incoming str length */ /* error in incoming str length */
return 0; return false;
} }
/* valid mac address */ /* valid mac address */
if (!id) if (!id)
return 1; return true;
for (i = 0; i < ESI_LEN; ++i) for (i = 0; i < ESI_LEN; ++i)
id->val[i] = a[i] & 0xff; id->val[i] = a[i] & 0xff;
return 1; return true;
} }
char *esi2str(struct eth_segment_id *id) char *esi2str(struct eth_segment_id *id)

View File

@ -51,7 +51,7 @@ struct bgp_route_evpn {
union gw_addr gw_ip; union gw_addr gw_ip;
}; };
extern int str2esi(const char *str, struct eth_segment_id *id); extern bool str2esi(const char *str, struct eth_segment_id *id);
extern char *esi2str(struct eth_segment_id *id); extern char *esi2str(struct eth_segment_id *id);
extern char *ecom_mac2str(char *ecom_mac); extern char *ecom_mac2str(char *ecom_mac);

View File

@ -72,21 +72,21 @@ void bgp_bfd_peer_group2peer_copy(struct peer *conf, struct peer *peer)
* bgp_bfd_is_peer_multihop - returns whether BFD peer is multi-hop or single * bgp_bfd_is_peer_multihop - returns whether BFD peer is multi-hop or single
* hop. * hop.
*/ */
int bgp_bfd_is_peer_multihop(struct peer *peer) bool bgp_bfd_is_peer_multihop(struct peer *peer)
{ {
struct bfd_info *bfd_info; struct bfd_info *bfd_info;
bfd_info = (struct bfd_info *)peer->bfd_info; bfd_info = (struct bfd_info *)peer->bfd_info;
if (!bfd_info) if (!bfd_info)
return 0; return false;
if ((bfd_info->type == BFD_TYPE_MULTIHOP) if ((bfd_info->type == BFD_TYPE_MULTIHOP)
|| ((peer->sort == BGP_PEER_IBGP) && !peer->shared_network) || ((peer->sort == BGP_PEER_IBGP) && !peer->shared_network)
|| is_ebgp_multihop_configured(peer)) || is_ebgp_multihop_configured(peer))
return 1; return true;
else else
return 0; return false;
} }
/* /*

View File

@ -39,6 +39,6 @@ extern void bgp_bfd_peer_config_write(struct vty *vty, struct peer *peer,
extern void bgp_bfd_show_info(struct vty *vty, struct peer *peer, bool use_json, extern void bgp_bfd_show_info(struct vty *vty, struct peer *peer, bool use_json,
json_object *json_neigh); json_object *json_neigh);
extern int bgp_bfd_is_peer_multihop(struct peer *peer); extern bool bgp_bfd_is_peer_multihop(struct peer *peer);
#endif /* _QUAGGA_BGP_BFD_H */ #endif /* _QUAGGA_BGP_BFD_H */

View File

@ -68,7 +68,7 @@ enum MRT_MSG_TYPES {
MSG_TABLE_DUMP /* routing table dump */ MSG_TABLE_DUMP /* routing table dump */
}; };
static int attr_parse(struct stream *s, uint16_t len) static void attr_parse(struct stream *s, uint16_t len)
{ {
unsigned int flag; unsigned int flag;
unsigned int type; unsigned int type;
@ -115,8 +115,6 @@ static int attr_parse(struct stream *s, uint16_t len)
break; break;
} }
} }
return 0;
} }
int main(int argc, char **argv) int main(int argc, char **argv)

View File

@ -128,7 +128,7 @@ static int community_compare(const void *a1, const void *a2)
return 0; return 0;
} }
int community_include(struct community *com, uint32_t val) bool community_include(struct community *com, uint32_t val)
{ {
int i; int i;
@ -136,9 +136,8 @@ int community_include(struct community *com, uint32_t val)
for (i = 0; i < com->size; i++) for (i = 0; i < com->size; i++)
if (memcmp(&val, com_nthval(com, i), sizeof(uint32_t)) == 0) if (memcmp(&val, com_nthval(com, i), sizeof(uint32_t)) == 0)
return 1; return true;
return false;
return 0;
} }
uint32_t community_val_get(struct community *com, int i) uint32_t community_val_get(struct community *com, int i)
@ -564,19 +563,19 @@ unsigned int community_hash_make(const struct community *com)
return jhash2(pnt, com->size, 0x43ea96c1); return jhash2(pnt, com->size, 0x43ea96c1);
} }
int community_match(const struct community *com1, const struct community *com2) bool community_match(const struct community *com1, const struct community *com2)
{ {
int i = 0; int i = 0;
int j = 0; int j = 0;
if (com1 == NULL && com2 == NULL) if (com1 == NULL && com2 == NULL)
return 1; return true;
if (com1 == NULL || com2 == NULL) if (com1 == NULL || com2 == NULL)
return 0; return false;
if (com1->size < com2->size) if (com1->size < com2->size)
return 0; return false;
/* Every community on com2 needs to be on com1 for this to match */ /* Every community on com2 needs to be on com1 for this to match */
while (i < com1->size && j < com2->size) { while (i < com1->size && j < com2->size) {
@ -586,9 +585,9 @@ int community_match(const struct community *com1, const struct community *com2)
} }
if (j == com2->size) if (j == com2->size)
return 1; return true;
else else
return 0; return false;
} }
/* If two aspath have same value then return 1 else return 0. This /* If two aspath have same value then return 1 else return 0. This

View File

@ -77,7 +77,7 @@ extern void community_unintern(struct community **);
extern char *community_str(struct community *, bool make_json); extern char *community_str(struct community *, bool make_json);
extern unsigned int community_hash_make(const struct community *); extern unsigned int community_hash_make(const struct community *);
extern struct community *community_str2com(const char *); extern struct community *community_str2com(const char *);
extern int community_match(const struct community *, const struct community *); extern bool community_match(const struct community *, const struct community *);
extern bool community_cmp(const struct community *c1, extern bool community_cmp(const struct community *c1,
const struct community *c2); const struct community *c2);
extern struct community *community_merge(struct community *, extern struct community *community_merge(struct community *,
@ -85,7 +85,7 @@ extern struct community *community_merge(struct community *,
extern struct community *community_delete(struct community *, extern struct community *community_delete(struct community *,
struct community *); struct community *);
extern struct community *community_dup(struct community *); extern struct community *community_dup(struct community *);
extern int community_include(struct community *, uint32_t); extern bool community_include(struct community *, uint32_t);
extern void community_del_val(struct community *, uint32_t *); extern void community_del_val(struct community *, uint32_t *);
extern unsigned long community_count(void); extern unsigned long community_count(void);
extern struct hash *community_hash(void); extern struct hash *community_hash(void);

View File

@ -184,8 +184,8 @@ static const struct message bgp_notify_fsm_msg[] = {
const char *const bgp_origin_str[] = {"i", "e", "?"}; const char *const bgp_origin_str[] = {"i", "e", "?"};
const char *const bgp_origin_long_str[] = {"IGP", "EGP", "incomplete"}; const char *const bgp_origin_long_str[] = {"IGP", "EGP", "incomplete"};
static int bgp_debug_print_evpn_prefix(struct vty *vty, const char *desc, static void bgp_debug_print_evpn_prefix(struct vty *vty, const char *desc,
struct prefix *p); struct prefix *p);
/* Given a string return a pointer the corresponding peer structure */ /* Given a string return a pointer the corresponding peer structure */
static struct peer *bgp_find_peer(struct vty *vty, const char *peer_str) static struct peer *bgp_find_peer(struct vty *vty, const char *peer_str)
{ {
@ -315,8 +315,8 @@ static void bgp_debug_list_add_entry(struct list *list, const char *host,
listnode_add(list, filter); listnode_add(list, filter);
} }
static int bgp_debug_list_remove_entry(struct list *list, const char *host, static bool bgp_debug_list_remove_entry(struct list *list, const char *host,
struct prefix *p) struct prefix *p)
{ {
struct bgp_debug_filter *filter; struct bgp_debug_filter *filter;
struct listnode *node, *nnode; struct listnode *node, *nnode;
@ -326,21 +326,21 @@ static int bgp_debug_list_remove_entry(struct list *list, const char *host,
listnode_delete(list, filter); listnode_delete(list, filter);
XFREE(MTYPE_BGP_DEBUG_STR, filter->host); XFREE(MTYPE_BGP_DEBUG_STR, filter->host);
XFREE(MTYPE_BGP_DEBUG_FILTER, filter); XFREE(MTYPE_BGP_DEBUG_FILTER, filter);
return 1; return true;
} else if (p && filter->p->prefixlen == p->prefixlen } else if (p && filter->p->prefixlen == p->prefixlen
&& prefix_match(filter->p, p)) { && prefix_match(filter->p, p)) {
listnode_delete(list, filter); listnode_delete(list, filter);
prefix_free(&filter->p); prefix_free(&filter->p);
XFREE(MTYPE_BGP_DEBUG_FILTER, filter); XFREE(MTYPE_BGP_DEBUG_FILTER, filter);
return 1; return true;
} }
} }
return 0; return false;
} }
static int bgp_debug_list_has_entry(struct list *list, const char *host, static bool bgp_debug_list_has_entry(struct list *list, const char *host,
const struct prefix *p) const struct prefix *p)
{ {
struct bgp_debug_filter *filter; struct bgp_debug_filter *filter;
struct listnode *node, *nnode; struct listnode *node, *nnode;
@ -348,32 +348,32 @@ static int bgp_debug_list_has_entry(struct list *list, const char *host,
for (ALL_LIST_ELEMENTS(list, node, nnode, filter)) { for (ALL_LIST_ELEMENTS(list, node, nnode, filter)) {
if (host) { if (host) {
if (strcmp(filter->host, host) == 0) { if (strcmp(filter->host, host) == 0) {
return 1; return true;
} }
} else if (p) { } else if (p) {
if (filter->p->prefixlen == p->prefixlen if (filter->p->prefixlen == p->prefixlen
&& prefix_match(filter->p, p)) { && prefix_match(filter->p, p)) {
return 1; return true;
} }
} }
} }
return 0; return false;
} }
int bgp_debug_peer_updout_enabled(char *host) bool bgp_debug_peer_updout_enabled(char *host)
{ {
return (bgp_debug_list_has_entry(bgp_debug_update_out_peers, host, return (bgp_debug_list_has_entry(bgp_debug_update_out_peers, host,
NULL)); NULL));
} }
/* Dump attribute. */ /* Dump attribute. */
int bgp_dump_attr(struct attr *attr, char *buf, size_t size) bool bgp_dump_attr(struct attr *attr, char *buf, size_t size)
{ {
char addrbuf[BUFSIZ]; char addrbuf[BUFSIZ];
if (!attr) if (!attr)
return 0; return false;
buf[0] = '\0'; buf[0] = '\0';
@ -455,9 +455,9 @@ int bgp_dump_attr(struct attr *attr, char *buf, size_t size)
} }
if (strlen(buf) > 1) if (strlen(buf) > 1)
return 1; return true;
else else
return 0; return false;
} }
const char *bgp_notify_code_str(char code) const char *bgp_notify_code_str(char code)
@ -561,8 +561,8 @@ static void bgp_debug_clear_updgrp_update_dbg(struct bgp *bgp)
update_group_walk(bgp, update_group_clear_update_dbg, NULL); update_group_walk(bgp, update_group_clear_update_dbg, NULL);
} }
static int bgp_debug_print_evpn_prefix(struct vty *vty, const char *desc, static void bgp_debug_print_evpn_prefix(struct vty *vty, const char *desc,
struct prefix *p) struct prefix *p)
{ {
char evpn_desc[PREFIX2STR_BUFFER + INET_ADDRSTRLEN]; char evpn_desc[PREFIX2STR_BUFFER + INET_ADDRSTRLEN];
char buf[PREFIX2STR_BUFFER]; char buf[PREFIX2STR_BUFFER];
@ -601,8 +601,6 @@ static int bgp_debug_print_evpn_prefix(struct vty *vty, const char *desc,
} }
vty_out(vty, "%s %s\n", desc, evpn_desc); vty_out(vty, "%s %s\n", desc, evpn_desc);
return 0;
} }
static int bgp_debug_parse_evpn_prefix(struct vty *vty, struct cmd_token **argv, static int bgp_debug_parse_evpn_prefix(struct vty *vty, struct cmd_token **argv,
@ -2491,8 +2489,8 @@ int bgp_debug_keepalive(struct peer *peer)
bgp_debug_keepalive_peers); bgp_debug_keepalive_peers);
} }
int bgp_debug_update(struct peer *peer, struct prefix *p, bool bgp_debug_update(struct peer *peer, struct prefix *p,
struct update_group *updgrp, unsigned int inbound) struct update_group *updgrp, unsigned int inbound)
{ {
char *host = NULL; char *host = NULL;
@ -2503,7 +2501,7 @@ int bgp_debug_update(struct peer *peer, struct prefix *p,
if (bgp_debug_per_peer(host, term_bgp_debug_update, if (bgp_debug_per_peer(host, term_bgp_debug_update,
BGP_DEBUG_UPDATE_IN, BGP_DEBUG_UPDATE_IN,
bgp_debug_update_in_peers)) bgp_debug_update_in_peers))
return 1; return true;
} }
/* outbound */ /* outbound */
@ -2511,12 +2509,12 @@ int bgp_debug_update(struct peer *peer, struct prefix *p,
if (bgp_debug_per_peer(host, term_bgp_debug_update, if (bgp_debug_per_peer(host, term_bgp_debug_update,
BGP_DEBUG_UPDATE_OUT, BGP_DEBUG_UPDATE_OUT,
bgp_debug_update_out_peers)) bgp_debug_update_out_peers))
return 1; return true;
/* Check if update debugging implicitly enabled for the group. /* Check if update debugging implicitly enabled for the group.
*/ */
if (updgrp && UPDGRP_DBG_ON(updgrp)) if (updgrp && UPDGRP_DBG_ON(updgrp))
return 1; return true;
} }
@ -2524,34 +2522,34 @@ int bgp_debug_update(struct peer *peer, struct prefix *p,
if (bgp_debug_per_prefix(p, term_bgp_debug_update, if (bgp_debug_per_prefix(p, term_bgp_debug_update,
BGP_DEBUG_UPDATE_PREFIX, BGP_DEBUG_UPDATE_PREFIX,
bgp_debug_update_prefixes)) bgp_debug_update_prefixes))
return 1; return true;
} }
return 0; return false;
} }
int bgp_debug_bestpath(struct prefix *p) bool bgp_debug_bestpath(struct prefix *p)
{ {
if (BGP_DEBUG(bestpath, BESTPATH)) { if (BGP_DEBUG(bestpath, BESTPATH)) {
if (bgp_debug_per_prefix(p, term_bgp_debug_bestpath, if (bgp_debug_per_prefix(p, term_bgp_debug_bestpath,
BGP_DEBUG_BESTPATH, BGP_DEBUG_BESTPATH,
bgp_debug_bestpath_prefixes)) bgp_debug_bestpath_prefixes))
return 1; return true;
} }
return 0; return false;
} }
int bgp_debug_zebra(struct prefix *p) bool bgp_debug_zebra(struct prefix *p)
{ {
if (BGP_DEBUG(zebra, ZEBRA)) { if (BGP_DEBUG(zebra, ZEBRA)) {
if (bgp_debug_per_prefix(p, term_bgp_debug_zebra, if (bgp_debug_per_prefix(p, term_bgp_debug_zebra,
BGP_DEBUG_ZEBRA, BGP_DEBUG_ZEBRA,
bgp_debug_zebra_prefixes)) bgp_debug_zebra_prefixes))
return 1; return true;
} }
return 0; return false;
} }
const char *bgp_debug_rdpfxpath2str(afi_t afi, safi_t safi, const char *bgp_debug_rdpfxpath2str(afi_t afi, safi_t safi,

View File

@ -157,8 +157,8 @@ struct bgp_debug_filter {
extern const char *const bgp_type_str[]; extern const char *const bgp_type_str[];
extern int bgp_dump_attr(struct attr *, char *, size_t); extern bool bgp_dump_attr(struct attr *, char *, size_t);
extern int bgp_debug_peer_updout_enabled(char *host); extern bool bgp_debug_peer_updout_enabled(char *host);
extern const char *bgp_notify_code_str(char); extern const char *bgp_notify_code_str(char);
extern const char *bgp_notify_subcode_str(char, char); extern const char *bgp_notify_subcode_str(char, char);
extern void bgp_notify_print(struct peer *, struct bgp_notify *, const char *); extern void bgp_notify_print(struct peer *, struct bgp_notify *, const char *);
@ -166,10 +166,10 @@ extern void bgp_notify_print(struct peer *, struct bgp_notify *, const char *);
extern const struct message bgp_status_msg[]; extern const struct message bgp_status_msg[];
extern int bgp_debug_neighbor_events(struct peer *peer); extern int bgp_debug_neighbor_events(struct peer *peer);
extern int bgp_debug_keepalive(struct peer *peer); extern int bgp_debug_keepalive(struct peer *peer);
extern int bgp_debug_update(struct peer *peer, struct prefix *p, extern bool bgp_debug_update(struct peer *peer, struct prefix *p,
struct update_group *updgrp, unsigned int inbound); struct update_group *updgrp, unsigned int inbound);
extern int bgp_debug_bestpath(struct prefix *p); extern bool bgp_debug_bestpath(struct prefix *p);
extern int bgp_debug_zebra(struct prefix *p); extern bool bgp_debug_zebra(struct prefix *p);
extern const char *bgp_debug_rdpfxpath2str(afi_t, safi_t, struct prefix_rd *, extern const char *bgp_debug_rdpfxpath2str(afi_t, safi_t, struct prefix_rd *,
union prefixconstptr, mpls_label_t *, union prefixconstptr, mpls_label_t *,

View File

@ -75,7 +75,7 @@ static void ecommunity_hash_free(struct ecommunity *ecom)
structure, we don't add the value. Newly added value is sorted by structure, we don't add the value. Newly added value is sorted by
numerical order. When the value is added to the structure return 1 numerical order. When the value is added to the structure return 1
else return 0. */ else return 0. */
int ecommunity_add_val(struct ecommunity *ecom, struct ecommunity_val *eval) bool ecommunity_add_val(struct ecommunity *ecom, struct ecommunity_val *eval)
{ {
int c; int c;
@ -84,7 +84,7 @@ int ecommunity_add_val(struct ecommunity *ecom, struct ecommunity_val *eval)
ecom->size = 1; ecom->size = 1;
ecom->val = XCALLOC(MTYPE_ECOMMUNITY_VAL, ECOMMUNITY_SIZE); ecom->val = XCALLOC(MTYPE_ECOMMUNITY_VAL, ECOMMUNITY_SIZE);
memcpy(ecom->val, eval->val, ECOMMUNITY_SIZE); memcpy(ecom->val, eval->val, ECOMMUNITY_SIZE);
return 1; return true;
} }
/* If the value already exists in the structure return 0. */ /* If the value already exists in the structure return 0. */
@ -93,7 +93,7 @@ int ecommunity_add_val(struct ecommunity *ecom, struct ecommunity_val *eval)
p += ECOMMUNITY_SIZE, c++) { p += ECOMMUNITY_SIZE, c++) {
int ret = memcmp(p, eval->val, ECOMMUNITY_SIZE); int ret = memcmp(p, eval->val, ECOMMUNITY_SIZE);
if (ret == 0) if (ret == 0)
return 0; return false;
else if (ret > 0) else if (ret > 0)
break; break;
} }
@ -108,7 +108,7 @@ int ecommunity_add_val(struct ecommunity *ecom, struct ecommunity_val *eval)
(ecom->size - 1 - c) * ECOMMUNITY_SIZE); (ecom->size - 1 - c) * ECOMMUNITY_SIZE);
memcpy(ecom->val + (c * ECOMMUNITY_SIZE), eval->val, ECOMMUNITY_SIZE); memcpy(ecom->val + (c * ECOMMUNITY_SIZE), eval->val, ECOMMUNITY_SIZE);
return 1; return true;
} }
/* This function takes pointer to Extended Communites strucutre then /* This function takes pointer to Extended Communites strucutre then
@ -837,20 +837,20 @@ char *ecommunity_ecom2str(struct ecommunity *ecom, int format, int filter)
return str_buf; return str_buf;
} }
int ecommunity_match(const struct ecommunity *ecom1, bool ecommunity_match(const struct ecommunity *ecom1,
const struct ecommunity *ecom2) const struct ecommunity *ecom2)
{ {
int i = 0; int i = 0;
int j = 0; int j = 0;
if (ecom1 == NULL && ecom2 == NULL) if (ecom1 == NULL && ecom2 == NULL)
return 1; return true;
if (ecom1 == NULL || ecom2 == NULL) if (ecom1 == NULL || ecom2 == NULL)
return 0; return false;
if (ecom1->size < ecom2->size) if (ecom1->size < ecom2->size)
return 0; return false;
/* Every community on com2 needs to be on com1 for this to match */ /* Every community on com2 needs to be on com1 for this to match */
while (i < ecom1->size && j < ecom2->size) { while (i < ecom1->size && j < ecom2->size) {
@ -862,9 +862,9 @@ int ecommunity_match(const struct ecommunity *ecom1,
} }
if (j == ecom2->size) if (j == ecom2->size)
return 1; return true;
else else
return 0; return false;
} }
/* return first occurence of type */ /* return first occurence of type */
@ -889,15 +889,14 @@ extern struct ecommunity_val *ecommunity_lookup(const struct ecommunity *ecom,
/* remove ext. community matching type and subtype /* remove ext. community matching type and subtype
* return 1 on success ( removed ), 0 otherwise (not present) * return 1 on success ( removed ), 0 otherwise (not present)
*/ */
extern int ecommunity_strip(struct ecommunity *ecom, uint8_t type, extern bool ecommunity_strip(struct ecommunity *ecom, uint8_t type,
uint8_t subtype) uint8_t subtype)
{ {
uint8_t *p, *q, *new; uint8_t *p, *q, *new;
int c, found = 0; int c, found = 0;
/* When this is fist value, just add it. */ /* When this is fist value, just add it. */
if (ecom == NULL || ecom->val == NULL) { if (ecom == NULL || ecom->val == NULL)
return 0; return false;
}
/* Check if any existing ext community matches. */ /* Check if any existing ext community matches. */
/* Certain extended communities like the Route Target can be present /* Certain extended communities like the Route Target can be present
@ -910,13 +909,13 @@ extern int ecommunity_strip(struct ecommunity *ecom, uint8_t type,
} }
/* If no matching ext community exists, return. */ /* If no matching ext community exists, return. */
if (found == 0) if (found == 0)
return 0; return false;
/* Handle the case where everything needs to be stripped. */ /* Handle the case where everything needs to be stripped. */
if (found == ecom->size) { if (found == ecom->size) {
XFREE(MTYPE_ECOMMUNITY_VAL, ecom->val); XFREE(MTYPE_ECOMMUNITY_VAL, ecom->val);
ecom->size = 0; ecom->size = 0;
return 1; return true;
} }
/* Strip matching ext community(ies). */ /* Strip matching ext community(ies). */
@ -932,21 +931,21 @@ extern int ecommunity_strip(struct ecommunity *ecom, uint8_t type,
XFREE(MTYPE_ECOMMUNITY_VAL, ecom->val); XFREE(MTYPE_ECOMMUNITY_VAL, ecom->val);
ecom->val = new; ecom->val = new;
ecom->size -= found; ecom->size -= found;
return 1; return true;
} }
/* /*
* Remove specified extended community value from extended community. * Remove specified extended community value from extended community.
* Returns 1 if value was present (and hence, removed), 0 otherwise. * Returns 1 if value was present (and hence, removed), 0 otherwise.
*/ */
int ecommunity_del_val(struct ecommunity *ecom, struct ecommunity_val *eval) bool ecommunity_del_val(struct ecommunity *ecom, struct ecommunity_val *eval)
{ {
uint8_t *p; uint8_t *p;
int c, found = 0; int c, found = 0;
/* Make sure specified value exists. */ /* Make sure specified value exists. */
if (ecom == NULL || ecom->val == NULL) if (ecom == NULL || ecom->val == NULL)
return 0; return false;
c = 0; c = 0;
for (p = ecom->val; c < ecom->size; p += ECOMMUNITY_SIZE, c++) { for (p = ecom->val; c < ecom->size; p += ECOMMUNITY_SIZE, c++) {
if (!memcmp(p, eval->val, ECOMMUNITY_SIZE)) { if (!memcmp(p, eval->val, ECOMMUNITY_SIZE)) {
@ -955,7 +954,7 @@ int ecommunity_del_val(struct ecommunity *ecom, struct ecommunity_val *eval)
} }
} }
if (found == 0) if (found == 0)
return 0; return false;
/* Delete the selected value */ /* Delete the selected value */
ecom->size--; ecom->size--;
@ -968,7 +967,7 @@ int ecommunity_del_val(struct ecommunity *ecom, struct ecommunity_val *eval)
(ecom->size - c) * ECOMMUNITY_SIZE); (ecom->size - c) * ECOMMUNITY_SIZE);
XFREE(MTYPE_ECOMMUNITY_VAL, ecom->val); XFREE(MTYPE_ECOMMUNITY_VAL, ecom->val);
ecom->val = p; ecom->val = p;
return 1; return true;
} }
int ecommunity_fill_pbr_action(struct ecommunity_val *ecom_eval, int ecommunity_fill_pbr_action(struct ecommunity_val *ecom_eval,

View File

@ -165,22 +165,22 @@ extern unsigned int ecommunity_hash_make(const void *);
extern struct ecommunity *ecommunity_str2com(const char *, int, int); extern struct ecommunity *ecommunity_str2com(const char *, int, int);
extern char *ecommunity_ecom2str(struct ecommunity *, int, int); extern char *ecommunity_ecom2str(struct ecommunity *, int, int);
extern void ecommunity_strfree(char **s); extern void ecommunity_strfree(char **s);
extern int ecommunity_match(const struct ecommunity *, extern bool ecommunity_match(const struct ecommunity *,
const struct ecommunity *); const struct ecommunity *);
extern char *ecommunity_str(struct ecommunity *); extern char *ecommunity_str(struct ecommunity *);
extern struct ecommunity_val *ecommunity_lookup(const struct ecommunity *, extern struct ecommunity_val *ecommunity_lookup(const struct ecommunity *,
uint8_t, uint8_t); uint8_t, uint8_t);
extern int ecommunity_add_val(struct ecommunity *ecom, extern bool ecommunity_add_val(struct ecommunity *ecom,
struct ecommunity_val *eval); struct ecommunity_val *eval);
/* for vpn */ /* for vpn */
extern struct ecommunity *ecommunity_new(void); extern struct ecommunity *ecommunity_new(void);
extern int ecommunity_add_val(struct ecommunity *, struct ecommunity_val *); extern bool ecommunity_add_val(struct ecommunity *, struct ecommunity_val *);
extern int ecommunity_strip(struct ecommunity *ecom, uint8_t type, extern bool ecommunity_strip(struct ecommunity *ecom, uint8_t type,
uint8_t subtype); uint8_t subtype);
extern struct ecommunity *ecommunity_new(void); extern struct ecommunity *ecommunity_new(void);
extern int ecommunity_del_val(struct ecommunity *ecom, extern bool ecommunity_del_val(struct ecommunity *ecom,
struct ecommunity_val *eval); struct ecommunity_val *eval);
struct bgp_pbr_entry_action; struct bgp_pbr_entry_action;
extern int ecommunity_fill_pbr_action(struct ecommunity_val *ecom_eval, extern int ecommunity_fill_pbr_action(struct ecommunity_val *ecom_eval,
struct bgp_pbr_entry_action *api); struct bgp_pbr_entry_action *api);

View File

@ -2210,13 +2210,13 @@ static struct bgpevpn *evpn_create_update_vni(struct bgp *bgp, vni_t vni)
* appropriate action) and the VNI marked as unconfigured; the * appropriate action) and the VNI marked as unconfigured; the
* VNI will continue to exist, purely as a "learnt" entity. * VNI will continue to exist, purely as a "learnt" entity.
*/ */
static int evpn_delete_vni(struct bgp *bgp, struct bgpevpn *vpn) static void evpn_delete_vni(struct bgp *bgp, struct bgpevpn *vpn)
{ {
assert(bgp->vnihash); assert(bgp->vnihash);
if (!is_vni_live(vpn)) { if (!is_vni_live(vpn)) {
bgp_evpn_free(bgp, vpn); bgp_evpn_free(bgp, vpn);
return 0; return;
} }
/* We need to take the unconfigure action for each parameter of this VNI /* We need to take the unconfigure action for each parameter of this VNI
@ -2234,8 +2234,6 @@ static int evpn_delete_vni(struct bgp *bgp, struct bgpevpn *vpn)
/* Next, deal with the import side. */ /* Next, deal with the import side. */
if (is_import_rt_configured(vpn)) if (is_import_rt_configured(vpn))
evpn_unconfigure_import_rt(bgp, vpn, NULL); evpn_unconfigure_import_rt(bgp, vpn, NULL);
return 0;
} }
/* /*

View File

@ -302,12 +302,9 @@ static void as_list_delete(struct as_list *aslist)
as_list_free(aslist); as_list_free(aslist);
} }
static int as_list_empty(struct as_list *aslist) static bool as_list_empty(struct as_list *aslist)
{ {
if (aslist->head == NULL && aslist->tail == NULL) return aslist->head == NULL && aslist->tail == NULL;
return 1;
else
return 0;
} }
static void as_list_filter_delete(struct as_list *aslist, static void as_list_filter_delete(struct as_list *aslist,
@ -337,11 +334,9 @@ static void as_list_filter_delete(struct as_list *aslist,
XFREE(MTYPE_AS_STR, name); XFREE(MTYPE_AS_STR, name);
} }
static int as_filter_match(struct as_filter *asfilter, struct aspath *aspath) static bool as_filter_match(struct as_filter *asfilter, struct aspath *aspath)
{ {
if (bgp_regexec(asfilter->reg, aspath) != REG_NOMATCH) return bgp_regexec(asfilter->reg, aspath) != REG_NOMATCH;
return 1;
return 0;
} }
/* Apply AS path filter to AS. */ /* Apply AS path filter to AS. */
@ -374,26 +369,25 @@ void as_list_delete_hook(void (*func)(const char *))
as_list_master.delete_hook = func; as_list_master.delete_hook = func;
} }
static int as_list_dup_check(struct as_list *aslist, struct as_filter *new) static bool as_list_dup_check(struct as_list *aslist, struct as_filter *new)
{ {
struct as_filter *asfilter; struct as_filter *asfilter;
for (asfilter = aslist->head; asfilter; asfilter = asfilter->next) { for (asfilter = aslist->head; asfilter; asfilter = asfilter->next) {
if (asfilter->type == new->type if (asfilter->type == new->type
&& strcmp(asfilter->reg_str, new->reg_str) == 0) && strcmp(asfilter->reg_str, new->reg_str) == 0)
return 1; return true;
} }
return 0; return false;
} }
int config_bgp_aspath_validate(const char *regstr) bool config_bgp_aspath_validate(const char *regstr)
{ {
char valid_chars[] = "1234567890_^|[,{}() ]$*+.?-\\"; char valid_chars[] = "1234567890_^|[,{}() ]$*+.?-\\";
if (strspn(regstr, valid_chars) == strlen(regstr)) if (strspn(regstr, valid_chars) == strlen(regstr))
return 1; return true;
return false;
return 0;
} }
DEFUN(as_path, bgp_as_path_cmd, DEFUN(as_path, bgp_as_path_cmd,

View File

@ -31,6 +31,6 @@ extern enum as_filter_type as_list_apply(struct as_list *, void *);
extern struct as_list *as_list_lookup(const char *); extern struct as_list *as_list_lookup(const char *);
extern void as_list_add_hook(void (*func)(char *)); extern void as_list_add_hook(void (*func)(char *));
extern void as_list_delete_hook(void (*func)(const char *)); extern void as_list_delete_hook(void (*func)(const char *));
extern int config_bgp_aspath_validate(const char *regstr); extern bool config_bgp_aspath_validate(const char *regstr);
#endif /* _QUAGGA_BGP_FILTER_H */ #endif /* _QUAGGA_BGP_FILTER_H */

View File

@ -599,8 +599,8 @@ int bgp_flowspec_match_rules_fill(uint8_t *nlri_content, int len,
} }
/* return 1 if FS entry invalid or no NH IP */ /* return 1 if FS entry invalid or no NH IP */
int bgp_flowspec_get_first_nh(struct bgp *bgp, struct bgp_path_info *pi, bool bgp_flowspec_get_first_nh(struct bgp *bgp, struct bgp_path_info *pi,
struct prefix *p) struct prefix *p)
{ {
struct bgp_pbr_entry_main api; struct bgp_pbr_entry_main api;
int i; int i;
@ -609,7 +609,7 @@ int bgp_flowspec_get_first_nh(struct bgp *bgp, struct bgp_path_info *pi,
memset(&api, 0, sizeof(struct bgp_pbr_entry_main)); memset(&api, 0, sizeof(struct bgp_pbr_entry_main));
if (bgp_pbr_build_and_validate_entry(&rn->p, pi, &api) < 0) if (bgp_pbr_build_and_validate_entry(&rn->p, pi, &api) < 0)
return 1; return true;
for (i = 0; i < api.action_num; i++) { for (i = 0; i < api.action_num; i++) {
api_action = &api.actions[i]; api_action = &api.actions[i];
if (api_action->action != ACTION_REDIRECT_IP) if (api_action->action != ACTION_REDIRECT_IP)
@ -617,7 +617,7 @@ int bgp_flowspec_get_first_nh(struct bgp *bgp, struct bgp_path_info *pi,
p->family = AF_INET; p->family = AF_INET;
p->prefixlen = IPV4_MAX_BITLEN; p->prefixlen = IPV4_MAX_BITLEN;
p->u.prefix4 = api_action->u.zr.redirect_ip_v4; p->u.prefix4 = api_action->u.zr.redirect_ip_v4;
return 0; return false;
} }
return 1; return true;
} }

View File

@ -54,8 +54,7 @@ extern bool bgp_flowspec_contains_prefix(struct prefix *pfs,
struct prefix *input, struct prefix *input,
int prefix_check); int prefix_check);
extern int bgp_flowspec_get_first_nh(struct bgp *bgp, extern bool bgp_flowspec_get_first_nh(struct bgp *bgp, struct bgp_path_info *pi,
struct bgp_path_info *pi, struct prefix *nh);
struct prefix *nh);
#endif /* _FRR_BGP_FLOWSPEC_UTIL_H */ #endif /* _FRR_BGP_FLOWSPEC_UTIL_H */

View File

@ -664,32 +664,29 @@ static int bgp_graceful_deferral_timer_expire(struct thread *thread)
return bgp_best_path_select_defer(bgp, afi, safi); return bgp_best_path_select_defer(bgp, afi, safi);
} }
static int bgp_update_delay_applicable(struct bgp *bgp) static bool bgp_update_delay_applicable(struct bgp *bgp)
{ {
/* update_delay_over flag should be reset (set to 0) for any new /* update_delay_over flag should be reset (set to 0) for any new
applicability of the update-delay during BGP process lifetime. applicability of the update-delay during BGP process lifetime.
And it should be set after an occurence of the update-delay is And it should be set after an occurence of the update-delay is
over)*/ over)*/
if (!bgp->update_delay_over) if (!bgp->update_delay_over)
return 1; return true;
return false;
return 0;
} }
int bgp_update_delay_active(struct bgp *bgp) bool bgp_update_delay_active(struct bgp *bgp)
{ {
if (bgp->t_update_delay) if (bgp->t_update_delay)
return 1; return true;
return false;
return 0;
} }
int bgp_update_delay_configured(struct bgp *bgp) bool bgp_update_delay_configured(struct bgp *bgp)
{ {
if (bgp->v_update_delay) if (bgp->v_update_delay)
return 1; return true;
return false;
return 0;
} }
/* Do the post-processing needed when bgp comes out of the read-only mode /* Do the post-processing needed when bgp comes out of the read-only mode
@ -840,28 +837,25 @@ void bgp_adjust_routeadv(struct peer *peer)
} }
} }
static int bgp_maxmed_onstartup_applicable(struct bgp *bgp) static bool bgp_maxmed_onstartup_applicable(struct bgp *bgp)
{ {
if (!bgp->maxmed_onstartup_over) if (!bgp->maxmed_onstartup_over)
return 1; return true;
return false;
return 0;
} }
int bgp_maxmed_onstartup_configured(struct bgp *bgp) bool bgp_maxmed_onstartup_configured(struct bgp *bgp)
{ {
if (bgp->v_maxmed_onstartup != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) if (bgp->v_maxmed_onstartup != BGP_MAXMED_ONSTARTUP_UNCONFIGURED)
return 1; return true;
return false;
return 0;
} }
int bgp_maxmed_onstartup_active(struct bgp *bgp) bool bgp_maxmed_onstartup_active(struct bgp *bgp)
{ {
if (bgp->t_maxmed_onstartup) if (bgp->t_maxmed_onstartup)
return 1; return true;
return false;
return 0;
} }
void bgp_maxmed_update(struct bgp *bgp) void bgp_maxmed_update(struct bgp *bgp)

View File

@ -119,8 +119,8 @@ extern void bgp_fsm_change_status(struct peer *peer, int status);
extern const char *const peer_down_str[]; extern const char *const peer_down_str[];
extern void bgp_update_delay_end(struct bgp *); extern void bgp_update_delay_end(struct bgp *);
extern void bgp_maxmed_update(struct bgp *); extern void bgp_maxmed_update(struct bgp *);
extern int bgp_maxmed_onstartup_configured(struct bgp *); extern bool bgp_maxmed_onstartup_configured(struct bgp *);
extern int bgp_maxmed_onstartup_active(struct bgp *); extern bool bgp_maxmed_onstartup_active(struct bgp *);
extern int bgp_fsm_error_subcode(int status); extern int bgp_fsm_error_subcode(int status);
/** /**

View File

@ -59,8 +59,8 @@ static void lcommunity_hash_free(struct lcommunity *lcom)
structure, we don't add the value. Newly added value is sorted by structure, we don't add the value. Newly added value is sorted by
numerical order. When the value is added to the structure return 1 numerical order. When the value is added to the structure return 1
else return 0. */ else return 0. */
static int lcommunity_add_val(struct lcommunity *lcom, static bool lcommunity_add_val(struct lcommunity *lcom,
struct lcommunity_val *lval) struct lcommunity_val *lval)
{ {
uint8_t *p; uint8_t *p;
int ret; int ret;
@ -71,7 +71,7 @@ static int lcommunity_add_val(struct lcommunity *lcom,
lcom->size++; lcom->size++;
lcom->val = XMALLOC(MTYPE_LCOMMUNITY_VAL, lcom_length(lcom)); lcom->val = XMALLOC(MTYPE_LCOMMUNITY_VAL, lcom_length(lcom));
memcpy(lcom->val, lval->val, LCOMMUNITY_SIZE); memcpy(lcom->val, lval->val, LCOMMUNITY_SIZE);
return 1; return true;
} }
/* If the value already exists in the structure return 0. */ /* If the value already exists in the structure return 0. */
@ -79,7 +79,7 @@ static int lcommunity_add_val(struct lcommunity *lcom,
for (p = lcom->val; c < lcom->size; p += LCOMMUNITY_SIZE, c++) { for (p = lcom->val; c < lcom->size; p += LCOMMUNITY_SIZE, c++) {
ret = memcmp(p, lval->val, LCOMMUNITY_SIZE); ret = memcmp(p, lval->val, LCOMMUNITY_SIZE);
if (ret == 0) if (ret == 0)
return 0; return false;
if (ret > 0) if (ret > 0)
break; break;
} }
@ -94,7 +94,7 @@ static int lcommunity_add_val(struct lcommunity *lcom,
(lcom->size - 1 - c) * LCOMMUNITY_SIZE); (lcom->size - 1 - c) * LCOMMUNITY_SIZE);
memcpy(lcom->val + c * LCOMMUNITY_SIZE, lval->val, LCOMMUNITY_SIZE); memcpy(lcom->val + c * LCOMMUNITY_SIZE, lval->val, LCOMMUNITY_SIZE);
return 1; return true;
} }
/* This function takes pointer to Large Communites strucutre then /* This function takes pointer to Large Communites strucutre then
@ -456,7 +456,7 @@ struct lcommunity *lcommunity_str2com(const char *str)
return lcom; return lcom;
} }
int lcommunity_include(struct lcommunity *lcom, uint8_t *ptr) bool lcommunity_include(struct lcommunity *lcom, uint8_t *ptr)
{ {
int i; int i;
uint8_t *lcom_ptr; uint8_t *lcom_ptr;
@ -464,25 +464,25 @@ int lcommunity_include(struct lcommunity *lcom, uint8_t *ptr)
for (i = 0; i < lcom->size; i++) { for (i = 0; i < lcom->size; i++) {
lcom_ptr = lcom->val + (i * LCOMMUNITY_SIZE); lcom_ptr = lcom->val + (i * LCOMMUNITY_SIZE);
if (memcmp(ptr, lcom_ptr, LCOMMUNITY_SIZE) == 0) if (memcmp(ptr, lcom_ptr, LCOMMUNITY_SIZE) == 0)
return 1; return true;
} }
return 0; return false;
} }
int lcommunity_match(const struct lcommunity *lcom1, bool lcommunity_match(const struct lcommunity *lcom1,
const struct lcommunity *lcom2) const struct lcommunity *lcom2)
{ {
int i = 0; int i = 0;
int j = 0; int j = 0;
if (lcom1 == NULL && lcom2 == NULL) if (lcom1 == NULL && lcom2 == NULL)
return 1; return true;
if (lcom1 == NULL || lcom2 == NULL) if (lcom1 == NULL || lcom2 == NULL)
return 0; return false;
if (lcom1->size < lcom2->size) if (lcom1->size < lcom2->size)
return 0; return false;
/* Every community on com2 needs to be on com1 for this to match */ /* Every community on com2 needs to be on com1 for this to match */
while (i < lcom1->size && j < lcom2->size) { while (i < lcom1->size && j < lcom2->size) {
@ -494,9 +494,9 @@ int lcommunity_match(const struct lcommunity *lcom1,
} }
if (j == lcom2->size) if (j == lcom2->size)
return 1; return true;
else else
return 0; return false;
} }
/* Delete one lcommunity. */ /* Delete one lcommunity. */

View File

@ -66,10 +66,10 @@ extern void lcommunity_unintern(struct lcommunity **);
extern unsigned int lcommunity_hash_make(const void *); extern unsigned int lcommunity_hash_make(const void *);
extern struct hash *lcommunity_hash(void); extern struct hash *lcommunity_hash(void);
extern struct lcommunity *lcommunity_str2com(const char *); extern struct lcommunity *lcommunity_str2com(const char *);
extern int lcommunity_match(const struct lcommunity *, extern bool lcommunity_match(const struct lcommunity *,
const struct lcommunity *); const struct lcommunity *);
extern char *lcommunity_str(struct lcommunity *, bool make_json); extern char *lcommunity_str(struct lcommunity *, bool make_json);
extern int lcommunity_include(struct lcommunity *lcom, uint8_t *ptr); extern bool lcommunity_include(struct lcommunity *lcom, uint8_t *ptr);
extern void lcommunity_del_val(struct lcommunity *lcom, uint8_t *ptr); extern void lcommunity_del_val(struct lcommunity *lcom, uint8_t *ptr);
extern void bgp_compute_aggregate_lcommunity( extern void bgp_compute_aggregate_lcommunity(

View File

@ -385,13 +385,13 @@ int vpn_leak_label_callback(
return 0; return 0;
} }
static int ecom_intersect(struct ecommunity *e1, struct ecommunity *e2) static bool ecom_intersect(struct ecommunity *e1, struct ecommunity *e2)
{ {
int i; int i;
int j; int j;
if (!e1 || !e2) if (!e1 || !e2)
return 0; return false;
for (i = 0; i < e1->size; ++i) { for (i = 0; i < e1->size; ++i) {
for (j = 0; j < e2->size; ++j) { for (j = 0; j < e2->size; ++j) {
@ -399,11 +399,11 @@ static int ecom_intersect(struct ecommunity *e1, struct ecommunity *e2)
e2->val + (j * ECOMMUNITY_SIZE), e2->val + (j * ECOMMUNITY_SIZE),
ECOMMUNITY_SIZE)) { ECOMMUNITY_SIZE)) {
return 1; return true;
} }
} }
} }
return 0; return false;
} }
static bool labels_same(struct bgp_path_info *bpi, mpls_label_t *label, static bool labels_same(struct bgp_path_info *bpi, mpls_label_t *label,

View File

@ -470,8 +470,8 @@ static void bgp_connected_cleanup(struct route_table *table,
} }
} }
int bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type, uint8_t sub_type, bool bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type,
struct attr *attr, struct bgp_node *rn) uint8_t sub_type, struct attr *attr, struct bgp_node *rn)
{ {
uint8_t new_afi = afi == AFI_IP ? AF_INET : AF_INET6; uint8_t new_afi = afi == AFI_IP ? AF_INET : AF_INET6;
struct bgp_addr tmp_addr = {{0}}, *addr = NULL; struct bgp_addr tmp_addr = {{0}}, *addr = NULL;
@ -505,7 +505,7 @@ int bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type, uint8_t sub_type,
attr->mp_nexthop_global_in; attr->mp_nexthop_global_in;
tmp_addr.p.prefixlen = IPV4_MAX_BITLEN; tmp_addr.p.prefixlen = IPV4_MAX_BITLEN;
} else } else
return 0; return false;
} }
break; break;
case AF_INET6: case AF_INET6:
@ -523,7 +523,7 @@ int bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type, uint8_t sub_type,
addr = hash_lookup(bgp->address_hash, &tmp_addr); addr = hash_lookup(bgp->address_hash, &tmp_addr);
if (addr) if (addr)
return 1; return true;
if (new_afi == AF_INET) { if (new_afi == AF_INET) {
memset(&tmp_tip, 0, sizeof(struct tip_addr)); memset(&tmp_tip, 0, sizeof(struct tip_addr));
@ -539,13 +539,13 @@ int bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type, uint8_t sub_type,
tip = hash_lookup(bgp->tip_hash, &tmp_tip); tip = hash_lookup(bgp->tip_hash, &tmp_tip);
if (tip) if (tip)
return 1; return true;
} }
return 0; return false;
} }
int bgp_multiaccess_check_v4(struct in_addr nexthop, struct peer *peer) bool bgp_multiaccess_check_v4(struct in_addr nexthop, struct peer *peer)
{ {
struct bgp_node *rn1; struct bgp_node *rn1;
struct bgp_node *rn2; struct bgp_node *rn2;
@ -558,7 +558,7 @@ int bgp_multiaccess_check_v4(struct in_addr nexthop, struct peer *peer)
rn1 = bgp_node_match(peer->bgp->connected_table[AFI_IP], &p); rn1 = bgp_node_match(peer->bgp->connected_table[AFI_IP], &p);
if (!rn1) if (!rn1)
return 0; return false;
p.family = AF_INET; p.family = AF_INET;
p.prefixlen = IPV4_MAX_BITLEN; p.prefixlen = IPV4_MAX_BITLEN;
@ -567,18 +567,18 @@ int bgp_multiaccess_check_v4(struct in_addr nexthop, struct peer *peer)
rn2 = bgp_node_match(peer->bgp->connected_table[AFI_IP], &p); rn2 = bgp_node_match(peer->bgp->connected_table[AFI_IP], &p);
if (!rn2) { if (!rn2) {
bgp_unlock_node(rn1); bgp_unlock_node(rn1);
return 0; return false;
} }
ret = (rn1 == rn2) ? 1 : 0; ret = (rn1 == rn2);
bgp_unlock_node(rn1); bgp_unlock_node(rn1);
bgp_unlock_node(rn2); bgp_unlock_node(rn2);
return (ret); return ret;
} }
int bgp_multiaccess_check_v6(struct in6_addr nexthop, struct peer *peer) bool bgp_multiaccess_check_v6(struct in6_addr nexthop, struct peer *peer)
{ {
struct bgp_node *rn1; struct bgp_node *rn1;
struct bgp_node *rn2; struct bgp_node *rn2;
@ -591,7 +591,7 @@ int bgp_multiaccess_check_v6(struct in6_addr nexthop, struct peer *peer)
rn1 = bgp_node_match(peer->bgp->connected_table[AFI_IP6], &p); rn1 = bgp_node_match(peer->bgp->connected_table[AFI_IP6], &p);
if (!rn1) if (!rn1)
return 0; return false;
p.family = AF_INET6; p.family = AF_INET6;
p.prefixlen = IPV6_MAX_BITLEN; p.prefixlen = IPV6_MAX_BITLEN;
@ -600,10 +600,10 @@ int bgp_multiaccess_check_v6(struct in6_addr nexthop, struct peer *peer)
rn2 = bgp_node_match(peer->bgp->connected_table[AFI_IP6], &p); rn2 = bgp_node_match(peer->bgp->connected_table[AFI_IP6], &p);
if (!rn2) { if (!rn2) {
bgp_unlock_node(rn1); bgp_unlock_node(rn1);
return 0; return false;
} }
ret = (rn1 == rn2) ? 1 : 0; ret = (rn1 == rn2);
bgp_unlock_node(rn1); bgp_unlock_node(rn1);
bgp_unlock_node(rn2); bgp_unlock_node(rn2);
@ -611,9 +611,9 @@ int bgp_multiaccess_check_v6(struct in6_addr nexthop, struct peer *peer)
return ret; return ret;
} }
int bgp_subgrp_multiaccess_check_v6(struct in6_addr nexthop, bool bgp_subgrp_multiaccess_check_v6(struct in6_addr nexthop,
struct update_subgroup *subgrp, struct update_subgroup *subgrp,
struct peer *exclude) struct peer *exclude)
{ {
struct bgp_node *rn1 = NULL, *rn2 = NULL; struct bgp_node *rn1 = NULL, *rn2 = NULL;
struct peer_af *paf = NULL; struct peer_af *paf = NULL;
@ -630,7 +630,7 @@ int bgp_subgrp_multiaccess_check_v6(struct in6_addr nexthop,
bgp = SUBGRP_INST(subgrp); bgp = SUBGRP_INST(subgrp);
rn1 = bgp_node_match(bgp->connected_table[AFI_IP6], &np); rn1 = bgp_node_match(bgp->connected_table[AFI_IP6], &np);
if (!rn1) if (!rn1)
return 0; return false;
SUBGRP_FOREACH_PEER (subgrp, paf) { SUBGRP_FOREACH_PEER (subgrp, paf) {
/* Skip peer we're told to exclude - e.g., source of route. */ /* Skip peer we're told to exclude - e.g., source of route. */
@ -642,7 +642,7 @@ int bgp_subgrp_multiaccess_check_v6(struct in6_addr nexthop,
if (rn1 == rn2) { if (rn1 == rn2) {
bgp_unlock_node(rn1); bgp_unlock_node(rn1);
bgp_unlock_node(rn2); bgp_unlock_node(rn2);
return 1; return true;
} }
if (rn2) if (rn2)
@ -650,12 +650,12 @@ int bgp_subgrp_multiaccess_check_v6(struct in6_addr nexthop,
} }
bgp_unlock_node(rn1); bgp_unlock_node(rn1);
return 0; return false;
} }
int bgp_subgrp_multiaccess_check_v4(struct in_addr nexthop, bool bgp_subgrp_multiaccess_check_v4(struct in_addr nexthop,
struct update_subgroup *subgrp, struct update_subgroup *subgrp,
struct peer *exclude) struct peer *exclude)
{ {
struct bgp_node *rn1, *rn2; struct bgp_node *rn1, *rn2;
struct peer_af *paf; struct peer_af *paf;
@ -672,7 +672,7 @@ int bgp_subgrp_multiaccess_check_v4(struct in_addr nexthop,
bgp = SUBGRP_INST(subgrp); bgp = SUBGRP_INST(subgrp);
rn1 = bgp_node_match(bgp->connected_table[AFI_IP], &np); rn1 = bgp_node_match(bgp->connected_table[AFI_IP], &np);
if (!rn1) if (!rn1)
return 0; return false;
SUBGRP_FOREACH_PEER (subgrp, paf) { SUBGRP_FOREACH_PEER (subgrp, paf) {
/* Skip peer we're told to exclude - e.g., source of route. */ /* Skip peer we're told to exclude - e.g., source of route. */
@ -685,7 +685,7 @@ int bgp_subgrp_multiaccess_check_v4(struct in_addr nexthop,
if (rn1 == rn2) { if (rn1 == rn2) {
bgp_unlock_node(rn1); bgp_unlock_node(rn1);
bgp_unlock_node(rn2); bgp_unlock_node(rn2);
return 1; return true;
} }
if (rn2) if (rn2)
@ -693,7 +693,7 @@ int bgp_subgrp_multiaccess_check_v4(struct in_addr nexthop,
} }
bgp_unlock_node(rn1); bgp_unlock_node(rn1);
return 0; return false;
} }
static void bgp_show_nexthops_detail(struct vty *vty, struct bgp *bgp, static void bgp_show_nexthops_detail(struct vty *vty, struct bgp *bgp,

View File

@ -81,18 +81,19 @@ struct bgp_addrv6 {
extern void bgp_connected_add(struct bgp *bgp, struct connected *c); extern void bgp_connected_add(struct bgp *bgp, struct connected *c);
extern void bgp_connected_delete(struct bgp *bgp, struct connected *c); extern void bgp_connected_delete(struct bgp *bgp, struct connected *c);
extern int bgp_subgrp_multiaccess_check_v4(struct in_addr nexthop, extern bool bgp_subgrp_multiaccess_check_v4(struct in_addr nexthop,
struct update_subgroup *subgrp, struct update_subgroup *subgrp,
struct peer *exclude); struct peer *exclude);
extern int bgp_subgrp_multiaccess_check_v6(struct in6_addr nexthop, extern bool bgp_subgrp_multiaccess_check_v6(struct in6_addr nexthop,
struct update_subgroup *subgrp, struct update_subgroup *subgrp,
struct peer *exclude); struct peer *exclude);
extern int bgp_multiaccess_check_v4(struct in_addr nexthop, struct peer *peer); extern bool bgp_multiaccess_check_v4(struct in_addr nexthop, struct peer *peer);
extern int bgp_multiaccess_check_v6(struct in6_addr nexthop, struct peer *peer); extern bool bgp_multiaccess_check_v6(struct in6_addr nexthop,
struct peer *peer);
extern int bgp_config_write_scan_time(struct vty *); extern int bgp_config_write_scan_time(struct vty *);
extern int bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type, extern bool bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type,
uint8_t sub_type, struct attr *attr, uint8_t sub_type, struct attr *attr,
struct bgp_node *rn); struct bgp_node *rn);
extern struct bgp_nexthop_cache *bnc_new(void); extern struct bgp_nexthop_cache *bnc_new(void);
extern void bnc_free(struct bgp_nexthop_cache *bnc); extern void bnc_free(struct bgp_nexthop_cache *bnc);
extern void bnc_nexthop_free(struct bgp_nexthop_cache *bnc); extern void bnc_nexthop_free(struct bgp_nexthop_cache *bnc);

View File

@ -1013,15 +1013,15 @@ static int bgp_auth_parse(struct peer *peer, size_t length)
return -1; return -1;
} }
static int strict_capability_same(struct peer *peer) static bool strict_capability_same(struct peer *peer)
{ {
int i, j; int i, j;
for (i = AFI_IP; i < AFI_MAX; i++) for (i = AFI_IP; i < AFI_MAX; i++)
for (j = SAFI_UNICAST; j < SAFI_MAX; j++) for (j = SAFI_UNICAST; j < SAFI_MAX; j++)
if (peer->afc[i][j] != peer->afc_nego[i][j]) if (peer->afc[i][j] != peer->afc_nego[i][j])
return 0; return false;
return 1; return true;
} }
/* peek into option, stores ASN to *as4 if the AS4 capability was found. /* peek into option, stores ASN to *as4 if the AS4 capability was found.

View File

@ -587,7 +587,7 @@ void bgp_open_send(struct peer *peer)
* @param peer * @param peer
* @return 0 * @return 0
*/ */
static int bgp_write_notify(struct peer *peer) static void bgp_write_notify(struct peer *peer)
{ {
int ret, val; int ret, val;
uint8_t type; uint8_t type;
@ -597,7 +597,7 @@ static int bgp_write_notify(struct peer *peer)
s = stream_fifo_pop(peer->obuf); s = stream_fifo_pop(peer->obuf);
if (!s) if (!s)
return 0; return;
assert(stream_get_endp(s) >= BGP_HEADER_SIZE); assert(stream_get_endp(s) >= BGP_HEADER_SIZE);
@ -617,7 +617,7 @@ static int bgp_write_notify(struct peer *peer)
if (ret <= 0) { if (ret <= 0) {
stream_free(s); stream_free(s);
BGP_EVENT_ADD(peer, TCP_fatal_error); BGP_EVENT_ADD(peer, TCP_fatal_error);
return 0; return;
} }
/* Disable Nagle, make NOTIFY packet go out right away */ /* Disable Nagle, make NOTIFY packet go out right away */
@ -649,8 +649,6 @@ static int bgp_write_notify(struct peer *peer)
BGP_EVENT_ADD(peer, BGP_Stop); BGP_EVENT_ADD(peer, BGP_Stop);
stream_free(s); stream_free(s);
return 0;
} }
/* /*

View File

@ -1282,30 +1282,30 @@ static enum filter_type bgp_output_filter(struct peer *peer, struct prefix *p,
} }
/* If community attribute includes no_export then return 1. */ /* If community attribute includes no_export then return 1. */
static int bgp_community_filter(struct peer *peer, struct attr *attr) static bool bgp_community_filter(struct peer *peer, struct attr *attr)
{ {
if (attr->community) { if (attr->community) {
/* NO_ADVERTISE check. */ /* NO_ADVERTISE check. */
if (community_include(attr->community, COMMUNITY_NO_ADVERTISE)) if (community_include(attr->community, COMMUNITY_NO_ADVERTISE))
return 1; return true;
/* NO_EXPORT check. */ /* NO_EXPORT check. */
if (peer->sort == BGP_PEER_EBGP if (peer->sort == BGP_PEER_EBGP
&& community_include(attr->community, COMMUNITY_NO_EXPORT)) && community_include(attr->community, COMMUNITY_NO_EXPORT))
return 1; return true;
/* NO_EXPORT_SUBCONFED check. */ /* NO_EXPORT_SUBCONFED check. */
if (peer->sort == BGP_PEER_EBGP if (peer->sort == BGP_PEER_EBGP
|| peer->sort == BGP_PEER_CONFED) || peer->sort == BGP_PEER_CONFED)
if (community_include(attr->community, if (community_include(attr->community,
COMMUNITY_NO_EXPORT_SUBCONFED)) COMMUNITY_NO_EXPORT_SUBCONFED))
return 1; return true;
} }
return 0; return false;
} }
/* Route reflection loop check. */ /* Route reflection loop check. */
static int bgp_cluster_filter(struct peer *peer, struct attr *attr) static bool bgp_cluster_filter(struct peer *peer, struct attr *attr)
{ {
struct in_addr cluster_id; struct in_addr cluster_id;
@ -1316,9 +1316,9 @@ static int bgp_cluster_filter(struct peer *peer, struct attr *attr)
cluster_id = peer->bgp->router_id; cluster_id = peer->bgp->router_id;
if (cluster_loop_check(attr->cluster, cluster_id)) if (cluster_loop_check(attr->cluster, cluster_id))
return 1; return true;
} }
return 0; return false;
} }
static int bgp_input_modifier(struct peer *peer, struct prefix *p, static int bgp_input_modifier(struct peer *peer, struct prefix *p,
@ -1543,9 +1543,9 @@ static void subgroup_announce_reset_nhop(uint8_t family, struct attr *attr)
memset(&attr->mp_nexthop_global_in, 0, BGP_ATTR_NHLEN_IPV4); memset(&attr->mp_nexthop_global_in, 0, BGP_ATTR_NHLEN_IPV4);
} }
int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi, bool subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
struct update_subgroup *subgrp, struct prefix *p, struct update_subgroup *subgrp, struct prefix *p,
struct attr *attr) struct attr *attr)
{ {
struct bgp_filter *filter; struct bgp_filter *filter;
struct peer *from; struct peer *from;
@ -1562,7 +1562,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
int samepeer_safe = 0; /* for synthetic mplsvpns routes */ int samepeer_safe = 0; /* for synthetic mplsvpns routes */
if (DISABLE_BGP_ANNOUNCE) if (DISABLE_BGP_ANNOUNCE)
return 0; return false;
afi = SUBGRP_AFI(subgrp); afi = SUBGRP_AFI(subgrp);
safi = SUBGRP_SAFI(subgrp); safi = SUBGRP_SAFI(subgrp);
@ -1609,7 +1609,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
if (!CHECK_FLAG(pi->flags, BGP_PATH_VALID) if (!CHECK_FLAG(pi->flags, BGP_PATH_VALID)
|| CHECK_FLAG(pi->flags, BGP_PATH_HISTORY) || CHECK_FLAG(pi->flags, BGP_PATH_HISTORY)
|| CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) { || CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) {
return 0; return false;
} }
/* If this is not the bestpath then check to see if there is an enabled /* If this is not the bestpath then check to see if there is an enabled
@ -1617,14 +1617,14 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
* feature that requires us to advertise it */ * feature that requires us to advertise it */
if (!CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)) { if (!CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)) {
if (!bgp_addpath_tx_path(peer->addpath_type[afi][safi], pi)) { if (!bgp_addpath_tx_path(peer->addpath_type[afi][safi], pi)) {
return 0; return false;
} }
} }
/* Aggregate-address suppress check. */ /* Aggregate-address suppress check. */
if (pi->extra && pi->extra->suppress) if (pi->extra && pi->extra->suppress)
if (!UNSUPPRESS_MAP_NAME(filter)) { if (!UNSUPPRESS_MAP_NAME(filter)) {
return 0; return false;
} }
/* /*
@ -1635,7 +1635,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
*/ */
if (safi == SAFI_MPLS_VPN && pi->extra && pi->extra->num_labels if (safi == SAFI_MPLS_VPN && pi->extra && pi->extra->num_labels
&& pi->extra->label[0] == BGP_PREVENT_VRF_2_VRF_LEAK) && pi->extra->label[0] == BGP_PREVENT_VRF_2_VRF_LEAK)
return 0; return false;
/* If it's labeled safi, make sure the route has a valid label. */ /* If it's labeled safi, make sure the route has a valid label. */
if (safi == SAFI_LABELED_UNICAST) { if (safi == SAFI_LABELED_UNICAST) {
@ -1648,13 +1648,13 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
inet_ntop(p->family, &p->u.prefix, inet_ntop(p->family, &p->u.prefix,
buf, SU_ADDRSTRLEN), buf, SU_ADDRSTRLEN),
p->prefixlen, &label); p->prefixlen, &label);
return 0; return false;
} }
} }
/* Do not send back route to sender. */ /* Do not send back route to sender. */
if (onlypeer && from == onlypeer) { if (onlypeer && from == onlypeer) {
return 0; return false;
} }
/* Do not send the default route in the BGP table if the neighbor is /* Do not send the default route in the BGP table if the neighbor is
@ -1662,9 +1662,9 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
if (CHECK_FLAG(peer->af_flags[afi][safi], if (CHECK_FLAG(peer->af_flags[afi][safi],
PEER_FLAG_DEFAULT_ORIGINATE)) { PEER_FLAG_DEFAULT_ORIGINATE)) {
if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY)
return 0; return false;
else if (p->family == AF_INET6 && p->prefixlen == 0) else if (p->family == AF_INET6 && p->prefixlen == 0)
return 0; return false;
} }
/* Transparency check. */ /* Transparency check. */
@ -1679,7 +1679,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) if (bgp_debug_update(NULL, p, subgrp->update_group, 0))
zlog_debug( zlog_debug(
"subgrpannouncecheck: community filter check fail"); "subgrpannouncecheck: community filter check fail");
return 0; return false;
} }
/* If the attribute has originator-id and it is same as remote /* If the attribute has originator-id and it is same as remote
@ -1692,7 +1692,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
"remote router-id", "remote router-id",
onlypeer->host, onlypeer->host,
prefix2str(p, buf, sizeof(buf))); prefix2str(p, buf, sizeof(buf)));
return 0; return false;
} }
/* ORF prefix-list filter check */ /* ORF prefix-list filter check */
@ -1710,7 +1710,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
peer->host, peer->host,
prefix2str(p, buf, prefix2str(p, buf,
sizeof(buf))); sizeof(buf)));
return 0; return false;
} }
} }
@ -1719,7 +1719,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) if (bgp_debug_update(NULL, p, subgrp->update_group, 0))
zlog_debug("%s [Update:SEND] %s is filtered", zlog_debug("%s [Update:SEND] %s is filtered",
peer->host, prefix2str(p, buf, sizeof(buf))); peer->host, prefix2str(p, buf, sizeof(buf)));
return 0; return false;
} }
/* AS path loop check. */ /* AS path loop check. */
@ -1730,7 +1730,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
"%s [Update:SEND] suppress announcement to peer AS %u " "%s [Update:SEND] suppress announcement to peer AS %u "
"that is part of AS path.", "that is part of AS path.",
onlypeer->host, onlypeer->as); onlypeer->host, onlypeer->as);
return 0; return false;
} }
/* If we're a CONFED we need to loop check the CONFED ID too */ /* If we're a CONFED we need to loop check the CONFED ID too */
@ -1741,7 +1741,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
"%s [Update:SEND] suppress announcement to peer AS %u" "%s [Update:SEND] suppress announcement to peer AS %u"
" is AS path.", " is AS path.",
peer->host, bgp->confed_id); peer->host, bgp->confed_id);
return 0; return false;
} }
} }
@ -1765,13 +1765,13 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
BGP_FLAG_NO_CLIENT_TO_CLIENT)) BGP_FLAG_NO_CLIENT_TO_CLIENT))
if (CHECK_FLAG(peer->af_flags[afi][safi], if (CHECK_FLAG(peer->af_flags[afi][safi],
PEER_FLAG_REFLECTOR_CLIENT)) PEER_FLAG_REFLECTOR_CLIENT))
return 0; return false;
} else { } else {
/* A route from a Non-client peer. Reflect to all other /* A route from a Non-client peer. Reflect to all other
clients. */ clients. */
if (!CHECK_FLAG(peer->af_flags[afi][safi], if (!CHECK_FLAG(peer->af_flags[afi][safi],
PEER_FLAG_REFLECTOR_CLIENT)) PEER_FLAG_REFLECTOR_CLIENT))
return 0; return false;
} }
} }
@ -1910,7 +1910,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
peer->host, prefix2str(p, buf, sizeof(buf))); peer->host, prefix2str(p, buf, sizeof(buf)));
bgp_attr_flush(attr); bgp_attr_flush(attr);
return 0; return false;
} }
} }
@ -1926,7 +1926,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
if (peer->bgp->ebgp_requires_policy if (peer->bgp->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED) == DEFAULT_EBGP_POLICY_ENABLED)
if (!bgp_outbound_policy_exists(peer, filter)) if (!bgp_outbound_policy_exists(peer, filter))
return 0; return false;
/* draft-ietf-idr-deprecate-as-set-confed-set /* draft-ietf-idr-deprecate-as-set-confed-set
* Filter routes having AS_SET or AS_CONFED_SET in the path. * Filter routes having AS_SET or AS_CONFED_SET in the path.
@ -1936,7 +1936,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
*/ */
if (peer->bgp->reject_as_sets == BGP_REJECT_AS_SETS_ENABLED) if (peer->bgp->reject_as_sets == BGP_REJECT_AS_SETS_ENABLED)
if (aspath_check_as_sets(attr->aspath)) if (aspath_check_as_sets(attr->aspath))
return 0; return false;
/* Codification of AS 0 Processing */ /* Codification of AS 0 Processing */
if (aspath_check_as_zero(attr->aspath)) if (aspath_check_as_zero(attr->aspath))
@ -2048,7 +2048,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
subgroup_announce_reset_nhop(AF_INET6, attr); subgroup_announce_reset_nhop(AF_INET6, attr);
} }
return 1; return true;
} }
static int bgp_route_select_timer_expire(struct thread *thread) static int bgp_route_select_timer_expire(struct thread *thread)
@ -2313,10 +2313,10 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn,
* A new route/change in bestpath of an existing route. Evaluate the path * A new route/change in bestpath of an existing route. Evaluate the path
* for advertisement to the subgroup. * for advertisement to the subgroup.
*/ */
int subgroup_process_announce_selected(struct update_subgroup *subgrp, void subgroup_process_announce_selected(struct update_subgroup *subgrp,
struct bgp_path_info *selected, struct bgp_path_info *selected,
struct bgp_node *rn, struct bgp_node *rn,
uint32_t addpath_tx_id) uint32_t addpath_tx_id)
{ {
struct prefix *p; struct prefix *p;
struct peer *onlypeer; struct peer *onlypeer;
@ -2340,7 +2340,7 @@ int subgroup_process_announce_selected(struct update_subgroup *subgrp,
/* First update is deferred until ORF or ROUTE-REFRESH is received */ /* First update is deferred until ORF or ROUTE-REFRESH is received */
if (onlypeer && CHECK_FLAG(onlypeer->af_sflags[afi][safi], if (onlypeer && CHECK_FLAG(onlypeer->af_sflags[afi][safi],
PEER_STATUS_ORF_WAIT_REFRESH)) PEER_STATUS_ORF_WAIT_REFRESH))
return 0; return;
memset(&attr, 0, sizeof(struct attr)); memset(&attr, 0, sizeof(struct attr));
/* It's initialized in bgp_announce_check() */ /* It's initialized in bgp_announce_check() */
@ -2359,8 +2359,6 @@ int subgroup_process_announce_selected(struct update_subgroup *subgrp,
else { else {
bgp_adj_out_unset_subgroup(rn, subgrp, 1, addpath_tx_id); bgp_adj_out_unset_subgroup(rn, subgrp, 1, addpath_tx_id);
} }
return 0;
} }
/* /*
@ -2384,8 +2382,8 @@ void bgp_zebra_clear_route_change_flags(struct bgp_node *rn)
* if the route selection returns the same best route as earlier - to * if the route selection returns the same best route as earlier - to
* determine if we need to update zebra or not. * determine if we need to update zebra or not.
*/ */
int bgp_zebra_has_route_changed(struct bgp_node *rn, bool bgp_zebra_has_route_changed(struct bgp_node *rn,
struct bgp_path_info *selected) struct bgp_path_info *selected)
{ {
struct bgp_path_info *mpinfo; struct bgp_path_info *mpinfo;
@ -2397,7 +2395,7 @@ int bgp_zebra_has_route_changed(struct bgp_node *rn,
*/ */
if (CHECK_FLAG(selected->flags, BGP_PATH_IGP_CHANGED) if (CHECK_FLAG(selected->flags, BGP_PATH_IGP_CHANGED)
|| CHECK_FLAG(selected->flags, BGP_PATH_MULTIPATH_CHG)) || CHECK_FLAG(selected->flags, BGP_PATH_MULTIPATH_CHG))
return 1; return true;
/* /*
* If this is multipath, check all selected paths for any nexthop change * If this is multipath, check all selected paths for any nexthop change
@ -2406,11 +2404,11 @@ int bgp_zebra_has_route_changed(struct bgp_node *rn,
mpinfo = bgp_path_info_mpath_next(mpinfo)) { mpinfo = bgp_path_info_mpath_next(mpinfo)) {
if (CHECK_FLAG(mpinfo->flags, BGP_PATH_IGP_CHANGED) if (CHECK_FLAG(mpinfo->flags, BGP_PATH_IGP_CHANGED)
|| CHECK_FLAG(mpinfo->flags, BGP_PATH_ATTR_CHANGED)) || CHECK_FLAG(mpinfo->flags, BGP_PATH_ATTR_CHANGED))
return 1; return true;
} }
/* Nothing has changed from the RIB's perspective. */ /* Nothing has changed from the RIB's perspective. */
return 0; return false;
} }
struct bgp_process_queue { struct bgp_process_queue {
@ -2948,20 +2946,20 @@ static int bgp_maximum_prefix_restart_timer(struct thread *thread)
return 0; return 0;
} }
int bgp_maximum_prefix_overflow(struct peer *peer, afi_t afi, safi_t safi, bool bgp_maximum_prefix_overflow(struct peer *peer, afi_t afi, safi_t safi,
int always) int always)
{ {
iana_afi_t pkt_afi; iana_afi_t pkt_afi;
iana_safi_t pkt_safi; iana_safi_t pkt_safi;
if (!CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) if (!CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
return 0; return false;
if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) { if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) {
if (CHECK_FLAG(peer->af_sflags[afi][safi], if (CHECK_FLAG(peer->af_sflags[afi][safi],
PEER_STATUS_PREFIX_LIMIT) PEER_STATUS_PREFIX_LIMIT)
&& !always) && !always)
return 0; return false;
zlog_info( zlog_info(
"%%MAXPFXEXCEED: No. of %s prefix received from %s %" PRIu32 "%%MAXPFXEXCEED: No. of %s prefix received from %s %" PRIu32
@ -2972,7 +2970,7 @@ int bgp_maximum_prefix_overflow(struct peer *peer, afi_t afi, safi_t safi,
if (CHECK_FLAG(peer->af_flags[afi][safi], if (CHECK_FLAG(peer->af_flags[afi][safi],
PEER_FLAG_MAX_PREFIX_WARNING)) PEER_FLAG_MAX_PREFIX_WARNING))
return 0; return false;
/* Convert AFI, SAFI to values for packet. */ /* Convert AFI, SAFI to values for packet. */
pkt_afi = afi_int2iana(afi); pkt_afi = afi_int2iana(afi);
@ -2996,7 +2994,7 @@ int bgp_maximum_prefix_overflow(struct peer *peer, afi_t afi, safi_t safi,
/* Dynamic peers will just close their connection. */ /* Dynamic peers will just close their connection. */
if (peer_dynamic_neighbor(peer)) if (peer_dynamic_neighbor(peer))
return 1; return true;
/* restart timer start */ /* restart timer start */
if (peer->pmax_restart[afi][safi]) { if (peer->pmax_restart[afi][safi]) {
@ -3013,7 +3011,7 @@ int bgp_maximum_prefix_overflow(struct peer *peer, afi_t afi, safi_t safi,
peer->v_pmax_restart); peer->v_pmax_restart);
} }
return 1; return true;
} else } else
UNSET_FLAG(peer->af_sflags[afi][safi], UNSET_FLAG(peer->af_sflags[afi][safi],
PEER_STATUS_PREFIX_LIMIT); PEER_STATUS_PREFIX_LIMIT);
@ -3023,7 +3021,7 @@ int bgp_maximum_prefix_overflow(struct peer *peer, afi_t afi, safi_t safi,
if (CHECK_FLAG(peer->af_sflags[afi][safi], if (CHECK_FLAG(peer->af_sflags[afi][safi],
PEER_STATUS_PREFIX_THRESHOLD) PEER_STATUS_PREFIX_THRESHOLD)
&& !always) && !always)
return 0; return false;
zlog_info( zlog_info(
"%%MAXPFX: No. of %s prefix received from %s reaches %" PRIu32 "%%MAXPFX: No. of %s prefix received from %s reaches %" PRIu32
@ -3035,7 +3033,7 @@ int bgp_maximum_prefix_overflow(struct peer *peer, afi_t afi, safi_t safi,
} else } else
UNSET_FLAG(peer->af_sflags[afi][safi], UNSET_FLAG(peer->af_sflags[afi][safi],
PEER_STATUS_PREFIX_THRESHOLD); PEER_STATUS_PREFIX_THRESHOLD);
return 0; return false;
} }
/* Unconditionally remove the route from the RIB, without taking /* Unconditionally remove the route from the RIB, without taking
@ -3204,23 +3202,23 @@ static bool overlay_index_equal(afi_t afi, struct bgp_path_info *path,
} }
/* Check if received nexthop is valid or not. */ /* Check if received nexthop is valid or not. */
static int bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi, static bool bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi,
uint8_t type, uint8_t stype, uint8_t type, uint8_t stype,
struct attr *attr, struct bgp_node *rn) struct attr *attr, struct bgp_node *rn)
{ {
int ret = 0; bool ret = 0;
/* Only validated for unicast and multicast currently. */ /* Only validated for unicast and multicast currently. */
/* Also valid for EVPN where the nexthop is an IP address. */ /* Also valid for EVPN where the nexthop is an IP address. */
if (safi != SAFI_UNICAST && safi != SAFI_MULTICAST && safi != SAFI_EVPN) if (safi != SAFI_UNICAST && safi != SAFI_MULTICAST && safi != SAFI_EVPN)
return 0; return false;
/* If NEXT_HOP is present, validate it. */ /* If NEXT_HOP is present, validate it. */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP)) { if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP)) {
if (attr->nexthop.s_addr == INADDR_ANY if (attr->nexthop.s_addr == INADDR_ANY
|| IPV4_CLASS_DE(ntohl(attr->nexthop.s_addr)) || IPV4_CLASS_DE(ntohl(attr->nexthop.s_addr))
|| bgp_nexthop_self(bgp, afi, type, stype, attr, rn)) || bgp_nexthop_self(bgp, afi, type, stype, attr, rn))
return 1; return true;
} }
/* If MP_NEXTHOP is present, validate it. */ /* If MP_NEXTHOP is present, validate it. */
@ -3251,7 +3249,7 @@ static int bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi,
break; break;
default: default:
ret = 1; ret = true;
break; break;
} }
} }
@ -4610,30 +4608,30 @@ void bgp_clear_stale_route(struct peer *peer, afi_t afi, safi_t safi)
} }
} }
int bgp_outbound_policy_exists(struct peer *peer, struct bgp_filter *filter) bool bgp_outbound_policy_exists(struct peer *peer, struct bgp_filter *filter)
{ {
if (peer->sort == BGP_PEER_IBGP) if (peer->sort == BGP_PEER_IBGP)
return 1; return true;
if (peer->sort == BGP_PEER_EBGP if (peer->sort == BGP_PEER_EBGP
&& (ROUTE_MAP_OUT_NAME(filter) || PREFIX_LIST_OUT_NAME(filter) && (ROUTE_MAP_OUT_NAME(filter) || PREFIX_LIST_OUT_NAME(filter)
|| FILTER_LIST_OUT_NAME(filter) || FILTER_LIST_OUT_NAME(filter)
|| DISTRIBUTE_OUT_NAME(filter))) || DISTRIBUTE_OUT_NAME(filter)))
return 1; return true;
return 0; return false;
} }
int bgp_inbound_policy_exists(struct peer *peer, struct bgp_filter *filter) bool bgp_inbound_policy_exists(struct peer *peer, struct bgp_filter *filter)
{ {
if (peer->sort == BGP_PEER_IBGP) if (peer->sort == BGP_PEER_IBGP)
return 1; return true;
if (peer->sort == BGP_PEER_EBGP if (peer->sort == BGP_PEER_EBGP
&& (ROUTE_MAP_IN_NAME(filter) || PREFIX_LIST_IN_NAME(filter) && (ROUTE_MAP_IN_NAME(filter) || PREFIX_LIST_IN_NAME(filter)
|| FILTER_LIST_IN_NAME(filter) || FILTER_LIST_IN_NAME(filter)
|| DISTRIBUTE_IN_NAME(filter))) || DISTRIBUTE_IN_NAME(filter)))
return 1; return true;
return 0; return false;
} }
static void bgp_cleanup_table(struct bgp *bgp, struct bgp_table *table, static void bgp_cleanup_table(struct bgp *bgp, struct bgp_table *table,
@ -6023,11 +6021,11 @@ static void bgp_aggregate_free(struct bgp_aggregate *aggregate)
XFREE(MTYPE_BGP_AGGREGATE, aggregate); XFREE(MTYPE_BGP_AGGREGATE, aggregate);
} }
static int bgp_aggregate_info_same(struct bgp_path_info *pi, uint8_t origin, static bool bgp_aggregate_info_same(struct bgp_path_info *pi, uint8_t origin,
struct aspath *aspath, struct aspath *aspath,
struct community *comm, struct community *comm,
struct ecommunity *ecomm, struct ecommunity *ecomm,
struct lcommunity *lcomm) struct lcommunity *lcomm)
{ {
static struct aspath *ae = NULL; static struct aspath *ae = NULL;
@ -6035,27 +6033,27 @@ static int bgp_aggregate_info_same(struct bgp_path_info *pi, uint8_t origin,
ae = aspath_empty(); ae = aspath_empty();
if (!pi) if (!pi)
return 0; return false;
if (origin != pi->attr->origin) if (origin != pi->attr->origin)
return 0; return false;
if (!aspath_cmp(pi->attr->aspath, (aspath) ? aspath : ae)) if (!aspath_cmp(pi->attr->aspath, (aspath) ? aspath : ae))
return 0; return false;
if (!community_cmp(pi->attr->community, comm)) if (!community_cmp(pi->attr->community, comm))
return 0; return false;
if (!ecommunity_cmp(pi->attr->ecommunity, ecomm)) if (!ecommunity_cmp(pi->attr->ecommunity, ecomm))
return 0; return false;
if (!lcommunity_cmp(pi->attr->lcommunity, lcomm)) if (!lcommunity_cmp(pi->attr->lcommunity, lcomm))
return 0; return false;
if (!CHECK_FLAG(pi->flags, BGP_PATH_VALID)) if (!CHECK_FLAG(pi->flags, BGP_PATH_VALID))
return 0; return false;
return 1; return true;
} }
static void bgp_aggregate_install(struct bgp *bgp, afi_t afi, safi_t safi, static void bgp_aggregate_install(struct bgp *bgp, afi_t afi, safi_t safi,

View File

@ -506,8 +506,8 @@ extern void bgp_clear_route(struct peer *, afi_t, safi_t);
extern void bgp_clear_route_all(struct peer *); extern void bgp_clear_route_all(struct peer *);
extern void bgp_clear_adj_in(struct peer *, afi_t, safi_t); extern void bgp_clear_adj_in(struct peer *, afi_t, safi_t);
extern void bgp_clear_stale_route(struct peer *, afi_t, safi_t); extern void bgp_clear_stale_route(struct peer *, afi_t, safi_t);
extern int bgp_outbound_policy_exists(struct peer *, struct bgp_filter *); extern bool bgp_outbound_policy_exists(struct peer *, struct bgp_filter *);
extern int bgp_inbound_policy_exists(struct peer *, struct bgp_filter *); extern bool bgp_inbound_policy_exists(struct peer *, struct bgp_filter *);
extern struct bgp_node *bgp_afi_node_get(struct bgp_table *table, afi_t afi, extern struct bgp_node *bgp_afi_node_get(struct bgp_table *table, afi_t afi,
safi_t safi, struct prefix *p, safi_t safi, struct prefix *p,
@ -529,7 +529,7 @@ extern void bgp_path_info_path_with_addpath_rx_str(struct bgp_path_info *pi,
extern int bgp_nlri_parse_ip(struct peer *, struct attr *, struct bgp_nlri *); extern int bgp_nlri_parse_ip(struct peer *, struct attr *, struct bgp_nlri *);
extern int bgp_maximum_prefix_overflow(struct peer *, afi_t, safi_t, int); extern bool bgp_maximum_prefix_overflow(struct peer *, afi_t, safi_t, int);
extern void bgp_redistribute_add(struct bgp *bgp, struct prefix *p, extern void bgp_redistribute_add(struct bgp *bgp, struct prefix *p,
const union g_addr *nexthop, ifindex_t ifindex, const union g_addr *nexthop, ifindex_t ifindex,
@ -614,15 +614,15 @@ extern void route_vty_out_overlay(struct vty *vty, struct prefix *p,
struct bgp_path_info *path, int display, struct bgp_path_info *path, int display,
json_object *json); json_object *json);
extern int subgroup_process_announce_selected(struct update_subgroup *subgrp, extern void subgroup_process_announce_selected(struct update_subgroup *subgrp,
struct bgp_path_info *selected, struct bgp_path_info *selected,
struct bgp_node *rn, struct bgp_node *rn,
uint32_t addpath_tx_id); uint32_t addpath_tx_id);
extern int subgroup_announce_check(struct bgp_node *rn, extern bool subgroup_announce_check(struct bgp_node *rn,
struct bgp_path_info *pi, struct bgp_path_info *pi,
struct update_subgroup *subgrp, struct update_subgroup *subgrp,
struct prefix *p, struct attr *attr); struct prefix *p, struct attr *attr);
extern void bgp_peer_clear_node_queue_drain_immediate(struct peer *peer); extern void bgp_peer_clear_node_queue_drain_immediate(struct peer *peer);
extern void bgp_process_queues_drain_immediate(void); extern void bgp_process_queues_drain_immediate(void);
@ -646,8 +646,8 @@ extern void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn,
struct bgp_path_info_pair *result, afi_t afi, struct bgp_path_info_pair *result, afi_t afi,
safi_t safi); safi_t safi);
extern void bgp_zebra_clear_route_change_flags(struct bgp_node *rn); extern void bgp_zebra_clear_route_change_flags(struct bgp_node *rn);
extern int bgp_zebra_has_route_changed(struct bgp_node *rn, extern bool bgp_zebra_has_route_changed(struct bgp_node *rn,
struct bgp_path_info *selected); struct bgp_path_info *selected);
extern void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp, extern void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
struct bgp_node *rn, struct bgp_node *rn,

View File

@ -831,17 +831,17 @@ void update_subgroup_inherit_info(struct update_subgroup *to,
* *
* Returns true if the subgroup was deleted. * Returns true if the subgroup was deleted.
*/ */
static int update_subgroup_check_delete(struct update_subgroup *subgrp) static bool update_subgroup_check_delete(struct update_subgroup *subgrp)
{ {
if (!subgrp) if (!subgrp)
return 0; return false;
if (!LIST_EMPTY(&(subgrp->peers))) if (!LIST_EMPTY(&(subgrp->peers)))
return 0; return false;
update_subgroup_delete(subgrp); update_subgroup_delete(subgrp);
return 1; return true;
} }
/* /*
@ -982,7 +982,7 @@ static struct update_subgroup *update_subgroup_find(struct update_group *updgrp,
* Returns true if this subgroup is in a state that allows it to be * Returns true if this subgroup is in a state that allows it to be
* merged into another subgroup. * merged into another subgroup.
*/ */
static int update_subgroup_ready_for_merge(struct update_subgroup *subgrp) static bool update_subgroup_ready_for_merge(struct update_subgroup *subgrp)
{ {
/* /*
@ -990,13 +990,13 @@ static int update_subgroup_ready_for_merge(struct update_subgroup *subgrp)
* out to peers. * out to peers.
*/ */
if (!bpacket_queue_is_empty(SUBGRP_PKTQ(subgrp))) if (!bpacket_queue_is_empty(SUBGRP_PKTQ(subgrp)))
return 0; return false;
/* /*
* Not ready if there enqueued updates waiting to be encoded. * Not ready if there enqueued updates waiting to be encoded.
*/ */
if (!advertise_list_is_empty(subgrp)) if (!advertise_list_is_empty(subgrp))
return 0; return false;
/* /*
* Don't attempt to merge a subgroup that needs a refresh. For one, * Don't attempt to merge a subgroup that needs a refresh. For one,
@ -1004,9 +1004,9 @@ static int update_subgroup_ready_for_merge(struct update_subgroup *subgrp)
* another group. * another group.
*/ */
if (update_subgroup_needs_refresh(subgrp)) if (update_subgroup_needs_refresh(subgrp))
return 0; return false;
return 1; return true;
} }
/* /*
@ -1095,13 +1095,13 @@ static void update_subgroup_merge(struct update_subgroup *subgrp,
* Returns true if the subgroup has been merged. The subgroup pointer * Returns true if the subgroup has been merged. The subgroup pointer
* should not be accessed in this case. * should not be accessed in this case.
*/ */
int update_subgroup_check_merge(struct update_subgroup *subgrp, bool update_subgroup_check_merge(struct update_subgroup *subgrp,
const char *reason) const char *reason)
{ {
struct update_subgroup *target; struct update_subgroup *target;
if (!update_subgroup_ready_for_merge(subgrp)) if (!update_subgroup_ready_for_merge(subgrp))
return 0; return false;
/* /*
* Look for a subgroup to merge into. * Look for a subgroup to merge into.
@ -1112,10 +1112,10 @@ int update_subgroup_check_merge(struct update_subgroup *subgrp,
} }
if (!target) if (!target)
return 0; return false;
update_subgroup_merge(subgrp, target, reason); update_subgroup_merge(subgrp, target, reason);
return 1; return true;
} }
/* /*
@ -1143,14 +1143,14 @@ static int update_subgroup_merge_check_thread_cb(struct thread *thread)
* *
* Returns true if a merge check will be performed shortly. * Returns true if a merge check will be performed shortly.
*/ */
int update_subgroup_trigger_merge_check(struct update_subgroup *subgrp, bool update_subgroup_trigger_merge_check(struct update_subgroup *subgrp,
int force) int force)
{ {
if (subgrp->t_merge_check) if (subgrp->t_merge_check)
return 1; return true;
if (!force && !update_subgroup_ready_for_merge(subgrp)) if (!force && !update_subgroup_ready_for_merge(subgrp))
return 0; return false;
subgrp->t_merge_check = NULL; subgrp->t_merge_check = NULL;
thread_add_timer_msec(bm->master, update_subgroup_merge_check_thread_cb, thread_add_timer_msec(bm->master, update_subgroup_merge_check_thread_cb,
@ -1158,7 +1158,7 @@ int update_subgroup_trigger_merge_check(struct update_subgroup *subgrp,
SUBGRP_INCR_STAT(subgrp, merge_checks_triggered); SUBGRP_INCR_STAT(subgrp, merge_checks_triggered);
return 1; return true;
} }
/* /*
@ -1212,8 +1212,8 @@ static int update_subgroup_copy_packets(struct update_subgroup *dest,
return count; return count;
} }
static int updgrp_prefix_list_update(struct update_group *updgrp, static bool updgrp_prefix_list_update(struct update_group *updgrp,
const char *name) const char *name)
{ {
struct peer *peer; struct peer *peer;
struct bgp_filter *filter; struct bgp_filter *filter;
@ -1225,13 +1225,13 @@ static int updgrp_prefix_list_update(struct update_group *updgrp,
&& (strcmp(name, PREFIX_LIST_OUT_NAME(filter)) == 0)) { && (strcmp(name, PREFIX_LIST_OUT_NAME(filter)) == 0)) {
PREFIX_LIST_OUT(filter) = prefix_list_lookup( PREFIX_LIST_OUT(filter) = prefix_list_lookup(
UPDGRP_AFI(updgrp), PREFIX_LIST_OUT_NAME(filter)); UPDGRP_AFI(updgrp), PREFIX_LIST_OUT_NAME(filter));
return 1; return true;
} }
return 0; return false;
} }
static int updgrp_filter_list_update(struct update_group *updgrp, static bool updgrp_filter_list_update(struct update_group *updgrp,
const char *name) const char *name)
{ {
struct peer *peer; struct peer *peer;
struct bgp_filter *filter; struct bgp_filter *filter;
@ -1243,13 +1243,13 @@ static int updgrp_filter_list_update(struct update_group *updgrp,
&& (strcmp(name, FILTER_LIST_OUT_NAME(filter)) == 0)) { && (strcmp(name, FILTER_LIST_OUT_NAME(filter)) == 0)) {
FILTER_LIST_OUT(filter) = FILTER_LIST_OUT(filter) =
as_list_lookup(FILTER_LIST_OUT_NAME(filter)); as_list_lookup(FILTER_LIST_OUT_NAME(filter));
return 1; return true;
} }
return 0; return false;
} }
static int updgrp_distribute_list_update(struct update_group *updgrp, static bool updgrp_distribute_list_update(struct update_group *updgrp,
const char *name) const char *name)
{ {
struct peer *peer; struct peer *peer;
struct bgp_filter *filter; struct bgp_filter *filter;
@ -1261,9 +1261,9 @@ static int updgrp_distribute_list_update(struct update_group *updgrp,
&& (strcmp(name, DISTRIBUTE_OUT_NAME(filter)) == 0)) { && (strcmp(name, DISTRIBUTE_OUT_NAME(filter)) == 0)) {
DISTRIBUTE_OUT(filter) = access_list_lookup( DISTRIBUTE_OUT(filter) = access_list_lookup(
UPDGRP_AFI(updgrp), DISTRIBUTE_OUT_NAME(filter)); UPDGRP_AFI(updgrp), DISTRIBUTE_OUT_NAME(filter));
return 1; return true;
} }
return 0; return false;
} }
static int updgrp_route_map_update(struct update_group *updgrp, static int updgrp_route_map_update(struct update_group *updgrp,

View File

@ -373,9 +373,9 @@ extern void update_subgroup_remove_peer(struct update_subgroup *,
struct peer_af *); struct peer_af *);
extern struct bgp_table *update_subgroup_rib(struct update_subgroup *); extern struct bgp_table *update_subgroup_rib(struct update_subgroup *);
extern void update_subgroup_split_peer(struct peer_af *, struct update_group *); extern void update_subgroup_split_peer(struct peer_af *, struct update_group *);
extern int update_subgroup_check_merge(struct update_subgroup *, const char *); extern bool update_subgroup_check_merge(struct update_subgroup *, const char *);
extern int update_subgroup_trigger_merge_check(struct update_subgroup *, extern bool update_subgroup_trigger_merge_check(struct update_subgroup *,
int force); int force);
extern void update_group_policy_update(struct bgp *bgp, bgp_policy_type_e ptype, extern void update_group_policy_update(struct bgp *bgp, bgp_policy_type_e ptype,
const char *pname, int route_update, const char *pname, int route_update,
int start_event); int start_event);
@ -404,13 +404,13 @@ extern struct bpacket *bpacket_queue_first(struct bpacket_queue *q);
struct bpacket *bpacket_queue_last(struct bpacket_queue *q); struct bpacket *bpacket_queue_last(struct bpacket_queue *q);
unsigned int bpacket_queue_length(struct bpacket_queue *q); unsigned int bpacket_queue_length(struct bpacket_queue *q);
unsigned int bpacket_queue_hwm_length(struct bpacket_queue *q); unsigned int bpacket_queue_hwm_length(struct bpacket_queue *q);
int bpacket_queue_is_full(struct bgp *bgp, struct bpacket_queue *q); bool bpacket_queue_is_full(struct bgp *bgp, struct bpacket_queue *q);
extern void bpacket_queue_advance_peer(struct peer_af *paf); extern void bpacket_queue_advance_peer(struct peer_af *paf);
extern void bpacket_queue_remove_peer(struct peer_af *paf); extern void bpacket_queue_remove_peer(struct peer_af *paf);
extern void bpacket_add_peer(struct bpacket *pkt, struct peer_af *paf); extern void bpacket_add_peer(struct bpacket *pkt, struct peer_af *paf);
unsigned int bpacket_queue_virtual_length(struct peer_af *paf); unsigned int bpacket_queue_virtual_length(struct peer_af *paf);
extern void bpacket_queue_show_vty(struct bpacket_queue *q, struct vty *vty); extern void bpacket_queue_show_vty(struct bpacket_queue *q, struct vty *vty);
int subgroup_packets_to_build(struct update_subgroup *subgrp); bool subgroup_packets_to_build(struct update_subgroup *subgrp);
extern struct bpacket *subgroup_update_packet(struct update_subgroup *s); extern struct bpacket *subgroup_update_packet(struct update_subgroup *s);
extern struct bpacket *subgroup_withdraw_packet(struct update_subgroup *s); extern struct bpacket *subgroup_withdraw_packet(struct update_subgroup *s);
extern struct stream *bpacket_reformat_for_peer(struct bpacket *pkt, extern struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,

View File

@ -226,11 +226,11 @@ unsigned int bpacket_queue_hwm_length(struct bpacket_queue *q)
return q->hwm_count - 1; return q->hwm_count - 1;
} }
int bpacket_queue_is_full(struct bgp *bgp, struct bpacket_queue *q) bool bpacket_queue_is_full(struct bgp *bgp, struct bpacket_queue *q)
{ {
if (q->curr_count >= bgp->default_subgroup_pkt_queue_max) if (q->curr_count >= bgp->default_subgroup_pkt_queue_max)
return 1; return true;
return 0; return false;
} }
void bpacket_add_peer(struct bpacket *pkt, struct peer_af *paf) void bpacket_add_peer(struct bpacket *pkt, struct peer_af *paf)
@ -656,22 +656,22 @@ static void bpacket_attr_vec_arr_update(struct bpacket_attr_vec_arr *vecarr,
/* /*
* Return if there are packets to build for this subgroup. * Return if there are packets to build for this subgroup.
*/ */
int subgroup_packets_to_build(struct update_subgroup *subgrp) bool subgroup_packets_to_build(struct update_subgroup *subgrp)
{ {
struct bgp_advertise *adv; struct bgp_advertise *adv;
if (!subgrp) if (!subgrp)
return 0; return false;
adv = bgp_adv_fifo_first(&subgrp->sync->withdraw); adv = bgp_adv_fifo_first(&subgrp->sync->withdraw);
if (adv) if (adv)
return 1; return true;
adv = bgp_adv_fifo_first(&subgrp->sync->update); adv = bgp_adv_fifo_first(&subgrp->sync->update);
if (adv) if (adv)
return 1; return true;
return 0; return false;
} }
/* Make BGP update packet. */ /* Make BGP update packet. */

View File

@ -533,7 +533,7 @@ int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty,
return *idx; return *idx;
} }
static int peer_address_self_check(struct bgp *bgp, union sockunion *su) static bool peer_address_self_check(struct bgp *bgp, union sockunion *su)
{ {
struct interface *ifp = NULL; struct interface *ifp = NULL;
@ -545,9 +545,9 @@ static int peer_address_self_check(struct bgp *bgp, union sockunion *su)
bgp->vrf_id); bgp->vrf_id);
if (ifp) if (ifp)
return 1; return true;
return 0; return false;
} }
/* Utility function for looking up peer from VTY. */ /* Utility function for looking up peer from VTY. */
@ -14086,7 +14086,8 @@ static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi,
/* Return true if the addpath type is set for peer and different from /* Return true if the addpath type is set for peer and different from
* peer-group. * peer-group.
*/ */
static int peergroup_af_addpath_check(struct peer *peer, afi_t afi, safi_t safi) static bool peergroup_af_addpath_check(struct peer *peer, afi_t afi,
safi_t safi)
{ {
enum bgp_addpath_strat type, g_type; enum bgp_addpath_strat type, g_type;
@ -14097,15 +14098,15 @@ static int peergroup_af_addpath_check(struct peer *peer, afi_t afi, safi_t safi)
g_type = peer->group->conf->addpath_type[afi][safi]; g_type = peer->group->conf->addpath_type[afi][safi];
if (type != g_type) if (type != g_type)
return 1; return true;
else else
return 0; return false;
} }
return 1; return true;
} }
return 0; return false;
} }
/* This is part of the address-family block (unicast only) */ /* This is part of the address-family block (unicast only) */

View File

@ -66,19 +66,19 @@
struct zclient *zclient = NULL; struct zclient *zclient = NULL;
/* Can we install into zebra? */ /* Can we install into zebra? */
static inline int bgp_install_info_to_zebra(struct bgp *bgp) static inline bool bgp_install_info_to_zebra(struct bgp *bgp)
{ {
if (zclient->sock <= 0) if (zclient->sock <= 0)
return 0; return false;
if (!IS_BGP_INST_KNOWN_TO_ZEBRA(bgp)) { if (!IS_BGP_INST_KNOWN_TO_ZEBRA(bgp)) {
zlog_debug( zlog_debug(
"%s: No zebra instance to talk to, not installing information", "%s: No zebra instance to talk to, not installing information",
__func__); __func__);
return 0; return false;
} }
return 1; return true;
} }
int zclient_num_connects; int zclient_num_connects;
@ -928,8 +928,8 @@ bgp_path_info_to_ipv6_nexthop(struct bgp_path_info *path, ifindex_t *ifindex)
return nexthop; return nexthop;
} }
static int bgp_table_map_apply(struct route_map *map, struct prefix *p, static bool bgp_table_map_apply(struct route_map *map, struct prefix *p,
struct bgp_path_info *path) struct bgp_path_info *path)
{ {
route_map_result_t ret; route_map_result_t ret;
@ -937,7 +937,7 @@ static int bgp_table_map_apply(struct route_map *map, struct prefix *p,
bgp_attr_flush(path->attr); bgp_attr_flush(path->attr);
if (ret != RMAP_DENYMATCH) if (ret != RMAP_DENYMATCH)
return 1; return true;
if (bgp_debug_zebra(p)) { if (bgp_debug_zebra(p)) {
if (p->family == AF_INET) { if (p->family == AF_INET) {
@ -965,7 +965,7 @@ static int bgp_table_map_apply(struct route_map *map, struct prefix *p,
buf[1], sizeof(buf[1]))); buf[1], sizeof(buf[1])));
} }
} }
return 0; return false;
} }
static struct thread *bgp_tm_thread_connect; static struct thread *bgp_tm_thread_connect;
@ -1058,12 +1058,10 @@ int bgp_zebra_get_table_range(uint32_t chunk_size,
return 0; return 0;
} }
static int update_ipv4nh_for_route_install(int nh_othervrf, static bool update_ipv4nh_for_route_install(int nh_othervrf, struct bgp *nh_bgp,
struct bgp *nh_bgp, struct in_addr *nexthop,
struct in_addr *nexthop, struct attr *attr, bool is_evpn,
struct attr *attr, struct zapi_nexthop *api_nh)
bool is_evpn,
struct zapi_nexthop *api_nh)
{ {
api_nh->gate.ipv4 = *nexthop; api_nh->gate.ipv4 = *nexthop;
api_nh->vrf_id = nh_bgp->vrf_id; api_nh->vrf_id = nh_bgp->vrf_id;
@ -1083,15 +1081,16 @@ static int update_ipv4nh_for_route_install(int nh_othervrf,
} else } else
api_nh->type = NEXTHOP_TYPE_IPV4; api_nh->type = NEXTHOP_TYPE_IPV4;
return 1; return true;
} }
static int static bool update_ipv6nh_for_route_install(int nh_othervrf, struct bgp *nh_bgp,
update_ipv6nh_for_route_install(int nh_othervrf, struct bgp *nh_bgp, struct in6_addr *nexthop,
struct in6_addr *nexthop, ifindex_t ifindex,
ifindex_t ifindex, struct bgp_path_info *pi, struct bgp_path_info *pi,
struct bgp_path_info *best_pi, bool is_evpn, struct bgp_path_info *best_pi,
struct zapi_nexthop *api_nh) bool is_evpn,
struct zapi_nexthop *api_nh)
{ {
struct attr *attr; struct attr *attr;
@ -1108,7 +1107,7 @@ update_ipv6nh_for_route_install(int nh_othervrf, struct bgp *nh_bgp,
api_nh->ifindex = attr->nh_ifindex; api_nh->ifindex = attr->nh_ifindex;
} else if (IN6_IS_ADDR_LINKLOCAL(nexthop)) { } else if (IN6_IS_ADDR_LINKLOCAL(nexthop)) {
if (ifindex == 0) if (ifindex == 0)
return 0; return false;
api_nh->type = NEXTHOP_TYPE_IPV6_IFINDEX; api_nh->type = NEXTHOP_TYPE_IPV6_IFINDEX;
api_nh->ifindex = ifindex; api_nh->ifindex = ifindex;
} else { } else {
@ -1136,7 +1135,7 @@ update_ipv6nh_for_route_install(int nh_othervrf, struct bgp *nh_bgp,
} }
if (ifindex == 0) if (ifindex == 0)
return 0; return false;
api_nh->type = NEXTHOP_TYPE_IPV6_IFINDEX; api_nh->type = NEXTHOP_TYPE_IPV6_IFINDEX;
api_nh->ifindex = ifindex; api_nh->ifindex = ifindex;
} else { } else {
@ -1146,7 +1145,7 @@ update_ipv6nh_for_route_install(int nh_othervrf, struct bgp *nh_bgp,
} }
api_nh->gate.ipv6 = *nexthop; api_nh->gate.ipv6 = *nexthop;
return 1; return true;
} }
void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p, void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p,
@ -1660,11 +1659,11 @@ int bgp_redistribute_resend(struct bgp *bgp, afi_t afi, int type,
} }
/* Redistribute with route-map specification. */ /* Redistribute with route-map specification. */
int bgp_redistribute_rmap_set(struct bgp_redist *red, const char *name, bool bgp_redistribute_rmap_set(struct bgp_redist *red, const char *name,
struct route_map *route_map) struct route_map *route_map)
{ {
if (red->rmap.name && (strcmp(red->rmap.name, name) == 0)) if (red->rmap.name && (strcmp(red->rmap.name, name) == 0))
return 0; return false;
XFREE(MTYPE_ROUTE_MAP_NAME, red->rmap.name); XFREE(MTYPE_ROUTE_MAP_NAME, red->rmap.name);
/* Decrement the count for existing routemap and /* Decrement the count for existing routemap and
@ -1675,18 +1674,18 @@ int bgp_redistribute_rmap_set(struct bgp_redist *red, const char *name,
red->rmap.map = route_map; red->rmap.map = route_map;
route_map_counter_increment(red->rmap.map); route_map_counter_increment(red->rmap.map);
return 1; return true;
} }
/* Redistribute with metric specification. */ /* Redistribute with metric specification. */
int bgp_redistribute_metric_set(struct bgp *bgp, struct bgp_redist *red, bool bgp_redistribute_metric_set(struct bgp *bgp, struct bgp_redist *red,
afi_t afi, int type, uint32_t metric) afi_t afi, int type, uint32_t metric)
{ {
struct bgp_node *rn; struct bgp_node *rn;
struct bgp_path_info *pi; struct bgp_path_info *pi;
if (red->redist_metric_flag && red->redist_metric == metric) if (red->redist_metric_flag && red->redist_metric == metric)
return 0; return false;
red->redist_metric_flag = 1; red->redist_metric_flag = 1;
red->redist_metric = metric; red->redist_metric = metric;
@ -1713,7 +1712,7 @@ int bgp_redistribute_metric_set(struct bgp *bgp, struct bgp_redist *red,
} }
} }
return 1; return true;
} }
/* Unset redistribution. */ /* Unset redistribution. */

View File

@ -53,10 +53,10 @@ extern struct bgp_redist *bgp_redist_add(struct bgp *, afi_t, uint8_t,
extern int bgp_redistribute_set(struct bgp *, afi_t, int, unsigned short, extern int bgp_redistribute_set(struct bgp *, afi_t, int, unsigned short,
bool changed); bool changed);
extern int bgp_redistribute_resend(struct bgp *, afi_t, int, unsigned short); extern int bgp_redistribute_resend(struct bgp *, afi_t, int, unsigned short);
extern int bgp_redistribute_rmap_set(struct bgp_redist *red, const char *name, extern bool bgp_redistribute_rmap_set(struct bgp_redist *red, const char *name,
struct route_map *route_map); struct route_map *route_map);
extern int bgp_redistribute_metric_set(struct bgp *, struct bgp_redist *, afi_t, extern bool bgp_redistribute_metric_set(struct bgp *, struct bgp_redist *,
int, uint32_t); afi_t, int, uint32_t);
extern int bgp_redistribute_unset(struct bgp *, afi_t, int, unsigned short); extern int bgp_redistribute_unset(struct bgp *, afi_t, int, unsigned short);
extern int bgp_redistribute_unreg(struct bgp *, afi_t, int, unsigned short); extern int bgp_redistribute_unreg(struct bgp *, afi_t, int, unsigned short);

View File

@ -320,13 +320,12 @@ void bgp_router_id_zebra_bump(vrf_id_t vrf_id, const struct prefix *router_id)
} }
} }
int bgp_router_id_static_set(struct bgp *bgp, struct in_addr id) void bgp_router_id_static_set(struct bgp *bgp, struct in_addr id)
{ {
bgp->router_id_static = id; bgp->router_id_static = id;
bgp_router_id_set(bgp, bgp_router_id_set(bgp,
id.s_addr != INADDR_ANY ? &id : &bgp->router_id_zebra, id.s_addr != INADDR_ANY ? &id : &bgp->router_id_zebra,
true /* is config */); true /* is config */);
return 0;
} }
/* BGP's cluster-id control. */ /* BGP's cluster-id control. */
@ -393,25 +392,21 @@ time_t bgp_clock(void)
} }
/* BGP timer configuration. */ /* BGP timer configuration. */
int bgp_timers_set(struct bgp *bgp, uint32_t keepalive, uint32_t holdtime, void bgp_timers_set(struct bgp *bgp, uint32_t keepalive, uint32_t holdtime,
uint32_t connect_retry) uint32_t connect_retry)
{ {
bgp->default_keepalive = bgp->default_keepalive =
(keepalive < holdtime / 3 ? keepalive : holdtime / 3); (keepalive < holdtime / 3 ? keepalive : holdtime / 3);
bgp->default_holdtime = holdtime; bgp->default_holdtime = holdtime;
bgp->default_connect_retry = connect_retry; bgp->default_connect_retry = connect_retry;
return 0;
} }
/* mostly for completeness - CLI uses its own defaults */ /* mostly for completeness - CLI uses its own defaults */
int bgp_timers_unset(struct bgp *bgp) void bgp_timers_unset(struct bgp *bgp)
{ {
bgp->default_keepalive = BGP_DEFAULT_KEEPALIVE; bgp->default_keepalive = BGP_DEFAULT_KEEPALIVE;
bgp->default_holdtime = BGP_DEFAULT_HOLDTIME; bgp->default_holdtime = BGP_DEFAULT_HOLDTIME;
bgp->default_connect_retry = BGP_DEFAULT_CONNECT_RETRY; bgp->default_connect_retry = BGP_DEFAULT_CONNECT_RETRY;
return 0;
} }
/* BGP confederation configuration. */ /* BGP confederation configuration. */
@ -499,18 +494,18 @@ int bgp_confederation_id_unset(struct bgp *bgp)
} }
/* Is an AS part of the confed or not? */ /* Is an AS part of the confed or not? */
int bgp_confederation_peers_check(struct bgp *bgp, as_t as) bool bgp_confederation_peers_check(struct bgp *bgp, as_t as)
{ {
int i; int i;
if (!bgp) if (!bgp)
return 0; return false;
for (i = 0; i < bgp->confed_peers_cnt; i++) for (i = 0; i < bgp->confed_peers_cnt; i++)
if (bgp->confed_peers[i] == as) if (bgp->confed_peers[i] == as)
return 1; return true;
return 0; return false;
} }
/* Add an AS to the confederation set. */ /* Add an AS to the confederation set. */
@ -1415,8 +1410,8 @@ static int bgp_peer_conf_if_to_su_update_v4(struct peer *peer,
return 0; return 0;
} }
static int bgp_peer_conf_if_to_su_update_v6(struct peer *peer, static bool bgp_peer_conf_if_to_su_update_v6(struct peer *peer,
struct interface *ifp) struct interface *ifp)
{ {
struct nbr_connected *ifc_nbr; struct nbr_connected *ifc_nbr;
@ -1430,10 +1425,10 @@ static int bgp_peer_conf_if_to_su_update_v6(struct peer *peer,
peer->su.sin6.sin6_len = sizeof(struct sockaddr_in6); peer->su.sin6.sin6_len = sizeof(struct sockaddr_in6);
#endif #endif
peer->su.sin6.sin6_scope_id = ifp->ifindex; peer->su.sin6.sin6_scope_id = ifp->ifindex;
return 1; return true;
} }
return 0; return false;
} }
/* /*
@ -2084,18 +2079,18 @@ int peer_activate(struct peer *peer, afi_t afi, safi_t safi)
return ret; return ret;
} }
static int non_peergroup_deactivate_af(struct peer *peer, afi_t afi, static bool non_peergroup_deactivate_af(struct peer *peer, afi_t afi,
safi_t safi) safi_t safi)
{ {
if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
flog_err(EC_BGP_PEER_GROUP, "%s was called for peer-group %s", flog_err(EC_BGP_PEER_GROUP, "%s was called for peer-group %s",
__func__, peer->host); __func__, peer->host);
return 1; return true;
} }
/* Nothing to do if we've already deactivated this peer */ /* Nothing to do if we've already deactivated this peer */
if (!peer->afc[afi][safi]) if (!peer->afc[afi][safi])
return 0; return false;
/* De-activate the address family configuration. */ /* De-activate the address family configuration. */
peer->afc[afi][safi] = 0; peer->afc[afi][safi] = 0;
@ -2104,7 +2099,7 @@ static int non_peergroup_deactivate_af(struct peer *peer, afi_t afi,
flog_err(EC_BGP_PEER_DELETE, flog_err(EC_BGP_PEER_DELETE,
"couldn't delete af structure for peer %s(%s, %s)", "couldn't delete af structure for peer %s(%s, %s)",
peer->host, afi2str(afi), safi2str(safi)); peer->host, afi2str(afi), safi2str(safi));
return 1; return true;
} }
if (peer->status == Established) { if (peer->status == Established) {
@ -2130,7 +2125,7 @@ static int non_peergroup_deactivate_af(struct peer *peer, afi_t afi,
} }
} }
return 0; return false;
} }
int peer_deactivate(struct peer *peer, afi_t afi, safi_t safi) int peer_deactivate(struct peer *peer, afi_t afi, safi_t safi)
@ -2547,15 +2542,14 @@ int peer_group_remote_as(struct bgp *bgp, const char *group_name, as_t *as,
return 0; return 0;
} }
int peer_notify_unconfig(struct peer *peer) void peer_notify_unconfig(struct peer *peer)
{ {
if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status))
bgp_notify_send(peer, BGP_NOTIFY_CEASE, bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_PEER_UNCONFIG); BGP_NOTIFY_CEASE_PEER_UNCONFIG);
return 0;
} }
int peer_group_notify_unconfig(struct peer_group *group) void peer_group_notify_unconfig(struct peer_group *group)
{ {
struct peer *peer, *other; struct peer *peer, *other;
struct listnode *node, *nnode; struct listnode *node, *nnode;
@ -2568,7 +2562,6 @@ int peer_group_notify_unconfig(struct peer_group *group)
} else } else
peer_notify_unconfig(peer); peer_notify_unconfig(peer);
} }
return 0;
} }
int peer_group_delete(struct peer_group *group) int peer_group_delete(struct peer_group *group)
@ -3771,10 +3764,10 @@ static void peer_drop_dynamic_neighbor(struct peer *peer)
} }
/* If peer is configured at least one address family return 1. */ /* If peer is configured at least one address family return 1. */
int peer_active(struct peer *peer) bool peer_active(struct peer *peer)
{ {
if (BGP_PEER_SU_UNSPEC(peer)) if (BGP_PEER_SU_UNSPEC(peer))
return 0; return false;
if (peer->afc[AFI_IP][SAFI_UNICAST] || peer->afc[AFI_IP][SAFI_MULTICAST] if (peer->afc[AFI_IP][SAFI_UNICAST] || peer->afc[AFI_IP][SAFI_MULTICAST]
|| peer->afc[AFI_IP][SAFI_LABELED_UNICAST] || peer->afc[AFI_IP][SAFI_LABELED_UNICAST]
|| peer->afc[AFI_IP][SAFI_MPLS_VPN] || peer->afc[AFI_IP][SAFI_ENCAP] || peer->afc[AFI_IP][SAFI_MPLS_VPN] || peer->afc[AFI_IP][SAFI_ENCAP]
@ -3786,12 +3779,12 @@ int peer_active(struct peer *peer)
|| peer->afc[AFI_IP6][SAFI_ENCAP] || peer->afc[AFI_IP6][SAFI_ENCAP]
|| peer->afc[AFI_IP6][SAFI_FLOWSPEC] || peer->afc[AFI_IP6][SAFI_FLOWSPEC]
|| peer->afc[AFI_L2VPN][SAFI_EVPN]) || peer->afc[AFI_L2VPN][SAFI_EVPN])
return 1; return true;
return 0; return false;
} }
/* If peer is negotiated at least one address family return 1. */ /* If peer is negotiated at least one address family return 1. */
int peer_active_nego(struct peer *peer) bool peer_active_nego(struct peer *peer)
{ {
if (peer->afc_nego[AFI_IP][SAFI_UNICAST] if (peer->afc_nego[AFI_IP][SAFI_UNICAST]
|| peer->afc_nego[AFI_IP][SAFI_MULTICAST] || peer->afc_nego[AFI_IP][SAFI_MULTICAST]
@ -3806,8 +3799,8 @@ int peer_active_nego(struct peer *peer)
|| peer->afc_nego[AFI_IP6][SAFI_ENCAP] || peer->afc_nego[AFI_IP6][SAFI_ENCAP]
|| peer->afc_nego[AFI_IP6][SAFI_FLOWSPEC] || peer->afc_nego[AFI_IP6][SAFI_FLOWSPEC]
|| peer->afc_nego[AFI_L2VPN][SAFI_EVPN]) || peer->afc_nego[AFI_L2VPN][SAFI_EVPN])
return 1; return true;
return 0; return false;
} }
void peer_change_action(struct peer *peer, afi_t afi, safi_t safi, void peer_change_action(struct peer *peer, afi_t afi, safi_t safi,
@ -4308,18 +4301,16 @@ int peer_af_flag_unset(struct peer *peer, afi_t afi, safi_t safi, uint32_t flag)
} }
int peer_tx_shutdown_message_set(struct peer *peer, const char *msg) void peer_tx_shutdown_message_set(struct peer *peer, const char *msg)
{ {
XFREE(MTYPE_PEER_TX_SHUTDOWN_MSG, peer->tx_shutdown_message); XFREE(MTYPE_PEER_TX_SHUTDOWN_MSG, peer->tx_shutdown_message);
peer->tx_shutdown_message = peer->tx_shutdown_message =
msg ? XSTRDUP(MTYPE_PEER_TX_SHUTDOWN_MSG, msg) : NULL; msg ? XSTRDUP(MTYPE_PEER_TX_SHUTDOWN_MSG, msg) : NULL;
return 0;
} }
int peer_tx_shutdown_message_unset(struct peer *peer) void peer_tx_shutdown_message_unset(struct peer *peer)
{ {
XFREE(MTYPE_PEER_TX_SHUTDOWN_MSG, peer->tx_shutdown_message); XFREE(MTYPE_PEER_TX_SHUTDOWN_MSG, peer->tx_shutdown_message);
return 0;
} }
@ -4426,20 +4417,16 @@ int peer_ebgp_multihop_unset(struct peer *peer)
} }
/* Neighbor description. */ /* Neighbor description. */
int peer_description_set(struct peer *peer, const char *desc) void peer_description_set(struct peer *peer, const char *desc)
{ {
XFREE(MTYPE_PEER_DESC, peer->desc); XFREE(MTYPE_PEER_DESC, peer->desc);
peer->desc = XSTRDUP(MTYPE_PEER_DESC, desc); peer->desc = XSTRDUP(MTYPE_PEER_DESC, desc);
return 0;
} }
int peer_description_unset(struct peer *peer) void peer_description_unset(struct peer *peer)
{ {
XFREE(MTYPE_PEER_DESC, peer->desc); XFREE(MTYPE_PEER_DESC, peer->desc);
return 0;
} }
/* Neighbor update-source. */ /* Neighbor update-source. */
@ -4789,16 +4776,14 @@ int peer_default_originate_unset(struct peer *peer, afi_t afi, safi_t safi)
return 0; return 0;
} }
int peer_port_set(struct peer *peer, uint16_t port) void peer_port_set(struct peer *peer, uint16_t port)
{ {
peer->port = port; peer->port = port;
return 0;
} }
int peer_port_unset(struct peer *peer) void peer_port_unset(struct peer *peer)
{ {
peer->port = BGP_PORT_DEFAULT; peer->port = BGP_PORT_DEFAULT;
return 0;
} }
/* /*

View File

@ -1742,8 +1742,8 @@ extern struct peer *peer_unlock_with_caller(const char *, struct peer *);
extern bgp_peer_sort_t peer_sort(struct peer *peer); extern bgp_peer_sort_t peer_sort(struct peer *peer);
extern bgp_peer_sort_t peer_sort_lookup(struct peer *peer); extern bgp_peer_sort_t peer_sort_lookup(struct peer *peer);
extern int peer_active(struct peer *); extern bool peer_active(struct peer *);
extern int peer_active_nego(struct peer *); extern bool peer_active_nego(struct peer *);
extern void bgp_recalculate_all_bestpaths(struct bgp *bgp); extern void bgp_recalculate_all_bestpaths(struct bgp *bgp);
extern struct peer *peer_create(union sockunion *, const char *, struct bgp *, extern struct peer *peer_create(union sockunion *, const char *, struct bgp *,
as_t, as_t, int, afi_t, safi_t, as_t, as_t, int, afi_t, safi_t,
@ -1777,21 +1777,21 @@ extern int bgp_handle_socket(struct bgp *bgp, struct vrf *vrf,
vrf_id_t old_vrf_id, bool create); vrf_id_t old_vrf_id, bool create);
extern void bgp_router_id_zebra_bump(vrf_id_t, const struct prefix *); extern void bgp_router_id_zebra_bump(vrf_id_t, const struct prefix *);
extern int bgp_router_id_static_set(struct bgp *, struct in_addr); extern void bgp_router_id_static_set(struct bgp *, struct in_addr);
extern int bgp_cluster_id_set(struct bgp *, struct in_addr *); extern int bgp_cluster_id_set(struct bgp *, struct in_addr *);
extern int bgp_cluster_id_unset(struct bgp *); extern int bgp_cluster_id_unset(struct bgp *);
extern int bgp_confederation_id_set(struct bgp *, as_t); extern int bgp_confederation_id_set(struct bgp *, as_t);
extern int bgp_confederation_id_unset(struct bgp *); extern int bgp_confederation_id_unset(struct bgp *);
extern int bgp_confederation_peers_check(struct bgp *, as_t); extern bool bgp_confederation_peers_check(struct bgp *, as_t);
extern int bgp_confederation_peers_add(struct bgp *, as_t); extern int bgp_confederation_peers_add(struct bgp *, as_t);
extern int bgp_confederation_peers_remove(struct bgp *, as_t); extern int bgp_confederation_peers_remove(struct bgp *, as_t);
extern int bgp_timers_set(struct bgp *, uint32_t keepalive, uint32_t holdtime, extern void bgp_timers_set(struct bgp *, uint32_t keepalive, uint32_t holdtime,
uint32_t connect_retry); uint32_t connect_retry);
extern int bgp_timers_unset(struct bgp *); extern void bgp_timers_unset(struct bgp *);
extern int bgp_default_local_preference_set(struct bgp *, uint32_t); extern int bgp_default_local_preference_set(struct bgp *, uint32_t);
extern int bgp_default_local_preference_unset(struct bgp *); extern int bgp_default_local_preference_unset(struct bgp *);
@ -1802,19 +1802,19 @@ extern int bgp_default_subgroup_pkt_queue_max_unset(struct bgp *bgp);
extern int bgp_listen_limit_set(struct bgp *, int); extern int bgp_listen_limit_set(struct bgp *, int);
extern int bgp_listen_limit_unset(struct bgp *); extern int bgp_listen_limit_unset(struct bgp *);
extern int bgp_update_delay_active(struct bgp *); extern bool bgp_update_delay_active(struct bgp *);
extern int bgp_update_delay_configured(struct bgp *); extern bool bgp_update_delay_configured(struct bgp *);
extern int bgp_afi_safi_peer_exists(struct bgp *bgp, afi_t afi, safi_t safi); extern int bgp_afi_safi_peer_exists(struct bgp *bgp, afi_t afi, safi_t safi);
extern void peer_as_change(struct peer *, as_t, int); extern void peer_as_change(struct peer *, as_t, int);
extern int peer_remote_as(struct bgp *, union sockunion *, const char *, as_t *, extern int peer_remote_as(struct bgp *, union sockunion *, const char *, as_t *,
int, afi_t, safi_t); int, afi_t, safi_t);
extern int peer_group_remote_as(struct bgp *, const char *, as_t *, int); extern int peer_group_remote_as(struct bgp *, const char *, as_t *, int);
extern int peer_delete(struct peer *peer); extern int peer_delete(struct peer *peer);
extern int peer_notify_unconfig(struct peer *peer); extern void peer_notify_unconfig(struct peer *peer);
extern int peer_group_delete(struct peer_group *); extern int peer_group_delete(struct peer_group *);
extern int peer_group_remote_as_delete(struct peer_group *); extern int peer_group_remote_as_delete(struct peer_group *);
extern int peer_group_listen_range_add(struct peer_group *, struct prefix *); extern int peer_group_listen_range_add(struct peer_group *, struct prefix *);
extern int peer_group_notify_unconfig(struct peer_group *group); extern void peer_group_notify_unconfig(struct peer_group *group);
extern int peer_activate(struct peer *, afi_t, safi_t); extern int peer_activate(struct peer *, afi_t, safi_t);
extern int peer_deactivate(struct peer *, afi_t, safi_t); extern int peer_deactivate(struct peer *, afi_t, safi_t);
@ -1839,8 +1839,8 @@ extern int peer_ebgp_multihop_set(struct peer *, int);
extern int peer_ebgp_multihop_unset(struct peer *); extern int peer_ebgp_multihop_unset(struct peer *);
extern int is_ebgp_multihop_configured(struct peer *peer); extern int is_ebgp_multihop_configured(struct peer *peer);
extern int peer_description_set(struct peer *, const char *); extern void peer_description_set(struct peer *, const char *);
extern int peer_description_unset(struct peer *); extern void peer_description_unset(struct peer *);
extern int peer_update_source_if_set(struct peer *, const char *); extern int peer_update_source_if_set(struct peer *, const char *);
extern int peer_update_source_addr_set(struct peer *, const union sockunion *); extern int peer_update_source_addr_set(struct peer *, const union sockunion *);
@ -1851,8 +1851,8 @@ extern int peer_default_originate_set(struct peer *peer, afi_t afi, safi_t safi,
struct route_map *route_map); struct route_map *route_map);
extern int peer_default_originate_unset(struct peer *, afi_t, safi_t); extern int peer_default_originate_unset(struct peer *, afi_t, safi_t);
extern int peer_port_set(struct peer *, uint16_t); extern void peer_port_set(struct peer *, uint16_t);
extern int peer_port_unset(struct peer *); extern void peer_port_unset(struct peer *);
extern int peer_weight_set(struct peer *, afi_t, safi_t, uint16_t); extern int peer_weight_set(struct peer *, afi_t, safi_t, uint16_t);
extern int peer_weight_unset(struct peer *, afi_t, safi_t); extern int peer_weight_unset(struct peer *, afi_t, safi_t);
@ -1909,8 +1909,8 @@ extern int peer_clear_soft(struct peer *, afi_t, safi_t, enum bgp_clear_type);
extern int peer_ttl_security_hops_set(struct peer *, int); extern int peer_ttl_security_hops_set(struct peer *, int);
extern int peer_ttl_security_hops_unset(struct peer *); extern int peer_ttl_security_hops_unset(struct peer *);
extern int peer_tx_shutdown_message_set(struct peer *, const char *msg); extern void peer_tx_shutdown_message_set(struct peer *, const char *msg);
extern int peer_tx_shutdown_message_unset(struct peer *); extern void peer_tx_shutdown_message_unset(struct peer *);
extern int bgp_route_map_update_timer(struct thread *thread); extern int bgp_route_map_update_timer(struct thread *thread);
extern void bgp_route_map_terminate(void); extern void bgp_route_map_terminate(void);

View File

@ -0,0 +1,24 @@
@@
identifier fn;
typedef bool;
symbol false;
symbol true;
identifier I;
struct thread *thread;
@@
- int
+ bool
fn (...)
{
... when strict
when != I = THREAD_ARG(thread);
(
- return 0;
+ return false;
|
- return 1;
+ return true;
)
?...
}