patch-2.3.6 linux/net/ipv6/addrconf.c

Next file: linux/net/ipv6/af_inet6.c
Previous file: linux/net/ipv4/utils.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.5/linux/net/ipv6/addrconf.c linux/net/ipv6/addrconf.c
@@ -5,7 +5,7 @@
  *	Authors:
  *	Pedro Roque		<roque@di.fc.ul.pt>	
  *
- *	$Id: addrconf.c,v 1.49 1999/05/27 00:38:20 davem Exp $
+ *	$Id: addrconf.c,v 1.50 1999/06/09 10:11:09 davem Exp $
  *
  *	This program is free software; you can redistribute it and/or
  *      modify it under the terms of the GNU General Public License
@@ -100,9 +100,7 @@
    1. The result of inet6_add_addr() is used only inside lock
       or from bh_atomic context.
 
-   2. inet6_get_lladdr() is used only from bh protected context.
-
-   3. The result of ipv6_chk_addr() is not used outside of bh protected context.
+   2. The result of ipv6_chk_addr() is not used outside of bh protected context.
  */
 
 static __inline__ void addrconf_lock(void)
@@ -463,7 +461,7 @@
 	return err;
 }
 
-struct inet6_ifaddr * ipv6_get_lladdr(struct device *dev)
+int ipv6_get_lladdr(struct device *dev, struct in6_addr *addr)
 {
 	struct inet6_ifaddr *ifp = NULL;
 	struct inet6_dev *idev;
@@ -471,12 +469,15 @@
 	if ((idev = ipv6_get_idev(dev)) != NULL) {
 		addrconf_lock();
 		for (ifp=idev->addr_list; ifp; ifp=ifp->if_next) {
-			if (ifp->scope == IFA_LINK)
-				break;
+			if (ifp->scope == IFA_LINK) {
+				ipv6_addr_copy(addr, &ifp->addr);
+				addrconf_unlock();
+				return 0;
+			}
 		}
 		addrconf_unlock();
 	}
-	return ifp;
+	return -EADDRNOTAVAIL;
 }
 
 /*
@@ -982,7 +983,7 @@
 		return;
 	}
 
-	read_lock_bh(&dev_base_lock);
+	read_lock(&dev_base_lock);
         for (dev = dev_base; dev != NULL; dev = dev->next) {
 		if (dev->ip_ptr && (dev->flags & IFF_UP)) {
 			struct in_device * in_dev = dev->ip_ptr;
@@ -1001,7 +1002,6 @@
 					flag |= IFA_HOST;
 				}
 
-				read_unlock_bh(&dev_base_lock);
 				addrconf_lock();
 				ifp = ipv6_add_addr(idev, &addr, flag);
 				if (ifp) {
@@ -1013,11 +1013,10 @@
 					ipv6_ifa_notify(RTM_NEWADDR, ifp);
 				}
 				addrconf_unlock();
-				read_lock_bh(&dev_base_lock);
 			}
 		}
         }
-	read_unlock_bh(&dev_base_lock);
+	read_unlock(&dev_base_lock);
 }
 
 static void init_loopback(struct device *dev)
@@ -1846,12 +1845,11 @@
 	struct device *dev;
 
 	/* This takes sense only during module load. */
-	read_lock_bh(&dev_base_lock);
+	read_lock(&dev_base_lock);
 	for (dev = dev_base; dev; dev = dev->next) {
 		if (!(dev->flags&IFF_UP))
 			continue;
 
-		read_unlock_bh(&dev_base_lock);
 		switch (dev->type) {
 		case ARPHRD_LOOPBACK:	
 			init_loopback(dev);
@@ -1862,9 +1860,8 @@
 		default:
 			/* Ignore all other */
 		}
-		read_lock_bh(&dev_base_lock);
 	}
-	read_unlock_bh(&dev_base_lock);
+	read_unlock(&dev_base_lock);
 #endif
 	
 #ifdef CONFIG_PROC_FS

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