summaryrefslogtreecommitdiffstats
path: root/zebra
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2018-10-17 21:27:12 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2018-10-19 19:14:45 +0200
commit74df8d6d9d665784b0273151fe04cd2f9ff5b353 (patch)
tree7b0d38ba7c6e9605634d40a64c4b904295d59d80 /zebra
parent*: Fixup to use proper list_cmp functions (diff)
downloadfrr-74df8d6d9d665784b0273151fe04cd2f9ff5b353.tar.xz
frr-74df8d6d9d665784b0273151fe04cd2f9ff5b353.zip
*: 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>
Diffstat (limited to 'zebra')
-rw-r--r--zebra/zebra_mpls.c4
-rw-r--r--zebra/zebra_pbr.c82
-rw-r--r--zebra/zebra_pbr.h9
-rw-r--r--zebra/zebra_vxlan.c20
4 files changed, 57 insertions, 58 deletions
diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c
index 0ccd3242d..5fe011615 100644
--- a/zebra/zebra_mpls.c
+++ b/zebra/zebra_mpls.c
@@ -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;
diff --git a/zebra/zebra_pbr.c b/zebra/zebra_pbr.c
index 40f97765d..1a528780c 100644
--- a/zebra/zebra_pbr.c
+++ b/zebra/zebra_pbr.c
@@ -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)
diff --git a/zebra/zebra_pbr.h b/zebra/zebra_pbr.h
index 3311af4d2..093fcfa8b 100644
--- a/zebra/zebra_pbr.h
+++ b/zebra/zebra_pbr.h
@@ -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);
diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c
index ab0b175cc..fe182780b 100644
--- a/zebra/zebra_vxlan.c
+++ b/zebra/zebra_vxlan.c
@@ -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;