Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet6/nd6_nbr.c
Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | |||||
static void nd6_dad_ns_output(struct dadq *); | static void nd6_dad_ns_output(struct dadq *); | ||||
static void nd6_dad_ns_input(struct ifaddr *, struct nd_opt_nonce *); | static void nd6_dad_ns_input(struct ifaddr *, struct nd_opt_nonce *); | ||||
static void nd6_dad_na_input(struct ifaddr *); | static void nd6_dad_na_input(struct ifaddr *); | ||||
static void nd6_na_output_fib(struct ifnet *, const struct in6_addr *, | static void nd6_na_output_fib(struct ifnet *, const struct in6_addr *, | ||||
const struct in6_addr *, u_long, int, struct sockaddr *, u_int); | const struct in6_addr *, u_long, int, struct sockaddr *, u_int); | ||||
static void nd6_ns_output_fib(struct ifnet *, const struct in6_addr *, | static void nd6_ns_output_fib(struct ifnet *, const struct in6_addr *, | ||||
const struct in6_addr *, const struct in6_addr *, uint8_t *, u_int); | const struct in6_addr *, const struct in6_addr *, uint8_t *, u_int); | ||||
static struct ifaddr *nd6_proxy_fill_sdl(struct ifnet *, | |||||
const struct in6_addr *, struct sockaddr_dl *); | |||||
VNET_DEFINE_STATIC(int, dad_enhanced) = 1; | VNET_DEFINE_STATIC(int, dad_enhanced) = 1; | ||||
#define V_dad_enhanced VNET(dad_enhanced) | #define V_dad_enhanced VNET(dad_enhanced) | ||||
SYSCTL_DECL(_net_inet6_ip6); | SYSCTL_DECL(_net_inet6_ip6); | ||||
SYSCTL_INT(_net_inet6_ip6, OID_AUTO, dad_enhanced, CTLFLAG_VNET | CTLFLAG_RW, | SYSCTL_INT(_net_inet6_ip6, OID_AUTO, dad_enhanced, CTLFLAG_VNET | CTLFLAG_RW, | ||||
&VNET_NAME(dad_enhanced), 0, | &VNET_NAME(dad_enhanced), 0, | ||||
"Enable Enhanced DAD, which adds a random nonce to NS messages for DAD."); | "Enable Enhanced DAD, which adds a random nonce to NS messages for DAD."); | ||||
▲ Show 20 Lines • Show All 142 Lines • ▼ Show 20 Lines | nd6_ns_input(struct mbuf *m, int off, int icmp6len) | ||||
/* (1) and (3) check. */ | /* (1) and (3) check. */ | ||||
if (ifp->if_carp) | if (ifp->if_carp) | ||||
ifa = (*carp_iamatch6_p)(ifp, &taddr6); | ifa = (*carp_iamatch6_p)(ifp, &taddr6); | ||||
else | else | ||||
ifa = (struct ifaddr *)in6ifa_ifpwithaddr(ifp, &taddr6); | ifa = (struct ifaddr *)in6ifa_ifpwithaddr(ifp, &taddr6); | ||||
/* (2) check. */ | /* (2) check. */ | ||||
proxy = 0; | proxy = 0; | ||||
if (ifa == NULL) { | if (ifa == NULL) { | ||||
struct sockaddr_dl rt_gateway; | if ((ifa = nd6_proxy_fill_sdl(ifp, &taddr6, &proxydl)) != NULL) | ||||
melifaro: Nit: worth considering moving it out as a separate function? like, `fill_proxyndp(struct infect… | |||||
Done Inline ActionsApplied, readability gets improved indeed. takahiro.kurosawa_gmail.com: Applied, readability gets improved indeed. | |||||
struct rt_addrinfo info; | |||||
struct sockaddr_in6 dst6; | |||||
bzero(&dst6, sizeof(dst6)); | |||||
dst6.sin6_len = sizeof(struct sockaddr_in6); | |||||
dst6.sin6_family = AF_INET6; | |||||
dst6.sin6_addr = taddr6; | |||||
bzero(&rt_gateway, sizeof(rt_gateway)); | |||||
rt_gateway.sdl_len = sizeof(rt_gateway); | |||||
bzero(&info, sizeof(info)); | |||||
info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&rt_gateway; | |||||
if (rib_lookup_info(ifp->if_fib, (struct sockaddr *)&dst6, | |||||
0, 0, &info) == 0) { | |||||
if ((info.rti_flags & RTF_ANNOUNCE) != 0 && | |||||
rt_gateway.sdl_family == AF_LINK) { | |||||
/* | |||||
* proxy NDP for single entry | |||||
*/ | |||||
proxydl = *SDL(&rt_gateway); | |||||
ifa = (struct ifaddr *)in6ifa_ifpforlinklocal( | |||||
ifp, IN6_IFF_NOTREADY|IN6_IFF_ANYCAST); | |||||
if (ifa) | |||||
proxy = 1; | proxy = 1; | ||||
} | } | ||||
} | |||||
} | |||||
if (ifa == NULL) { | if (ifa == NULL) { | ||||
/* | /* | ||||
* We've got an NS packet, and we don't have that adddress | * We've got an NS packet, and we don't have that adddress | ||||
* assigned for us. We MUST silently ignore it. | * assigned for us. We MUST silently ignore it. | ||||
* See RFC2461 7.2.3. | * See RFC2461 7.2.3. | ||||
*/ | */ | ||||
Not Done Inline ActionsNit: no need to check LLE_STATIC and LLE_IFADDR here. melifaro: Nit: no need to check `LLE_STATIC` and `LLE_IFADDR` here. | |||||
Done Inline ActionsFixed. Thanks! takahiro.kurosawa_gmail.com: Fixed. Thanks! | |||||
goto freeit; | goto freeit; | ||||
} | } | ||||
myaddr6 = *IFA_IN6(ifa); | myaddr6 = *IFA_IN6(ifa); | ||||
anycast = ((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_ANYCAST; | anycast = ((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_ANYCAST; | ||||
tentative = ((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_TENTATIVE; | tentative = ((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_TENTATIVE; | ||||
if (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_DUPLICATED) | if (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_DUPLICATED) | ||||
goto freeit; | goto freeit; | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | nd6log((LOG_ERR, "nd6_ns_input: dst=%s\n", | ||||
ip6_sprintf(ip6bufs, &daddr6))); | ip6_sprintf(ip6bufs, &daddr6))); | ||||
nd6log((LOG_ERR, "nd6_ns_input: tgt=%s\n", | nd6log((LOG_ERR, "nd6_ns_input: tgt=%s\n", | ||||
ip6_sprintf(ip6bufs, &taddr6))); | ip6_sprintf(ip6bufs, &taddr6))); | ||||
bads: | bads: | ||||
ICMP6STAT_INC(icp6s_badns); | ICMP6STAT_INC(icp6s_badns); | ||||
if (ifa != NULL) | if (ifa != NULL) | ||||
ifa_free(ifa); | ifa_free(ifa); | ||||
m_freem(m); | m_freem(m); | ||||
} | |||||
static struct ifaddr * | |||||
nd6_proxy_fill_sdl(struct ifnet *ifp, const struct in6_addr *taddr6, | |||||
struct sockaddr_dl *sdl) | |||||
{ | |||||
struct ifaddr *ifa; | |||||
struct llentry *ln; | |||||
ifa = NULL; | |||||
ln = nd6_lookup(taddr6, LLE_SF(AF_INET6, 0), ifp); | |||||
if (ln == NULL) | |||||
return (ifa); | |||||
if ((ln->la_flags & (LLE_PUB | LLE_VALID)) == (LLE_PUB | LLE_VALID)) { | |||||
link_init_sdl(ifp, (struct sockaddr *)sdl, ifp->if_type); | |||||
sdl->sdl_alen = ifp->if_addrlen; | |||||
bcopy(ln->ll_addr, &sdl->sdl_data, ifp->if_addrlen); | |||||
LLE_RUNLOCK(ln); | |||||
ifa = (struct ifaddr *)in6ifa_ifpforlinklocal(ifp, | |||||
IN6_IFF_NOTREADY|IN6_IFF_ANYCAST); | |||||
} else | |||||
LLE_RUNLOCK(ln); | |||||
return (ifa); | |||||
} | } | ||||
/* | /* | ||||
* Output a Neighbor Solicitation Message. Caller specifies: | * Output a Neighbor Solicitation Message. Caller specifies: | ||||
* - ICMP6 header source IP6 address | * - ICMP6 header source IP6 address | ||||
* - ND6 header target IP6 address | * - ND6 header target IP6 address | ||||
* - ND6 header source datalink address | * - ND6 header source datalink address | ||||
* | * | ||||
▲ Show 20 Lines • Show All 1,193 Lines • Show Last 20 Lines |
Nit: worth considering moving it out as a separate function? like, fill_proxyndp(struct infect *ifp, struct in6_addr *taddr, struct. sockaddr_dl *proxydl).
Should improve readability a bit.