if (IN6_IS_ADDR_UNSPECIFIED(&saddr6)) {
/* dst has to be solicited node multicast address. */
if (daddr6.s6_addr16[0] == IPV6_ADDR_INT16_MLL
- /*don't check ifindex portion*/
+ /* don't check ifindex portion */
&& daddr6.s6_addr32[1] == 0
&& daddr6.s6_addr32[2] == IPV6_ADDR_INT32_ONE
&& daddr6.s6_addr8[12] == 0xff) {
- ; /*good*/
+ ; /* good */
} else {
nd6log((LOG_INFO, "nd6_ns_input: bad DAD packet "
"(wrong ip6 dst)\n"));
}
if (ndopts.nd_opts_src_lladdr) {
- lladdr = (char *)(ndopts.nd_opts_src_lladdr +1);
+ lladdr = (char *)(ndopts.nd_opts_src_lladdr + 1);
lladdrlen = ndopts.nd_opts_src_lladdr->nd_opt_len << 3;
}
}
if (IN6_ARE_ADDR_EQUAL(&myaddr6, &saddr6)) {
- log(LOG_INFO,
- "nd6_ns_input: duplicate IP6 address %s\n",
- ip6_sprintf(&saddr6));
+ nd6log((LOG_INFO,
+ "nd6_ns_input: duplicate IP6 address %s\n",
+ ip6_sprintf(&saddr6)));
goto freeit;
}
icmp6len = sizeof(*nd_ns);
m->m_pkthdr.len = m->m_len = sizeof(*ip6) + icmp6len;
- m->m_data += max_linkhdr; /*or MH_ALIGN() equivalent?*/
+ m->m_data += max_linkhdr; /* or MH_ALIGN() equivalent? */
/* fill neighbor solicitation packet */
ip6 = mtod(m, struct ip6_hdr *);
* - saddr6 belongs to the outgoing interface.
* Otherwise, we perform a scope-wise match.
*/
- struct ip6_hdr *hip6; /*hold ip6*/
+ struct ip6_hdr *hip6; /* hold ip6 */
struct in6_addr *saddr6;
if (ln && ln->ln_hold) {
else {
ia = in6_ifawithifp(ifp, &ip6->ip6_dst);
if (ia == NULL) {
- m_freem(m); /*XXX*/
+ if (ln && ln->ln_hold)
+ m_freem(ln->ln_hold);
+ ln->ln_hold = NULL;
+ m_freem(m);
return;
}
ip6->ip6_src = ia->ia_addr.sin6_addr;
goto freeit;
}
- /* Just for safety, maybe unnecessery. */
+ /* Just for safety, maybe unnecessary. */
if (ifa) {
log(LOG_ERR,
"nd6_na_input: duplicate IP6 address %s\n",
int s;
in6 = &((struct sockaddr_in6 *)rt_key(rt))->sin6_addr;
+
+ /*
+ * Lock to protect the default router list.
+ * XXX: this might be unnecessary, since this function
+ * is only called under the network software interrupt
+ * context. However, we keep it just for safety.
+ */
s = splnet();
dr = defrouter_lookup(in6, rt->rt_ifp);
if (dr)
defrtrlist_del(dr);
- else if (!ip6_forwarding && ip6_accept_rtadv) {
+ else if (!ip6_forwarding && (ip6_accept_rtadv || (rt->rt_ifp->if_eflags & IFEF_ACCEPT_RTADVD))) {
/*
* Even if the neighbor is not in the default
* router list, the neighbor may be used
ln->ln_asked = 0;
if (ln->ln_hold) {
/*
- * we assume ifp is not a p2p here, so just set the 2nd
+ * we assume ifp is not a loopback here, so just set the 2nd
* argument as the 1st one.
*/
nd6_output(ifp, ifp, ln->ln_hold,
struct ip6_moptions im6o;
int icmp6len;
int maxlen;
- caddr_t mac;
+ caddr_t mac = NULL;
struct ifnet *outif = NULL;
/* estimate the size of message */
icmp6len = sizeof(*nd_na);
m->m_pkthdr.len = m->m_len = sizeof(struct ip6_hdr) + icmp6len;
- m->m_data += max_linkhdr; /*or MH_ALIGN() equivalent?*/
+ m->m_data += max_linkhdr; /* or MH_ALIGN() equivalent? */
/* fill neighbor advertisement packet */
ip6 = mtod(m, struct ip6_hdr *);
* target lladdr option SHOULD NOT be included.
*/
if (tlladdr) {
- mac = NULL;
/*
* sdl0 != NULL indicates proxy NA. If we do proxy, use
* lladdr in sdl0. If we are not proxying (sending NA for
int dad_ns_ocount; /* NS sent so far */
int dad_ns_icount;
int dad_na_icount;
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
- struct callout_handle dad_timer;
-#endif
};
static struct dadq_head dadq;
callout_reset(&dp->dad_timer_ch, ticks,
(void (*) __P((void *)))nd6_dad_timer, (void *)dp->dad_ifa);
}
+
static void
nd6_dad_stoptimer(dp)
struct dadq *dp;
return;
}
bzero(dp, sizeof(*dp));
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
- callout_init(&dp->dad_timer_ch);
-#endif
TAILQ_INSERT_TAIL(&dadq, (struct dadq *)dp, dad_list);
nd6log((LOG_DEBUG, "%s: starting DAD for %s\n", if_name(ifa->ifa_ifp),
dp->dad_count = ip6_dad_count;
dp->dad_ns_icount = dp->dad_na_icount = 0;
dp->dad_ns_ocount = dp->dad_ns_tcount = 0;
- if (!tick) {
+ if (tick == NULL) {
nd6_dad_ns_output(dp, ifa);
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
- dp->dad_timer =
-#endif
timeout((void (*) __P((void *)))nd6_dad_timer_funnel, (void *)ifa,
nd_ifinfo[ifa->ifa_ifp->if_index].retrans * hz / 1000);
} else {
else
ntick = *tick + random() % (hz / 2);
*tick = ntick;
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
- dp->dad_timer =
-#endif
timeout((void (*) __P((void *)))nd6_dad_timer_funnel, (void *)ifa,
ntick);
}
struct in6_ifaddr *ia = (struct in6_ifaddr *)ifa;
struct dadq *dp;
- s = splnet(); /*XXX*/
+ s = splnet(); /* XXX */
/* Sanity check */
if (ia == NULL) {
* We have more NS to go. Send NS packet for DAD.
*/
nd6_dad_ns_output(dp, ifa);
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
- dp->dad_timer =
-#endif
timeout((void (*) __P((void *)))nd6_dad_timer_funnel, (void *)ifa,
nd_ifinfo[ifa->ifa_ifp->if_index].retrans * hz / 1000);
} else {
}
if (dp->dad_ns_icount) {
-#if 0 /*heuristics*/
+#if 0 /* heuristics */
/*
* if
* - we have sent many(?) DAD NS, and