addrconf.c (8e8e676d0b3c7f074c719c7c05b20296b9b0b0b1) addrconf.c (5f40ef77adb237954d615a76621df1b80a329b31)
1/*
2 * IPv6 Address [auto]configuration
3 * Linux INET6 implementation
4 *
5 * Authors:
6 * Pedro Roque <roque@di.fc.ul.pt>
7 * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
8 *

--- 1696 unchanged lines hidden (view full) ---

1705 }
1706 spin_unlock_bh(&ifp->lock);
1707
1708 return err;
1709}
1710
1711void addrconf_dad_failure(struct inet6_ifaddr *ifp)
1712{
1/*
2 * IPv6 Address [auto]configuration
3 * Linux INET6 implementation
4 *
5 * Authors:
6 * Pedro Roque <roque@di.fc.ul.pt>
7 * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
8 *

--- 1696 unchanged lines hidden (view full) ---

1705 }
1706 spin_unlock_bh(&ifp->lock);
1707
1708 return err;
1709}
1710
1711void addrconf_dad_failure(struct inet6_ifaddr *ifp)
1712{
1713 struct in6_addr addr;
1713 struct inet6_dev *idev = ifp->idev;
1714
1715 if (addrconf_dad_end(ifp)) {
1716 in6_ifa_put(ifp);
1717 return;
1718 }
1719
1720 net_info_ratelimited("%s: IPv6 duplicate address %pI6c detected!\n",
1721 ifp->idev->dev->name, &ifp->addr);
1722
1714 struct inet6_dev *idev = ifp->idev;
1715
1716 if (addrconf_dad_end(ifp)) {
1717 in6_ifa_put(ifp);
1718 return;
1719 }
1720
1721 net_info_ratelimited("%s: IPv6 duplicate address %pI6c detected!\n",
1722 ifp->idev->dev->name, &ifp->addr);
1723
1723 if (idev->cnf.accept_dad > 1 && !idev->cnf.disable_ipv6) {
1724 struct in6_addr addr;
1724 spin_lock_bh(&ifp->lock);
1725
1725
1726 if (ifp->flags & IFA_F_STABLE_PRIVACY) {
1727 int scope = ifp->scope;
1728 u32 flags = ifp->flags;
1729 struct in6_addr new_addr;
1730 struct inet6_ifaddr *ifp2;
1731 u32 valid_lft, preferred_lft;
1732 int pfxlen = ifp->prefix_len;
1733 const unsigned int idgen_retries = 3;
1734 const unsigned int idgen_delay = 1 * HZ;
1735 int retries = ifp->stable_privacy_retry + 1;
1736
1737 if (retries > idgen_retries) {
1738 net_info_ratelimited("%s: privacy stable address generation failed because of DAD conflicts!\n",
1739 ifp->idev->dev->name);
1740 goto errdad;
1741 }
1742
1743 new_addr = ifp->addr;
1744 if (ipv6_generate_stable_address(&new_addr, retries,
1745 idev))
1746 goto errdad;
1747
1748 valid_lft = ifp->valid_lft;
1749 preferred_lft = ifp->prefered_lft;
1750
1751 spin_unlock_bh(&ifp->lock);
1752
1753 if (idev->cnf.max_addresses &&
1754 ipv6_count_addresses(idev) >=
1755 idev->cnf.max_addresses)
1756 goto lock_errdad;
1757
1758 net_info_ratelimited("%s: generating new stable privacy address because of DAD conflict\n",
1759 ifp->idev->dev->name);
1760
1761 ifp2 = ipv6_add_addr(idev, &new_addr, NULL, pfxlen,
1762 scope, flags, valid_lft,
1763 preferred_lft);
1764 if (IS_ERR(ifp2))
1765 goto lock_errdad;
1766
1767 spin_lock_bh(&ifp2->lock);
1768 ifp2->stable_privacy_retry = retries;
1769 ifp2->state = INET6_IFADDR_STATE_PREDAD;
1770 spin_unlock_bh(&ifp2->lock);
1771
1772 addrconf_mod_dad_work(ifp2, idgen_delay);
1773 in6_ifa_put(ifp2);
1774lock_errdad:
1775 spin_lock_bh(&ifp->lock);
1776 } else if (idev->cnf.accept_dad > 1 && !idev->cnf.disable_ipv6) {
1726 addr.s6_addr32[0] = htonl(0xfe800000);
1727 addr.s6_addr32[1] = 0;
1728
1729 if (!ipv6_generate_eui64(addr.s6_addr + 8, idev->dev) &&
1730 ipv6_addr_equal(&ifp->addr, &addr)) {
1731 /* DAD failed for link-local based on MAC address */
1732 idev->cnf.disable_ipv6 = 1;
1733
1734 pr_info("%s: IPv6 being disabled!\n",
1735 ifp->idev->dev->name);
1736 }
1737 }
1738
1777 addr.s6_addr32[0] = htonl(0xfe800000);
1778 addr.s6_addr32[1] = 0;
1779
1780 if (!ipv6_generate_eui64(addr.s6_addr + 8, idev->dev) &&
1781 ipv6_addr_equal(&ifp->addr, &addr)) {
1782 /* DAD failed for link-local based on MAC address */
1783 idev->cnf.disable_ipv6 = 1;
1784
1785 pr_info("%s: IPv6 being disabled!\n",
1786 ifp->idev->dev->name);
1787 }
1788 }
1789
1739 spin_lock_bh(&ifp->lock);
1790errdad:
1740 /* transition from _POSTDAD to _ERRDAD */
1741 ifp->state = INET6_IFADDR_STATE_ERRDAD;
1742 spin_unlock_bh(&ifp->lock);
1743
1744 addrconf_mod_dad_work(ifp, 0);
1745}
1746
1747/* Join to solicited addr multicast group.

--- 4064 unchanged lines hidden ---
1791 /* transition from _POSTDAD to _ERRDAD */
1792 ifp->state = INET6_IFADDR_STATE_ERRDAD;
1793 spin_unlock_bh(&ifp->lock);
1794
1795 addrconf_mod_dad_work(ifp, 0);
1796}
1797
1798/* Join to solicited addr multicast group.

--- 4064 unchanged lines hidden ---