*: Replace hash_cmp function return value to a bool

The ->hash_cmp and linked list ->cmp functions were sometimes
being used interchangeably and this really is not a good
thing.  So let's modify the hash_cmp function pointer to return
a boolean and convert everything to use the new syntax.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2018-10-17 15:27:12 -04:00
parent 27fa33984b
commit 74df8d6d9d
52 changed files with 239 additions and 240 deletions

View file

@ -861,15 +861,10 @@ static struct hash *bfd_vrf_hash;
static struct hash *bfd_iface_hash;
static unsigned int bfd_id_hash_do(void *p);
static int bfd_id_hash_cmp(const void *n1, const void *n2);
static unsigned int bfd_shop_hash_do(void *p);
static int bfd_shop_hash_cmp(const void *n1, const void *n2);
static unsigned int bfd_mhop_hash_do(void *p);
static int bfd_mhop_hash_cmp(const void *n1, const void *n2);
static unsigned int bfd_vrf_hash_do(void *p);
static int bfd_vrf_hash_cmp(const void *n1, const void *n2);
static unsigned int bfd_iface_hash_do(void *p);
static int bfd_iface_hash_cmp(const void *n1, const void *n2);
static void _shop_key(struct bfd_session *bs, const struct bfd_shop_key *shop);
static void _shop_key2(struct bfd_session *bs, const struct bfd_shop_key *shop);
@ -889,7 +884,7 @@ static unsigned int bfd_id_hash_do(void *p)
return jhash_1word(bs->discrs.my_discr, 0);
}
static int bfd_id_hash_cmp(const void *n1, const void *n2)
static bool bfd_id_hash_cmp(const void *n1, const void *n2)
{
const struct bfd_session *bs1 = n1, *bs2 = n2;
@ -904,7 +899,7 @@ static unsigned int bfd_shop_hash_do(void *p)
return jhash(&bs->shop, sizeof(bs->shop), 0);
}
static int bfd_shop_hash_cmp(const void *n1, const void *n2)
static bool bfd_shop_hash_cmp(const void *n1, const void *n2)
{
const struct bfd_session *bs1 = n1, *bs2 = n2;
@ -919,7 +914,7 @@ static unsigned int bfd_mhop_hash_do(void *p)
return jhash(&bs->mhop, sizeof(bs->mhop), 0);
}
static int bfd_mhop_hash_cmp(const void *n1, const void *n2)
static bool bfd_mhop_hash_cmp(const void *n1, const void *n2)
{
const struct bfd_session *bs1 = n1, *bs2 = n2;
@ -934,7 +929,7 @@ static unsigned int bfd_vrf_hash_do(void *p)
return jhash_1word(vrf->vrf_id, 0);
}
static int bfd_vrf_hash_cmp(const void *n1, const void *n2)
static bool bfd_vrf_hash_cmp(const void *n1, const void *n2)
{
const struct bfd_vrf *v1 = n1, *v2 = n2;
@ -949,7 +944,7 @@ static unsigned int bfd_iface_hash_do(void *p)
return string_hash_make(iface->ifname);
}
static int bfd_iface_hash_cmp(const void *n1, const void *n2)
static bool bfd_iface_hash_cmp(const void *n1, const void *n2)
{
const struct bfd_iface *i1 = n1, *i2 = n2;

View file

@ -71,7 +71,7 @@ unsigned int baa_hash_key(void *p)
return attrhash_key_make(baa->attr);
}
int baa_hash_cmp(const void *p1, const void *p2)
bool baa_hash_cmp(const void *p1, const void *p2)
{
const struct bgp_advertise_attr *baa1 = p1;
const struct bgp_advertise_attr *baa2 = p2;

View file

@ -177,7 +177,7 @@ extern void bgp_adj_in_remove(struct bgp_node *, struct bgp_adj_in *);
extern void bgp_sync_init(struct peer *);
extern void bgp_sync_delete(struct peer *);
extern unsigned int baa_hash_key(void *p);
extern int baa_hash_cmp(const void *p1, const void *p2);
extern bool baa_hash_cmp(const void *p1, const void *p2);
extern void bgp_advertise_add(struct bgp_advertise_attr *baa,
struct bgp_advertise *adv);
extern struct bgp_advertise *bgp_advertise_new(void);

View file

@ -1726,23 +1726,23 @@ struct aspath *aspath_reconcile_as4(struct aspath *aspath,
/* Compare leftmost AS value for MED check. If as1's leftmost AS and
as2's leftmost AS is same return 1. (confederation as-path
only). */
int aspath_cmp_left_confed(const struct aspath *aspath1,
const struct aspath *aspath2)
bool aspath_cmp_left_confed(const struct aspath *aspath1,
const struct aspath *aspath2)
{
if (!(aspath1 && aspath2))
return 0;
return false;
if (!(aspath1->segments && aspath2->segments))
return 0;
return false;
if ((aspath1->segments->type != AS_CONFED_SEQUENCE)
|| (aspath2->segments->type != AS_CONFED_SEQUENCE))
return 0;
return false;
if (aspath1->segments->as[0] == aspath2->segments->as[0])
return 1;
return true;
return 0;
return false;
}
/* Delete all AS_CONFED_SEQUENCE/SET segments from aspath.
@ -2008,7 +2008,7 @@ unsigned int aspath_key_make(void *p)
}
/* If two aspath have same value then return 1 else return 0 */
int aspath_cmp(const void *arg1, const void *arg2)
bool aspath_cmp(const void *arg1, const void *arg2)
{
const struct assegment *seg1 = ((const struct aspath *)arg1)->segments;
const struct assegment *seg2 = ((const struct aspath *)arg2)->segments;
@ -2016,18 +2016,18 @@ int aspath_cmp(const void *arg1, const void *arg2)
while (seg1 || seg2) {
int i;
if ((!seg1 && seg2) || (seg1 && !seg2))
return 0;
return false;
if (seg1->type != seg2->type)
return 0;
return false;
if (seg1->length != seg2->length)
return 0;
return false;
for (i = 0; i < seg1->length; i++)
if (seg1->as[i] != seg2->as[i])
return 0;
return false;
seg1 = seg1->next;
seg2 = seg2->next;
}
return 1;
return true;
}
/* AS path hash initialize. */

View file

@ -85,9 +85,10 @@ extern struct aspath *aspath_filter_exclude(struct aspath *, struct aspath *);
extern struct aspath *aspath_add_seq_n(struct aspath *, as_t, unsigned);
extern struct aspath *aspath_add_seq(struct aspath *, as_t);
extern struct aspath *aspath_add_confed_seq(struct aspath *, as_t);
extern int aspath_cmp(const void *, const void *);
extern bool aspath_cmp(const void *as1, const void *as2);
extern int aspath_cmp_left(const struct aspath *, const struct aspath *);
extern int aspath_cmp_left_confed(const struct aspath *, const struct aspath *);
extern bool aspath_cmp_left_confed(const struct aspath *as1,
const struct aspath *as2xs);
extern struct aspath *aspath_delete_confed_seq(struct aspath *);
extern struct aspath *aspath_empty(void);
extern struct aspath *aspath_empty_get(void);

View file

@ -146,7 +146,7 @@ static unsigned int cluster_hash_key_make(void *p)
return jhash(cluster->list, cluster->length, 0);
}
static int cluster_hash_cmp(const void *p1, const void *p2)
static bool cluster_hash_cmp(const void *p1, const void *p2)
{
const struct cluster_list *cluster1 = p1;
const struct cluster_list *cluster2 = p2;
@ -355,7 +355,7 @@ static unsigned int encap_hash_key_make(void *p)
return jhash(encap->value, encap->length, 0);
}
static int encap_hash_cmp(const void *p1, const void *p2)
static bool encap_hash_cmp(const void *p1, const void *p2)
{
return encap_same((const struct bgp_attr_encap_subtlv *)p1,
(const struct bgp_attr_encap_subtlv *)p2);
@ -441,7 +441,7 @@ static unsigned int transit_hash_key_make(void *p)
return jhash(transit->val, transit->length, 0);
}
static int transit_hash_cmp(const void *p1, const void *p2)
static bool transit_hash_cmp(const void *p1, const void *p2)
{
const struct transit *transit1 = p1;
const struct transit *transit2 = p2;
@ -527,7 +527,7 @@ unsigned int attrhash_key_make(void *p)
return key;
}
int attrhash_cmp(const void *p1, const void *p2)
bool attrhash_cmp(const void *p1, const void *p2)
{
const struct attr *attr1 = p1;
const struct attr *attr2 = p2;
@ -565,10 +565,10 @@ int attrhash_cmp(const void *p1, const void *p2)
&& overlay_index_same(attr1, attr2)
&& attr1->nh_ifindex == attr2->nh_ifindex
&& attr1->nh_lla_ifindex == attr2->nh_lla_ifindex)
return 1;
return true;
}
return 0;
return false;
}
static void attrhash_init(void)

