patch-2.3.15 linux/include/net/addrconf.h

Next file: linux/include/net/af_unix.h
Previous file: linux/include/linux/wireless.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.14/linux/include/net/addrconf.h linux/include/net/addrconf.h
@@ -51,8 +51,10 @@
 extern int			addrconf_del_ifaddr(void *arg);
 extern int			addrconf_set_dstaddr(void *arg);
 
-extern struct inet6_ifaddr *	ipv6_chk_addr(struct in6_addr *addr,
-					      struct net_device *dev, int nd);
+extern int			ipv6_chk_addr(struct in6_addr *addr,
+					      struct net_device *dev);
+extern struct inet6_ifaddr *	ipv6_get_ifaddr(struct in6_addr *addr,
+						struct net_device *dev);
 extern int			ipv6_get_saddr(struct dst_entry *dst, 
 					       struct in6_addr *daddr,
 					       struct in6_addr *saddr);
@@ -85,7 +87,50 @@
 extern void			addrconf_prefix_rcv(struct net_device *dev,
 						    u8 *opt, int len);
 
-extern struct inet6_dev *	ipv6_get_idev(struct net_device *dev);
+extern __inline__ struct inet6_dev *
+__in6_dev_get(struct net_device *dev)
+{
+	return (struct inet6_dev *)dev->ip6_ptr;
+}
+
+extern rwlock_t addrconf_lock;
+
+extern __inline__ struct inet6_dev *
+in6_dev_get(struct net_device *dev)
+{
+	struct inet6_dev *idev = NULL;
+	read_lock(&addrconf_lock);
+	idev = dev->ip6_ptr;
+	if (idev)
+		atomic_inc(&idev->refcnt);
+	read_unlock(&addrconf_lock);
+	return idev;
+}
+
+extern void in6_dev_finish_destroy(struct inet6_dev *idev);
+
+extern __inline__ void
+in6_dev_put(struct inet6_dev *idev)
+{
+	if (atomic_dec_and_test(&idev->refcnt))
+		in6_dev_finish_destroy(idev);
+}
+
+#define __in6_dev_put(idev)  atomic_dec(&(idev)->refcnt)
+#define in6_dev_hold(idev)   atomic_inc(&(idev)->refcnt)
+
+
+extern void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp);
+
+extern __inline__ void in6_ifa_put(struct inet6_ifaddr *ifp)
+{
+	if (atomic_dec_and_test(&ifp->refcnt))
+		inet6_ifa_finish_destroy(ifp);
+}
+
+#define __in6_ifa_put(idev)  atomic_dec(&(idev)->refcnt)
+#define in6_ifa_hold(idev)   atomic_inc(&(idev)->refcnt)
+
 
 extern void			addrconf_forwarding_on(void);
 /*
@@ -95,7 +140,6 @@
 static __inline__ u8 ipv6_addr_hash(struct in6_addr *addr)
 {	
 	__u32 word;
-	unsigned tmp;
 
 	/* 
 	 * We perform the hash function over the last 64 bits of the address
@@ -103,15 +147,10 @@
 	 */
 
 	word = addr->s6_addr[2] ^ addr->s6_addr32[3];
-	tmp  = word ^ (word>>16);
-	tmp ^= (tmp >> 8);
+	word  ^= (word>>16);
+	word ^= (word >> 8);
 
-	return ((tmp ^ (tmp >> 4)) & 0x0f);
-}
-
-static __inline__ int ipv6_devindex_hash(int ifindex)
-{
-	return ifindex & (IN6_ADDR_HSIZE - 1);
+	return ((word ^ (word >> 4)) & 0x0f);
 }
 
 /*

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)