aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/addrconf.c
diff options
context:
space:
mode:
authorDaniel Lezcano <dlezcano@fr.ibm.com>2008-01-11 01:44:09 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:01:45 -0500
commit1cab3da6be6c7659f62d0d297b389cc0e48b2178 (patch)
treef5a3e8a21136322625cb61dcf94d3edfac5ab7d1 /net/ipv6/addrconf.c
parent06bfe655e7db7719c0eb51eb420fb9c2a6aa1e00 (diff)
[NETNS][IPV6]: inet6_addr - ipv6_get_ifaddr namespace aware
The inet6_addr_lst is browsed taking into account the network namespace specified as parameter. If an address does not belong to the specified namespace, it is ignored. Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com> Signed-off-by: Benjamin Thery <benjamin.thery@bull.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/addrconf.c')
-rw-r--r--net/ipv6/addrconf.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 41cc31ee297e..c4df6cdff650 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1247,13 +1247,16 @@ int ipv6_chk_same_addr(struct net *net, const struct in6_addr *addr,
1247 return ifp != NULL; 1247 return ifp != NULL;
1248} 1248}
1249 1249
1250struct inet6_ifaddr * ipv6_get_ifaddr(struct in6_addr *addr, struct net_device *dev, int strict) 1250struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net, struct in6_addr *addr,
1251 struct net_device *dev, int strict)
1251{ 1252{
1252 struct inet6_ifaddr * ifp; 1253 struct inet6_ifaddr * ifp;
1253 u8 hash = ipv6_addr_hash(addr); 1254 u8 hash = ipv6_addr_hash(addr);
1254 1255
1255 read_lock_bh(&addrconf_hash_lock); 1256 read_lock_bh(&addrconf_hash_lock);
1256 for(ifp = inet6_addr_lst[hash]; ifp; ifp=ifp->lst_next) { 1257 for(ifp = inet6_addr_lst[hash]; ifp; ifp=ifp->lst_next) {
1258 if (ifp->idev->dev->nd_net != net)
1259 continue;
1257 if (ipv6_addr_equal(&ifp->addr, addr)) { 1260 if (ipv6_addr_equal(&ifp->addr, addr)) {
1258 if (dev == NULL || ifp->idev->dev == dev || 1261 if (dev == NULL || ifp->idev->dev == dev ||
1259 !(ifp->scope&(IFA_LINK|IFA_HOST) || strict)) { 1262 !(ifp->scope&(IFA_LINK|IFA_HOST) || strict)) {
@@ -1739,7 +1742,7 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len)
1739 1742
1740ok: 1743ok:
1741 1744
1742 ifp = ipv6_get_ifaddr(&addr, dev, 1); 1745 ifp = ipv6_get_ifaddr(&init_net, &addr, dev, 1);
1743 1746
1744 if (ifp == NULL && valid_lft) { 1747 if (ifp == NULL && valid_lft) {
1745 int max_addresses = in6_dev->cnf.max_addresses; 1748 int max_addresses = in6_dev->cnf.max_addresses;
@@ -3135,7 +3138,7 @@ inet6_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
3135 /* We ignore other flags so far. */ 3138 /* We ignore other flags so far. */
3136 ifa_flags = ifm->ifa_flags & (IFA_F_NODAD | IFA_F_HOMEADDRESS); 3139 ifa_flags = ifm->ifa_flags & (IFA_F_NODAD | IFA_F_HOMEADDRESS);
3137 3140
3138 ifa = ipv6_get_ifaddr(pfx, dev, 1); 3141 ifa = ipv6_get_ifaddr(net, pfx, dev, 1);
3139 if (ifa == NULL) { 3142 if (ifa == NULL) {
3140 /* 3143 /*
3141 * It would be best to check for !NLM_F_CREATE here but 3144 * It would be best to check for !NLM_F_CREATE here but
@@ -3442,7 +3445,7 @@ static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr* nlh,
3442 if (ifm->ifa_index) 3445 if (ifm->ifa_index)
3443 dev = __dev_get_by_index(&init_net, ifm->ifa_index); 3446 dev = __dev_get_by_index(&init_net, ifm->ifa_index);
3444 3447
3445 if ((ifa = ipv6_get_ifaddr(addr, dev, 1)) == NULL) { 3448 if ((ifa = ipv6_get_ifaddr(net, addr, dev, 1)) == NULL) {
3446 err = -EADDRNOTAVAIL; 3449 err = -EADDRNOTAVAIL;
3447 goto errout; 3450 goto errout;
3448 } 3451 }