- Define link-local all-node / all-router multicast addresses.
- Remove ipv6_addr_all_nodes() and ipv6_addr_all_routers().
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
 #define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
 extern const struct in6_addr in6addr_loopback;
 #define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
+#ifdef __KERNEL__
+extern const struct in6_addr in6addr_linklocal_allnodes;
+#define IN6ADDR_LINKLOCAL_ALLNODES_INIT        \
+               { { { 0xff,2,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
+extern const struct in6_addr in6addr_linklocal_allrouters;
+#define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \
+               { { { 0xff,2,0,0,0,0,0,0,0,0,0,0,0,0,0,2 } } }
+#endif
 
 struct sockaddr_in6 {
        unsigned short int      sin6_family;    /* AF_INET6 */
 
                      htonl(0xFF000000) | addr->s6_addr32[3]);
 }
 
-
-static inline void ipv6_addr_all_nodes(struct in6_addr *addr)
-{
-       ipv6_addr_set(addr, htonl(0xFF020000), 0, 0, htonl(0x1));
-}
-
-static inline void ipv6_addr_all_routers(struct in6_addr *addr)
-{
-       ipv6_addr_set(addr, htonl(0xFF020000), 0, 0, htonl(0x2));
-}
-
 static inline int ipv6_addr_is_multicast(const struct in6_addr *addr)
 {
        return (addr->s6_addr32[0] & htonl(0xFF000000)) == htonl(0xFF000000);
 
 /* IPv6 Wildcard Address and Loopback Address defined by RFC2553 */
 const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
 const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
+const struct in6_addr in6addr_linklocal_allnodes = IN6ADDR_LINKLOCAL_ALLNODES_INIT;
+const struct in6_addr in6addr_linklocal_allrouters = IN6ADDR_LINKLOCAL_ALLROUTERS_INIT;
 
 /* Check if a valid qdisc is available */
 static inline int addrconf_qdisc_ok(struct net_device *dev)
 static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
 {
        struct inet6_dev *ndev;
-       struct in6_addr maddr;
 
        ASSERT_RTNL();
 
        rcu_assign_pointer(dev->ip6_ptr, ndev);
 
        /* Join all-node multicast group */
-       ipv6_addr_all_nodes(&maddr);
-       ipv6_dev_mc_inc(dev, &maddr);
+       ipv6_dev_mc_inc(dev, &in6addr_linklocal_allnodes);
 
        return ndev;
 }
 {
        struct net_device *dev;
        struct inet6_ifaddr *ifa;
-       struct in6_addr addr;
 
        if (!idev)
                return;
        dev = idev->dev;
        if (dev && (dev->flags & IFF_MULTICAST)) {
-               ipv6_addr_all_routers(&addr);
-
                if (idev->cnf.forwarding)
-                       ipv6_dev_mc_inc(dev, &addr);
+                       ipv6_dev_mc_inc(dev, &in6addr_linklocal_allrouters);
                else
-                       ipv6_dev_mc_dec(dev, &addr);
+                       ipv6_dev_mc_dec(dev, &in6addr_linklocal_allrouters);
        }
        for (ifa=idev->addr_list; ifa; ifa=ifa->if_next) {
                if (ifa->flags&IFA_F_TENTATIVE)
 
        spin_lock(&ifp->lock);
        if (ifp->probes++ < ifp->idev->cnf.rtr_solicits) {
-               struct in6_addr all_routers;
-
                /* The wait after the last probe can be shorter */
                addrconf_mod_timer(ifp, AC_RS,
                                   (ifp->probes == ifp->idev->cnf.rtr_solicits) ?
                                   ifp->idev->cnf.rtr_solicit_interval);
                spin_unlock(&ifp->lock);
 
-               ipv6_addr_all_routers(&all_routers);
-
-               ndisc_send_rs(ifp->idev->dev, &ifp->addr, &all_routers);
+               ndisc_send_rs(ifp->idev->dev, &ifp->addr, &in6addr_linklocal_allrouters);
        } else {
                spin_unlock(&ifp->lock);
                /*
            ifp->idev->cnf.rtr_solicits > 0 &&
            (dev->flags&IFF_LOOPBACK) == 0 &&
            (ipv6_addr_type(&ifp->addr) & IPV6_ADDR_LINKLOCAL)) {
-               struct in6_addr all_routers;
-
-               ipv6_addr_all_routers(&all_routers);
-
                /*
                 *      If a host as already performed a random delay
                 *      [...] as part of DAD [...] there is no need
                 *      to delay again before sending the first RS
                 */
-               ndisc_send_rs(ifp->idev->dev, &ifp->addr, &all_routers);
+               ndisc_send_rs(ifp->idev->dev, &ifp->addr, &in6addr_linklocal_allrouters);
 
                spin_lock_bh(&ifp->lock);
                ifp->probes = 1;
 
        struct inet6_dev *idev;
        struct sk_buff *skb;
        struct icmp6hdr *hdr;
-       struct in6_addr *snd_addr;
+       const struct in6_addr *snd_addr;
        struct in6_addr *addrp;
        struct in6_addr addr_buf;
-       struct in6_addr all_routers;
        int err, len, payload_len, full_len;
        u8 ra[8] = { IPPROTO_ICMPV6, 0,
                     IPV6_TLV_ROUTERALERT, 2, 0, 0,
        IP6_INC_STATS(__in6_dev_get(dev),
                      IPSTATS_MIB_OUTREQUESTS);
        rcu_read_unlock();
-       snd_addr = addr;
-       if (type == ICMPV6_MGM_REDUCTION) {
-               snd_addr = &all_routers;
-               ipv6_addr_all_routers(&all_routers);
-       }
+       if (type == ICMPV6_MGM_REDUCTION)
+               snd_addr = &in6addr_linklocal_allrouters;
+       else
+               snd_addr = addr;
 
        len = sizeof(struct icmp6hdr) + sizeof(struct in6_addr);
        payload_len = len + sizeof(ra);
 void ipv6_mc_destroy_dev(struct inet6_dev *idev)
 {
        struct ifmcaddr6 *i;
-       struct in6_addr maddr;
 
        /* Deactivate timers */
        ipv6_mc_down(idev);
 
        /* Delete all-nodes address. */
-       ipv6_addr_all_nodes(&maddr);
-
        /* We cannot call ipv6_dev_mc_dec() directly, our caller in
         * addrconf.c has NULL'd out dev->ip6_ptr so in6_dev_get() will
         * fail.
         */
-       __ipv6_dev_mc_dec(idev, &maddr);
+       __ipv6_dev_mc_dec(idev, &in6addr_linklocal_allnodes);
 
-       if (idev->cnf.forwarding) {
-               ipv6_addr_all_routers(&maddr);
-               __ipv6_dev_mc_dec(idev, &maddr);
-       }
+       if (idev->cnf.forwarding)
+               __ipv6_dev_mc_dec(idev, &in6addr_linklocal_allrouters);
 
        write_lock_bh(&idev->lock);
        while ((i = idev->mc_list) != NULL) {
 
                is_router = !!idev->cnf.forwarding;
 
        if (dad) {
-               struct in6_addr maddr;
-
-               ipv6_addr_all_nodes(&maddr);
-               ndisc_send_na(dev, NULL, &maddr, &msg->target,
+               ndisc_send_na(dev, NULL, &in6addr_linklocal_allnodes, &msg->target,
                              is_router, 0, (ifp != NULL), 1);
                goto out;
        }