inet6: Cosmetic clean up
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 8 Aug 2015 15:40:04 +0000 (23:40 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 9 Aug 2015 11:08:41 +0000 (19:08 +0800)
No functional changes.

Obtained-from: KAME via FreeBSD

sys/netinet6/mld6.c
sys/netinet6/mld6_var.h
sys/netinet6/nd6.c
sys/netinet6/nd6.h
sys/netinet6/nd6_nbr.c
sys/netinet6/nd6_rtr.c
sys/netinet6/raw_ip6.c

index 2944ad7..da6f72d 100644 (file)
@@ -105,7 +105,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 (struct in6_multi *, int, const struct in6_addr *);
+static void mld6_sendpkt(struct in6_multi *, int, const struct in6_addr *);
 
 static struct lwkt_token mld6_token = LWKT_TOKEN_INITIALIZER(mp_token);
 
@@ -200,7 +200,7 @@ mld6_input(struct mbuf *m, int off)
 
        lwkt_gettoken(&mld6_token);
        /* 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)) {
 #if 0
                log(LOG_ERR,
@@ -262,7 +262,8 @@ mld6_input(struct mbuf *m, int 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] =
@@ -287,6 +288,7 @@ mld6_input(struct mbuf *m, int off)
                        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) <
@@ -325,6 +327,7 @@ mld6_input(struct mbuf *m, int 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
@@ -377,6 +380,7 @@ mld6_fasttimeo(void)
         * to minimize the overhead of fasttimo processing.
         */
        lwkt_gettoken(&mld6_token);
+
        if (!mld6_timers_are_running) {
                lwkt_reltoken(&mld6_token);
                return;
@@ -395,6 +399,7 @@ mld6_fasttimeo(void)
                }
                IN6_NEXT_MULTI(step, in6m);
        }
+
        lwkt_reltoken(&mld6_token);
 }
 
@@ -460,9 +465,8 @@ mld6_sendpkt(struct in6_multi *in6m, int type, const struct in6_addr *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));
index d4d1ce2..e3bbaa2 100644 (file)
 struct mbuf;
 struct in6_multi;
 
-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);
+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 */
 
index addfd46..eb2d350 100644 (file)
  * 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"
 
@@ -856,8 +848,9 @@ nd6_lookup(struct in6_addr *addr6, int create, struct ifnet *ifp)
                         * This hack is necessary for a neighbor which can't
                         * be covered by our own prefix.
                         */
-                       struct ifaddr *ifa =
-                               ifaof_ifpforaddr((struct sockaddr *)&sin6, ifp);
+                       struct ifaddr *ifa;
+
+                       ifa = ifaof_ifpforaddr((struct sockaddr *)&sin6, ifp);
                        if (ifa == NULL)
                                return (NULL);
 
@@ -868,21 +861,20 @@ nd6_lookup(struct in6_addr *addr6, int create, struct ifnet *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
@@ -905,7 +897,8 @@ nd6_lookup(struct in6_addr *addr6, int create, struct ifnet *ifp)
            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",
+                       log(LOG_DEBUG,
+                           "nd6_lookup: failed to lookup %s (if = %s)\n",
                            ip6_sprintf(addr6), ifp ? if_name(ifp) : "unspec");
                        /* xxx more logs... kazu */
                }
@@ -984,8 +977,9 @@ nd6_free(struct rtentry *rt)
 
        if (!ip6_forwarding && ip6_accept_rtadv) { /* XXX: too restrictive? */
                mtx_lock(&nd6_mtx);
-               dr = defrouter_lookup(&((struct sockaddr_in6 *)rt_key(rt))->sin6_addr,
-                                     rt->rt_ifp);
+               dr = defrouter_lookup(
+                   &((struct sockaddr_in6 *)rt_key(rt))->sin6_addr,
+                   rt->rt_ifp);
 
                if (ln->ln_router || dr) {
                        /*
@@ -1172,16 +1166,10 @@ nd6_rtrequest(int req, struct rtentry *rt)
                        SDL(gate)->sdl_index = ifp->if_index;
                        if (ln)
                                ln->ln_expire = time_uptime;
-#if 1
                        if (ln && ln->ln_expire == 0) {
                                /* kludge for desktops */
-#if 0
-                               kprintf("nd6_rtequest: time.tv_sec is zero; "
-                                      "treat it as 1\n");
-#endif
                                ln->ln_expire = 1;
                        }
-#endif
                        if ((rt->rt_flags & RTF_CLONING))
                                break;
                }
