MCPcopy Create free account
hub / github.com/F-Stack/f-stack / in6m_record_source

Function in6m_record_source

freebsd/netinet6/in6_mcast.c:667–700  ·  view source on GitHub ↗

* Record a source as pending for a Source-Group MLDv2 query. * This lives here as it modifies the shared tree. * * inm is the group descriptor. * naddr is the address of the source to record in network-byte order. * * If the net.inet6.mld.sgalloc sysctl is non-zero, we will * lazy-allocate a source node in response to an SG query. * Otherwise, no allocation is performed. This saves some me

Source from the content-addressed store, hash-verified

665 * Return <0 if any error occurred (negated errno code).
666 */
667int
668in6m_record_source(struct in6_multi *inm, const struct in6_addr *addr)
669{
670 struct ip6_msource find;
671 struct ip6_msource *ims, *nims;
672
673 IN6_MULTI_LIST_LOCK_ASSERT();
674
675 find.im6s_addr = *addr;
676 ims = RB_FIND(ip6_msource_tree, &inm->in6m_srcs, &find);
677 if (ims && ims->im6s_stp)
678 return (0);
679 if (ims == NULL) {
680 if (inm->in6m_nsrc == in6_mcast_maxgrpsrc)
681 return (-ENOSPC);
682 nims = malloc(sizeof(struct ip6_msource), M_IP6MSOURCE,
683 M_NOWAIT | M_ZERO);
684 if (nims == NULL)
685 return (-ENOMEM);
686 nims->im6s_addr = find.im6s_addr;
687 RB_INSERT(ip6_msource_tree, &inm->in6m_srcs, nims);
688 ++inm->in6m_nsrc;
689 ims = nims;
690 }
691
692 /*
693 * Mark the source as recorded and update the recorded
694 * source count.
695 */
696 ++ims->im6s_stp;
697 ++inm->in6m_st[1].iss_rec;
698
699 return (1);
700}
701
702/*
703 * Return a pointer to an in6_msource owned by an in6_mfilter,

Callers 1

Calls 1

mallocFunction · 0.85

Tested by

no test coverage detected