* 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
| 665 | * Return <0 if any error occurred (negated errno code). |
| 666 | */ |
| 667 | int |
| 668 | in6m_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, |
no test coverage detected