@@ -1273,7 +1261,7 @@ nd6_rtrequest(int req, struct rtentry *rt)
                 * 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;
@@ -1483,7 +1471,7 @@ nd6_ioctl(u_long cmd, caddr_t     data, struct ifnet *ifp)
                /* xxx sumikawa: flush prefix list */
                break;
        case SIOCSPFXFLUSH_IN6:
-           {
+       {
                /* flush all the prefix advertised by routers */
                struct nd_prefix *pr, *next;
 
@@ -1511,9 +1499,9 @@ nd6_ioctl(u_long cmd, caddr_t     data, struct ifnet *ifp)
                }
                mtx_unlock(&nd6_mtx);
                break;
-           }
+       }
        case SIOCSRTRFLUSH_IN6:
-           {
+       {
                /* flush all the default routers */
                struct nd_defrouter *dr, *next;
 
@@ -1531,9 +1519,9 @@ nd6_ioctl(u_long cmd, caddr_t     data, struct ifnet *ifp)
                }
                mtx_unlock(&nd6_mtx);
                break;
-           }
+       }
        case SIOCGNBRINFO_IN6:
-           {
+       {
                struct llinfo_nd6 *ln;
                struct in6_addr nb_addr = nbi->addr; /* make local for safety */
 
@@ -1563,20 +1551,19 @@ nd6_ioctl(u_long cmd, caddr_t   data, struct ifnet *ifp)
                mtx_unlock(&nd6_mtx);
 
                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(struct ifnet *ifp, struct in6_addr *from, char *lladdr,
@@ -1675,12 +1662,13 @@ 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) */
+               } else {                                /* (1-2,4) */
                        do_update = 0;
+               }
        } else {
                do_update = 1;
                if (!lladdr)                            /* (6) */
@@ -1710,8 +1698,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) {
@@ -1760,8 +1747,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;
@@ -1778,8 +1765,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;
@@ -2129,8 +2116,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));
@@ -2200,11 +2186,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;
                                }
@@ -2213,7 +2197,7 @@ nd6_sysctl_prlist(SYSCTL_HANDLER_ARGS)
                                s6->sin6_family = AF_INET6;
                                s6->sin6_len = sizeof(*sin6);
                                if (in6_recoverscope(s6, &pfr->router->rtaddr,
-                                                    pfr->router->ifp) != 0)
+                                   pfr->router->ifp) != 0)
                                        log(LOG_ERR,
                                            "scope error in "
                                            "prefix list (%s)\n",
@@ -2221,8 +2205,9 @@ nd6_sysctl_prlist(SYSCTL_HANDLER_ARGS)
                                advrtrs++;
                        }
                        p->advrtrs = advrtrs;
-               } else
+               } else {
                        panic("buffer too short");
+               }
 
                advance = sizeof(*p) + sizeof(*sin6) * advrtrs;
                error = SYSCTL_OUT(req, buf, advance);
index 2d97f83..564cb76 100644 (file)
@@ -383,16 +383,16 @@ void nd6_setmtu (struct ifnet *);
 void nd6_purge (struct ifnet *);
 struct llinfo_nd6 *nd6_free (struct rtentry *);
 void nd6_nud_hint (struct rtentry *, struct in6_addr *, int);
