Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet6/in6_mcast.c
Show First 20 Lines • Show All 1,264 Lines • ▼ Show 20 Lines | #endif | ||||
*/ | */ | ||||
KASSERT(IN6_IS_ADDR_MULTICAST(mcaddr), | KASSERT(IN6_IS_ADDR_MULTICAST(mcaddr), | ||||
("%s: not a multicast address", __func__)); | ("%s: not a multicast address", __func__)); | ||||
if (IN6_IS_ADDR_MC_LINKLOCAL(mcaddr) || | if (IN6_IS_ADDR_MC_LINKLOCAL(mcaddr) || | ||||
IN6_IS_ADDR_MC_INTFACELOCAL(mcaddr)) { | IN6_IS_ADDR_MC_INTFACELOCAL(mcaddr)) { | ||||
KASSERT(mcaddr->s6_addr16[1] != 0, | KASSERT(mcaddr->s6_addr16[1] != 0, | ||||
("%s: scope zone ID not set", __func__)); | ("%s: scope zone ID not set", __func__)); | ||||
} | } | ||||
IN6_MULTI_LOCK_ASSERT(); | IN6_MULTI_LOCK_ASSERT(); | ||||
IN6_MULTI_LIST_UNLOCK_ASSERT(); | IN6_MULTI_LIST_UNLOCK_ASSERT(); | ||||
CTR4(KTR_MLD, "%s: join %s on %p(%s))", __func__, | CTR4(KTR_MLD, "%s: join %s on %p(%s))", __func__, | ||||
ip6_sprintf(ip6tbuf, mcaddr), ifp, if_name(ifp)); | ip6_sprintf(ip6tbuf, mcaddr), ifp, if_name(ifp)); | ||||
error = 0; | error = 0; | ||||
inm = NULL; | inm = NULL; | ||||
▲ Show 20 Lines • Show All 1,570 Lines • ▼ Show 20 Lines | #endif | ||||
memcpy(&mcaddr, &name[1], sizeof(struct in6_addr)); | memcpy(&mcaddr, &name[1], sizeof(struct in6_addr)); | ||||
if (!IN6_IS_ADDR_MULTICAST(&mcaddr)) { | if (!IN6_IS_ADDR_MULTICAST(&mcaddr)) { | ||||
CTR2(KTR_MLD, "%s: group %s is not multicast", | CTR2(KTR_MLD, "%s: group %s is not multicast", | ||||
__func__, ip6_sprintf(ip6tbuf, &mcaddr)); | __func__, ip6_sprintf(ip6tbuf, &mcaddr)); | ||||
return (EINVAL); | return (EINVAL); | ||||
} | } | ||||
NET_EPOCH_ENTER(et); | |||||
ifp = ifnet_byindex(ifindex); | ifp = ifnet_byindex(ifindex); | ||||
if (ifp == NULL) { | if (ifp == NULL) { | ||||
NET_EPOCH_EXIT(et); | |||||
CTR2(KTR_MLD, "%s: no ifp for ifindex %u", | CTR2(KTR_MLD, "%s: no ifp for ifindex %u", | ||||
__func__, ifindex); | __func__, ifindex); | ||||
return (ENOENT); | return (ENOENT); | ||||
} | } | ||||
/* | /* | ||||
* Internal MLD lookups require that scope/zone ID is set. | * Internal MLD lookups require that scope/zone ID is set. | ||||
*/ | */ | ||||
(void)in6_setscope(&mcaddr, ifp, NULL); | (void)in6_setscope(&mcaddr, ifp, NULL); | ||||
retval = sysctl_wire_old_buffer(req, | retval = sysctl_wire_old_buffer(req, | ||||
sizeof(uint32_t) + (in6_mcast_maxgrpsrc * sizeof(struct in6_addr))); | sizeof(uint32_t) + (in6_mcast_maxgrpsrc * sizeof(struct in6_addr))); | ||||
if (retval) | if (retval) { | ||||
NET_EPOCH_EXIT(et); | |||||
return (retval); | return (retval); | ||||
} | |||||
IN6_MULTI_LOCK(); | IN6_MULTI_LOCK(); | ||||
IN6_MULTI_LIST_LOCK(); | IN6_MULTI_LIST_LOCK(); | ||||
NET_EPOCH_ENTER(et); | |||||
CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { | CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { | ||||
inm = in6m_ifmultiaddr_get_inm(ifma); | inm = in6m_ifmultiaddr_get_inm(ifma); | ||||
if (inm == NULL) | if (inm == NULL) | ||||
continue; | continue; | ||||
if (!IN6_ARE_ADDR_EQUAL(&inm->in6m_addr, &mcaddr)) | if (!IN6_ARE_ADDR_EQUAL(&inm->in6m_addr, &mcaddr)) | ||||
continue; | continue; | ||||
fmode = inm->in6m_st[1].iss_fmode; | fmode = inm->in6m_st[1].iss_fmode; | ||||
retval = SYSCTL_OUT(req, &fmode, sizeof(uint32_t)); | retval = SYSCTL_OUT(req, &fmode, sizeof(uint32_t)); | ||||
Show All 11 Lines | RB_FOREACH(ims, ip6_msource_tree, &inm->in6m_srcs) { | ||||
} | } | ||||
src = ims->im6s_addr; | src = ims->im6s_addr; | ||||
retval = SYSCTL_OUT(req, &src, | retval = SYSCTL_OUT(req, &src, | ||||
sizeof(struct in6_addr)); | sizeof(struct in6_addr)); | ||||
if (retval != 0) | if (retval != 0) | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
NET_EPOCH_EXIT(et); | |||||
IN6_MULTI_LIST_UNLOCK(); | IN6_MULTI_LIST_UNLOCK(); | ||||
IN6_MULTI_UNLOCK(); | IN6_MULTI_UNLOCK(); | ||||
NET_EPOCH_EXIT(et); | |||||
return (retval); | return (retval); | ||||
} | } | ||||
#ifdef KTR | #ifdef KTR | ||||
static const char *in6m_modestrs[] = { "un", "in", "ex" }; | static const char *in6m_modestrs[] = { "un", "in", "ex" }; | ||||
▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines |