pimd: Re-align pim_msg_get_jp_group_size

This function was/is heavily indented, let's refactor
this a bit.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2024-01-12 12:00:45 -05:00
parent 8006207a92
commit 413c0ebe5b

View file

@ -185,14 +185,15 @@ size_t pim_msg_get_jp_group_size(struct list *sources)
size += sizeof(pim_encoded_source) * sources->count; size += sizeof(pim_encoded_source) * sources->count;
js = listgetdata(listhead(sources)); js = listgetdata(listhead(sources));
if (js && pim_addr_is_any(js->up->sg.src) && js->is_join) { if (!js || !pim_addr_is_any(js->up->sg.src) || !js->is_join)
return size;
struct pim_upstream *child, *up; struct pim_upstream *child, *up;
struct listnode *up_node; struct listnode *up_node;
up = js->up; up = js->up;
if (PIM_DEBUG_PIM_PACKETS) if (PIM_DEBUG_PIM_PACKETS)
zlog_debug( zlog_debug("%s: Considering (%s) children for (S,G,rpt) prune",
"%s: Considering (%s) children for (S,G,rpt) prune",
__func__, up->sg_str); __func__, up->sg_str);
for (ALL_LIST_ELEMENTS_RO(up->sources, up_node, child)) { for (ALL_LIST_ELEMENTS_RO(up->sources, up_node, child)) {
@ -230,39 +231,32 @@ size_t pim_msg_get_jp_group_size(struct list *sources)
* same IIF as RPF_interface(RP). * same IIF as RPF_interface(RP).
*/ */
if (child->rpf.source_nexthop.interface && if (child->rpf.source_nexthop.interface &&
!pim_rpf_is_same(&up->rpf, !pim_rpf_is_same(&up->rpf, &child->rpf)) {
&child->rpf)) {
size += sizeof(pim_encoded_source); size += sizeof(pim_encoded_source);
PIM_UPSTREAM_FLAG_SET_SEND_SG_RPT_PRUNE( PIM_UPSTREAM_FLAG_SET_SEND_SG_RPT_PRUNE(
child->flags); child->flags);
if (PIM_DEBUG_PIM_PACKETS) if (PIM_DEBUG_PIM_PACKETS)
zlog_debug( zlog_debug("%s: SPT Bit and RPF'(%s) != RPF'(S,G): Add Prune (%s,rpt) to compound message",
"%s: SPT Bit and RPF'(%s) != RPF'(S,G): Add Prune (%s,rpt) to compound message",
__func__, up->sg_str, __func__, up->sg_str,
child->sg_str); child->sg_str);
} else if (PIM_DEBUG_PIM_PACKETS) } else if (PIM_DEBUG_PIM_PACKETS)
zlog_debug( zlog_debug("%s: SPT Bit and RPF'(%s) == RPF'(S,G): Not adding Prune for (%s,rpt)",
"%s: SPT Bit and RPF'(%s) == RPF'(S,G): Not adding Prune for (%s,rpt)", __func__, up->sg_str, child->sg_str);
__func__, up->sg_str,
child->sg_str);
} else if (pim_upstream_empty_inherited_olist(child)) { } else if (pim_upstream_empty_inherited_olist(child)) {
/* S is supposed to be forwarded along the RPT /* S is supposed to be forwarded along the RPT
* but it's inherited OIL is empty. So just * but it's inherited OIL is empty. So just
* prune it off. * prune it off.
*/ */
size += sizeof(pim_encoded_source); size += sizeof(pim_encoded_source);
PIM_UPSTREAM_FLAG_SET_SEND_SG_RPT_PRUNE( PIM_UPSTREAM_FLAG_SET_SEND_SG_RPT_PRUNE(child->flags);
child->flags);
if (PIM_DEBUG_PIM_PACKETS) if (PIM_DEBUG_PIM_PACKETS)
zlog_debug( zlog_debug("%s: inherited_olist(%s,rpt) is NULL, Add Prune to compound message",
"%s: inherited_olist(%s,rpt) is NULL, Add Prune to compound message",
__func__, child->sg_str); __func__, child->sg_str);
} else if (PIM_DEBUG_PIM_PACKETS) } else if (PIM_DEBUG_PIM_PACKETS)
zlog_debug( zlog_debug("%s: Do not add Prune %s to compound message %s",
"%s: Do not add Prune %s to compound message %s",
__func__, child->sg_str, up->sg_str); __func__, child->sg_str, up->sg_str);
} }
}
return size; return size;
} }