Subject: [PATCH] nethost ipv6: Don't allow global ipv6 addresses that another nethost is already using. From: Eric W. Biederman Date: 1134318161 -0700 --- net/ipv6/addrconf.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) 9f5507ea8b3cce466257c14c7afa42ad061ed9d5 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 7c34835..8c8f41d 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -142,7 +142,9 @@ static void ipv6_ifa_notify(int event, s static void inet6_prefix_notify(int event, struct inet6_dev *idev, struct prefix_info *pinfo); -static int ipv6_chk_same_addr(const struct in6_addr *addr, struct net_device *dev); +static int ipv6_chk_same_host_addr(const struct in6_addr *addr, + struct net_device *dev, + struct nethost *host); static struct notifier_block *inet6addr_chain; @@ -510,7 +512,8 @@ ipv6_add_addr(struct nethost *host, stru write_lock(&addrconf_hash_lock); /* Ignore adding duplicate addresses on an interface */ - if (ipv6_chk_same_addr(addr, idev->dev)) { + /* Deny adding global addresses already used by another host */ + if (ipv6_chk_same_host_addr(addr, idev->dev, host)) { ADBG(("ipv6_add_addr: already assigned\n")); err = -EEXIST; goto out; @@ -1020,7 +1023,8 @@ int ipv6_chk_addr(struct nethost *host, } static -int ipv6_chk_same_addr(const struct in6_addr *addr, struct net_device *dev) +int ipv6_chk_same_host_addr(const struct in6_addr *addr, struct net_device *dev, + struct nethost *host) { struct inet6_ifaddr * ifp; u8 hash = ipv6_addr_hash(addr); @@ -1029,6 +1033,9 @@ int ipv6_chk_same_addr(const struct in6_ if (ipv6_addr_equal(&ifp->addr, addr)) { if (dev == NULL || ifp->idev->dev == dev) break; + if (host && (ifp->host != host) && + !(ipv6_addr_type(addr) & (IPV6_ADDR_LOOPBACK | IPV6_ADDR_LINKLOCAL))) + break; } } return ifp != NULL; -- 1.0.GIT