Changeset View
Standalone View
sys/netinet6/in6.c
Show First 20 Lines • Show All 2,608 Lines • ▼ Show 20 Lines | in6_sin_2_v4mapsin6_in_sock(struct sockaddr **nam) | ||||||||||||||||||
struct sockaddr_in6 *sin6_p; | struct sockaddr_in6 *sin6_p; | ||||||||||||||||||
sin6_p = malloc(sizeof *sin6_p, M_SONAME, M_WAITOK); | sin6_p = malloc(sizeof *sin6_p, M_SONAME, M_WAITOK); | ||||||||||||||||||
sin_p = (struct sockaddr_in *)*nam; | sin_p = (struct sockaddr_in *)*nam; | ||||||||||||||||||
in6_sin_2_v4mapsin6(sin_p, sin6_p); | in6_sin_2_v4mapsin6(sin_p, sin6_p); | ||||||||||||||||||
free(*nam, M_SONAME); | free(*nam, M_SONAME); | ||||||||||||||||||
*nam = (struct sockaddr *)sin6_p; | *nam = (struct sockaddr *)sin6_p; | ||||||||||||||||||
} | } | ||||||||||||||||||
/* | |||||||||||||||||||
* Join/leave the solicited multicast groups for proxy NDP entries. | |||||||||||||||||||
melifaro: I'd prefer using existing bits&pieces that we have instead of introducing another layer of… | |||||||||||||||||||
Done Inline Actions
I have submitted D35323 to prepare for adding the member. Could you review it?
I'll try to change the code as you proposed. takahiro.kurosawa_gmail.com: > I'd suggest doing the following:
> * mark lltable (for example, by introducing special… | |||||||||||||||||||
Done Inline ActionsI've added lltable_flags_free() for purging LLEs on if_detach case. If I miss the point, let me know. takahiro.kurosawa_gmail.com: I've added lltable_flags_free() for purging LLEs on if_detach case. If I miss the point, let… | |||||||||||||||||||
*/ | |||||||||||||||||||
static struct mtx pndp_mc_list_mtx; | |||||||||||||||||||
MTX_SYSINIT(pndp_mc_list_mtx, &pndp_mc_list_mtx, "pndp_mc_listmtx", MTX_DEF); | |||||||||||||||||||
#define PNDP_MC_LIST_LOCK() mtx_lock(&pndp_mc_list_mtx) | |||||||||||||||||||
#define PNDP_MC_LIST_UNLOCK() mtx_unlock(&pndp_mc_list_mtx) | |||||||||||||||||||
static LIST_HEAD(in6_pndp_mc_list, in6_multi_mship) pndp_mc_list; | |||||||||||||||||||
static void in6_pndp_mc_list_add(struct in6_multi_mship *imm); | |||||||||||||||||||
static void in6_pndp_mc_list_delete(struct in6_multi *inm); | |||||||||||||||||||
void | |||||||||||||||||||
in6_handle_proxy_ndp_mc(int cmd, struct ifnet *ifp, const struct sockaddr *nam) | |||||||||||||||||||
Lint: Possible Spelling Mistake Possible spelling error. You wrote 'nam', but did you mean 'name'? Lint: Possible Spelling Mistake: Possible spelling error. You wrote 'nam', but did you mean 'name'? | |||||||||||||||||||
{ | |||||||||||||||||||
const struct sockaddr_in6 *sin6; | |||||||||||||||||||
struct in6_multi_mship *imm; | |||||||||||||||||||
struct in6_multi *inm; | |||||||||||||||||||
struct in6_addr mltaddr; | |||||||||||||||||||
struct epoch_tracker et; | |||||||||||||||||||
char ip6buf[INET6_ADDRSTRLEN]; | |||||||||||||||||||
int error; | |||||||||||||||||||
Not Done Inline ActionsProbably worth splitting add&delete use cases to the separation functions as they don't share anything except 1 line (in6_solicited_node_maddr). melifaro: Probably worth splitting add&delete use cases to the separation functions as they don't share… | |||||||||||||||||||
Done Inline ActionsApplied, thanks! takahiro.kurosawa_gmail.com: Applied, thanks! | |||||||||||||||||||
sin6 = (const struct sockaddr_in6 *)nam; | |||||||||||||||||||
Lint: Possible Spelling Mistake Possible spelling error. You wrote 'nam', but did you mean 'name'? Lint: Possible Spelling Mistake: Possible spelling error. You wrote 'nam', but did you mean 'name'? | |||||||||||||||||||
bzero(&mltaddr, sizeof(struct in6_addr)); | |||||||||||||||||||
mltaddr.s6_addr32[0] = IPV6_ADDR_INT32_MLL; | |||||||||||||||||||
mltaddr.s6_addr32[2] = htonl(1); | |||||||||||||||||||
mltaddr.s6_addr32[3] = sin6->sin6_addr.s6_addr32[3]; | |||||||||||||||||||
mltaddr.s6_addr8[12] = 0xff; | |||||||||||||||||||
if ((error = in6_setscope(&mltaddr, ifp, NULL)) != 0) { | |||||||||||||||||||
nd6log((LOG_ERR, "%s: in6_setscope failed\n", __func__)); | |||||||||||||||||||
return; | |||||||||||||||||||
} | |||||||||||||||||||
if (cmd == RTM_ADD) { | |||||||||||||||||||
imm = in6_joingroup_legacy(ifp, &mltaddr, &error, 0); | |||||||||||||||||||
if (imm != NULL) | |||||||||||||||||||
in6_pndp_mc_list_add(imm); | |||||||||||||||||||
else { | |||||||||||||||||||
nd6log((LOG_WARNING, | |||||||||||||||||||
"%s: in6_joingroup_legacy failed for %s on %s " | |||||||||||||||||||
"(errno=%d)\n", __func__, | |||||||||||||||||||
ip6_sprintf(ip6buf, &mltaddr), if_name(ifp), | |||||||||||||||||||
error)); | |||||||||||||||||||
return; | |||||||||||||||||||
Not Done Inline ActionsCould you factor out this code from in6_update_ifa_join_mc() into a separate function, which can be used both here and in in6_update_ifa_join_mc() so we don't duplicate the logic? melifaro: Could you factor out this code from `in6_update_ifa_join_mc()` into a separate function, which… | |||||||||||||||||||
Done Inline ActionsI've added in6_solicited_node_maddr() for factoring out the common part. takahiro.kurosawa_gmail.com: I've added in6_solicited_node_maddr() for factoring out the common part. | |||||||||||||||||||
} | |||||||||||||||||||
} else { | |||||||||||||||||||
NET_EPOCH_ENTER(et); | |||||||||||||||||||
inm = in6m_lookup(ifp, &mltaddr); | |||||||||||||||||||
NET_EPOCH_EXIT(et); | |||||||||||||||||||
if (inm != NULL) { | |||||||||||||||||||
in6_pndp_mc_list_delete(inm); | |||||||||||||||||||
in6_leavegroup(inm, NULL); | |||||||||||||||||||
} else { | |||||||||||||||||||
nd6log((LOG_WARNING, | |||||||||||||||||||
"%s: in6_lookup failed for %s on %s\n", | |||||||||||||||||||
__func__, ip6_sprintf(ip6buf, &mltaddr), | |||||||||||||||||||
if_name(ifp))); | |||||||||||||||||||
} | |||||||||||||||||||
} | |||||||||||||||||||
} | |||||||||||||||||||
void | |||||||||||||||||||
in6_purge_proxy_ndp_mc(struct ifnet *ifp) | |||||||||||||||||||
{ | |||||||||||||||||||
struct in6_pndp_mc_list removed; | |||||||||||||||||||
struct in6_multi_mship *imm; | |||||||||||||||||||
LIST_INIT(&removed); | |||||||||||||||||||
PNDP_MC_LIST_LOCK(); | |||||||||||||||||||
LIST_FOREACH(imm, &pndp_mc_list, i6mm_chain) { | |||||||||||||||||||
Not Done Inline Actions
Nit: probably be a bit simpler. melifaro: Nit: probably be a bit simpler. | |||||||||||||||||||
Done Inline ActionsApplied. takahiro.kurosawa_gmail.com: Applied. | |||||||||||||||||||
if (imm->i6mm_maddr->in6m_ifp == ifp) { | |||||||||||||||||||
LIST_REMOVE(imm, i6mm_chain); | |||||||||||||||||||
LIST_INSERT_HEAD(&removed, imm, i6mm_chain); | |||||||||||||||||||
} | |||||||||||||||||||
} | |||||||||||||||||||
PNDP_MC_LIST_UNLOCK(); | |||||||||||||||||||
while ((imm = LIST_FIRST(&removed)) != NULL) { | |||||||||||||||||||
LIST_REMOVE(imm, i6mm_chain); | |||||||||||||||||||
in6_leavegroup(imm->i6mm_maddr, NULL); | |||||||||||||||||||
free(imm, M_IP6MADDR); | |||||||||||||||||||
} | |||||||||||||||||||
} | |||||||||||||||||||
static void | |||||||||||||||||||
in6_pndp_mc_list_add(struct in6_multi_mship *imm) | |||||||||||||||||||
{ | |||||||||||||||||||
PNDP_MC_LIST_LOCK(); | |||||||||||||||||||
LIST_INSERT_HEAD(&pndp_mc_list, imm, i6mm_chain); | |||||||||||||||||||
PNDP_MC_LIST_UNLOCK(); | |||||||||||||||||||
} | |||||||||||||||||||
static void | |||||||||||||||||||
in6_pndp_mc_list_delete(struct in6_multi *inm) | |||||||||||||||||||
{ | |||||||||||||||||||
struct in6_multi_mship *imm; | |||||||||||||||||||
PNDP_MC_LIST_LOCK(); | |||||||||||||||||||
LIST_FOREACH(imm, &pndp_mc_list, i6mm_chain) { | |||||||||||||||||||
if (imm->i6mm_maddr == inm) { | |||||||||||||||||||
LIST_REMOVE(imm, i6mm_chain); | |||||||||||||||||||
break; | |||||||||||||||||||
} | |||||||||||||||||||
} | |||||||||||||||||||
PNDP_MC_LIST_UNLOCK(); | |||||||||||||||||||
if (imm != NULL) | |||||||||||||||||||
free(imm, M_IP6MADDR); | |||||||||||||||||||
else | |||||||||||||||||||
nd6log((LOG_WARNING, | |||||||||||||||||||
"in6_multi %p not found on proxy ndp list.\n", inm)); | |||||||||||||||||||
} |
I'd prefer using existing bits&pieces that we have instead of introducing another layer of locking.
I'd suggest doing the following: