diff options
Diffstat (limited to 'sys/netinet6')
-rw-r--r-- | sys/netinet6/mld6.c | 20 | ||||
-rw-r--r-- | sys/netinet6/mld6_var.h | 10 | ||||
-rw-r--r-- | sys/netinet6/nd6.c | 131 | ||||
-rw-r--r-- | sys/netinet6/nd6.h | 19 | ||||
-rw-r--r-- | sys/netinet6/nd6_nbr.c | 101 | ||||
-rw-r--r-- | sys/netinet6/nd6_rtr.c | 197 | ||||
-rw-r--r-- | sys/netinet6/raw_ip6.c | 18 | ||||
-rw-r--r-- | sys/netinet6/scope6.c | 12 | ||||
-rw-r--r-- | sys/netinet6/scope6_var.h | 4 | ||||
-rw-r--r-- | sys/netinet6/udp6_usrreq.c | 2 |
10 files changed, 225 insertions, 289 deletions
diff --git a/sys/netinet6/mld6.c b/sys/netinet6/mld6.c index 61c0e0c..5f20cc5 100644 --- a/sys/netinet6/mld6.c +++ b/sys/netinet6/mld6.c @@ -108,7 +108,7 @@ static int mld6_timers_are_running; static struct in6_addr mld6_all_nodes_linklocal = IN6ADDR_LINKLOCAL_ALLNODES_INIT; static struct in6_addr mld6_all_routers_linklocal = IN6ADDR_LINKLOCAL_ALLROUTERS_INIT; -static void mld6_sendpkt __P((struct in6_multi *, int, const struct in6_addr *)); +static void mld6_sendpkt(struct in6_multi *, int, const struct in6_addr *); void mld6_init() @@ -203,7 +203,7 @@ mld6_input(m, off) #endif /* source address validation */ - ip6 = mtod(m, struct ip6_hdr *);/* in case mpullup */ + ip6 = mtod(m, struct ip6_hdr *); /* in case mpullup */ if (!IN6_IS_ADDR_LINKLOCAL(&ip6->ip6_src)) { log(LOG_ERR, "mld6_input: src %s is not link-local (grp=%s)\n", @@ -262,17 +262,17 @@ mld6_input(m, off) * the calculated value equals to zero when Max Response * Delay is positive. */ - timer = ntohs(mldh->mld_maxdelay)*PR_FASTHZ/MLD6_TIMER_SCALE; + timer = ntohs(mldh->mld_maxdelay) * PR_FASTHZ / MLD6_TIMER_SCALE; if (timer == 0 && mldh->mld_maxdelay) timer = 1; mld6_all_nodes_linklocal.s6_addr16[1] = htons(ifp->if_index); /* XXX */ - - TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) - { + + TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_INET6) continue; in6m = (struct in6_multi *)ifma->ifma_protospec; + if (IN6_ARE_ADDR_EQUAL(&in6m->in6m_addr, &mld6_all_nodes_linklocal) || IPV6_ADDR_MC_SCOPE(&in6m->in6m_addr) < @@ -302,6 +302,7 @@ mld6_input(m, off) if (IN6_IS_ADDR_MC_LINKLOCAL(&mldh->mld_addr)) mldh->mld_addr.s6_addr16[1] = 0; /* XXX */ break; + case MLD_LISTENER_REPORT: /* * For fast leave to work, we have to know that we are the @@ -357,6 +358,7 @@ mld6_fasttimeo() return; s = splnet(); + mld6_timers_are_running = 0; IN6_FIRST_MULTI(step, in6m); while (in6m != NULL) { @@ -370,6 +372,7 @@ mld6_fasttimeo() } IN6_NEXT_MULTI(step, in6m); } + splx(s); } @@ -438,9 +441,8 @@ mld6_sendpkt(in6m, type, dst) mldh->mld_addr = in6m->in6m_addr; if (IN6_IS_ADDR_MC_LINKLOCAL(&mldh->mld_addr)) mldh->mld_addr.s6_addr16[1] = 0; /* XXX */ - mldh->mld_cksum = in6_cksum(mh, IPPROTO_ICMPV6, - sizeof(struct ip6_hdr), - sizeof(struct mld_hdr)); + mldh->mld_cksum = in6_cksum(mh, IPPROTO_ICMPV6, sizeof(struct ip6_hdr), + sizeof(struct mld_hdr)); /* construct multicast option */ bzero(&im6o, sizeof(im6o)); diff --git a/sys/netinet6/mld6_var.h b/sys/netinet6/mld6_var.h index e58560e..405f45a 100644 --- a/sys/netinet6/mld6_var.h +++ b/sys/netinet6/mld6_var.h @@ -43,11 +43,11 @@ #define MLD6_OTHERLISTENER 0 #define MLD6_IREPORTEDLAST 1 -void mld6_init __P((void)); -void mld6_input __P((struct mbuf *, int)); -void mld6_start_listening __P((struct in6_multi *)); -void mld6_stop_listening __P((struct in6_multi *)); -void mld6_fasttimeo __P((void)); +void mld6_init(void); +void mld6_input(struct mbuf *, int); +void mld6_start_listening(struct in6_multi *); +void mld6_stop_listening(struct in6_multi *); +void mld6_fasttimeo(void); #endif /* _KERNEL */ #endif /* _NETINET6_MLD6_VAR_H_ */ diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 758897e..2c3ad2c 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -30,14 +30,6 @@ * SUCH DAMAGE. */ -/* - * XXX - * KAME 970409 note: - * BSD/OS version heavily modifies this code, related to llinfo. - * Since we don't have BSD/OS version of net/route.c in our hand, - * I left the code mostly as it was in 970310. -- itojun - */ - #include "opt_inet.h" #include "opt_inet6.h" #include "opt_mac.h" @@ -275,6 +267,7 @@ nd6_option_init(opt, icmp6len, ndopts) int icmp6len; union nd_opts *ndopts; { + bzero(ndopts, sizeof(*ndopts)); ndopts->nd_opts_search = (struct nd_opt_hdr *)opt; ndopts->nd_opts_last @@ -432,10 +425,10 @@ nd6_timer(ignored_arg) struct ifnet *ifp; struct in6_ifaddr *ia6, *nia6; struct in6_addrlifetime *lt6; - + s = splnet(); callout_reset(&nd6_timer_ch, nd6_prune * hz, - nd6_timer, NULL); + nd6_timer, NULL); ln = llinfo_nd6.ln_next; while (ln && ln != &llinfo_nd6) { @@ -540,7 +533,7 @@ nd6_timer(ignored_arg) } ln = next; } - + /* expire default router list */ dr = TAILQ_FIRST(&nd_defrouter); while (dr) { @@ -576,7 +569,7 @@ nd6_timer(ignored_arg) * addresses. Although we may have to restart the * loop (see below), it must be after purging the * address. Otherwise, we'd see an infinite loop of - * regeneration. + * regeneration. */ if (ip6_use_tempaddr && (ia6->ia6_flags & IN6_IFF_TEMPORARY) != 0) { @@ -612,7 +605,7 @@ nd6_timer(ignored_arg) * would not cause disaster (because * it's not a deletion, but an * addition,) we'd rather restart the - * loop just for safety. Or does this + * loop just for safety. Or does this * significantly reduce performance?? */ goto addrloop; @@ -662,8 +655,7 @@ regen_tmpaddr(ia6) ifp = ia6->ia_ifa.ifa_ifp; for (ifa = ifp->if_addrlist.tqh_first; ifa; - ifa = ifa->ifa_list.tqe_next) - { + ifa = ifa->ifa_list.tqe_next) { struct in6_ifaddr *it6; if (ifa->ifa_addr->sa_family != AF_INET6) @@ -836,7 +828,7 @@ nd6_lookup(addr6, create, ifp) * be covered by our own prefix. */ struct ifaddr *ifa = - ifaof_ifpforaddr((struct sockaddr *)&sin6, ifp); + ifaof_ifpforaddr((struct sockaddr *)&sin6, ifp); if (ifa == NULL) return (NULL); @@ -847,21 +839,19 @@ nd6_lookup(addr6, create, ifp) * called in rtrequest via ifa->ifa_rtrequest. */ if ((e = rtrequest(RTM_ADD, (struct sockaddr *)&sin6, - ifa->ifa_addr, - (struct sockaddr *)&all1_sa, - (ifa->ifa_flags | - RTF_HOST | RTF_LLINFO) & - ~RTF_CLONING, - &rt)) != 0) + ifa->ifa_addr, (struct sockaddr *)&all1_sa, + (ifa->ifa_flags | RTF_HOST | RTF_LLINFO) & + ~RTF_CLONING, &rt)) != 0) { log(LOG_ERR, "nd6_lookup: failed to add route for a " "neighbor(%s), errno=%d\n", ip6_sprintf(addr6), e); + } if (rt == NULL) return (NULL); if (rt->rt_llinfo) { struct llinfo_nd6 *ln = - (struct llinfo_nd6 *)rt->rt_llinfo; + (struct llinfo_nd6 *)rt->rt_llinfo; ln->ln_state = ND6_LLINFO_NOSTATE; } } else @@ -878,14 +868,16 @@ nd6_lookup(addr6, create, ifp) * it might be the loopback interface if the entry is for our * own address on a non-loopback interface. Instead, we should * use rt->rt_ifa->ifa_ifp, which would specify the REAL - * interface. + * interface. */ if ((rt->rt_flags & RTF_GATEWAY) || (rt->rt_flags & RTF_LLINFO) == 0 || rt->rt_gateway->sa_family != AF_LINK || rt->rt_llinfo == NULL || (ifp && rt->rt_ifa->ifa_ifp != ifp)) { if (create) { - log(LOG_DEBUG, "nd6_lookup: failed to lookup %s (if = %s)\n", - ip6_sprintf(addr6), ifp ? if_name(ifp) : "unspec"); + log(LOG_DEBUG, + "nd6_lookup: failed to lookup %s (if = %s)\n", + ip6_sprintf(addr6), + ifp ? if_name(ifp) : "unspec"); /* xxx more logs... kazu */ } return (NULL); @@ -921,10 +913,8 @@ nd6_is_addr_neighbor(addr, ifp) * If the address matches one of our addresses, * it should be a neighbor. */ - for (ifa = ifp->if_addrlist.tqh_first; - ifa; - ifa = ifa->ifa_list.tqe_next) - { + for (ifa = ifp->if_addrlist.tqh_first; ifa; + ifa = ifa->ifa_list.tqe_next) { if (ifa->ifa_addr->sa_family != AF_INET6) next: continue; @@ -961,7 +951,7 @@ nd6_free(rt) struct nd_defrouter *dr; /* - * we used to have pfctlinput(PRC_HOSTDEAD) here. + * we used to have pfctlinput(PRC_HOSTDEAD) here. * even though it is not harmful, it was not really necessary. */ @@ -969,7 +959,7 @@ nd6_free(rt) int s; s = splnet(); dr = defrouter_lookup(&((struct sockaddr_in6 *)rt_key(rt))->sin6_addr, - rt->rt_ifp); + rt->rt_ifp); if (ln->ln_router || dr) { /* @@ -1035,7 +1025,7 @@ nd6_free(rt) * cached routes. */ rtrequest(RTM_DELETE, rt_key(rt), (struct sockaddr *)0, - rt_mask(rt), 0, (struct rtentry **)0); + rt_mask(rt), 0, (struct rtentry **)0); return (next); } @@ -1106,7 +1096,7 @@ nd6_rtrequest(req, rt, info) RT_LOCK_ASSERT(rt); - if ((rt->rt_flags & RTF_GATEWAY)) + if ((rt->rt_flags & RTF_GATEWAY) != 0) return; if (nd6_need_cache(ifp) == 0 && (rt->rt_flags & RTF_HOST) == 0) { @@ -1164,17 +1154,11 @@ nd6_rtrequest(req, rt, info) SDL(gate)->sdl_index = ifp->if_index; if (ln) ln->ln_expire = time_second; -#if 1 if (ln && ln->ln_expire == 0) { /* kludge for desktops */ -#if 0 - printf("nd6_rtequest: time.tv_sec is zero; " - "treat it as 1\n"); -#endif ln->ln_expire = 1; } -#endif - if ((rt->rt_flags & RTF_CLONING)) + if ((rt->rt_flags & RTF_CLONING) != 0) break; } /* @@ -1265,7 +1249,7 @@ nd6_rtrequest(req, rt, info) * to the interface. */ ifa = (struct ifaddr *)in6ifa_ifpwithaddr(rt->rt_ifp, - &SIN6(rt_key(rt))->sin6_addr); + &SIN6(rt_key(rt))->sin6_addr); if (ifa) { caddr_t macp = nd6_ifptomac(ifp); ln->ln_expire = 0; @@ -1511,7 +1495,7 @@ nd6_ioctl(cmd, data, ifp) /* xxx sumikawa: flush prefix list */ break; case SIOCSPFXFLUSH_IN6: - { + { /* flush all the prefix advertised by routers */ struct nd_prefix *pr, *next; @@ -1539,9 +1523,9 @@ nd6_ioctl(cmd, data, ifp) } splx(s); break; - } + } case SIOCSRTRFLUSH_IN6: - { + { /* flush all the default routers */ struct nd_defrouter *dr, *next; @@ -1559,9 +1543,9 @@ nd6_ioctl(cmd, data, ifp) } splx(s); break; - } + } case SIOCGNBRINFO_IN6: - { + { struct llinfo_nd6 *ln; struct in6_addr nb_addr = nbi->addr; /* make local for safety */ @@ -1589,22 +1573,21 @@ nd6_ioctl(cmd, data, ifp) nbi->isrouter = ln->ln_router; nbi->expire = ln->ln_expire; splx(s); - + break; - } + } case SIOCGDEFIFACE_IN6: /* XXX: should be implemented as a sysctl? */ ndif->ifindex = nd6_defifindex; break; case SIOCSDEFIFACE_IN6: /* XXX: should be implemented as a sysctl? */ return (nd6_setdefaultiface(ndif->ifindex)); - break; } return (error); } /* * Create neighbor cache entry and cache link-layer address, - * on reception of inbound ND6 packets. (RS/RA/NS/redirect) + * on reception of inbound ND6 packets. (RS/RA/NS/redirect) */ struct rtentry * nd6_cache_lladdr(ifp, from, lladdr, lladdrlen, type, code) @@ -1706,8 +1689,8 @@ fail: } if (!is_newentry) { - if ((!olladdr && lladdr) /* (3) */ - || (olladdr && lladdr && llchange)) { /* (5) */ + if ((!olladdr && lladdr) || /* (3) */ + (olladdr && lladdr && llchange)) { /* (5) */ do_update = 1; newstate = ND6_LLINFO_STALE; } else /* (1-2,4) */ @@ -1741,8 +1724,7 @@ fail: * set the 2nd argument as the 1st one. */ nd6_output(ifp, ifp, ln->ln_hold, - (struct sockaddr_in6 *)rt_key(rt), - rt); + (struct sockaddr_in6 *)rt_key(rt), rt); ln->ln_hold = NULL; } } else if (ln->ln_state == ND6_LLINFO_INCOMPLETE) { @@ -1791,8 +1773,8 @@ fail: case ND_REDIRECT: /* * If the icmp is a redirect to a better router, always set the - * is_router flag. Otherwise, if the entry is newly created, - * clear the flag. [RFC 2461, sec 8.3] + * is_router flag. Otherwise, if the entry is newly created, + * clear the flag. [RFC 2461, sec 8.3] */ if (code == ND_REDIRECT_ROUTER) ln->ln_router = 1; @@ -1809,8 +1791,8 @@ fail: /* * Mark an entry with lladdr as a router. */ - if ((!is_newentry && (olladdr || lladdr)) /* (2-5) */ - || (is_newentry && lladdr)) { /* (7) */ + if ((!is_newentry && (olladdr || lladdr)) || /* (2-5) */ + (is_newentry && lladdr)) { /* (7) */ ln->ln_router = 1; } break; @@ -1899,7 +1881,7 @@ nd6_output(ifp, origifp, m0, dst, rt0) if (rt->rt_ifp != ifp) { /* XXX: loop care? */ return nd6_output(ifp, origifp, m0, - dst, rt); + dst, rt); } } else senderr(EHOSTUNREACH); @@ -1933,7 +1915,8 @@ nd6_output(ifp, origifp, m0, dst, rt0) goto lookup; if (((rt = rt->rt_gwroute)->rt_flags & RTF_UP) == 0) { rtfree(rt); rt = rt0; - lookup: rt->rt_gwroute = rtalloc1(rt->rt_gateway, 1, 0UL); + lookup: + rt->rt_gwroute = rtalloc1(rt->rt_gateway, 1, 0UL); if ((rt = rt->rt_gwroute) == 0) senderr(EHOSTUNREACH); RT_UNLOCK(rt); @@ -2026,7 +2009,7 @@ nd6_output(ifp, origifp, m0, dst, rt0) } } return (0); - + sendpkt: #ifdef MAC @@ -2034,7 +2017,7 @@ nd6_output(ifp, origifp, m0, dst, rt0) #endif if ((ifp->if_flags & IFF_LOOPBACK) != 0) { return ((*ifp->if_output)(origifp, m, (struct sockaddr *)dst, - rt)); + rt)); } return ((*ifp->if_output)(ifp, m, (struct sockaddr *)dst, rt)); @@ -2042,7 +2025,7 @@ nd6_output(ifp, origifp, m0, dst, rt0) if (m) m_freem(m); return (error); -} +} #undef senderr int @@ -2160,8 +2143,7 @@ nd6_sysctl_drlist(SYSCTL_HANDLER_ARGS) return EPERM; error = 0; - for (dr = TAILQ_FIRST(&nd_defrouter); - dr; + for (dr = TAILQ_FIRST(&nd_defrouter); dr; dr = TAILQ_NEXT(dr, dr_entry)) { d = (struct in6_defrouter *)buf; de = (struct in6_defrouter *)(buf + sizeof(buf)); @@ -2187,7 +2169,8 @@ nd6_sysctl_drlist(SYSCTL_HANDLER_ARGS) if (error) break; } - return error; + + return (error); } static int @@ -2231,11 +2214,9 @@ nd6_sysctl_prlist(SYSCTL_HANDLER_ARGS) p->flags = pr->ndpr_stateflags; p->origin = PR_ORIG_RA; advrtrs = 0; - for (pfr = pr->ndpr_advrtrs.lh_first; - pfr; + for (pfr = pr->ndpr_advrtrs.lh_first; pfr; pfr = pfr->pfr_next) { - if ((void *)&sin6[advrtrs + 1] > - (void *)pe) { + if ((void *)&sin6[advrtrs + 1] > (void *)pe) { advrtrs++; continue; } @@ -2243,8 +2224,7 @@ nd6_sysctl_prlist(SYSCTL_HANDLER_ARGS) bzero(s6, sizeof(*s6)); s6->sin6_family = AF_INET6; s6->sin6_len = sizeof(*sin6); - if (in6_recoverscope(s6, - &pfr->router->rtaddr, + if (in6_recoverscope(s6, &pfr->router->rtaddr, pfr->router->ifp) != 0) log(LOG_ERR, "scope error in " @@ -2253,7 +2233,7 @@ nd6_sysctl_prlist(SYSCTL_HANDLER_ARGS) advrtrs++; } p->advrtrs = advrtrs; - } else + } else panic("buffer too short"); advance = sizeof(*p) + sizeof(*sin6) * advrtrs; @@ -2261,5 +2241,6 @@ nd6_sysctl_prlist(SYSCTL_HANDLER_ARGS) if (error) break; } - return error; + + return (error); } diff --git a/sys/netinet6/nd6.h b/sys/netinet6/nd6.h index 397a505..e8bf02e 100644 --- a/sys/netinet6/nd6.h +++ b/sys/netinet6/nd6.h @@ -297,7 +297,7 @@ extern struct nd_drhead nd_defrouter; extern struct nd_prhead nd_prefix; extern int nd6_debug; -#define nd6log(x) do { if (nd6_debug) log x; } while (0) +#define nd6log(x) do { if (nd6_debug) log x; } while (/*CONSTCOND*/ 0) extern struct callout nd6_timer_ch; @@ -352,16 +352,16 @@ void nd6_timer __P((void *)); void nd6_purge __P((struct ifnet *)); struct llinfo_nd6 *nd6_free __P((struct rtentry *)); void nd6_nud_hint __P((struct rtentry *, struct in6_addr *, int)); -int nd6_resolve __P((struct ifnet *, struct rtentry *, - struct mbuf *, struct sockaddr *, u_char *)); +int nd6_resolve __P((struct ifnet *, struct rtentry *, struct mbuf *, + struct sockaddr *, u_char *)); void nd6_rtrequest __P((int, struct rtentry *, struct rt_addrinfo *)); int nd6_ioctl __P((u_long, caddr_t, struct ifnet *)); struct rtentry *nd6_cache_lladdr __P((struct ifnet *, struct in6_addr *, char *, int, int, int)); int nd6_output __P((struct ifnet *, struct ifnet *, struct mbuf *, - struct sockaddr_in6 *, struct rtentry *)); + struct sockaddr_in6 *, struct rtentry *)); int nd6_storelladdr __P((struct ifnet *, struct rtentry *, struct mbuf *, - struct sockaddr *, u_char *)); + struct sockaddr *, u_char *)); int nd6_need_cache __P((struct ifnet *)); /* nd6_nbr.c */ @@ -386,16 +386,15 @@ void defrouter_select __P((void)); void defrtrlist_del __P((struct nd_defrouter *)); void prelist_remove __P((struct nd_prefix *)); int prelist_update __P((struct nd_prefix *, struct nd_defrouter *, - struct mbuf *)); + struct mbuf *)); int nd6_prelist_add __P((struct nd_prefix *, struct nd_defrouter *, - struct nd_prefix **)); + struct nd_prefix **)); int nd6_prefix_onlink __P((struct nd_prefix *)); int nd6_prefix_offlink __P((struct nd_prefix *)); void pfxlist_onlink_check __P((void)); -struct nd_defrouter *defrouter_lookup __P((struct in6_addr *, - struct ifnet *)); +struct nd_defrouter *defrouter_lookup __P((struct in6_addr *, struct ifnet *)); struct nd_prefix *nd6_prefix_lookup __P((struct nd_prefix *)); -int in6_init_prefix_ltimes __P((struct nd_prefix *ndpr)); +int in6_init_prefix_ltimes __P((struct nd_prefix *)); void rt6_flush __P((struct in6_addr *, struct ifnet *)); int nd6_setdefaultiface __P((int)); int in6_tmpifadd __P((const struct in6_ifaddr *, int)); diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c index 287892e..7a56bad 100644 --- a/sys/netinet6/nd6_nbr.c +++ b/sys/netinet6/nd6_nbr.c @@ -132,15 +132,15 @@ nd6_ns_input(m, off, icmp6len) if (IN6_IS_ADDR_UNSPECIFIED(&saddr6)) { /* dst has to be solicited node multicast address. */ - if (daddr6.s6_addr16[0] == IPV6_ADDR_INT16_MLL + if (daddr6.s6_addr16[0] == IPV6_ADDR_INT16_MLL && /* don't check ifindex portion */ - && daddr6.s6_addr32[1] == 0 - && daddr6.s6_addr32[2] == IPV6_ADDR_INT32_ONE - && daddr6.s6_addr8[12] == 0xff) { + daddr6.s6_addr32[1] == 0 && + daddr6.s6_addr32[2] == IPV6_ADDR_INT32_ONE && + daddr6.s6_addr8[12] == 0xff) { ; /* good */ } else { nd6log((LOG_INFO, "nd6_ns_input: bad DAD packet " - "(wrong ip6 dst)\n")); + "(wrong ip6 dst)\n")); goto bad; } } @@ -166,7 +166,7 @@ nd6_ns_input(m, off, icmp6len) lladdr = (char *)(ndopts.nd_opts_src_lladdr + 1); lladdrlen = ndopts.nd_opts_src_lladdr->nd_opt_len << 3; } - + if (IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src) && lladdr) { nd6log((LOG_INFO, "nd6_ns_input: bad DAD packet " "(link-layer address option)\n")); @@ -244,17 +244,16 @@ nd6_ns_input(m, off, icmp6len) goto freeit; if (lladdr && ((ifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) { - nd6log((LOG_INFO, - "nd6_ns_input: lladdrlen mismatch for %s " + nd6log((LOG_INFO, "nd6_ns_input: lladdrlen mismatch for %s " "(if %d, NS packet %d)\n", - ip6_sprintf(&taddr6), ifp->if_addrlen, lladdrlen - 2)); + ip6_sprintf(&taddr6), + ifp->if_addrlen, lladdrlen - 2)); goto bad; } if (IN6_ARE_ADDR_EQUAL(&myaddr6, &saddr6)) { - nd6log((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; } @@ -296,20 +295,19 @@ nd6_ns_input(m, off, icmp6len) saddr6 = in6addr_linklocal_allnodes; saddr6.s6_addr16[1] = htons(ifp->if_index); nd6_na_output(ifp, &saddr6, &taddr6, - ((anycast || proxy || !tlladdr) - ? 0 : ND_NA_FLAG_OVERRIDE) - | (ip6_forwarding ? ND_NA_FLAG_ROUTER : 0), - tlladdr, (struct sockaddr *)proxydl); + ((anycast || proxy || !tlladdr) ? 0 : ND_NA_FLAG_OVERRIDE) | + (ip6_forwarding ? ND_NA_FLAG_ROUTER : 0), + tlladdr, (struct sockaddr *)proxydl); goto freeit; } - nd6_cache_lladdr(ifp, &saddr6, lladdr, lladdrlen, ND_NEIGHBOR_SOLICIT, 0); + nd6_cache_lladdr(ifp, &saddr6, lladdr, lladdrlen, + ND_NEIGHBOR_SOLICIT, 0); nd6_na_output(ifp, &saddr6, &taddr6, - ((anycast || proxy || !tlladdr) ? 0 : ND_NA_FLAG_OVERRIDE) - | (ip6_forwarding ? ND_NA_FLAG_ROUTER : 0) - | ND_NA_FLAG_SOLICITED, - tlladdr, (struct sockaddr *)proxydl); + ((anycast || proxy || !tlladdr) ? 0 : ND_NA_FLAG_OVERRIDE) | + (ip6_forwarding ? ND_NA_FLAG_ROUTER : 0) | ND_NA_FLAG_SOLICITED, + tlladdr, (struct sockaddr *)proxydl); freeit: m_freem(m); return; @@ -347,7 +345,7 @@ nd6_ns_output(ifp, daddr6, taddr6, ln, dad) int maxlen; caddr_t mac; struct ifnet *outif = NULL; - + if (IN6_IS_ADDR_MULTICAST(taddr6)) return; @@ -404,20 +402,6 @@ nd6_ns_output(ifp, daddr6, taddr6, ln, dad) ip6->ip6_dst.s6_addr8[12] = 0xff; } if (!dad) { -#if 0 /* KAME way, exact address scope match */ - /* - * Select a source whose scope is the same as that of the dest. - * Typically, the dest is link-local solicitation multicast - * (i.e. neighbor discovery) or link-local/global unicast - * (i.e. neighbor un-reachability detection). - */ - ia = in6_ifawithifp(ifp, &ip6->ip6_dst); - if (ia == NULL) { - m_freem(m); - return; - } - ip6->ip6_src = ia->ia_addr.sin6_addr; -#else /* spec-wise correct */ /* * RFC2461 7.2.2: * "If the source address of the packet prompting the @@ -455,7 +439,6 @@ nd6_ns_output(ifp, daddr6, taddr6, ln, dad) } ip6->ip6_src = ia->ia_addr.sin6_addr; } -#endif } else { /* * Source address for DAD packet must always be IPv6 @@ -489,7 +472,7 @@ nd6_ns_output(ifp, daddr6, taddr6, ln, dad) struct nd_opt_hdr *nd_opt = (struct nd_opt_hdr *)(nd_ns + 1); /* 8 byte alignments... */ optlen = (optlen + 7) & ~7; - + m->m_pkthdr.len += optlen; m->m_len += optlen; icmp6len += optlen; @@ -501,8 +484,8 @@ nd6_ns_output(ifp, daddr6, taddr6, ln, dad) ip6->ip6_plen = htons((u_short)icmp6len); nd_ns->nd_ns_cksum = 0; - nd_ns->nd_ns_cksum - = in6_cksum(m, IPPROTO_ICMPV6, sizeof(*ip6), icmp6len); + nd_ns->nd_ns_cksum = + in6_cksum(m, IPPROTO_ICMPV6, sizeof(*ip6), icmp6len); ip6_output(m, NULL, NULL, dad ? IPV6_DADOUTPUT : 0, &im6o, &outif, NULL); if (outif) { @@ -530,9 +513,6 @@ nd6_na_input(m, off, icmp6len) struct ifnet *ifp = m->m_pkthdr.rcvif; struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); struct nd_neighbor_advert *nd_na; -#if 0 - struct in6_addr saddr6 = ip6->ip6_src; -#endif struct in6_addr daddr6 = ip6->ip6_dst; struct in6_addr taddr6; int flags; @@ -627,15 +607,15 @@ nd6_na_input(m, off, icmp6len) } if (lladdr && ((ifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) { - nd6log((LOG_INFO, - "nd6_na_input: lladdrlen mismatch for %s " - "(if %d, NA packet %d)\n", - ip6_sprintf(&taddr6), ifp->if_addrlen, lladdrlen - 2)); + nd6log((LOG_INFO, "nd6_na_input: lladdrlen mismatch for %s " + "(if %d, NA packet %d)\n", ip6_sprintf(&taddr6), + ifp->if_addrlen, lladdrlen - 2)); goto bad; } /* - * If no neighbor cache entry is found, NA SHOULD silently be discarded. + * If no neighbor cache entry is found, NA SHOULD silently be + * discarded. */ rt = nd6_lookup(&taddr6, 0, ifp); if ((rt == NULL) || @@ -659,9 +639,10 @@ nd6_na_input(m, off, icmp6len) if (is_solicited) { ln->ln_state = ND6_LLINFO_REACHABLE; ln->ln_byhint = 0; - if (ln->ln_expire) + if (ln->ln_expire) { ln->ln_expire = time_second + nd_ifinfo[rt->rt_ifp->if_index].reachable; + } } else { ln->ln_state = ND6_LLINFO_STALE; ln->ln_expire = time_second + nd6_gctimer; @@ -768,7 +749,7 @@ nd6_na_input(m, off, icmp6len) * 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. + * context. However, we keep it just for safety. */ s = splnet(); dr = defrouter_lookup(in6, rt->rt_ifp); @@ -797,7 +778,7 @@ nd6_na_input(m, off, icmp6len) */ nd6_output(ifp, ifp, ln->ln_hold, (struct sockaddr_in6 *)rt_key(rt), rt); - ln->ln_hold = 0; + ln->ln_hold = NULL; } freeit: @@ -928,7 +909,7 @@ nd6_na_output(ifp, daddr6, taddr6, flags, tlladdr, sdl0) if (tlladdr && mac) { int optlen = sizeof(struct nd_opt_hdr) + ifp->if_addrlen; struct nd_opt_hdr *nd_opt = (struct nd_opt_hdr *)(nd_na + 1); - + /* roundup to 8 bytes alignment! */ optlen = (optlen + 7) & ~7; @@ -946,7 +927,7 @@ nd6_na_output(ifp, daddr6, taddr6, flags, tlladdr, sdl0) nd_na->nd_na_flags_reserved = flags; nd_na->nd_na_cksum = 0; nd_na->nd_na_cksum = - in6_cksum(m, IPPROTO_ICMPV6, sizeof(struct ip6_hdr), icmp6len); + in6_cksum(m, IPPROTO_ICMPV6, sizeof(struct ip6_hdr), icmp6len); ip6_output(m, NULL, NULL, 0, &im6o, &outif, NULL); if (outif) { @@ -973,7 +954,6 @@ nd6_ifptomac(ifp) #endif case IFT_ISO88025: return ((caddr_t)(ifp + 1)); - break; default: return NULL; } @@ -1065,8 +1045,9 @@ nd6_dad_start(ifa, tick) } if (!ifa->ifa_ifp) panic("nd6_dad_start: ifa->ifa_ifp == NULL"); - if (!(ifa->ifa_ifp->if_flags & IFF_UP)) + if (!(ifa->ifa_ifp->if_flags & IFF_UP)) { return; + } if (nd6_dad_find(ifa) != NULL) { /* DAD already in progress */ return; @@ -1177,7 +1158,7 @@ nd6_dad_timer(ifa) /* timeouted with IFF_{RUNNING,UP} check */ if (dp->dad_ns_tcount > dad_maxtry) { nd6log((LOG_INFO, "%s: could not run DAD, driver problem?\n", - if_name(ifa->ifa_ifp))); + if_name(ifa->ifa_ifp))); TAILQ_REMOVE(&dadq, (struct dadq *)dp, dad_list); free(dp, M_IP6NDP); @@ -1192,7 +1173,7 @@ nd6_dad_timer(ifa) * We have more NS to go. Send NS packet for DAD. */ nd6_dad_ns_output(dp, ifa); - nd6_dad_starttimer(dp, + nd6_dad_starttimer(dp, nd_ifinfo[ifa->ifa_ifp->if_index].retrans * hz / 1000); } else { /* @@ -1226,9 +1207,9 @@ nd6_dad_timer(ifa) && dp->dad_ns_icount == dp->dad_count && dp->dad_na_icount == 0) { log(LOG_INFO, "DAD questionable for %s(%s): " - "network card loops back multicast?\n", - ip6_sprintf(&ia->ia_addr.sin6_addr), - if_name(ifa->ifa_ifp)); + "network card loops back multicast?\n", + ip6_sprintf(&ia->ia_addr.sin6_addr), + if_name(ifa->ifa_ifp)); /* XXX consider it a duplicate or not? */ /* duplicate++; */ } else { diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c index ede69a4..65d219d 100644 --- a/sys/netinet6/nd6_rtr.c +++ b/sys/netinet6/nd6_rtr.c @@ -76,8 +76,8 @@ static struct nd_pfxrouter *find_pfxlist_reachable_router static void defrouter_addifreq __P((struct ifnet *)); static void nd6_rtmsg __P((int, struct rtentry *)); -static void in6_init_address_ltimes __P((struct nd_prefix *ndpr, - struct in6_addrlifetime *lt6)); +static void in6_init_address_ltimes __P((struct nd_prefix *, + struct in6_addrlifetime *)); static int rt6_deleteroute __P((struct radix_node *, void *)); @@ -114,9 +114,6 @@ nd6_rs_input(m, off, icmp6len) struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); struct nd_router_solicit *nd_rs; struct in6_addr saddr6 = ip6->ip6_src; -#if 0 - struct in6_addr daddr6 = ip6->ip6_dst; -#endif char *lladdr = NULL; int lladdrlen = 0; #if 0 @@ -176,7 +173,8 @@ nd6_rs_input(m, off, icmp6len) nd6log((LOG_INFO, "nd6_rs_input: lladdrlen mismatch for %s " "(if %d, RS packet %d)\n", - ip6_sprintf(&saddr6), ifp->if_addrlen, lladdrlen - 2)); + ip6_sprintf(&saddr6), + ifp->if_addrlen, lladdrlen - 2)); goto bad; } @@ -350,17 +348,14 @@ nd6_ra_input(m, off, icmp6len) pr.ndpr_ifp = (struct ifnet *)m->m_pkthdr.rcvif; pr.ndpr_raf_onlink = (pi->nd_opt_pi_flags_reserved & - ND_OPT_PI_FLAG_ONLINK) ? 1 : 0; + ND_OPT_PI_FLAG_ONLINK) ? 1 : 0; pr.ndpr_raf_auto = (pi->nd_opt_pi_flags_reserved & - ND_OPT_PI_FLAG_AUTO) ? 1 : 0; + ND_OPT_PI_FLAG_AUTO) ? 1 : 0; pr.ndpr_plen = pi->nd_opt_pi_prefix_len; pr.ndpr_vltime = ntohl(pi->nd_opt_pi_valid_time); - pr.ndpr_pltime = - ntohl(pi->nd_opt_pi_preferred_time); - + pr.ndpr_pltime = ntohl(pi->nd_opt_pi_preferred_time); if (in6_init_prefix_ltimes(&pr)) continue; /* prefix lifetime init failed */ - (void)prelist_update(&pr, dr, m); } } @@ -369,7 +364,9 @@ nd6_ra_input(m, off, icmp6len) * MTU */ if (ndopts.nd_opts_mtu && ndopts.nd_opts_mtu->nd_opt_mtu_len == 1) { - u_int32_t mtu = ntohl(ndopts.nd_opts_mtu->nd_opt_mtu_mtu); + u_int32_t mtu; + + mtu = ntohl(ndopts.nd_opts_mtu->nd_opt_mtu_mtu); /* lower bound */ if (mtu < IPV6_MMTU) { @@ -403,14 +400,14 @@ nd6_ra_input(m, off, icmp6len) } skip: - + /* * Source link layer address */ { char *lladdr = NULL; int lladdrlen = 0; - + if (ndopts.nd_opts_src_lladdr) { lladdr = (char *)(ndopts.nd_opts_src_lladdr + 1); lladdrlen = ndopts.nd_opts_src_lladdr->nd_opt_len << 3; @@ -419,12 +416,13 @@ nd6_ra_input(m, off, icmp6len) if (lladdr && ((ifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) { nd6log((LOG_INFO, "nd6_ra_input: lladdrlen mismatch for %s " - "(if %d, RA packet %d)\n", - ip6_sprintf(&saddr6), ifp->if_addrlen, lladdrlen - 2)); + "(if %d, RA packet %d)\n", ip6_sprintf(&saddr6), + ifp->if_addrlen, lladdrlen - 2)); goto bad; } - nd6_cache_lladdr(ifp, &saddr6, lladdr, lladdrlen, ND_ROUTER_ADVERT, 0); + nd6_cache_lladdr(ifp, &saddr6, lladdr, + lladdrlen, ND_ROUTER_ADVERT, 0); /* * Installing a link-layer address might change the state of the @@ -477,14 +475,14 @@ defrouter_addreq(new) Bzero(&mask, sizeof(mask)); Bzero(&gate, sizeof(gate)); - def.sin6_len = mask.sin6_len = gate.sin6_len - = sizeof(struct sockaddr_in6); + def.sin6_len = mask.sin6_len = gate.sin6_len = + sizeof(struct sockaddr_in6); def.sin6_family = mask.sin6_family = gate.sin6_family = AF_INET6; gate.sin6_addr = new->rtaddr; (void)rtrequest(RTM_ADD, (struct sockaddr *)&def, - (struct sockaddr *)&gate, (struct sockaddr *)&mask, - RTF_GATEWAY, &newrt); + (struct sockaddr *)&gate, (struct sockaddr *)&mask, + RTF_GATEWAY, &newrt); if (newrt) { RT_LOCK(newrt); nd6_rtmsg(RTM_ADD, newrt); /* tell user process */ @@ -524,7 +522,7 @@ defrouter_addifreq(ifp) flags = ifa->ifa_flags; error = rtrequest(RTM_ADD, (struct sockaddr *)&def, ifa->ifa_addr, - (struct sockaddr *)&mask, flags, &newrt); + (struct sockaddr *)&mask, flags, &newrt); if (error != 0) { nd6log((LOG_ERR, "defrouter_addifreq: failed to install a route to " @@ -568,15 +566,14 @@ defrouter_delreq(dr, dofree) Bzero(&mask, sizeof(mask)); Bzero(&gate, sizeof(gate)); - def.sin6_len = mask.sin6_len = gate.sin6_len - = sizeof(struct sockaddr_in6); + def.sin6_len = mask.sin6_len = gate.sin6_len = + sizeof(struct sockaddr_in6); def.sin6_family = mask.sin6_family = gate.sin6_family = AF_INET6; gate.sin6_addr = dr->rtaddr; rtrequest(RTM_DELETE, (struct sockaddr *)&def, - (struct sockaddr *)&gate, - (struct sockaddr *)&mask, - RTF_GATEWAY, &oldrt); + (struct sockaddr *)&gate, + (struct sockaddr *)&mask, RTF_GATEWAY, &oldrt); if (oldrt) { nd6_rtmsg(RTM_DELETE, oldrt); RTFREE(oldrt); @@ -597,10 +594,8 @@ defrtrlist_del(dr) * Flush all the routing table entries that use the router * as a next hop. */ - if (!ip6_forwarding && ip6_accept_rtadv) { - /* above is a good condition? */ + if (!ip6_forwarding && ip6_accept_rtadv) /* XXX: better condition? */ rt6_flush(&dr->rtaddr, dr->ifp); - } if (dr == TAILQ_FIRST(&nd_defrouter)) deldr = dr; /* The router is primary. */ @@ -755,7 +750,7 @@ defrtrlist_update(new) if (TAILQ_FIRST(&nd_defrouter) == n) defrouter_select(); splx(s); - + return (n); } @@ -765,7 +760,7 @@ pfxrtr_lookup(pr, dr) struct nd_defrouter *dr; { struct nd_pfxrouter *search; - + for (search = pr->ndpr_advrtrs.lh_first; search; search = search->pfr_next) { if (search->router == dr) break; @@ -810,9 +805,7 @@ nd6_prefix_lookup(pr) if (pr->ndpr_ifp == search->ndpr_ifp && pr->ndpr_plen == search->ndpr_plen && in6_are_prefix_equal(&pr->ndpr_prefix.sin6_addr, - &search->ndpr_prefix.sin6_addr, - pr->ndpr_plen) - ) { + &search->ndpr_prefix.sin6_addr, pr->ndpr_plen)) { break; } } @@ -830,19 +823,19 @@ nd6_prelist_add(pr, dr, newp) new = (struct nd_prefix *)malloc(sizeof(*new), M_IP6NDP, M_NOWAIT); if (new == NULL) - return ENOMEM; + return(ENOMEM); bzero(new, sizeof(*new)); *new = *pr; if (newp != NULL) *newp = new; - /* initilization */ + /* initialization */ LIST_INIT(&new->ndpr_advrtrs); in6_prefixlen2mask(&new->ndpr_mask, new->ndpr_plen); /* make prefix in the canonical form */ for (i = 0; i < 4; i++) new->ndpr_prefix.sin6_addr.s6_addr32[i] &= - new->ndpr_mask.s6_addr32[i]; + new->ndpr_mask.s6_addr32[i]; s = splnet(); /* link ndpr_entry to nd_prefix list */ @@ -862,9 +855,8 @@ nd6_prelist_add(pr, dr, newp) } } - if (dr) { + if (dr) pfxrtr_add(new, dr); - } return 0; } @@ -940,12 +932,11 @@ prelist_update(new, dr, m) * both IP header and IP datagrams, doesn't it ? */ #if defined(M_AUTHIPHDR) && defined(M_AUTHIPDGM) - auth = (m->m_flags & M_AUTHIPHDR - && m->m_flags & M_AUTHIPDGM) ? 1 : 0; + auth = ((m->m_flags & M_AUTHIPHDR) && + (m->m_flags & M_AUTHIPDGM)); #endif } - if ((pr = nd6_prefix_lookup(new)) != NULL) { /* * nd6_prefix_lookup() ensures that pr and new have the same @@ -1003,8 +994,8 @@ prelist_update(new, dr, m) "nd6_prelist_add failed for %s/%d on %s " "errno=%d, returnpr=%p\n", ip6_sprintf(&new->ndpr_prefix.sin6_addr), - new->ndpr_plen, if_name(new->ndpr_ifp), - error, newpr)); + new->ndpr_plen, if_name(new->ndpr_ifp), + error, newpr)); goto end; /* we should just give up in this case. */ } @@ -1012,7 +1003,7 @@ prelist_update(new, dr, m) * XXX: from the ND point of view, we can ignore a prefix * with the on-link bit being zero. However, we need a * prefix structure for references from autoconfigured - * addresses. Thus, we explicitly make suret that the prefix + * addresses. Thus, we explicitly make sure that the prefix * itself expires now. */ if (newpr->ndpr_raf_onlink == 0) { @@ -1049,8 +1040,7 @@ prelist_update(new, dr, m) * form an address. Note that even a manually configured address * should reject autoconfiguration of a new address. */ - TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) - { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { struct in6_ifaddr *ifa6; int ifa_plen; u_int32_t storedlifetime; @@ -1067,12 +1057,11 @@ prelist_update(new, dr, m) */ if ((ifa6->ia6_flags & IN6_IFF_ANYCAST) != 0) continue; - + ifa_plen = in6_mask2len(&ifa6->ia_prefixmask.sin6_addr, NULL); if (ifa_plen != new->ndpr_plen || !in6_are_prefix_equal(&ifa6->ia_addr.sin6_addr, - &new->ndpr_prefix.sin6_addr, - ifa_plen)) + &new->ndpr_prefix.sin6_addr, ifa_plen)) continue; if (ia6_match == NULL) /* remember the first one */ @@ -1140,13 +1129,13 @@ prelist_update(new, dr, m) lt6_tmp.ia6t_expire > ifa6->ia6_lifetime.ia6t_expire) { lt6_tmp.ia6t_expire = - ifa6->ia6_lifetime.ia6t_expire; + ifa6->ia6_lifetime.ia6t_expire; } if (lt6_tmp.ia6t_preferred == 0 || /* no expire */ lt6_tmp.ia6t_preferred > ifa6->ia6_lifetime.ia6t_preferred) { lt6_tmp.ia6t_preferred = - ifa6->ia6_lifetime.ia6t_preferred; + ifa6->ia6_lifetime.ia6t_preferred; } } @@ -1164,11 +1153,6 @@ prelist_update(new, dr, m) pr->ndpr_refcnt++; ia6->ia6_ndpr = pr; -#if 0 - /* XXXYYY Don't do this, according to Jinmei. */ - pr->ndpr_addr = new->ndpr_addr; -#endif - /* * RFC 3041 3.3 (2). * When a new public address is created as described @@ -1226,14 +1210,13 @@ find_pfxlist_reachable_router(pr) for (pfxrtr = LIST_FIRST(&pr->ndpr_advrtrs); pfxrtr; pfxrtr = LIST_NEXT(pfxrtr, pfr_entry)) { if ((rt = nd6_lookup(&pfxrtr->router->rtaddr, 0, - pfxrtr->router->ifp)) && + pfxrtr->router->ifp)) && (ln = (struct llinfo_nd6 *)rt->rt_llinfo) && ND6_IS_LLINFO_PROBREACH(ln)) break; /* found */ } return (pfxrtr); - } /* @@ -1352,7 +1335,7 @@ pfxlist_onlink_check() * The precise detection logic is same as the one for prefixes. */ for (ifa = in6_ifaddr; ifa; ifa = ifa->ia_next) { - if ((ifa->ia6_flags & IN6_IFF_AUTOCONF) == 0) + if (!(ifa->ia6_flags & IN6_IFF_AUTOCONF)) continue; if (ifa->ia6_ndpr == NULL) { @@ -1427,22 +1410,19 @@ nd6_prefix_onlink(pr) if (opr->ndpr_plen == pr->ndpr_plen && in6_are_prefix_equal(&pr->ndpr_prefix.sin6_addr, - &opr->ndpr_prefix.sin6_addr, - pr->ndpr_plen)) + &opr->ndpr_prefix.sin6_addr, pr->ndpr_plen)) return (0); } /* - * We prefer link-local addresses as the associated interface address. + * We prefer link-local addresses as the associated interface address. */ /* search for a link-local addr */ ifa = (struct ifaddr *)in6ifa_ifpforlinklocal(ifp, - IN6_IFF_NOTREADY| - IN6_IFF_ANYCAST); + IN6_IFF_NOTREADY | IN6_IFF_ANYCAST); if (ifa == NULL) { /* XXX: freebsd does not have ifa_ifwithaf */ - TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) - { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if (ifa->ifa_addr->sa_family == AF_INET6) break; } @@ -1481,14 +1461,12 @@ nd6_prefix_onlink(pr) rtflags &= ~RTF_CLONING; } error = rtrequest(RTM_ADD, (struct sockaddr *)&pr->ndpr_prefix, - ifa->ifa_addr, (struct sockaddr *)&mask6, - rtflags, &rt); + ifa->ifa_addr, (struct sockaddr *)&mask6, rtflags, &rt); if (error == 0) { if (rt != NULL) /* this should be non NULL, though */ nd6_rtmsg(RTM_ADD, rt); pr->ndpr_stateflags |= NDPRF_ONLINK; - } - else { + } else { nd6log((LOG_ERR, "nd6_prefix_onlink: failed to add route for a" " prefix (%s/%d) on %s, gw=%s, mask=%s, flags=%lx " "errno = %d\n", @@ -1529,13 +1507,13 @@ nd6_prefix_offlink(pr) sa6.sin6_family = AF_INET6; sa6.sin6_len = sizeof(sa6); bcopy(&pr->ndpr_prefix.sin6_addr, &sa6.sin6_addr, - sizeof(struct in6_addr)); + sizeof(struct in6_addr)); bzero(&mask6, sizeof(mask6)); mask6.sin6_family = AF_INET6; mask6.sin6_len = sizeof(sa6); bcopy(&pr->ndpr_mask, &mask6.sin6_addr, sizeof(struct in6_addr)); error = rtrequest(RTM_DELETE, (struct sockaddr *)&sa6, NULL, - (struct sockaddr *)&mask6, 0, &rt); + (struct sockaddr *)&mask6, 0, &rt); if (error == 0) { pr->ndpr_stateflags &= ~NDPRF_ONLINK; @@ -1566,8 +1544,7 @@ nd6_prefix_offlink(pr) if (opr->ndpr_plen == pr->ndpr_plen && in6_are_prefix_equal(&pr->ndpr_prefix.sin6_addr, - &opr->ndpr_prefix.sin6_addr, - pr->ndpr_plen)) { + &opr->ndpr_prefix.sin6_addr, pr->ndpr_plen)) { int e; if ((e = nd6_prefix_onlink(opr)) != 0) { @@ -1581,8 +1558,7 @@ nd6_prefix_offlink(pr) } } } - } - else { + } else { /* XXX: can we still set the NDPRF_ONLINK flag? */ nd6log((LOG_ERR, "nd6_prefix_offlink: failed to delete route: " @@ -1591,8 +1567,9 @@ nd6_prefix_offlink(pr) error)); } - if (rt != NULL) + if (rt != NULL) { RTFREE(rt); + } return (error); } @@ -1624,7 +1601,7 @@ in6_ifadd(pr, ifid) * (2) RFC2462 5.4 suggesting the use of the same interface identifier * for multiple addresses on a single interface, and possible shortcut * of DAD. we omitted DAD for this reason in the past. - * (3) a user can prevent autoconfiguration of global address + * (3) a user can prevent autoconfiguration of global address * by removing link-local address by hand (this is partly because we * don't have other way to control the use of IPv6 on an interface. * this has been our design choice - cf. NRL's "ifconfig auto"). @@ -1636,7 +1613,7 @@ in6_ifadd(pr, ifid) * ID. This is to not break connections when moving addresses between * interfaces. */ - ifa = (struct ifaddr *)in6ifa_ifpforlinklocal(ifp, 0);/* 0 is OK? */ + ifa = (struct ifaddr *)in6ifa_ifpforlinklocal(ifp, 0); /* 0 is OK? */ if (ifa) ib = (struct in6_ifaddr *)ifa; else @@ -1671,7 +1648,7 @@ in6_ifadd(pr, ifid) ifra.ifra_addr.sin6_len = sizeof(struct sockaddr_in6); /* prefix */ bcopy(&pr->ndpr_prefix.sin6_addr, &ifra.ifra_addr.sin6_addr, - sizeof(ifra.ifra_addr.sin6_addr)); + sizeof(ifra.ifra_addr.sin6_addr)); ifra.ifra_addr.sin6_addr.s6_addr32[0] &= mask.s6_addr32[0]; ifra.ifra_addr.sin6_addr.s6_addr32[1] &= mask.s6_addr32[1]; ifra.ifra_addr.sin6_addr.s6_addr32[2] &= mask.s6_addr32[2]; @@ -1680,25 +1657,25 @@ in6_ifadd(pr, ifid) /* interface ID */ if (ifid == NULL || IN6_IS_ADDR_UNSPECIFIED(ifid)) ifid = &ib->ia_addr.sin6_addr; - ifra.ifra_addr.sin6_addr.s6_addr32[0] - |= (ifid->s6_addr32[0] & ~mask.s6_addr32[0]); - ifra.ifra_addr.sin6_addr.s6_addr32[1] - |= (ifid->s6_addr32[1] & ~mask.s6_addr32[1]); - ifra.ifra_addr.sin6_addr.s6_addr32[2] - |= (ifid->s6_addr32[2] & ~mask.s6_addr32[2]); - ifra.ifra_addr.sin6_addr.s6_addr32[3] - |= (ifid->s6_addr32[3] & ~mask.s6_addr32[3]); - + ifra.ifra_addr.sin6_addr.s6_addr32[0] |= + (ifid->s6_addr32[0] & ~mask.s6_addr32[0]); + ifra.ifra_addr.sin6_addr.s6_addr32[1] |= + (ifid->s6_addr32[1] & ~mask.s6_addr32[1]); + ifra.ifra_addr.sin6_addr.s6_addr32[2] |= + (ifid->s6_addr32[2] & ~mask.s6_addr32[2]); + ifra.ifra_addr.sin6_addr.s6_addr32[3] |= + (ifid->s6_addr32[3] & ~mask.s6_addr32[3]); + /* new prefix mask. */ ifra.ifra_prefixmask.sin6_len = sizeof(struct sockaddr_in6); ifra.ifra_prefixmask.sin6_family = AF_INET6; bcopy(&mask, &ifra.ifra_prefixmask.sin6_addr, - sizeof(ifra.ifra_prefixmask.sin6_addr)); + sizeof(ifra.ifra_prefixmask.sin6_addr)); /* * lifetime. * XXX: in6_init_address_ltimes would override these values later. - * We should reconsider this logic. + * We should reconsider this logic. */ ifra.ifra_lifetime.ia6t_vltime = pr->ndpr_vltime; ifra.ifra_lifetime.ia6t_pltime = pr->ndpr_pltime; @@ -1731,7 +1708,7 @@ in6_ifadd(pr, ifid) ia = in6ifa_ifpwithaddr(ifp, &ifra.ifra_addr.sin6_addr); - return (ia); /* this must NOT be NULL. */ + return (ia); /* this is always non-NULL */ } int @@ -1754,18 +1731,17 @@ in6_tmpifadd(ia0, forcegen) ifra.ifra_prefixmask = ia0->ia_prefixmask; /* clear the old IFID */ for (i = 0; i < 4; i++) { - ifra.ifra_addr.sin6_addr.s6_addr32[i] - &= ifra.ifra_prefixmask.sin6_addr.s6_addr32[i]; + ifra.ifra_addr.sin6_addr.s6_addr32[i] &= + ifra.ifra_prefixmask.sin6_addr.s6_addr32[i]; } again: in6_get_tmpifid(ifp, (u_int8_t *)randid, - (const u_int8_t *)&ia0->ia_addr.sin6_addr.s6_addr[8], - forcegen); - ifra.ifra_addr.sin6_addr.s6_addr32[2] - |= (randid[0] & ~(ifra.ifra_prefixmask.sin6_addr.s6_addr32[2])); - ifra.ifra_addr.sin6_addr.s6_addr32[3] - |= (randid[1] & ~(ifra.ifra_prefixmask.sin6_addr.s6_addr32[3])); + (const u_int8_t *)&ia0->ia_addr.sin6_addr.s6_addr[8], forcegen); + ifra.ifra_addr.sin6_addr.s6_addr32[2] |= + (randid[0] & ~(ifra.ifra_prefixmask.sin6_addr.s6_addr32[2])); + ifra.ifra_addr.sin6_addr.s6_addr32[3] |= + (randid[1] & ~(ifra.ifra_prefixmask.sin6_addr.s6_addr32[3])); /* * If by chance the new temporary address is the same as an address @@ -1792,17 +1768,17 @@ in6_tmpifadd(ia0, forcegen) */ if (ia0->ia6_lifetime.ia6t_expire != 0) { vltime0 = IFA6_IS_INVALID(ia0) ? 0 : - (ia0->ia6_lifetime.ia6t_expire - time_second); + (ia0->ia6_lifetime.ia6t_expire - time_second); if (vltime0 > ip6_temp_valid_lifetime) vltime0 = ip6_temp_valid_lifetime; } else vltime0 = ip6_temp_valid_lifetime; if (ia0->ia6_lifetime.ia6t_preferred != 0) { pltime0 = IFA6_IS_DEPRECATED(ia0) ? 0 : - (ia0->ia6_lifetime.ia6t_preferred - time_second); + (ia0->ia6_lifetime.ia6t_preferred - time_second); if (pltime0 > ip6_temp_preferred_lifetime - ip6_desync_factor){ pltime0 = ip6_temp_preferred_lifetime - - ip6_desync_factor; + ip6_desync_factor; } } else pltime0 = ip6_temp_preferred_lifetime - ip6_desync_factor; @@ -1845,7 +1821,7 @@ in6_tmpifadd(ia0, forcegen) pfxlist_onlink_check(); return (0); -} +} int in6_init_prefix_ltimes(struct nd_prefix *ndpr) @@ -1928,8 +1904,9 @@ rt6_deleteroute(rn, arg) if (rt->rt_gateway == NULL || rt->rt_gateway->sa_family != AF_INET6) return (0); - if (!IN6_ARE_ADDR_EQUAL(gate, &SIN6(rt->rt_gateway)->sin6_addr)) + if (!IN6_ARE_ADDR_EQUAL(gate, &SIN6(rt->rt_gateway)->sin6_addr)) { return (0); + } /* * Do not delete a static route. @@ -1946,8 +1923,8 @@ rt6_deleteroute(rn, arg) if ((rt->rt_flags & RTF_HOST) == 0) return (0); - return (rtrequest(RTM_DELETE, rt_key(rt), - rt->rt_gateway, rt_mask(rt), rt->rt_flags, 0)); + return (rtrequest(RTM_DELETE, rt_key(rt), rt->rt_gateway, + rt_mask(rt), rt->rt_flags, 0)); #undef SIN6 } diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index 1a8f6a5..a4bd1c3 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -323,9 +323,9 @@ rip6_output(m, va_alist) va_dcl #endif { + struct mbuf *control; struct socket *so; struct sockaddr_in6 *dstsock; - struct mbuf *control; struct in6_addr *dst; struct ip6_hdr *ip6; struct inpcb *in6p; @@ -403,13 +403,13 @@ rip6_output(m, va_alist) ip6->ip6_dst.s6_addr16[1] = htons(oifp->if_index); } else if (dstsock->sin6_scope_id) { /* boundary check */ - if (dstsock->sin6_scope_id < 0 - || if_index < dstsock->sin6_scope_id) { + if (dstsock->sin6_scope_id < 0 || + if_index < dstsock->sin6_scope_id) { error = ENXIO; /* XXX EINVAL? */ goto bad; } - ip6->ip6_dst.s6_addr16[1] - = htons(dstsock->sin6_scope_id & 0xffff);/*XXX*/ + ip6->ip6_dst.s6_addr16[1] = + htons(dstsock->sin6_scope_id & 0xffff); /* XXX */ } } @@ -419,11 +419,8 @@ rip6_output(m, va_alist) { struct in6_addr *in6a; - if ((in6a = in6_selectsrc(dstsock, optp, - in6p->in6p_moptions, - &in6p->in6p_route, - &in6p->in6p_laddr, - &error)) == 0) { + if ((in6a = in6_selectsrc(dstsock, optp, in6p->in6p_moptions, + &in6p->in6p_route, &in6p->in6p_laddr, &error)) == 0) { if (error == 0) error = EADDRNOTAVAIL; goto bad; @@ -632,7 +629,6 @@ rip6_bind(struct socket *so, struct sockaddr *nam, struct thread *td) if (nam->sa_len != sizeof(*addr)) return EINVAL; - if (TAILQ_EMPTY(&ifnet) || addr->sin6_family != AF_INET6) return EADDRNOTAVAIL; #ifdef ENABLE_DEFAULT_SCOPE diff --git a/sys/netinet6/scope6.c b/sys/netinet6/scope6.c index d38ac44..1e6c135 100644 --- a/sys/netinet6/scope6.c +++ b/sys/netinet6/scope6.c @@ -4,7 +4,7 @@ /* * Copyright (C) 2000 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -16,7 +16,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -125,7 +125,7 @@ scope6_set(ifp, idlist) /* * TODO(XXX): after setting, we should reflect the changes to - * interface addresses, routing table entries, PCB entries... + * interface addresses, routing table entries, PCB entries... */ s = splnet(); @@ -178,7 +178,7 @@ scope6_get(ifp, idlist) */ int in6_addrscope(addr) -struct in6_addr *addr; + struct in6_addr *addr; { int scope; @@ -277,9 +277,9 @@ scope6_setdefault(ifp) if (ifp) { scope6_ids[0].s6id_list[IPV6_ADDR_SCOPE_LINKLOCAL] = ifp->if_index; - } - else + } else { scope6_ids[0].s6id_list[IPV6_ADDR_SCOPE_LINKLOCAL] = 0; + } } int diff --git a/sys/netinet6/scope6_var.h b/sys/netinet6/scope6_var.h index 6e107d7..b4eda9c 100644 --- a/sys/netinet6/scope6_var.h +++ b/sys/netinet6/scope6_var.h @@ -4,7 +4,7 @@ /* * Copyright (C) 2000 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -16,7 +16,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index 3bb2f9f..8a78fb4 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -286,7 +286,7 @@ udp6_input(mp, offp, proto) || last->in6p_socket->so_options & SO_TIMESTAMP) ip6_savecontrol(last, &opts, ip6, n); - + m_adj(n, off + sizeof(struct udphdr)); if (sbappendaddr(&last->in6p_socket->so_rcv, (struct sockaddr *)&udp_in6, |