-int nd6_resolve (struct ifnet *, struct rtentry *,
-                    struct mbuf *, struct sockaddr *, u_char *);
+int nd6_resolve(struct ifnet *, struct rtentry *,
+       struct mbuf *, struct sockaddr *, u_char *);
 void nd6_rtrequest (int, struct rtentry *);
 int nd6_ioctl (u_long, caddr_t, struct ifnet *);
 struct rtentry *nd6_cache_lladdr (struct ifnet *, struct in6_addr *,
        char *, int, int, int);
-int nd6_output (struct ifnet *, struct ifnet *, struct mbuf *,
-                   struct sockaddr_in6 *, struct rtentry *);
-int nd6_storelladdr (struct ifnet *, struct rtentry *, struct mbuf *,
-                        struct sockaddr *, u_char *);
+int nd6_output(struct ifnet *, struct ifnet *, struct mbuf *,
+       struct sockaddr_in6 *, struct rtentry *);
+int nd6_storelladdr(struct ifnet *, struct rtentry *, struct mbuf *,
+       struct sockaddr *, u_char *);
 int nd6_need_cache (struct ifnet *);
 
 /* nd6_nbr.c */
@@ -415,17 +415,16 @@ void defrouter_delreq (struct nd_defrouter *, int);
 void defrouter_select (void);
 void defrtrlist_del (struct nd_defrouter *);
 void prelist_remove (struct nd_prefix *);
-int prelist_update (struct nd_prefix *, struct nd_defrouter *,
-                       struct mbuf *);
-int nd6_prelist_add (struct nd_prefix *, struct nd_defrouter *,
-                        struct nd_prefix **);
+int prelist_update(struct nd_prefix *, struct nd_defrouter *,
+       struct mbuf *);
+int nd6_prelist_add(struct nd_prefix *, struct nd_defrouter *,
+       struct nd_prefix **);
 int nd6_prefix_onlink (struct nd_prefix *);
 int nd6_prefix_offlink (struct nd_prefix *);
 void pfxlist_onlink_check (void);
-struct nd_defrouter *defrouter_lookup (struct in6_addr *,
-                                          struct ifnet *);
+struct nd_defrouter *defrouter_lookup(struct in6_addr *, struct ifnet *);
 struct nd_prefix *nd6_prefix_lookup (struct nd_prefix *);
-int in6_init_prefix_ltimes (struct nd_prefix *ndpr);
+int in6_init_prefix_ltimes (struct nd_prefix *);
 void rt6_flush (struct in6_addr *, struct ifnet *);
 int nd6_setdefaultiface (int);
 int in6_tmpifadd (const struct in6_ifaddr *, int);