View file

@ -287,7 +287,7 @@ extern bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *,
mpls_label_t *, uint32_t, int, uint32_t);
extern void bgp_dump_routes_attr(struct stream *, struct attr *,
struct prefix *);
extern int attrhash_cmp(const void *, const void *);
extern bool attrhash_cmp(const void *arg1, const void *arg2);
extern unsigned int attrhash_key_make(void *);
extern void attr_show_all(struct vty *);
extern unsigned long int attr_count(void);

View file

@ -614,17 +614,17 @@ int community_match(const struct community *com1, const struct community *com2)
/* If two aspath have same value then return 1 else return 0. This
function is used by hash package. */
int community_cmp(const struct community *com1, const struct community *com2)
bool community_cmp(const struct community *com1, const struct community *com2)
{
if (com1 == NULL && com2 == NULL)
return 1;
return true;
if (com1 == NULL || com2 == NULL)
return 0;
return false;
if (com1->size == com2->size)
if (memcmp(com1->val, com2->val, com1->size * 4) == 0)
return 1;
return 0;
return true;
return false;
}
/* Add com2 to the end of com1. */
@ -902,7 +902,7 @@ void community_init(void)
{
comhash =
hash_create((unsigned int (*)(void *))community_hash_make,
(int (*)(const void *, const void *))community_cmp,
(bool (*)(const void *, const void *))community_cmp,
"BGP Community Hash");
}

View file

