diff options
Diffstat (limited to 'pimd/pim_igmp.c')
| -rw-r--r-- | pimd/pim_igmp.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/pimd/pim_igmp.c b/pimd/pim_igmp.c index 8d39d7e800..851b00b2ac 100644 --- a/pimd/pim_igmp.c +++ b/pimd/pim_igmp.c @@ -753,6 +753,39 @@ static void igmp_group_free(struct igmp_group *group) XFREE(MTYPE_PIM_IGMP_GROUP, group); } +static void igmp_group_count_incr(struct igmp_sock *igmp) +{ + struct pim_interface *pim_ifp = igmp->interface->info; + + if (!pim_ifp) + return; + + ++pim_ifp->pim->igmp_group_count; + if (pim_ifp->pim->igmp_group_count + == pim_ifp->pim->igmp_watermark_limit) { + zlog_warn( + "IGMP group count reached watermark limit: %u(vrf: %s)", + pim_ifp->pim->igmp_group_count, + VRF_LOGNAME(pim_ifp->pim->vrf)); + } +} + +static void igmp_group_count_decr(struct igmp_sock *igmp) +{ + struct pim_interface *pim_ifp = igmp->interface->info; + + if (!pim_ifp) + return; + + if (pim_ifp->pim->igmp_group_count == 0) { + zlog_warn("Cannot decrement igmp group count below 0(vrf: %s)", + VRF_LOGNAME(pim_ifp->pim->vrf)); + return; + } + + --pim_ifp->pim->igmp_group_count; +} + void igmp_group_delete(struct igmp_group *group) { struct listnode *src_node; @@ -778,6 +811,7 @@ void igmp_group_delete(struct igmp_group *group) } group_timer_off(group); + igmp_group_count_decr(group->group_igmp_sock); listnode_delete(group->group_igmp_sock->igmp_group_list, group); hash_release(group->group_igmp_sock->igmp_group_hash, group); @@ -879,7 +913,7 @@ static struct igmp_sock *igmp_sock_new(int fd, struct in_addr ifaddr, igmp->igmp_group_list = list_new(); igmp->igmp_group_list->del = (void (*)(void *))igmp_group_free; - snprintf(hash_name, 64, "IGMP %s hash", ifp->name); + snprintf(hash_name, sizeof(hash_name), "IGMP %s hash", ifp->name); igmp->igmp_group_hash = hash_create(igmp_group_hash_key, igmp_group_hash_equal, hash_name); @@ -1158,6 +1192,8 @@ struct igmp_group *igmp_add_group_by_addr(struct igmp_sock *igmp, group_str, igmp->fd, igmp->interface->name); } + igmp_group_count_incr(igmp); + /* RFC 3376: 6.2.2. Definition of Group Timers |