index eba527d..09c0211 100644 (file)
@@ -155,15 +155,15 @@ nd6_ns_input(struct mbuf *m, int off, int 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;
                }
        } else if (!nd6_onlink_ns_rfc4861) {
@@ -328,17 +328,15 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len)
                goto freeit;
 
        if (lladdr && ((cmpifp->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), cmpifp->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;
        }
 
@@ -380,21 +378,19 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len)
                saddr6 = kin6addr_linklocal_allnodes;
                saddr6.s6_addr16[1] = htons(cmpifp->if_index);
                nd6_na_output(cmpifp, &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(cmpifp, &saddr6, lladdr,
-                        lladdrlen, ND_NEIGHBOR_SOLICIT, 0);
+       nd6_cache_lladdr(cmpifp, &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;
@@ -480,20 +476,6 @@ nd6_ns_output(struct ifnet *ifp, const struct in6_addr *daddr6,
                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
@@ -531,7 +513,6 @@ nd6_ns_output(struct ifnet *ifp, const struct in6_addr *daddr6,
                        }
                        ip6->ip6_src = ia->ia_addr.sin6_addr;
                }
-#endif
        } else {
                /*
                 * Source address for DAD packet must always be IPv6
@@ -577,8 +558,8 @@ nd6_ns_output(struct ifnet *ifp, const struct in6_addr *daddr6,
 
        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) {
@@ -708,10 +689,9 @@ nd6_na_input(struct mbuf *m, int off, int 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;
        }
 
@@ -740,9 +720,10 @@ nd6_na_input(struct mbuf *m, int off, int 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_uptime +
                                    ND_IFINFO(rt->rt_ifp)->reachable;
+                       }
                } else {
                        ln->ln_state = ND6_LLINFO_STALE;
                        ln->ln_expire = time_uptime + nd6_gctimer;
@@ -878,7 +859,7 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
                 */
                nd6_output(ifp, ifp, ln->ln_hold,
                           (struct sockaddr_in6 *)rt_key(rt), rt);
-               ln->ln_hold = 0;
+               ln->ln_hold = NULL;
        }
 
 freeit:
@@ -1025,7 +1006,7 @@ nd6_na_output(struct ifnet *ifp, const struct in6_addr *daddr6,
        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) {
@@ -1051,7 +1032,6 @@ nd6_ifptomac(struct ifnet *ifp)
        case IFT_CARP:
 #endif
                return ((caddr_t)(ifp + 1));
-               break;
        default:
                return NULL;
        }
@@ -1286,7 +1266,7 @@ nd6_dad_timer_handler(netmsg_t msg)
        /* Timed out 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)));
                goto destroy;
        }
 
@@ -1297,7 +1277,7 @@ nd6_dad_timer_handler(netmsg_t msg)
                 */
                nd6_dad_ns_output(dp);
                nd6_dad_starttimer(dp,
-                       ND_IFINFO(ifa->ifa_ifp)->retrans * hz / 1000);
+                   ND_IFINFO(ifa->ifa_ifp)->retrans * hz / 1000);
        } else {
                /*
                 * We have transmitted sufficient number of DAD packets.
@@ -1330,9 +1310,9 @@ nd6_dad_timer_handler(netmsg_t msg)
                         && 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 {
index 43dad65..f8dbba4 100644 (file)
@@ -80,8 +80,8 @@ static struct nd_pfxrouter *find_pfxlist_reachable_router
        (struct nd_prefix *);
 static void defrouter_addifreq (struct ifnet *);
 
-static void in6_init_address_ltimes (struct nd_prefix *ndpr,
-                                        struct in6_addrlifetime *lt6);
+static void in6_init_address_ltimes(struct nd_prefix *ndpr,
+       struct in6_addrlifetime *lt6);
 
 static int rt6_deleteroute (struct radix_node *, void *);
 
@@ -116,9 +116,6 @@ nd6_rs_input(struct mbuf *m, int off, int 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
@@ -178,7 +175,7 @@ nd6_rs_input(struct mbuf *m, int off, int 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;
        }
 
@@ -339,17 +336,14 @@ nd6_ra_input(struct mbuf *m, int off, int 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 */
-
                        prelist_update(&pr, dr, m);
                }
        }
@@ -409,7 +403,7 @@ skip:
                nd6log((LOG_INFO,
                    "nd6_ra_input: lladdrlen mismatch for %s "
                    "(if %d, RA packet %d)\n",
-                       ip6_sprintf(&saddr6), ifp->if_addrlen, lladdrlen - 2));
+                   ip6_sprintf(&saddr6), ifp->if_addrlen, lladdrlen - 2));
                goto bad;
        }
 
@@ -469,14 +463,13 @@ defrouter_addreq(struct nd_defrouter *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;
 
        rtrequest_global(RTM_ADD, (struct sockaddr *)&def,
-                        (struct sockaddr *)&gate, (struct sockaddr *)&mask,
-                        RTF_GATEWAY);
+           (struct sockaddr *)&gate, (struct sockaddr *)&mask, RTF_GATEWAY);
        return;
 }
 
@@ -507,11 +500,8 @@ defrouter_addifreq(struct ifnet *ifp)
        }
 
        flags = ifa->ifa_flags;
