OpenVZ Forum


Home » Mailing lists » Devel » [patch 07/38][IPV6] inet6_addr - ipv6_get_ifaddr namespace aware
[patch 07/38][IPV6] inet6_addr - ipv6_get_ifaddr namespace aware [message #24303] Mon, 03 December 2007 16:16
Daniel Lezcano is currently offline  Daniel Lezcano
Messages: 417
Registered: June 2006
Senior Member
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.

In order to reduce the scope of the patch, a wrapper has been
created to not impact all the callers.

The next patch will remove this wrapper and change all the wrappers
to take into account this new parameter.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: Benjamin Thery <benjamin.thery@bull.net>
---
 include/net/addrconf.h |   15 ++++++++++++---
 net/ipv6/addrconf.c    |    5 ++++-
 2 files changed, 16 insertions(+), 4 deletions(-)

Index: linux-2.6-netns/include/net/addrconf.h
===================================================================
--- linux-2.6-netns.orig/include/net/addrconf.h
+++ linux-2.6-netns/include/net/addrconf.h
@@ -66,9 +66,18 @@ extern int			ipv6_chk_addr(struct net *n
 #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
 extern int			ipv6_chk_home_addr(struct in6_addr *addr);
 #endif
-extern struct inet6_ifaddr *	ipv6_get_ifaddr(struct in6_addr *addr,
-						struct net_device *dev,
-						int strict);
+extern struct inet6_ifaddr      *__ipv6_get_ifaddr(struct net *net,
+						   struct in6_addr *addr,
+						   struct net_device *dev,
+						   int strict);
+
+static inline struct inet6_ifaddr *ipv6_get_ifaddr(struct in6_addr *addr,
+						   struct net_device *dev,
+						   int strict)
+{
+	return __ipv6_get_ifaddr(&init_net, addr, dev, strict);
+}
+
 extern int			ipv6_get_saddr(struct dst_entry *dst, 
 					       struct in6_addr *daddr,
 					       struct in6_addr *saddr);
Index: linux-2.6-netns/net/ipv6/addrconf.c
===================================================================
--- linux-2.6-netns.orig/net/ipv6/addrconf.c
+++ linux-2.6-netns/net/ipv6/addrconf.c
@@ -1223,13 +1223,16 @@ int ipv6_chk_same_addr(struct net *net, 
 	return ifp != NULL;
 }
 
-struct inet6_ifaddr * ipv6_get_ifaddr(struct in6_addr *addr, struct net_device *dev, int strict)
+struct inet6_ifaddr * __ipv6_get_ifaddr(struct net *net, struct in6_addr *addr,
+					struct net_device *dev, int strict)
 {
 	struct inet6_ifaddr * ifp;
 	u8 hash = ipv6_addr_hash(addr);
 
 	read_lock_bh(&addrconf_hash_lock);
 	for(ifp = inet6_addr_lst[hash]; ifp; ifp=ifp->lst_next) {
+		if (ifp->idev->dev->nd_net != net)
+			continue;
 		if (ipv6_addr_equal(&ifp->addr, addr)) {
 			if (dev == NULL || ifp->idev->dev == dev ||
 			    !(ifp->scope&(IFA_LINK|IFA_HOST) || strict)) {

-- 
_______________________________________________
Containers mailing list
Containers@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers
Previous Topic: [patch 06/38][IPV6] inet6_addr - ipv6_chk_same_addr namespace aware
Next Topic: [patch 08/38][IPV6] inet6_addr - remove ipv6_get_ifaddr wrapper
Goto Forum:
  


Current Time: Tue Aug 05 00:22:58 GMT 2025

Total time taken to generate the page: 1.38453 seconds