mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-06 16:20:08 +00:00
pimd: move & deploy pim_addr_cmp() helper
Comparing `s_addr` isn't cutting it for IPv6 support. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
parent
2a27f13b21
commit
032a741219
@ -41,6 +41,11 @@ static inline bool pim_addr_is_any(pim_addr addr)
|
||||
return memcmp(&addr, &zero, sizeof(zero)) == 0;
|
||||
}
|
||||
|
||||
static inline int pim_addr_cmp(pim_addr a, pim_addr b)
|
||||
{
|
||||
return memcmp(&a, &b, sizeof(a));
|
||||
}
|
||||
|
||||
/* don't use this struct directly, use the pim_sgaddr typedef */
|
||||
struct _pim_sgaddr {
|
||||
pim_addr grp;
|
||||
|
@ -5932,11 +5932,11 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty,
|
||||
if (!c_oil->installed)
|
||||
continue;
|
||||
|
||||
if (sg->grp.s_addr != INADDR_ANY
|
||||
&& sg->grp.s_addr != c_oil->oil.mfcc_mcastgrp.s_addr)
|
||||
if (!pim_addr_is_any(sg->grp) &&
|
||||
pim_addr_cmp(sg->grp, c_oil->oil.mfcc_mcastgrp))
|
||||
continue;
|
||||
if (sg->src.s_addr != INADDR_ANY
|
||||
&& sg->src.s_addr != c_oil->oil.mfcc_origin.s_addr)
|
||||
if (!pim_addr_is_any(sg->src) &&
|
||||
pim_addr_cmp(sg->src, c_oil->oil.mfcc_origin))
|
||||
continue;
|
||||
|
||||
pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, grp_str,
|
||||
@ -10493,8 +10493,8 @@ static void pim_show_vxlan_sg_entry(struct pim_vxlan_sg *vxlan_sg,
|
||||
else
|
||||
oif_name = vxlan_sg->term_oif?vxlan_sg->term_oif->name:"";
|
||||
|
||||
if (cwd->addr_match && (vxlan_sg->sg.src.s_addr != cwd->addr.s_addr) &&
|
||||
(vxlan_sg->sg.grp.s_addr != cwd->addr.s_addr)) {
|
||||
if (cwd->addr_match && pim_addr_cmp(vxlan_sg->sg.src, cwd->addr) &&
|
||||
pim_addr_cmp(vxlan_sg->sg.grp, cwd->addr)) {
|
||||
return;
|
||||
}
|
||||
pim_inet4_dump("<src?>", vxlan_sg->sg.src, src_str, sizeof(src_str));
|
||||
|
@ -115,8 +115,7 @@ static void pim_ifchannel_find_new_children(struct pim_ifchannel *ch)
|
||||
|
||||
RB_FOREACH (child, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) {
|
||||
if (!pim_addr_is_any(ch->sg.grp) &&
|
||||
(child->sg.grp.s_addr == ch->sg.grp.s_addr) &&
|
||||
(child != ch)) {
|
||||
!pim_addr_cmp(child->sg.grp, ch->sg.grp) && (child != ch)) {
|
||||
child->parent = ch;
|
||||
listnode_add_sort(ch->sources, child);
|
||||
}
|
||||
|
@ -80,13 +80,7 @@ static int pim_jp_agg_src_cmp(void *arg1, void *arg2)
|
||||
if (!js1->is_join && js2->is_join)
|
||||
return 1;
|
||||
|
||||
if ((uint32_t)js1->up->sg.src.s_addr < (uint32_t)js2->up->sg.src.s_addr)
|
||||
return -1;
|
||||
|
||||
if ((uint32_t)js1->up->sg.src.s_addr > (uint32_t)js2->up->sg.src.s_addr)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
return pim_addr_cmp(js1->up->sg.src, js2->up->sg.src);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -156,7 +150,7 @@ void pim_jp_agg_remove_group(struct list *group, struct pim_upstream *up,
|
||||
struct pim_jp_sources *js = NULL;
|
||||
|
||||
for (ALL_LIST_ELEMENTS(group, node, nnode, jag)) {
|
||||
if (jag->group.s_addr == up->sg.grp.s_addr)
|
||||
if (!pim_addr_cmp(jag->group, up->sg.grp))
|
||||
break;
|
||||
}
|
||||
|
||||
@ -202,7 +196,7 @@ int pim_jp_agg_is_in_list(struct list *group, struct pim_upstream *up)
|
||||
struct pim_jp_sources *js = NULL;
|
||||
|
||||
for (ALL_LIST_ELEMENTS(group, node, nnode, jag)) {
|
||||
if (jag->group.s_addr == up->sg.grp.s_addr)
|
||||
if (!pim_addr_cmp(jag->group, up->sg.grp))
|
||||
break;
|
||||
}
|
||||
|
||||
@ -276,7 +270,7 @@ void pim_jp_agg_add_group(struct list *group, struct pim_upstream *up,
|
||||
struct pim_jp_sources *js = NULL;
|
||||
|
||||
for (ALL_LIST_ELEMENTS(group, node, nnode, jag)) {
|
||||
if (jag->group.s_addr == up->sg.grp.s_addr)
|
||||
if (!pim_addr_cmp(jag->group, up->sg.grp))
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -632,7 +632,7 @@ void pim_msdp_up_join_state_changed(struct pim_instance *pim,
|
||||
/* XXX: Need to maintain SAs per-group to avoid all this unnecessary
|
||||
* walking */
|
||||
for (ALL_LIST_ELEMENTS_RO(pim->msdp.sa_list, sanode, sa)) {
|
||||
if (sa->sg.grp.s_addr != xg_up->sg.grp.s_addr) {
|
||||
if (pim_addr_cmp(sa->sg.grp, xg_up->sg.grp)) {
|
||||
continue;
|
||||
}
|
||||
pim_msdp_sa_upstream_update(sa, xg_up, "up-jp-change");
|
||||
@ -656,7 +656,7 @@ static void pim_msdp_up_xg_del(struct pim_instance *pim, pim_sgaddr *sg)
|
||||
/* XXX: Need to maintain SAs per-group to avoid all this unnecessary
|
||||
* walking */
|
||||
for (ALL_LIST_ELEMENTS_RO(pim->msdp.sa_list, sanode, sa)) {
|
||||
if (sa->sg.grp.s_addr != sg->grp.s_addr) {
|
||||
if (pim_addr_cmp(sa->sg.grp, sg->grp)) {
|
||||
continue;
|
||||
}
|
||||
pim_msdp_sa_upstream_update(sa, NULL /* xg */, "up-jp-change");
|
||||
|
@ -44,11 +44,6 @@ static inline void pim_addr_copy(pim_addr *dest, pim_addr *source)
|
||||
dest->s_addr = source->s_addr;
|
||||
}
|
||||
|
||||
static inline int pim_addr_cmp(pim_addr addr1, pim_addr addr2)
|
||||
{
|
||||
return IPV4_ADDR_CMP(&addr1, &addr2);
|
||||
}
|
||||
|
||||
void pim_addr_dump(const char *onfail, struct prefix *p, char *buf,
|
||||
int buf_size);
|
||||
void pim_inet4_dump(const char *onfail, struct in_addr addr, char *buf,
|
||||
|
@ -109,8 +109,7 @@ static void pim_upstream_find_new_children(struct pim_instance *pim,
|
||||
|
||||
frr_each (rb_pim_upstream, &pim->upstream_head, child) {
|
||||
if (!pim_addr_is_any(up->sg.grp) &&
|
||||
(child->sg.grp.s_addr == up->sg.grp.s_addr) &&
|
||||
(child != up)) {
|
||||
!pim_addr_cmp(child->sg.grp, up->sg.grp) && (child != up)) {
|
||||
child->parent = up;
|
||||
listnode_add_sort(up->sources, child);
|
||||
if (PIM_UPSTREAM_FLAG_TEST_USE_RPT(child->flags))
|
||||
|
Loading…
Reference in New Issue
Block a user