[IPV6]: Fix address deletion

If you add more than one IPv6 address belonging to the same prefix and
delete the address that was last added, routing table entry for that
prefix is also deleted.
Tested on 2.6.14.4

To reproduce:
ip addr add 3ffe::1/64 dev eth0
ip addr add 3ffe::2/64 dev eth0
/* wait DAD */
sleep 1
ip addr del 3ffe::2/64 dev eth0
ip -6 route

(route to 3ffe::/64 should be gone)

In ipv6_del_addr(), if ifa == ifp, we set ifa->if_next to NULL, and later
assign ifap = &ifa->if_next, effectively terminating the for-loop.
This prevents us from checking if there are other addresses using the same
prefix that are valid, and thus resulting in deletion of the prefix.
This applies only if the first entry in idev->addr_list is the address to
be deleted.

Signed-off-by: Kristian Slavov <kristian.slavov@nomadiclab.com>
Acked-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Kristian Slavov and committed by David S. Miller 1d142804 7eb1b3d3

+3 -2
+3 -2
net/ipv6/addrconf.c
··· 634 634 } 635 635 #endif 636 636 637 - for (ifap = &idev->addr_list; (ifa=*ifap) != NULL; 638 - ifap = &ifa->if_next) { 637 + for (ifap = &idev->addr_list; (ifa=*ifap) != NULL;) { 639 638 if (ifa == ifp) { 640 639 *ifap = ifa->if_next; 641 640 __in6_ifa_put(ifp); ··· 642 643 if (!(ifp->flags & IFA_F_PERMANENT) || onlink > 0) 643 644 break; 644 645 deleted = 1; 646 + continue; 645 647 } else if (ifp->flags & IFA_F_PERMANENT) { 646 648 if (ipv6_prefix_equal(&ifa->addr, &ifp->addr, 647 649 ifp->prefix_len)) { ··· 666 666 } 667 667 } 668 668 } 669 + ifap = &ifa->if_next; 669 670 } 670 671 write_unlock_bh(&idev->lock); 671 672