@ -77,7 +77,8 @@ extern char *community_str(struct community *, bool make_json);
extern unsigned int community_hash_make(struct community *);
extern struct community *community_str2com(const char *);
extern int community_match(const struct community *, const struct community *);
extern int community_cmp(const struct community *, const struct community *);
extern bool community_cmp(const struct community *c1,
const struct community *c2);
extern struct community *community_merge(struct community *,
struct community *);
extern struct community *community_delete(struct community *,

View file

@ -253,16 +253,16 @@ unsigned int ecommunity_hash_make(void *arg)
}
/* Compare two Extended Communities Attribute structure. */
int ecommunity_cmp(const void *arg1, const void *arg2)
bool ecommunity_cmp(const void *arg1, const void *arg2)
{
const struct ecommunity *ecom1 = arg1;
const struct ecommunity *ecom2 = arg2;
if (ecom1 == NULL && ecom2 == NULL)
return 1;
return true;
if (ecom1 == NULL || ecom2 == NULL)
return 0;
return false;
return (ecom1->size == ecom2->size
&& memcmp(ecom1->val, ecom2->val, ecom1->size * ECOMMUNITY_SIZE)

View file

@ -154,7 +154,7 @@ extern struct ecommunity *ecommunity_merge(struct ecommunity *,
struct ecommunity *);
extern struct ecommunity *ecommunity_uniq_sort(struct ecommunity *);
extern struct ecommunity *ecommunity_intern(struct ecommunity *);
extern int ecommunity_cmp(const void *, const void *);
extern bool ecommunity_cmp(const void *arg1, const void *arg2);
extern void ecommunity_unintern(struct ecommunity **);
extern unsigned int ecommunity_hash_make(void *);
extern struct ecommunity *ecommunity_str2com(const char *, int, int);

View file

@ -92,16 +92,16 @@ static unsigned int esi_hash_keymake(void *p)
/*
* Compare two ESIs.
*/
static int esi_cmp(const void *p1, const void *p2)
static bool esi_cmp(const void *p1, const void *p2)
{
const struct evpnes *pes1 = p1;
const struct evpnes *pes2 = p2;
if (pes1 == NULL && pes2 == NULL)
return 1;
return true;
if (pes1 == NULL || pes2 == NULL)
return 0;
return false;
return (memcmp(pes1->esi.val, pes2->esi.val, ESI_BYTES) == 0);
}
@ -118,15 +118,15 @@ static unsigned int vni_hash_key_make(void *p)
/*
* Comparison function for vni hash
*/
static int vni_hash_cmp(const void *p1, const void *p2)
static bool vni_hash_cmp(const void *p1, const void *p2)
{
const struct bgpevpn *vpn1 = p1;
const struct bgpevpn *vpn2 = p2;
if (!vpn1 && !vpn2)
return 1;
return true;
if (!vpn1 || !vpn2)
return 0;
return false;
return (vpn1->vni == vpn2->vni);
}
@ -152,16 +152,16 @@ static unsigned int vrf_import_rt_hash_key_make(void *p)
/*
* Comparison function for vrf import rt hash
*/
static int vrf_import_rt_hash_cmp(const void *p1, const void *p2)
static bool vrf_import_rt_hash_cmp(const void *p1, const void *p2)
{
const struct vrf_irt_node *irt1 = p1;
const struct vrf_irt_node *irt2 = p2;
if (irt1 == NULL && irt2 == NULL)
return 1;
return true;
if (irt1 == NULL || irt2 == NULL)
return 0;
return false;
return (memcmp(irt1->rt.val, irt2->rt.val, ECOMMUNITY_SIZE) == 0);
}
@ -269,16 +269,16 @@ static unsigned int import_rt_hash_key_make(void *p)
/*
* Comparison function for import rt hash
*/
static int import_rt_hash_cmp(const void *p1, const void *p2)
static bool import_rt_hash_cmp(const void *p1, const void *p2)
{
const struct irt_node *irt1 = p1;
const struct irt_node *irt2 = p2;
if (irt1 == NULL && irt2 == NULL)
return 1;
return true;
if (irt1 == NULL || irt2 == NULL)
return 0;
return false;
return (memcmp(irt1->rt.val, irt2->rt.val, ECOMMUNITY_SIZE) == 0);
}

View file

@ -123,10 +123,11 @@ static void peer_process(struct hash_backet *hb, void *arg)
*next_update = diff;
}
static int peer_hash_cmp(const void *f, const void *s)
static bool peer_hash_cmp(const void *f, const void *s)
{
const struct pkat *p1 = f;
const struct pkat *p2 = s;
return p1->peer == p2->peer;
}

View file

@ -313,7 +313,7 @@ unsigned int lcommunity_hash_make(void *arg)
}
/* Compare two Large Communities Attribute structure. */
int lcommunity_cmp(const void *arg1, const void *arg2)
bool lcommunity_cmp(const void *arg1, const void *arg2)
{
const struct lcommunity *lcom1 = arg1;
const struct lcommunity *lcom2 = arg2;

View file

@ -60,7 +60,7 @@ extern struct lcommunity *lcommunity_merge(struct lcommunity *,
struct lcommunity *);
extern struct lcommunity *lcommunity_uniq_sort(struct lcommunity *);
extern struct lcommunity *lcommunity_intern(struct lcommunity *);
extern int lcommunity_cmp(const void *, const void *);
extern bool lcommunity_cmp(const void *arg1, const void *arg2);
extern void lcommunity_unintern(struct lcommunity **);
extern unsigned int lcommunity_hash_make(void *);
extern struct hash *lcommunity_hash(void);

View file

@ -123,7 +123,7 @@ static unsigned int bgp_tip_hash_key_make(void *p)
return jhash_1word(addr->addr.s_addr, 0);
}
static int bgp_tip_hash_cmp(const void *p1, const void *p2)
static bool bgp_tip_hash_cmp(const void *p1, const void *p2)
{
const struct tip_addr *addr1 = p1;
const struct tip_addr *addr2 = p2;
@ -246,7 +246,7 @@ static unsigned int bgp_address_hash_key_make(void *p)
return jhash_1word(addr->addr.s_addr, 0);
}
static int bgp_address_hash_cmp(const void *p1, const void *p2)
static bool bgp_address_hash_cmp(const void *p1, const void *p2)
{
const struct bgp_addr *addr1 = p1;
const struct bgp_addr *addr2 = p2;

View file

@ -847,7 +847,7 @@ uint32_t bgp_pbr_match_hash_key(void *arg)
return jhash_1word(pbm->type, key);
}
int bgp_pbr_match_hash_equal(const void *arg1, const void *arg2)
bool bgp_pbr_match_hash_equal(const void *arg1, const void *arg2)
{
const struct bgp_pbr_match *r1, *r2;
@ -855,35 +855,35 @@ int bgp_pbr_match_hash_equal(const void *arg1, const void *arg2)
r2 = (const struct bgp_pbr_match *)arg2;
if (r1->vrf_id != r2->vrf_id)
return 0;
return false;
if (r1->type != r2->type)
return 0;
return false;
if (r1->flags != r2->flags)
return 0;
return false;
if (r1->action != r2->action)
return 0;
return false;
if (r1->pkt_len_min != r2->pkt_len_min)
return 0;
return false;
if (r1->pkt_len_max != r2->pkt_len_max)
return 0;
return false;
if (r1->tcp_flags != r2->tcp_flags)
return 0;
return false;
if (r1->tcp_mask_flags != r2->tcp_mask_flags)
return 0;
return false;
if (r1->dscp_value != r2->dscp_value)
return 0;
return false;
if (r1->fragment != r2->fragment)
return 0;
return 1;
return false;
return true;
}
uint32_t bgp_pbr_match_entry_hash_key(void *arg)
@ -903,45 +903,41 @@ uint32_t bgp_pbr_match_entry_hash_key(void *arg)
return key;
}
int bgp_pbr_match_entry_hash_equal(const void *arg1, const void *arg2)
bool bgp_pbr_match_entry_hash_equal(const void *arg1, const void *arg2)
{
const struct bgp_pbr_match_entry *r1, *r2;
r1 = (const struct bgp_pbr_match_entry *)arg1;
r2 = (const struct bgp_pbr_match_entry *)arg2;
/* on updates, comparing
* backpointer is not necessary
*/
/* unique value is self calculated
*/
/* rate is ignored for now
/*
* on updates, comparing backpointer is not necessary
* unique value is self calculated
* rate is ignored for now
*/
if (!prefix_same(&r1->src, &r2->src))
return 0;
return false;
if (!prefix_same(&r1->dst, &r2->dst))
return 0;
return false;
if (r1->src_port_min != r2->src_port_min)
return 0;
return false;
if (r1->dst_port_min != r2->dst_port_min)
return 0;
return false;
if (r1->src_port_max != r2->src_port_max)
return 0;
return false;
if (r1->dst_port_max != r2->dst_port_max)
return 0;
return false;
if (r1->proto != r2->proto)
return 0;
return false;
return 1;
return true;
}
uint32_t bgp_pbr_action_hash_key(void *arg)
@ -955,7 +951,7 @@ uint32_t bgp_pbr_action_hash_key(void *arg)
return key;
}
int bgp_pbr_action_hash_equal(const void *arg1, const void *arg2)
bool bgp_pbr_action_hash_equal(const void *arg1, const void *arg2)
{
const struct bgp_pbr_action *r1, *r2;
@ -967,11 +963,12 @@ int bgp_pbr_action_hash_equal(const void *arg1, const void *arg2)
* rate is ignored
*/
if (r1->vrf_id != r2->vrf_id)
return 0;
return false;
if (memcmp(&r1->nh, &r2->nh, sizeof(struct nexthop)))
return 0;
return 1;
return false;
return true;
}
struct bgp_pbr_action *bgp_pbr_action_rule_lookup(vrf_id_t vrf_id,

View file

@ -267,13 +267,13 @@ extern void bgp_pbr_cleanup(struct bgp *bgp);
extern void bgp_pbr_init(struct bgp *bgp);
extern uint32_t bgp_pbr_action_hash_key(void *arg);
extern int bgp_pbr_action_hash_equal(const void *arg1,
extern bool bgp_pbr_action_hash_equal(const void *arg1,
const void *arg2);
extern uint32_t bgp_pbr_match_entry_hash_key(void *arg);
extern int bgp_pbr_match_entry_hash_equal(const void *arg1,
extern bool bgp_pbr_match_entry_hash_equal(const void *arg1,
const void *arg2);
extern uint32_t bgp_pbr_match_hash_key(void *arg);
extern int bgp_pbr_match_hash_equal(const void *arg1,
extern bool bgp_pbr_match_hash_equal(const void *arg1,
const void *arg2);
void bgp_pbr_print_policy_route(struct bgp_pbr_entry_main *api);

View file

@ -393,7 +393,7 @@ static unsigned int updgrp_hash_key_make(void *p)
return key;
}
static int updgrp_hash_cmp(const void *p1, const void *p2)
static bool updgrp_hash_cmp(const void *p1, const void *p2)
{
const struct update_group *grp1;
const struct update_group *grp2;
@ -407,7 +407,7 @@ static int updgrp_hash_cmp(const void *p1, const void *p2)
safi_t safi;
if (!p1 || !p2)
return 0;
return false;
grp1 = p1;
grp2 = p2;
@ -422,68 +422,68 @@ static int updgrp_hash_cmp(const void *p1, const void *p2)
/* put EBGP and IBGP peers in different update groups */
if (pe1->sort != pe2->sort)
return 0;
return false;
/* check peer flags */
if ((pe1->flags & PEER_UPDGRP_FLAGS)
!= (pe2->flags & PEER_UPDGRP_FLAGS))
return 0;
return false;
/* If there is 'local-as' configured, it should match. */
if (pe1->change_local_as != pe2->change_local_as)
return 0;
return false;
/* flags like route reflector client */
if ((flags1 & PEER_UPDGRP_AF_FLAGS) != (flags2 & PEER_UPDGRP_AF_FLAGS))
return 0;
return false;
if ((pe1->cap & PEER_UPDGRP_CAP_FLAGS)
!= (pe2->cap & PEER_UPDGRP_CAP_FLAGS))
return 0;
return false;
if ((pe1->af_cap[afi][safi] & PEER_UPDGRP_AF_CAP_FLAGS)
!= (pe2->af_cap[afi][safi] & PEER_UPDGRP_AF_CAP_FLAGS))
return 0;
return false;
if (pe1->v_routeadv != pe2->v_routeadv)
return 0;
return false;
if (pe1->group != pe2->group)
return 0;
return false;
/* route-map names should be the same */
if ((fl1->map[RMAP_OUT].name && !fl2->map[RMAP_OUT].name)
|| (!fl1->map[RMAP_OUT].name && fl2->map[RMAP_OUT].name)
|| (fl1->map[RMAP_OUT].name && fl2->map[RMAP_OUT].name
&& strcmp(fl1->map[RMAP_OUT].name, fl2->map[RMAP_OUT].name)))
return 0;
return false;
if ((fl1->dlist[FILTER_OUT].name && !fl2->dlist[FILTER_OUT].name)
|| (!fl1->dlist[FILTER_OUT].name && fl2->dlist[FILTER_OUT].name)
|| (fl1->dlist[FILTER_OUT].name && fl2->dlist[FILTER_OUT].name
&& strcmp(fl1->dlist[FILTER_OUT].name,
fl2->dlist[FILTER_OUT].name)))
return 0;
return false;
if ((fl1->plist[FILTER_OUT].name && !fl2->plist[FILTER_OUT].name)
|| (!fl1->plist[FILTER_OUT].name && fl2->plist[FILTER_OUT].name)
|| (fl1->plist[FILTER_OUT].name && fl2->plist[FILTER_OUT].name
&& strcmp(fl1->plist[FILTER_OUT].name,
fl2->plist[FILTER_OUT].name)))
return 0;
return false;
if ((fl1->aslist[FILTER_OUT].name && !fl2->aslist[FILTER_OUT].name)
|| (!fl1->aslist[FILTER_OUT].name && fl2->aslist[FILTER_OUT].name)
|| (fl1->aslist[FILTER_OUT].name && fl2->aslist[FILTER_OUT].name
&& strcmp(fl1->aslist[FILTER_OUT].name,
fl2->aslist[FILTER_OUT].name)))
return 0;
return false;
if ((fl1->usmap.name && !fl2->usmap.name)
|| (!fl1->usmap.name && fl2->usmap.name)
|| (fl1->usmap.name && fl2->usmap.name
&& strcmp(fl1->usmap.name, fl2->usmap.name)))
return 0;
return false;
if ((pe1->default_rmap[afi][safi].name
&& !pe2->default_rmap[afi][safi].name)
@ -493,19 +493,19 @@ static int updgrp_hash_cmp(const void *p1, const void *p2)
&& pe2->default_rmap[afi][safi].name
&& strcmp(pe1->default_rmap[afi][safi].name,
pe2->default_rmap[afi][safi].name)))
return 0;
return false;
if ((afi == AFI_IP6) && (pe1->shared_network != pe2->shared_network))
return 0;
return false;
if ((CHECK_FLAG(pe1->flags, PEER_FLAG_LONESOUL)
|| CHECK_FLAG(pe1->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
|| CHECK_FLAG(pe1->af_cap[afi][safi],
PEER_CAP_ORF_PREFIX_SM_OLD_RCV))
&& !sockunion_same(&pe1->su, &pe2->su))
return 0;
return false;
return 1;
return true;
}
static void peer_lonesoul_or_not(struct peer *peer, int set)

View file

@ -769,7 +769,7 @@ static unsigned int peer_hash_key_make(void *p)
return sockunion_hash(&peer->su);
}
static int peer_hash_same(const void *p1, const void *p2)
static bool peer_hash_same(const void *p1, const void *p2)
{
const struct peer *peer1 = p1;
const struct peer *peer2 = p2;

View file

@ -105,7 +105,7 @@ static unsigned neighbor_entry_hash_key(void *np)
return jhash(n->vertex->N.id, ISIS_SYS_ID_LEN, 0x55aa5a5a);
}
static int neighbor_entry_hash_cmp(const void *a, const void *b)
static bool neighbor_entry_hash_cmp(const void *a, const void *b)
{
const struct neighbor_entry *na = a, *nb = b;

View file

@ -95,16 +95,16 @@ static unsigned isis_vertex_queue_hash_key(void *vp)
}
__attribute__((__unused__))
static int isis_vertex_queue_hash_cmp(const void *a, const void *b)
static bool isis_vertex_queue_hash_cmp(const void *a, const void *b)
{
const struct isis_vertex *va = a, *vb = b;
if (va->type != vb->type)
return 0;
return false;
if (VTYPE_IP(va->type)) {
if (prefix_cmp(&va->N.ip.dest, &vb->N.ip.dest))
return 0;
return false;
return prefix_cmp((const struct prefix *)&va->N.ip.src,
(const struct prefix *)&vb->N.ip.src) == 0;

View file

@ -58,18 +58,18 @@ static unsigned tx_queue_hash_key(void *p)
return jhash_1word(e->lsp->level, id_key);
}
static int tx_queue_hash_cmp(const void *a, const void *b)
static bool tx_queue_hash_cmp(const void *a, const void *b)
{
const struct isis_tx_queue_entry *ea = a, *eb = b;
if (ea->lsp->level != eb->lsp->level)
return 0;
return false;
if (memcmp(ea->lsp->hdr.lsp_id, eb->lsp->hdr.lsp_id,
ISIS_SYS_ID_LEN + 2))
return 0;
return false;
return 1;
return true;
}
struct isis_tx_queue *isis_tx_queue_new(void *arg,

View file

@ -337,7 +337,7 @@ static unsigned int cmd_hash_key(void *p)
return jhash(p, size, 0);
}
static int cmd_hash_cmp(const void *a, const void *b)
static bool cmd_hash_cmp(const void *a, const void *b)
{
return a == b;
}

View file

@ -140,15 +140,15 @@ static unsigned int distribute_hash_make(void *arg)
/* If two distribute-list have same value then return 1 else return
0. This function is used by hash package. */
static int distribute_cmp(const struct distribute *dist1,
static bool distribute_cmp(const struct distribute *dist1,
const struct distribute *dist2)
{
if (dist1->ifname && dist2->ifname)
if (strcmp(dist1->ifname, dist2->ifname) == 0)
return 1;
return true;
if (!dist1->ifname && !dist2->ifname)
return 1;
return 0;
return true;
return false;
}
/* Set access-list name to the distribute list. */
@ -521,7 +521,7 @@ void distribute_list_init(int node)
{
disthash = hash_create(
distribute_hash_make,
(int (*)(const void *, const void *))distribute_cmp, NULL);
(bool (*)(const void *, const void *))distribute_cmp, NULL);
/* vtysh command-extraction doesn't grok install_element(node, ) */
if (node == RIP_NODE) {

View file

@ -64,7 +64,7 @@ static void err_key_fini(void)
pthread_mutex_t refs_mtx = PTHREAD_MUTEX_INITIALIZER;
struct hash *refs;
static int ferr_hash_cmp(const void *a, const void *b)
static bool ferr_hash_cmp(const void *a, const void *b)
{
const struct log_ref *f_a = a;
const struct log_ref *f_b = b;

View file

@ -38,7 +38,7 @@ static struct list *_hashes;
struct hash *hash_create_size(unsigned int size,
unsigned int (*hash_key)(void *),
int (*hash_cmp)(const void *, const void *),
bool (*hash_cmp)(const void *, const void *),
const char *name)
{
struct hash *hash;
@ -67,7 +67,7 @@ struct hash *hash_create_size(unsigned int size,
}
struct hash *hash_create(unsigned int (*hash_key)(void *),
int (*hash_cmp)(const void *, const void *),
bool (*hash_cmp)(const void *, const void *),
const char *name)
{
return hash_create_size(HASH_INITIAL_SIZE, hash_key, hash_cmp, name);

View file

@ -73,7 +73,7 @@ struct hash {
unsigned int (*hash_key)(void *);
/* Data compare function. */
int (*hash_cmp)(const void *, const void *);
bool (*hash_cmp)(const void *, const void *);
/* Backet alloc. */
unsigned long count;
@ -115,7 +115,7 @@ struct hash {
* a new hash table
*/
extern struct hash *hash_create(unsigned int (*hash_key)(void *),
int (*hash_cmp)(const void *, const void *),
bool (*hash_cmp)(const void *, const void *),
const char *name);
/*
@ -150,7 +150,8 @@ extern struct hash *hash_create(unsigned int (*hash_key)(void *),
*/
extern struct hash *
hash_create_size(unsigned int size, unsigned int (*hash_key)(void *),
int (*hash_cmp)(const void *, const void *), const char *name);
bool (*hash_cmp)(const void *, const void *),
const char *name);
/*
* Retrieve or insert data from / into a hash table.

View file

@ -117,7 +117,7 @@ static unsigned int if_rmap_hash_make(void *data)
return string_hash_make(if_rmap->ifname);
}
static int if_rmap_hash_cmp(const void *arg1, const void *arg2)
static bool if_rmap_hash_cmp(const void *arg1, const void *arg2)
{
const struct if_rmap *if_rmap1 = arg1;
const struct if_rmap *if_rmap2 = arg2;

View file

@ -36,7 +36,7 @@ static unsigned int qobj_key(void *data)
return (unsigned int)node->nid;
}
static int qobj_cmp(const void *a, const void *b)
static bool qobj_cmp(const void *a, const void *b)
{
const struct qobj_node *na = a, *nb = b;
return na->nid == nb->nid;

View file

@ -631,7 +631,7 @@ static unsigned int route_map_hash_key_make(void *p)
return string_hash_make(map->name);
}
static int route_map_hash_cmp(const void *p1, const void *p2)
static bool route_map_hash_cmp(const void *p1, const void *p2)
{
const struct route_map *map1 = p1;
const struct route_map *map2 = p2;
@ -639,14 +639,14 @@ static int route_map_hash_cmp(const void *p1, const void *p2)
if (map1->deleted == map2->deleted) {
if (map1->name && map2->name) {
if (!strcmp(map1->name, map2->name)) {
return 1;
return true;
}
} else if (!map1->name && !map2->name) {
return 1;
return true;
}
}
return 0;
return false;
}
enum route_map_upd8_type {
@ -676,7 +676,6 @@ struct route_map_dep {
struct hash *route_map_dep_hash[ROUTE_MAP_DEP_MAX];
static unsigned int route_map_dep_hash_make_key(void *p);
static int route_map_dep_hash_cmp(const void *p1, const void *p2);
static void route_map_clear_all_references(char *rmap_name);
static void route_map_rule_delete(struct route_map_rule_list *,
struct route_map_rule *);
@ -1624,12 +1623,12 @@ void route_map_event_hook(void (*func)(route_map_event_t, const char *))
}
/* Routines for route map dependency lists and dependency processing */
static int route_map_rmap_hash_cmp(const void *p1, const void *p2)
static bool route_map_rmap_hash_cmp(const void *p1, const void *p2)
{
return (strcmp((const char *)p1, (const char *)p2) == 0);
}
static int route_map_dep_hash_cmp(const void *p1, const void *p2)
static bool route_map_dep_hash_cmp(const void *p1, const void *p2)
{
return (strcmp(((const struct route_map_dep *)p1)->dep_name,

View file

@ -33,7 +33,7 @@ DEFINE_MTYPE(LIB, ROUTE_NODE, "Route node")
static void route_table_free(struct route_table *);
static int route_table_hash_cmp(const void *a, const void *b)
static bool route_table_hash_cmp(const void *a, const void *b)
{
const struct prefix *pa = a, *pb = b;
return prefix_cmp(pa, pb) == 0;

View file

@ -68,7 +68,7 @@ static unsigned int cpu_record_hash_key(struct cpu_thread_history *a)
return jhash(&a->func, size, 0);
}
static int cpu_record_hash_cmp(const struct cpu_thread_history *a,
static bool cpu_record_hash_cmp(const struct cpu_thread_history *a,
const struct cpu_thread_history *b)
{
return a->func == b->func;
@ -434,7 +434,7 @@ struct thread_master *thread_master_create(const char *name)
rv->cpu_record = hash_create_size(
8, (unsigned int (*)(void *))cpu_record_hash_key,
(int (*)(const void *, const void *))cpu_record_hash_cmp,
(bool (*)(const void *, const void *))cpu_record_hash_cmp,
"Thread Hash");

View file

@ -366,7 +366,7 @@ static unsigned int vrf_hash_bitmap_key(void *data)
return bit->vrf_id;
}
static int vrf_hash_bitmap_cmp(const void *a, const void *b)
static bool vrf_hash_bitmap_cmp(const void *a, const void *b)
{
const struct vrf_bit_set *bit1 = a;
const struct vrf_bit_set *bit2 = b;

View file

@ -36,10 +36,12 @@ static unsigned int nhrp_cache_protocol_key(void *peer_data)
return sockunion_hash(&p->remote_addr);
}
static int nhrp_cache_protocol_cmp(const void *cache_data, const void *key_data)
static bool nhrp_cache_protocol_cmp(const void *cache_data,
const void *key_data)
{
const struct nhrp_cache *a = cache_data;
const struct nhrp_cache *b = key_data;
return sockunion_same(&a->remote_addr, &b->remote_addr);
}

View file

@ -157,10 +157,11 @@ static unsigned int nhrp_peer_key(void *peer_data)
return sockunion_hash(&p->vc->remote.nbma);
}
static int nhrp_peer_cmp(const void *cache_data, const void *key_data)
static bool nhrp_peer_cmp(const void *cache_data, const void *key_data)
{
const struct nhrp_peer *a = cache_data;
const struct nhrp_peer *b = key_data;
return a->ifp == b->ifp && a->vc == b->vc;
}

View file

@ -35,10 +35,11 @@ static unsigned int nhrp_vc_key(void *peer_data)
sockunion_hash(&vc->remote.nbma), 0);
}
static int nhrp_vc_cmp(const void *cache_data, const void *key_data)
static bool nhrp_vc_cmp(const void *cache_data, const void *key_data)
{
const struct nhrp_vc *a = cache_data;
const struct nhrp_vc *b = key_data;
return sockunion_same(&a->local.nbma, &b->local.nbma)
&& sockunion_same(&a->remote.nbma, &b->remote.nbma);
}

View file

@ -8,9 +8,10 @@ static unsigned int nhrp_reqid_key(void *data)
return r->request_id;
}
static int nhrp_reqid_cmp(const void *data, const void *key)
static bool nhrp_reqid_cmp(const void *data, const void *key)
{
const struct nhrp_reqid *a = data, *b = key;
return a->request_id == b->request_id;
}

View file

@ -94,7 +94,7 @@ static unsigned int sr_hash(void *p)
}
/* Compare 2 Router ID hash entries based on SR Node */
static int sr_cmp(const void *p1, const void *p2)
static bool sr_cmp(const void *p1, const void *p2)
{
const struct sr_node *srn = p1;
const struct in_addr *rid = p2;

View file

@ -69,7 +69,7 @@ static void *pbr_nhrc_hash_alloc(void *p)
return nhrc;
}
static int pbr_nhrc_hash_equal(const void *arg1, const void *arg2)
static bool pbr_nhrc_hash_equal(const void *arg1, const void *arg2)
{
const struct nexthop *nh1, *nh2;
@ -139,7 +139,7 @@ static uint32_t pbr_nh_hash_key(void *arg)
return key;
}
static int pbr_nh_hash_equal(const void *arg1, const void *arg2)
static bool pbr_nh_hash_equal(const void *arg1, const void *arg2)
{
const struct pbr_nexthop_cache *pbrnc1 =
(const struct pbr_nexthop_cache *)arg1;
@ -147,25 +147,25 @@ static int pbr_nh_hash_equal(const void *arg1, const void *arg2)
(const struct pbr_nexthop_cache *)arg2;
if (pbrnc1->nexthop->vrf_id != pbrnc2->nexthop->vrf_id)
return 0;
return false;
if (pbrnc1->nexthop->ifindex != pbrnc2->nexthop->ifindex)
return 0;
return false;
if (pbrnc1->nexthop->type != pbrnc2->nexthop->type)
return 0;
return false;
switch (pbrnc1->nexthop->type) {
case NEXTHOP_TYPE_IFINDEX:
return 1;
return true;
case NEXTHOP_TYPE_IPV4_IFINDEX:
case NEXTHOP_TYPE_IPV4:
return pbrnc1->nexthop->gate.ipv4.s_addr
== pbrnc2->nexthop->gate.ipv4.s_addr;
case NEXTHOP_TYPE_IPV6_IFINDEX:
case NEXTHOP_TYPE_IPV6:
return !memcmp(&pbrnc1->nexthop->gate.ipv6,
&pbrnc2->nexthop->gate.ipv6, 16);
return !!memcmp(&pbrnc1->nexthop->gate.ipv6,
&pbrnc2->nexthop->gate.ipv6, 16);
case NEXTHOP_TYPE_BLACKHOLE:
return pbrnc1->nexthop->bh_type == pbrnc2->nexthop->bh_type;
}
@ -173,7 +173,7 @@ static int pbr_nh_hash_equal(const void *arg1, const void *arg2)
/*
* We should not get here
*/
return 0;
return false;
}
static void pbr_nhgc_delete(struct pbr_nexthop_group_cache *p)
@ -724,7 +724,7 @@ static uint32_t pbr_nhg_hash_key(void *arg)
return jhash(&nhgc->name, strlen(nhgc->name), 0x52c34a96);
}
static int pbr_nhg_hash_equal(const void *arg1, const void *arg2)
static bool pbr_nhg_hash_equal(const void *arg1, const void *arg2)
{
const struct pbr_nexthop_group_cache *nhgc1 =
(const struct pbr_nexthop_group_cache *)arg1;

View file

@ -836,15 +836,15 @@ static unsigned int igmp_group_hash_key(void *arg)
return jhash_1word(group->group_addr.s_addr, 0);
}
static int igmp_group_hash_equal(const void *arg1, const void *arg2)
static bool igmp_group_hash_equal(const void *arg1, const void *arg2)
{
const struct igmp_group *g1 = (const struct igmp_group *)arg1;
const struct igmp_group *g2 = (const struct igmp_group *)arg2;
if (g1->group_addr.s_addr == g2->group_addr.s_addr)
return 1;
return true;
return 0;
return false;
}
static struct igmp_sock *igmp_sock_new(int fd, struct in_addr ifaddr,

View file

@ -687,7 +687,7 @@ static unsigned int pim_msdp_sa_hash_key_make(void *p)
return (jhash_2words(sa->sg.src.s_addr, sa->sg.grp.s_addr, 0));
}
static int pim_msdp_sa_hash_eq(const void *p1, const void *p2)
static bool pim_msdp_sa_hash_eq(const void *p1, const void *p2)
{
const struct pim_msdp_sa *sa1 = p1;
const struct pim_msdp_sa *sa2 = p2;
@ -1221,7 +1221,7 @@ static unsigned int pim_msdp_peer_hash_key_make(void *p)
return (jhash_1word(mp->peer.s_addr, 0));
}
static int pim_msdp_peer_hash_eq(const void *p1, const void *p2)
static bool pim_msdp_peer_hash_eq(const void *p1, const void *p2)
{
const struct pim_msdp_peer *mp1 = p1;
const struct pim_msdp_peer *mp2 = p2;

View file

@ -79,16 +79,16 @@ static int pim_channel_oil_compare(struct channel_oil *c1,
return 0;
}
static int pim_oil_equal(const void *arg1, const void *arg2)
static bool pim_oil_equal(const void *arg1, const void *arg2)
{
const struct channel_oil *c1 = (const struct channel_oil *)arg1;
const struct channel_oil *c2 = (const struct channel_oil *)arg2;
if ((c1->oil.mfcc_mcastgrp.s_addr == c2->oil.mfcc_mcastgrp.s_addr)
&& (c1->oil.mfcc_origin.s_addr == c2->oil.mfcc_origin.s_addr))
return 1;
return true;
return 0;
return false;
}
static unsigned int pim_oil_hash_key(void *arg)

View file

@ -407,7 +407,7 @@ unsigned int pim_rpf_hash_key(void *arg)
return jhash_1word(r->rpf.rpf_addr.u.prefix4.s_addr, 0);
}
int pim_rpf_equal(const void *arg1, const void *arg2)
bool pim_rpf_equal(const void *arg1, const void *arg2)
{
const struct pim_nexthop_cache *r1 =
(const struct pim_nexthop_cache *)arg1;

View file

@ -57,7 +57,7 @@ enum pim_rpf_result { PIM_RPF_OK = 0, PIM_RPF_CHANGED, PIM_RPF_FAILURE };
struct pim_upstream;
unsigned int pim_rpf_hash_key(void *arg);
int pim_rpf_equal(const void *arg1, const void *arg2);
bool pim_rpf_equal(const void *arg1, const void *arg2);
int pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop,
struct in_addr addr, int neighbor_needed);

View file

@ -1554,16 +1554,16 @@ void pim_upstream_terminate(struct pim_instance *pim)
pim->upstream_sg_wheel = NULL;
}
int pim_upstream_equal(const void *arg1, const void *arg2)
bool pim_upstream_equal(const void *arg1, const void *arg2)
{
const struct pim_upstream *up1 = (const struct pim_upstream *)arg1;
const struct pim_upstream *up2 = (const struct pim_upstream *)arg2;
if ((up1->sg.grp.s_addr == up2->sg.grp.s_addr)
&& (up1->sg.src.s_addr == up2->sg.src.s_addr))
return 1;
return true;
return 0;
return false;
}
/* rfc4601:section-4.2:"Data Packet Forwarding Rules" defines

View file

@ -223,5 +223,5 @@ void pim_upstream_spt_prefix_list_update(struct pim_instance *pim,
struct prefix_list *pl);
unsigned int pim_upstream_hash_key(void *arg);
int pim_upstream_equal(const void *arg1, const void *arg2);
bool pim_upstream_equal(const void *arg1, const void *arg2);
#endif /* PIM_UPSTREAM_H */

View file

@ -234,13 +234,13 @@ static unsigned int static_nht_hash_key(void *data)
return jhash_1word(nhtd->nh_vrf_id, key);
}
static int static_nht_hash_cmp(const void *d1, const void *d2)
static bool static_nht_hash_cmp(const void *d1, const void *d2)
{
const struct static_nht_data *nhtd1 = d1;
const struct static_nht_data *nhtd2 = d2;
if (nhtd1->nh_vrf_id != nhtd2->nh_vrf_id)
return 0;
return false;
return prefix_same(nhtd1->nh, nhtd2->nh);
}

View file

@ -79,7 +79,7 @@ static zebra_fec_t *fec_add(struct route_table *table, struct prefix *p,
static int fec_del(zebra_fec_t *fec);
static unsigned int label_hash(void *p);
static int label_cmp(const void *p1, const void *p2);
static bool label_cmp(const void *p1, const void *p2);
static int nhlfe_nexthop_active_ipv4(zebra_nhlfe_t *nhlfe,
struct nexthop *nexthop);
static int nhlfe_nexthop_active_ipv6(zebra_nhlfe_t *nhlfe,
@ -592,7 +592,7 @@ static unsigned int label_hash(void *p)
/*
* Compare 2 LSP hash entries based on in-label.
*/
static int label_cmp(const void *p1, const void *p2)
static bool label_cmp(const void *p1, const void *p2)
{
const zebra_ile_t *ile1 = p1;
const zebra_ile_t *ile2 = p2;

View file

@ -164,7 +164,7 @@ uint32_t zebra_pbr_rules_hash_key(void *arg)
jhash_1word(rule->rule.unique, key));
}
int zebra_pbr_rules_hash_equal(const void *arg1, const void *arg2)
bool zebra_pbr_rules_hash_equal(const void *arg1, const void *arg2)
{
const struct zebra_pbr_rule *r1, *r2;
@ -172,36 +172,36 @@ int zebra_pbr_rules_hash_equal(const void *arg1, const void *arg2)
r2 = (const struct zebra_pbr_rule *)arg2;
if (r1->rule.seq != r2->rule.seq)
return 0;
return false;
if (r1->rule.priority != r2->rule.priority)
return 0;
return false;
if (r1->rule.unique != r2->rule.unique)
return 0;
return false;
if (r1->rule.action.table != r2->rule.action.table)
return 0;
return false;
if (r1->rule.filter.src_port != r2->rule.filter.src_port)
return 0;
return false;
if (r1->rule.filter.dst_port != r2->rule.filter.dst_port)
return 0;
return false;
if (r1->rule.filter.fwmark != r2->rule.filter.fwmark)
return 0;
return false;
if (!prefix_same(&r1->rule.filter.src_ip, &r2->rule.filter.src_ip))
return 0;
return false;
if (!prefix_same(&r1->rule.filter.dst_ip, &r2->rule.filter.dst_ip))
return 0;
return false;
if (r1->ifp != r2->ifp)
return 0;
return false;
return 1;
return true;
}
struct pbr_rule_unique_lookup {
@ -260,7 +260,7 @@ uint32_t zebra_pbr_ipset_hash_key(void *arg)
return jhash2(pnt, ZEBRA_IPSET_NAME_HASH_SIZE, 0x63ab42de);
}
int zebra_pbr_ipset_hash_equal(const void *arg1, const void *arg2)
bool zebra_pbr_ipset_hash_equal(const void *arg1, const void *arg2)
{
const struct zebra_pbr_ipset *r1, *r2;
@ -268,13 +268,13 @@ int zebra_pbr_ipset_hash_equal(const void *arg1, const void *arg2)
r2 = (const struct zebra_pbr_ipset *)arg2;
if (r1->type != r2->type)
return 0;
return false;
if (r1->unique != r2->unique)
return 0;
return false;
if (strncmp(r1->ipset_name, r2->ipset_name,
ZEBRA_IPSET_NAME_SIZE))
return 0;
return 1;
return false;
return true;
}
void zebra_pbr_ipset_entry_free(void *arg)
@ -313,7 +313,7 @@ uint32_t zebra_pbr_ipset_entry_hash_key(void *arg)
return key;
}
int zebra_pbr_ipset_entry_hash_equal(const void *arg1, const void *arg2)
bool zebra_pbr_ipset_entry_hash_equal(const void *arg1, const void *arg2)
{
const struct zebra_pbr_ipset_entry *r1, *r2;
@ -321,29 +321,29 @@ int zebra_pbr_ipset_entry_hash_equal(const void *arg1, const void *arg2)
r2 = (const struct zebra_pbr_ipset_entry *)arg2;
if (r1->unique != r2->unique)
return 0;
return false;
if (!prefix_same(&r1->src, &r2->src))
return 0;
return false;
if (!prefix_same(&r1->dst, &r2->dst))
return 0;
return false;
if (r1->src_port_min != r2->src_port_min)
return 0;
return false;
if (r1->src_port_max != r2->src_port_max)
return 0;
return false;
if (r1->dst_port_min != r2->dst_port_min)
return 0;
return false;
if (r1->dst_port_max != r2->dst_port_max)
return 0;
return false;
if (r1->proto != r2->proto)
return 0;
return 1;
return false;
return true;
}
void zebra_pbr_iptable_free(void *arg)
@ -389,7 +389,7 @@ uint32_t zebra_pbr_iptable_hash_key(void *arg)
iptable->unique, key);
}
int zebra_pbr_iptable_hash_equal(const void *arg1, const void *arg2)
bool zebra_pbr_iptable_hash_equal(const void *arg1, const void *arg2)
{
const struct zebra_pbr_iptable *r1, *r2;
@ -397,31 +397,31 @@ int zebra_pbr_iptable_hash_equal(const void *arg1, const void *arg2)
r2 = (const struct zebra_pbr_iptable *)arg2;
if (r1->type != r2->type)
return 0;
return false;
if (r1->unique != r2->unique)
return 0;
return false;
if (r1->filter_bm != r2->filter_bm)
return 0;
return false;
if (r1->fwmark != r2->fwmark)
return 0;
return false;
if (r1->action != r2->action)
return 0;
return false;
if (strncmp(r1->ipset_name, r2->ipset_name,
ZEBRA_IPSET_NAME_SIZE))
return 0;
return false;
if (r1->pkt_len_min != r2->pkt_len_min)
return 0;
return false;
if (r1->pkt_len_max != r2->pkt_len_max)
return 0;
return false;
if (r1->tcp_flags != r2->tcp_flags)
return 0;
return false;
if (r1->tcp_mask_flags != r2->tcp_mask_flags)
return 0;
return false;
if (r1->dscp_value != r2->dscp_value)
return 0;
return false;
if (r1->fragment != r2->fragment)
return 0;
return 1;
return false;
return true;
}
static void *pbr_rule_alloc_intern(void *arg)

View file

@ -213,7 +213,7 @@ extern int kernel_pbr_rule_del(struct zebra_pbr_rule *rule);
extern void zebra_pbr_rules_free(void *arg);
extern uint32_t zebra_pbr_rules_hash_key(void *arg);
extern int zebra_pbr_rules_hash_equal(const void *arg1, const void *arg2);
extern bool zebra_pbr_rules_hash_equal(const void *arg1, const void *arg2);
/* has operates on 32bit pointer
* and field is a string of 8bit
@ -222,15 +222,16 @@ extern int zebra_pbr_rules_hash_equal(const void *arg1, const void *arg2);
extern void zebra_pbr_ipset_free(void *arg);
extern uint32_t zebra_pbr_ipset_hash_key(void *arg);
extern int zebra_pbr_ipset_hash_equal(const void *arg1, const void *arg2);
extern bool zebra_pbr_ipset_hash_equal(const void *arg1, const void *arg2);
extern void zebra_pbr_ipset_entry_free(void *arg);
extern uint32_t zebra_pbr_ipset_entry_hash_key(void *arg);
extern int zebra_pbr_ipset_entry_hash_equal(const void *arg1, const void *arg2);
extern bool zebra_pbr_ipset_entry_hash_equal(const void *arg1,
const void *arg2);
extern void zebra_pbr_iptable_free(void *arg);
extern uint32_t zebra_pbr_iptable_hash_key(void *arg);
extern int zebra_pbr_iptable_hash_equal(const void *arg1, const void *arg2);
extern bool zebra_pbr_iptable_hash_equal(const void *arg1, const void *arg2);
extern void zebra_pbr_init(void);
extern void zebra_pbr_show_ipset_list(struct vty *vty, char *ipsetname);

View file

@ -81,7 +81,6 @@ static int zvni_macip_send_msg_to_client(vni_t vni, struct ethaddr *macaddr,
struct ipaddr *ip, uint8_t flags,
uint32_t seq, uint16_t cmd);
static unsigned int neigh_hash_keymake(void *p);
static int neigh_cmp(const void *p1, const void *p2);
static void *zvni_neigh_alloc(void *p);
static zebra_neigh_t *zvni_neigh_add(zebra_vni_t *zvni, struct ipaddr *ip,
struct ethaddr *mac);
@ -137,7 +136,7 @@ static void zebra_vxlan_process_l3vni_oper_up(zebra_l3vni_t *zl3vni);
static void zebra_vxlan_process_l3vni_oper_down(zebra_l3vni_t *zl3vni);
static unsigned int mac_hash_keymake(void *p);
static int mac_cmp(const void *p1, const void *p2);
static bool mac_cmp(const void *p1, const void *p2);
static void *zvni_mac_alloc(void *p);
static zebra_mac_t *zvni_mac_add(zebra_vni_t *zvni, struct ethaddr *macaddr);
static int zvni_mac_del(zebra_vni_t *zvni, zebra_mac_t *mac);
@ -157,7 +156,6 @@ static int zvni_mac_uninstall(zebra_vni_t *zvni, zebra_mac_t *mac);
static void zvni_install_mac_hash(struct hash_backet *backet, void *ctxt);
static unsigned int vni_hash_keymake(void *p);
static int vni_hash_cmp(const void *p1, const void *p2);
static void *zvni_alloc(void *p);
static zebra_vni_t *zvni_lookup(vni_t vni);
static zebra_vni_t *zvni_add(vni_t vni);
@ -1254,16 +1252,16 @@ static unsigned int neigh_hash_keymake(void *p)
/*
* Compare two neighbor hash structures.
*/
static int neigh_cmp(const void *p1, const void *p2)
static bool neigh_cmp(const void *p1, const void *p2)
{
const zebra_neigh_t *n1 = p1;
const zebra_neigh_t *n2 = p2;
if (n1 == NULL && n2 == NULL)
return 1;
return true;
if (n1 == NULL || n2 == NULL)
return 0;
return false;
return (memcmp(&n1->ip, &n2->ip, sizeof(struct ipaddr)) == 0);
}
@ -2240,16 +2238,16 @@ static unsigned int mac_hash_keymake(void *p)
/*
* Compare two MAC addresses.
*/
static int mac_cmp(const void *p1, const void *p2)
static bool mac_cmp(const void *p1, const void *p2)
{
const zebra_mac_t *pmac1 = p1;
const zebra_mac_t *pmac2 = p2;
if (pmac1 == NULL && pmac2 == NULL)
return 1;
return true;
if (pmac1 == NULL || pmac2 == NULL)
return 0;
return false;
return (memcmp(pmac1->macaddr.octet, pmac2->macaddr.octet, ETH_ALEN)
== 0);
@ -2761,7 +2759,7 @@ static unsigned int vni_hash_keymake(void *p)
/*
* Compare 2 VNI hash entries.
*/
static int vni_hash_cmp(const void *p1, const void *p2)
static bool vni_hash_cmp(const void *p1, const void *p2)
{
const zebra_vni_t *zvni1 = p1;
const zebra_vni_t *zvni2 = p2;
@ -3619,7 +3617,7 @@ static unsigned int l3vni_hash_keymake(void *p)
/*
* Compare 2 L3 VNI hash entries.
*/
static int l3vni_hash_cmp(const void *p1, const void *p2)
static bool l3vni_hash_cmp(const void *p1, const void *p2)
{
const zebra_l3vni_t *zl3vni1 = p1;
const zebra_l3vni_t *zl3vni2 = p2;