diff options
| author | David Lamparter <equinox@opensourcerouting.org> | 2018-10-23 12:31:25 +0200 |
|---|---|---|
| committer | David Lamparter <equinox@opensourcerouting.org> | 2018-10-23 12:31:25 +0200 |
| commit | 064518517c57024e65e177ee79c0a98f9f28ef6e (patch) | |
| tree | dcc1d14ad647a210ef2d93da4fe827d9337ada4b /zebra/zebra_vxlan.c | |
| parent | 920b243c1b154476ab9a629ac002817ead5a1efa (diff) | |
| parent | d17743d390757c170bad6a776de43d1809afe3c3 (diff) | |
Merge branch 'pull/3197'
...with a nit fix
Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'zebra/zebra_vxlan.c')
| -rw-r--r-- | zebra/zebra_vxlan.c | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index 5078eff590..fe182780be 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,20 +1252,28 @@ 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); } +static int neigh_list_cmp(void *p1, void *p2) +{ + const zebra_neigh_t *n1 = p1; + const zebra_neigh_t *n2 = p2; + + return memcmp(&n1->ip, &n2->ip, sizeof(struct ipaddr)); +} + /* * Callback to allocate neighbor hash entry. */ @@ -2232,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); @@ -2275,7 +2281,7 @@ static zebra_mac_t *zvni_mac_add(zebra_vni_t *zvni, struct ethaddr *macaddr) assert(mac); mac->neigh_list = list_new(); - mac->neigh_list->cmp = (int (*)(void *, void *))neigh_cmp; + mac->neigh_list->cmp = neigh_list_cmp; return mac; } @@ -2753,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; @@ -2761,6 +2767,16 @@ static int vni_hash_cmp(const void *p1, const void *p2) return (zvni1->vni == zvni2->vni); } +static int vni_list_cmp(void *p1, void *p2) +{ + const zebra_vni_t *zvni1 = p1; + const zebra_vni_t *zvni2 = p2; + + if (zvni1->vni == zvni2->vni) + return 0; + return (zvni1->vni < zvni2->vni) ? -1 : 1; +} + /* * Callback to allocate VNI hash entry. */ @@ -3601,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; @@ -3662,7 +3678,7 @@ static zebra_l3vni_t *zl3vni_add(vni_t vni, vrf_id_t vrf_id) zl3vni->svi_if = NULL; zl3vni->vxlan_if = NULL; zl3vni->l2vnis = list_new(); - zl3vni->l2vnis->cmp = (int (*)(void *, void *))vni_hash_cmp; + zl3vni->l2vnis->cmp = vni_list_cmp; /* Create hash table for remote RMAC */ zl3vni->rmac_table = hash_create(mac_hash_keymake, mac_cmp, |