-       error = rtrequest_global(RTM_ADD,
-                                (struct sockaddr *)&def,
-                                ifa->ifa_addr,
-                                (struct sockaddr *)&mask,
-                                flags);
+       error = rtrequest_global(RTM_ADD, (struct sockaddr *)&def,
+           ifa->ifa_addr, (struct sockaddr *)&mask, flags);
        if (error != 0) {
                nd6log((LOG_ERR,
                    "defrouter_addifreq: failed to install a route to "
@@ -543,16 +533,13 @@ defrouter_delreq(struct nd_defrouter *dr, int 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_global(RTM_DELETE,
-                        (struct sockaddr *)&def,
-                        (struct sockaddr *)&gate,
-                        (struct sockaddr *)&mask,
-                        RTF_GATEWAY);
+       rtrequest_global(RTM_DELETE, (struct sockaddr *)&def,
+           (struct sockaddr *)&gate, (struct sockaddr *)&mask, RTF_GATEWAY);
        if (dofree)             /* XXX: necessary? */
                kfree(dr, M_IP6NDP);
 }
@@ -567,10 +554,8 @@ defrtrlist_del(struct nd_defrouter *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. */
@@ -770,11 +755,8 @@ nd6_prefix_lookup(struct nd_prefix *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;
-               }
        }
 
        return (search);
@@ -792,13 +774,14 @@ nd6_prelist_add(struct nd_prefix *pr, struct nd_defrouter *dr,
        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++)
+       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];
+       }
 
        mtx_lock(&nd6_mtx);
        /* link ndpr_entry to nd_prefix list */
@@ -818,9 +801,8 @@ nd6_prelist_add(struct nd_prefix *pr, struct nd_defrouter *dr,
                }
        }
 
-       if (dr) {
+       if (dr)
                pfxrtr_add(new, dr);
-       }
 
        return 0;
 }
@@ -895,12 +877,11 @@ prelist_update(struct nd_prefix *new, struct nd_defrouter *dr, struct mbuf *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
@@ -956,8 +937,8 @@ prelist_update(struct nd_prefix *new, struct nd_defrouter *dr, struct mbuf *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. */
                }
 
@@ -965,7 +946,7 @@ prelist_update(struct nd_prefix *new, struct nd_defrouter *dr, struct mbuf *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) {
@@ -1024,8 +1005,7 @@ prelist_update(struct nd_prefix *new, struct nd_defrouter *dr, struct mbuf *m)
                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 */
@@ -1093,13 +1073,13 @@ prelist_update(struct nd_prefix *new, struct nd_defrouter *dr, struct mbuf *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;
                        }
                }
 
@@ -1117,11 +1097,6 @@ prelist_update(struct nd_prefix *new, struct nd_defrouter *dr, struct mbuf *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
@@ -1178,14 +1153,13 @@ find_pfxlist_reachable_router(struct nd_prefix *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);
-
 }
 
 /*
@@ -1377,8 +1351,7 @@ nd6_prefix_onlink(struct nd_prefix *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);
        }
 
@@ -1387,8 +1360,7 @@ nd6_prefix_onlink(struct nd_prefix *pr)
         */
        /* 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) {
                struct ifaddr_container *ifac;
 
@@ -1433,15 +1405,11 @@ nd6_prefix_onlink(struct nd_prefix *pr)
                 */
                rtflags &= ~RTF_CLONING;
        }
