diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2022-01-04 21:48:13 +0100 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2022-01-17 14:03:26 +0100 |
commit | 2a27f13b2197d07d11454b6cc8d0e5fc5b6ded87 (patch) | |
tree | 0e3e3f4f21943f7b960b11e474216dc3a3c36b77 /pimd/pim_ifchannel.c | |
parent | pimd: remove pim_str_sg_dump() (diff) | |
download | frr-2a27f13b2197d07d11454b6cc8d0e5fc5b6ded87.tar.xz frr-2a27f13b2197d07d11454b6cc8d0e5fc5b6ded87.zip |
pimd: move, rename and deploy pim_addr_is_any()
Replaces comparison against INADDR_ANY, so we can do IPv6 too.
(Renamed from "pim_is_addr_any" for "pim_addr_*" naming pattern, and
type fixed to bool.)
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'pimd/pim_ifchannel.c')
-rw-r--r-- | pimd/pim_ifchannel.c | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c index dba1a10cc..d7011cabf 100644 --- a/pimd/pim_ifchannel.c +++ b/pimd/pim_ifchannel.c @@ -107,18 +107,16 @@ static void pim_ifchannel_find_new_children(struct pim_ifchannel *ch) struct pim_ifchannel *child; // Basic Sanity that we are not being silly - if ((ch->sg.src.s_addr != INADDR_ANY) - && (ch->sg.grp.s_addr != INADDR_ANY)) + if (!pim_addr_is_any(ch->sg.src) && !pim_addr_is_any(ch->sg.grp)) return; - if ((ch->sg.src.s_addr == INADDR_ANY) - && (ch->sg.grp.s_addr == INADDR_ANY)) + if (pim_addr_is_any(ch->sg.src) && pim_addr_is_any(ch->sg.grp)) return; RB_FOREACH (child, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) { - if ((ch->sg.grp.s_addr != INADDR_ANY) - && (child->sg.grp.s_addr == ch->sg.grp.s_addr) - && (child != ch)) { + if (!pim_addr_is_any(ch->sg.grp) && + (child->sg.grp.s_addr == ch->sg.grp.s_addr) && + (child != ch)) { child->parent = ch; listnode_add_sort(ch->sources, child); } @@ -162,9 +160,9 @@ void pim_ifchannel_delete(struct pim_ifchannel *ch) * being inherited. So let's figure out what * needs to be done here */ - if ((ch->sg.src.s_addr != INADDR_ANY) && - pim_upstream_evaluate_join_desired_interface( - ch->upstream, ch, ch->parent)) + if (!pim_addr_is_any(ch->sg.src) && + pim_upstream_evaluate_join_desired_interface( + ch->upstream, ch, ch->parent)) pim_channel_add_oif(ch->upstream->channel_oil, ch->interface, PIM_OIF_FLAG_PROTO_STAR, @@ -293,7 +291,7 @@ void pim_ifchannel_ifjoin_switch(const char *caller, struct pim_ifchannel *ch, ch->ifjoin_state = new_state; - if (ch->sg.src.s_addr == INADDR_ANY) { + if (pim_addr_is_any(ch->sg.src)) { struct pim_upstream *up = ch->upstream; struct pim_upstream *child; struct listnode *up_node; @@ -527,8 +525,8 @@ static struct pim_ifchannel *pim_ifchannel_find_parent(struct pim_ifchannel *ch) struct pim_ifchannel *parent = NULL; // (S,G) - if ((parent_sg.src.s_addr != INADDR_ANY) - && (parent_sg.grp.s_addr != INADDR_ANY)) { + if (!pim_addr_is_any(parent_sg.src) && + !pim_addr_is_any(parent_sg.grp)) { parent_sg.src.s_addr = INADDR_ANY; parent = pim_ifchannel_find(ch->interface, &parent_sg); @@ -576,7 +574,7 @@ struct pim_ifchannel *pim_ifchannel_add(struct interface *ifp, pim_sgaddr *sg, ch->sg = *sg; snprintfrr(ch->sg_str, sizeof(ch->sg_str), "%pSG", sg); ch->parent = pim_ifchannel_find_parent(ch); - if (ch->sg.src.s_addr == INADDR_ANY) { + if (pim_addr_is_any(ch->sg.src)) { ch->sources = list_new(); ch->sources->cmp = (int (*)(void *, void *))pim_ifchannel_compare; @@ -992,8 +990,8 @@ void pim_ifchannel_join_add(struct interface *ifp, struct in_addr neigh_addr, THREAD_OFF(ch->t_ifjoin_prune_pending_timer); /* Check if SGRpt join Received */ - if ((source_flags & PIM_ENCODE_RPT_BIT) - && (sg->src.s_addr != INADDR_ANY)) { + if ((source_flags & PIM_ENCODE_RPT_BIT) && + !pim_addr_is_any(sg->src)) { /* * Transitions from Prune-Pending State (Rcv SGRpt Join) * RFC 7761 Sec 4.5.3: @@ -1194,7 +1192,7 @@ int pim_ifchannel_local_membership_add(struct interface *ifp, pim_sgaddr *sg, pim = pim_ifp->pim; /* skip (*,G) ch creation if G is of type SSM */ - if (sg->src.s_addr == INADDR_ANY) { + if (pim_addr_is_any(sg->src)) { if (pim_is_grp_ssm(pim, sg->grp)) { if (PIM_DEBUG_PIM_EVENTS) zlog_debug("%s: local membership (S,G)=%pSG ignored as group is SSM", @@ -1212,7 +1210,7 @@ int pim_ifchannel_local_membership_add(struct interface *ifp, pim_sgaddr *sg, ifmembership_set(ch, PIM_IFMEMBERSHIP_INCLUDE); - if (sg->src.s_addr == INADDR_ANY) { + if (pim_addr_is_any(sg->src)) { struct pim_upstream *up = pim_upstream_find(pim, sg); struct pim_upstream *child; struct listnode *up_node; @@ -1288,7 +1286,7 @@ void pim_ifchannel_local_membership_del(struct interface *ifp, pim_sgaddr *sg) return; ifmembership_set(ch, PIM_IFMEMBERSHIP_NOINFO); - if (sg->src.s_addr == INADDR_ANY) { + if (pim_addr_is_any(sg->src)) { struct pim_upstream *up = pim_upstream_find(pim_ifp->pim, sg); struct pim_upstream *child; struct listnode *up_node, *up_nnode; |