FreeBSD/sys/netinet6/in6_mcast.c
/*
 * 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 memory
 * with the trade-off that the source will not be reported to the
 * router if joined in the window between the query response and
 * the group actually being joined on the local host.
 *
 * VIMAGE: XXX: Currently the mld_sgalloc feature has been removed.
 * This turns off the allocation of a recorded source entry if
 * the group has not been joined.
 *
 * Return 0 if the source didn't exist or was already marked as recorded.
 * Return 1 if the source was marked as recorded by this function.
 * Return <0 if any error occurred (negated errno code).
 */
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 memory
with the trade-off that the source will not be reported to the
router if joined in the window between the query response and
the group actually being joined on the local host.

Currently the mld_sgalloc feature has been removed.
This turns off the allocation of a recorded source entry if
the group has not been joined.

Return 0 if the source didn't exist or was already marked as recorded.
Return 1 if the source was marked as recorded by this function.
Return <0 if any error occurred (negated errno code).
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 memory with the trade - off that the source will not be reported to the router if joined in the window between the query response and the group actually being joined on the local host . Currently the mld_sgalloc feature has been removed . This turns off the allocation of a recorded source entry if the group has not been joined . Return 0 if the source didn ' t exist or was already marked as recorded . Return 1 if the source was marked as recorded by this function . Return <0 if any error occurred ( negated errno code ) .
int
in6m_record_source(struct in6_multi *inm, const struct in6_addr *addr)
{
	struct ip6_msource	 find;
	struct ip6_msource	*ims, *nims;
	IN6_MULTI_LOCK_ASSERT();
	find.im6s_addr = *addr;
	ims = RB_FIND(ip6_msource_tree, &inm->in6m_srcs, &find);
	if (ims && ims->im6s_stp)
		return (0);
	if (ims == NULL) {
		if (inm->in6m_nsrc == in6_mcast_maxgrpsrc)
			return (-ENOSPC);
		nims = malloc(sizeof(struct ip6_msource), M_IP6MSOURCE,
		    M_NOWAIT | M_ZERO);
		if (nims == NULL)
			return (-ENOMEM);
		nims->im6s_addr = find.im6s_addr;
		RB_INSERT(ip6_msource_tree, &inm->in6m_srcs, nims);
		++inm->in6m_nsrc;
		ims = nims;
	}
	++ims->im6s_stp;
	++inm->in6m_st[1].iss_rec;
	return (1);
}
int in6m_record_source ( struct in6_multi * inm , const struct in6_addr * addr ) { struct ip6_msource find ; struct ip6_msource * ims , * nims ; IN6_MULTI_LOCK_ASSERT ( ) ; find . im6s_addr = * addr ; ims = RB_FIND ( ip6_msource_tree , & inm -> in6m_srcs , & find ) ; if ( ims && ims -> im6s_stp ) return ( 0 ) ; if ( ims == NULL ) { if ( inm -> in6m_nsrc == in6_mcast_maxgrpsrc ) return ( - ENOSPC ) ; nims = malloc ( sizeof ( struct ip6_msource ) , M_IP6MSOURCE , M_NOWAIT | M_ZERO ) ; if ( nims == NULL ) return ( - ENOMEM ) ; nims -> im6s_addr = find . im6s_addr ; RB_INSERT ( ip6_msource_tree , & inm -> in6m_srcs , nims ) ; ++ inm -> in6m_nsrc ; ims = nims ; } ++ ims -> im6s_stp ; ++ inm -> in6m_st [ 1 ] . iss_rec ; return ( 1 ) ; }
Record a source as pending for a Source-Group MLDv2 query.
Record a source as pending for a Source - Group MLDv2 query .
/*
	 * Mark the source as recorded and update the recorded
	 * source count.
	 */