Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[IPV6]: Define constants for link-local multicast addresses.

- 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>

+24 -48
+8
include/linux/in6.h
··· 48 48 #define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } } 49 49 extern const struct in6_addr in6addr_loopback; 50 50 #define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } } 51 + #ifdef __KERNEL__ 52 + extern const struct in6_addr in6addr_linklocal_allnodes; 53 + #define IN6ADDR_LINKLOCAL_ALLNODES_INIT \ 54 + { { { 0xff,2,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } } 55 + extern const struct in6_addr in6addr_linklocal_allrouters; 56 + #define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \ 57 + { { { 0xff,2,0,0,0,0,0,0,0,0,0,0,0,0,0,2 } } } 58 + #endif 51 59 52 60 struct sockaddr_in6 { 53 61 unsigned short int sin6_family; /* AF_INET6 */
-11
include/net/addrconf.h
··· 205 205 htonl(0xFF000000) | addr->s6_addr32[3]); 206 206 } 207 207 208 - 209 - static inline void ipv6_addr_all_nodes(struct in6_addr *addr) 210 - { 211 - ipv6_addr_set(addr, htonl(0xFF020000), 0, 0, htonl(0x1)); 212 - } 213 - 214 - static inline void ipv6_addr_all_routers(struct in6_addr *addr) 215 - { 216 - ipv6_addr_set(addr, htonl(0xFF020000), 0, 0, htonl(0x2)); 217 - } 218 - 219 208 static inline int ipv6_addr_is_multicast(const struct in6_addr *addr) 220 209 { 221 210 return (addr->s6_addr32[0] & htonl(0xFF000000)) == htonl(0xFF000000);
+7 -18
net/ipv6/addrconf.c
··· 222 222 /* IPv6 Wildcard Address and Loopback Address defined by RFC2553 */ 223 223 const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT; 224 224 const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT; 225 + const struct in6_addr in6addr_linklocal_allnodes = IN6ADDR_LINKLOCAL_ALLNODES_INIT; 226 + const struct in6_addr in6addr_linklocal_allrouters = IN6ADDR_LINKLOCAL_ALLROUTERS_INIT; 225 227 226 228 /* Check if a valid qdisc is available */ 227 229 static inline int addrconf_qdisc_ok(struct net_device *dev) ··· 323 321 static struct inet6_dev * ipv6_add_dev(struct net_device *dev) 324 322 { 325 323 struct inet6_dev *ndev; 326 - struct in6_addr maddr; 327 324 328 325 ASSERT_RTNL(); 329 326 ··· 407 406 rcu_assign_pointer(dev->ip6_ptr, ndev); 408 407 409 408 /* Join all-node multicast group */ 410 - ipv6_addr_all_nodes(&maddr); 411 - ipv6_dev_mc_inc(dev, &maddr); 409 + ipv6_dev_mc_inc(dev, &in6addr_linklocal_allnodes); 412 410 413 411 return ndev; 414 412 } ··· 433 433 { 434 434 struct net_device *dev; 435 435 struct inet6_ifaddr *ifa; 436 - struct in6_addr addr; 437 436 438 437 if (!idev) 439 438 return; 440 439 dev = idev->dev; 441 440 if (dev && (dev->flags & IFF_MULTICAST)) { 442 - ipv6_addr_all_routers(&addr); 443 - 444 441 if (idev->cnf.forwarding) 445 - ipv6_dev_mc_inc(dev, &addr); 442 + ipv6_dev_mc_inc(dev, &in6addr_linklocal_allrouters); 446 443 else 447 - ipv6_dev_mc_dec(dev, &addr); 444 + ipv6_dev_mc_dec(dev, &in6addr_linklocal_allrouters); 448 445 } 449 446 for (ifa=idev->addr_list; ifa; ifa=ifa->if_next) { 450 447 if (ifa->flags&IFA_F_TENTATIVE) ··· 2651 2654 2652 2655 spin_lock(&ifp->lock); 2653 2656 if (ifp->probes++ < ifp->idev->cnf.rtr_solicits) { 2654 - struct in6_addr all_routers; 2655 - 2656 2657 /* The wait after the last probe can be shorter */ 2657 2658 addrconf_mod_timer(ifp, AC_RS, 2658 2659 (ifp->probes == ifp->idev->cnf.rtr_solicits) ? ··· 2658 2663 ifp->idev->cnf.rtr_solicit_interval); 2659 2664 spin_unlock(&ifp->lock); 2660 2665 2661 - ipv6_addr_all_routers(&all_routers); 2662 - 2663 - ndisc_send_rs(ifp->idev->dev, &ifp->addr, &all_routers); 2666 + ndisc_send_rs(ifp->idev->dev, &ifp->addr, &in6addr_linklocal_allrouters); 2664 2667 } else { 2665 2668 spin_unlock(&ifp->lock); 2666 2669 /* ··· 2799 2806 ifp->idev->cnf.rtr_solicits > 0 && 2800 2807 (dev->flags&IFF_LOOPBACK) == 0 && 2801 2808 (ipv6_addr_type(&ifp->addr) & IPV6_ADDR_LINKLOCAL)) { 2802 - struct in6_addr all_routers; 2803 - 2804 - ipv6_addr_all_routers(&all_routers); 2805 - 2806 2809 /* 2807 2810 * If a host as already performed a random delay 2808 2811 * [...] as part of DAD [...] there is no need 2809 2812 * to delay again before sending the first RS 2810 2813 */ 2811 - ndisc_send_rs(ifp->idev->dev, &ifp->addr, &all_routers); 2814 + ndisc_send_rs(ifp->idev->dev, &ifp->addr, &in6addr_linklocal_allrouters); 2812 2815 2813 2816 spin_lock_bh(&ifp->lock); 2814 2817 ifp->probes = 1;
+8 -15
net/ipv6/mcast.c
··· 1766 1766 struct inet6_dev *idev; 1767 1767 struct sk_buff *skb; 1768 1768 struct icmp6hdr *hdr; 1769 - struct in6_addr *snd_addr; 1769 + const struct in6_addr *snd_addr; 1770 1770 struct in6_addr *addrp; 1771 1771 struct in6_addr addr_buf; 1772 - struct in6_addr all_routers; 1773 1772 int err, len, payload_len, full_len; 1774 1773 u8 ra[8] = { IPPROTO_ICMPV6, 0, 1775 1774 IPV6_TLV_ROUTERALERT, 2, 0, 0, ··· 1779 1780 IP6_INC_STATS(__in6_dev_get(dev), 1780 1781 IPSTATS_MIB_OUTREQUESTS); 1781 1782 rcu_read_unlock(); 1782 - snd_addr = addr; 1783 - if (type == ICMPV6_MGM_REDUCTION) { 1784 - snd_addr = &all_routers; 1785 - ipv6_addr_all_routers(&all_routers); 1786 - } 1783 + if (type == ICMPV6_MGM_REDUCTION) 1784 + snd_addr = &in6addr_linklocal_allrouters; 1785 + else 1786 + snd_addr = addr; 1787 1787 1788 1788 len = sizeof(struct icmp6hdr) + sizeof(struct in6_addr); 1789 1789 payload_len = len + sizeof(ra); ··· 2307 2309 void ipv6_mc_destroy_dev(struct inet6_dev *idev) 2308 2310 { 2309 2311 struct ifmcaddr6 *i; 2310 - struct in6_addr maddr; 2311 2312 2312 2313 /* Deactivate timers */ 2313 2314 ipv6_mc_down(idev); 2314 2315 2315 2316 /* Delete all-nodes address. */ 2316 - ipv6_addr_all_nodes(&maddr); 2317 - 2318 2317 /* We cannot call ipv6_dev_mc_dec() directly, our caller in 2319 2318 * addrconf.c has NULL'd out dev->ip6_ptr so in6_dev_get() will 2320 2319 * fail. 2321 2320 */ 2322 - __ipv6_dev_mc_dec(idev, &maddr); 2321 + __ipv6_dev_mc_dec(idev, &in6addr_linklocal_allnodes); 2323 2322 2324 - if (idev->cnf.forwarding) { 2325 - ipv6_addr_all_routers(&maddr); 2326 - __ipv6_dev_mc_dec(idev, &maddr); 2327 - } 2323 + if (idev->cnf.forwarding) 2324 + __ipv6_dev_mc_dec(idev, &in6addr_linklocal_allrouters); 2328 2325 2329 2326 write_lock_bh(&idev->lock); 2330 2327 while ((i = idev->mc_list) != NULL) {
+1 -4
net/ipv6/ndisc.c
··· 818 818 is_router = !!idev->cnf.forwarding; 819 819 820 820 if (dad) { 821 - struct in6_addr maddr; 822 - 823 - ipv6_addr_all_nodes(&maddr); 824 - ndisc_send_na(dev, NULL, &maddr, &msg->target, 821 + ndisc_send_na(dev, NULL, &in6addr_linklocal_allnodes, &msg->target, 825 822 is_router, 0, (ifp != NULL), 1); 826 823 goto out; 827 824 }