patch-2.3.4 linux/net/ipv4/devinet.c

Next file: linux/net/ipv4/fib_hash.c
Previous file: linux/net/ipv4/af_inet.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.3/linux/net/ipv4/devinet.c linux/net/ipv4/devinet.c
@@ -1,7 +1,7 @@
 /*
  *	NET3	IP device support routines.
  *
- *	Version: $Id: devinet.c,v 1.28 1999/05/08 20:00:16 davem Exp $
+ *	Version: $Id: devinet.c,v 1.29 1999/05/27 00:37:57 davem Exp $
  *
  *		This program is free software; you can redistribute it and/or
  *		modify it under the terms of the GNU General Public License
@@ -661,15 +661,19 @@
 	   in this case. It is importnat that lo is the first interface
 	   in dev_base list.
 	 */
+	read_lock_bh(&dev_base_lock);
 	for (dev=dev_base; dev; dev=dev->next) {
 		if ((in_dev=dev->ip_ptr) == NULL)
 			continue;
 
 		for_primary_ifa(in_dev) {
-			if (ifa->ifa_scope <= scope)
+			if (ifa->ifa_scope <= scope) {
+				read_unlock_bh(&dev_base_lock);
 				return ifa->ifa_local;
+			}
 		} endfor_ifa(in_dev);
 	}
+	read_unlock_bh(&dev_base_lock);
 
 	return 0;
 }
@@ -790,6 +794,7 @@
 
 	s_idx = cb->args[0];
 	s_ip_idx = ip_idx = cb->args[1];
+	read_lock_bh(&dev_base_lock);
 	for (dev=dev_base, idx=0; dev; dev = dev->next, idx++) {
 		if (idx < s_idx)
 			continue;
@@ -807,6 +812,7 @@
 		}
 	}
 done:
+	read_unlock_bh(&dev_base_lock);
 	cb->args[0] = idx;
 	cb->args[1] = ip_idx;
 
@@ -881,11 +887,13 @@
 	ipv4_devconf.accept_redirects = !on;
 	ipv4_devconf_dflt.forwarding = on;
 
+	read_lock_bh(&dev_base_lock);
 	for (dev = dev_base; dev; dev = dev->next) {
 		struct in_device *in_dev = dev->ip_ptr;
 		if (in_dev)
 			in_dev->cnf.forwarding = on;
 	}
+	read_unlock_bh(&dev_base_lock);
 
 	rt_cache_flush(0);
 

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