Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet6/nd6_nbr.c
Show First 20 Lines • Show All 405 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
struct mbuf *m; | struct mbuf *m; | ||||
struct m_tag *mtag; | struct m_tag *mtag; | ||||
struct ip6_hdr *ip6; | struct ip6_hdr *ip6; | ||||
struct nd_neighbor_solicit *nd_ns; | struct nd_neighbor_solicit *nd_ns; | ||||
struct ip6_moptions im6o; | struct ip6_moptions im6o; | ||||
int icmp6len; | int icmp6len; | ||||
int maxlen; | int maxlen; | ||||
caddr_t mac; | |||||
NET_EPOCH_ASSERT(); | NET_EPOCH_ASSERT(); | ||||
if (IN6_IS_ADDR_MULTICAST(taddr6)) | if (IN6_IS_ADDR_MULTICAST(taddr6)) | ||||
return; | return; | ||||
/* estimate the size of message */ | /* estimate the size of message */ | ||||
maxlen = sizeof(*ip6) + sizeof(*nd_ns); | maxlen = sizeof(*ip6) + sizeof(*nd_ns); | ||||
▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | nd6_ns_output_fib(struct ifnet *ifp, const struct in6_addr *saddr6, | ||||
* --- --- | * --- --- | ||||
* DAD packet MUST NOT do not add the option | * DAD packet MUST NOT do not add the option | ||||
* there's no link layer address: | * there's no link layer address: | ||||
* impossible do not add the option | * impossible do not add the option | ||||
* there's link layer address: | * there's link layer address: | ||||
* Multicast NS MUST add one add the option | * Multicast NS MUST add one add the option | ||||
* Unicast NS SHOULD add one add the option | * Unicast NS SHOULD add one add the option | ||||
*/ | */ | ||||
if (nonce == NULL && (mac = nd6_ifptomac(ifp))) { | if (nonce == NULL) { | ||||
int optlen = sizeof(struct nd_opt_hdr) + ifp->if_addrlen; | struct nd_opt_hdr *nd_opt; | ||||
struct nd_opt_hdr *nd_opt = (struct nd_opt_hdr *)(nd_ns + 1); | char *mac; | ||||
int optlen; | |||||
mac = NULL; | |||||
if (ifp->if_carp) | |||||
mac = (*carp_macmatch6_p)(ifp, m, &ip6->ip6_src); | |||||
if (mac == NULL) | |||||
mac = nd6_ifptomac(ifp); | |||||
if (mac != NULL) { | |||||
nd_opt = (struct nd_opt_hdr *)(nd_ns + 1); | |||||
optlen = sizeof(struct nd_opt_hdr) + ifp->if_addrlen; | |||||
/* 8 byte alignments... */ | /* 8 byte alignments... */ | ||||
optlen = (optlen + 7) & ~7; | optlen = (optlen + 7) & ~7; | ||||
m->m_pkthdr.len += optlen; | m->m_pkthdr.len += optlen; | ||||
m->m_len += optlen; | m->m_len += optlen; | ||||
icmp6len += optlen; | icmp6len += optlen; | ||||
bzero((caddr_t)nd_opt, optlen); | bzero(nd_opt, optlen); | ||||
nd_opt->nd_opt_type = ND_OPT_SOURCE_LINKADDR; | nd_opt->nd_opt_type = ND_OPT_SOURCE_LINKADDR; | ||||
nd_opt->nd_opt_len = optlen >> 3; | nd_opt->nd_opt_len = optlen >> 3; | ||||
bcopy(mac, (caddr_t)(nd_opt + 1), ifp->if_addrlen); | bcopy(mac, nd_opt + 1, ifp->if_addrlen); | ||||
} | |||||
} | } | ||||
/* | /* | ||||
* Add a Nonce option (RFC 3971) to detect looped back NS messages. | * Add a Nonce option (RFC 3971) to detect looped back NS messages. | ||||
* This behavior is documented as Enhanced Duplicate Address | * This behavior is documented as Enhanced Duplicate Address | ||||
* Detection in RFC 7527. | * Detection in RFC 7527. | ||||
* net.inet6.ip6.dad_enhanced=0 disables this. | * net.inet6.ip6.dad_enhanced=0 disables this. | ||||
*/ | */ | ||||
if (V_dad_enhanced != 0 && nonce != NULL) { | if (V_dad_enhanced != 0 && nonce != NULL) { | ||||
▲ Show 20 Lines • Show All 1,022 Lines • Show Last 20 Lines |