

Patch from Stephen Hemminger <shemminger@osdl.org>

Replace brlock in IPV6 with RCU.



 25-akpm/net/ipv6/af_inet6.c            |   13 ++++++-------
 25-akpm/net/ipv6/ipv6_sockglue.c       |    9 ++++-----
 25-akpm/net/ipv6/netfilter/ip6_queue.c |    3 ---
 25-akpm/net/ipv6/protocol.c            |   12 ++++++------
 4 files changed, 16 insertions(+), 21 deletions(-)

diff -puN net/ipv6/af_inet6.c~brlock-7 net/ipv6/af_inet6.c
--- 25/net/ipv6/af_inet6.c~brlock-7	Tue Mar 11 16:59:54 2003
+++ 25-akpm/net/ipv6/af_inet6.c	Tue Mar 11 16:59:54 2003
@@ -45,7 +45,6 @@
 #include <linux/inet.h>
 #include <linux/netdevice.h>
 #include <linux/icmpv6.h>
-#include <linux/brlock.h>
 #include <linux/smp_lock.h>
 
 #include <net/ip.h>
@@ -101,6 +100,7 @@ kmem_cache_t *raw6_sk_cachep;
  * build a new socket.
  */
 struct list_head inetsw6[SOCK_MAX];
+static spinlock_t inetsw6_lock = SPIN_LOCK_UNLOCKED;
 
 static void inet6_sock_destruct(struct sock *sk)
 {
@@ -161,8 +161,8 @@ static int inet6_create(struct socket *s
 
 	/* Look for the requested type/protocol pair. */
 	answer = NULL;
-	br_read_lock_bh(BR_NETPROTO_LOCK);
-	list_for_each(p, &inetsw6[sock->type]) {
+	rcu_read_lock();
+	list_for_each_rcu(p, &inetsw6[sock->type]) {
 		answer = list_entry(p, struct inet_protosw, list);
 
 		/* Check the non-wild match. */
@@ -180,7 +180,7 @@ static int inet6_create(struct socket *s
 		}
 		answer = NULL;
 	}
-	br_read_unlock_bh(BR_NETPROTO_LOCK);
+	rcu_read_unlock();
 
 	if (!answer)
 		goto free_and_badtype;
@@ -571,8 +571,7 @@ inet6_register_protosw(struct inet_proto
 	int protocol = p->protocol;
 	struct list_head *last_perm;
 
-	br_write_lock_bh(BR_NETPROTO_LOCK);
-
+	spin_lock_bh(&inetsw6_lock);
 	if (p->type > SOCK_MAX)
 		goto out_illegal;
 
@@ -602,7 +601,7 @@ inet6_register_protosw(struct inet_proto
 	 */
 	list_add(&p->list, last_perm);
 out:
-	br_write_unlock_bh(BR_NETPROTO_LOCK);
+	spin_unlock_bh(&inetsw6_lock);
 	return;
 
 out_permanent:
diff -puN net/ipv6/ipv6_sockglue.c~brlock-7 net/ipv6/ipv6_sockglue.c
--- 25/net/ipv6/ipv6_sockglue.c~brlock-7	Tue Mar 11 16:59:54 2003
+++ 25-akpm/net/ipv6/ipv6_sockglue.c	Tue Mar 11 16:59:54 2003
@@ -54,11 +54,10 @@ DEFINE_SNMP_STAT(struct ipv6_mib, ipv6_s
 
 static struct packet_type ipv6_packet_type =
 {
-	__constant_htons(ETH_P_IPV6), 
-	NULL,					/* All devices */
-	ipv6_rcv,
-	(void*)1,
-	NULL
+	.type = __constant_htons(ETH_P_IPV6), 
+	.dev = NULL,					/* All devices */
+	.func = ipv6_rcv,
+	.data = (void*)1,
 };
 
 /*
diff -puN net/ipv6/netfilter/ip6_queue.c~brlock-7 net/ipv6/netfilter/ip6_queue.c
--- 25/net/ipv6/netfilter/ip6_queue.c~brlock-7	Tue Mar 11 16:59:54 2003
+++ 25-akpm/net/ipv6/netfilter/ip6_queue.c	Tue Mar 11 16:59:54 2003
@@ -26,7 +26,6 @@
 #include <linux/netfilter.h>
 #include <linux/netlink.h>
 #include <linux/spinlock.h>
-#include <linux/brlock.h>
 #include <linux/sysctl.h>
 #include <linux/proc_fs.h>
 #include <net/sock.h>
@@ -688,8 +687,6 @@ init_or_cleanup(int init)
 
 cleanup:
 	nf_unregister_queue_handler(PF_INET6);
-	br_write_lock_bh(BR_NETPROTO_LOCK);
-	br_write_unlock_bh(BR_NETPROTO_LOCK);
 	ipq_flush(NF_DROP);
 	
 cleanup_sysctl:
diff -puN net/ipv6/protocol.c~brlock-7 net/ipv6/protocol.c
--- 25/net/ipv6/protocol.c~brlock-7	Tue Mar 11 16:59:54 2003
+++ 25-akpm/net/ipv6/protocol.c	Tue Mar 11 16:59:54 2003
@@ -32,7 +32,6 @@
 #include <linux/in6.h>
 #include <linux/netdevice.h>
 #include <linux/if_arp.h>
-#include <linux/brlock.h>
 
 #include <net/sock.h>
 #include <net/snmp.h>
@@ -41,21 +40,21 @@
 #include <net/protocol.h>
 
 struct inet6_protocol *inet6_protos[MAX_INET_PROTOS];
+static spinlock_t inet6_proto_lock = SPIN_LOCK_UNLOCKED;
 
 int inet6_add_protocol(struct inet6_protocol *prot, unsigned char protocol)
 {
 	int ret, hash = protocol & (MAX_INET_PROTOS - 1);
 
-	br_write_lock_bh(BR_NETPROTO_LOCK);
 
+	spin_lock_bh(&inet6_proto_lock);
 	if (inet6_protos[hash]) {
 		ret = -1;
 	} else {
 		inet6_protos[hash] = prot;
 		ret = 0;
 	}
-
-	br_write_unlock_bh(BR_NETPROTO_LOCK);
+	spin_unlock_bh(&inet6_proto_lock);
 
 	return ret;
 }
@@ -68,7 +67,7 @@ int inet6_del_protocol(struct inet6_prot
 {
 	int ret, hash = protocol & (MAX_INET_PROTOS - 1);
 
-	br_write_lock_bh(BR_NETPROTO_LOCK);
+	spin_lock_bh(&inet6_proto_lock);
 
 	if (inet6_protos[hash] != prot) {
 		ret = -1;
@@ -76,8 +75,9 @@ int inet6_del_protocol(struct inet6_prot
 		inet6_protos[hash] = NULL;
 		ret = 0;
 	}
+	spin_unlock_bh(&inet6_proto_lock);
 
-	br_write_unlock_bh(BR_NETPROTO_LOCK);
+	synchronize_kernel();
 
 	return ret;
 }

_