-       error = rtrequest_global(RTM_ADD,
-                                (struct sockaddr *)&pr->ndpr_prefix,
-                                ifa->ifa_addr,
-                                (struct sockaddr *)&mask6,
-                                rtflags);
+       error = rtrequest_global(RTM_ADD, (struct sockaddr *)&pr->ndpr_prefix,
+           ifa->ifa_addr, (struct sockaddr *)&mask6, rtflags);
        if (error == 0) {
                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",
@@ -1473,16 +1441,13 @@ nd6_prefix_offlink(struct nd_prefix *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_global(RTM_DELETE,
-                                (struct sockaddr *)&sa6,
-                                NULL,
-                                (struct sockaddr *)&mask6,
-                                0);
+       error = rtrequest_global(RTM_DELETE, (struct sockaddr *)&sa6, NULL,
+           (struct sockaddr *)&mask6, 0);
        if (error == 0) {
                pr->ndpr_stateflags &= ~NDPRF_ONLINK;
 
@@ -1509,8 +1474,7 @@ nd6_prefix_offlink(struct nd_prefix *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) {
@@ -1524,8 +1488,7 @@ nd6_prefix_offlink(struct nd_prefix *pr)
                                }
                        }
                }
-       }
-       else {
+       } else {
                /* XXX: can we still set the NDPRF_ONLINK flag? */
                nd6log((LOG_ERR,
                    "nd6_prefix_offlink: failed to delete route: "
@@ -1578,7 +1541,7 @@ in6_ifadd(struct nd_prefix *pr, struct in6_addr *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
@@ -1613,7 +1576,7 @@ in6_ifadd(struct nd_prefix *pr, struct in6_addr *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];
@@ -1622,20 +1585,20 @@ in6_ifadd(struct nd_prefix *pr, struct in6_addr *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.
@@ -1673,7 +1636,7 @@ in6_ifadd(struct nd_prefix *pr, struct in6_addr *ifid)
 
        ia = in6ifa_ifpwithaddr(ifp, &ifra.ifra_addr.sin6_addr);
 
-       return (ia);            /* this must NOT be NULL. */
+       return (ia);            /* this is always non-NULL */
 }
 
 /*
@@ -1698,18 +1661,17 @@ in6_tmpifadd(const struct in6_ifaddr *ia0, int 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
@@ -1735,18 +1697,18 @@ again:
          * DESYNC_FACTOR.
         */
        if (ia0->ia6_lifetime.ia6t_expire != 0) {
-               vltime0 = IFA6_IS_INVALID(ia0) ? 0 :
-                       (ia0->ia6_lifetime.ia6t_expire - time_uptime);
+               vltime0 = IFA6_IS_INVALID(ia0) ?
+                   0 : (ia0->ia6_lifetime.ia6t_expire - time_uptime);
                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_uptime);
+               pltime0 = IFA6_IS_DEPRECATED(ia0) ?
+                   0 : (ia0->ia6_lifetime.ia6t_preferred - time_uptime);
                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;
@@ -1871,8 +1833,8 @@ rt6_deleteroute(struct radix_node *rn, void *arg)
        if (!(rt->rt_flags & RTF_HOST))
                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
 }
 
index 5c5d4d5..fdfee29 100644 (file)
@@ -408,13 +408,13 @@ rip6_output(struct mbuf *m, struct socket *so, ...)
                        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 */
                }
        }
 
@@ -424,11 +424,9 @@ rip6_output(struct mbuf *m, struct socket *so, ...)
        {
                struct in6_addr *in6a;
 
-               if ((in6a = in6_selectsrc(dstsock, optp,
-                                         in6p->in6p_moptions,
-                                         &in6p->in6p_route,
-                                         &in6p->in6p_laddr,
-                                         &error, NULL)) == NULL) {
+               if ((in6a = in6_selectsrc(dstsock, optp, in6p->in6p_moptions,
+                   &in6p->in6p_route, &in6p->in6p_laddr, &error, NULL))
+                   == NULL) {
                        if (error == 0)
                                error = EADDRNOTAVAIL;
                        goto bad;
@@ -671,7 +669,6 @@ rip6_bind(netmsg_t msg)
                error = EINVAL;
                goto out;
        }
-
        if (ifnet_array_isempty() || addr->sin6_family != AF_INET6) {
                error = EADDRNOTAVAIL;
                goto out;