lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1257514891-18917-1-git-send-email-remi@remlab.net>
Date:	Fri,  6 Nov 2009 15:41:31 +0200
From:	Rémi Denis-Courmont <remi@...lab.net>
To:	netdev@...r.kernel.org
Cc:	Rémi Denis-Courmont 
	<remi.denis-courmont@...ia.com>
Subject: [PATCH net-next] Phonet: use rwlock for sockets list

From: Rémi Denis-Courmont <remi.denis-courmont@...ia.com>

Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@...ia.com>
---
 net/phonet/socket.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/net/phonet/socket.c b/net/phonet/socket.c
index 0412beb..ecb5f20 100644
--- a/net/phonet/socket.c
+++ b/net/phonet/socket.c
@@ -47,10 +47,10 @@ static int pn_socket_release(struct socket *sock)
 
 static struct  {
 	struct hlist_head hlist;
-	spinlock_t lock;
+	rwlock_t lock;
 } pnsocks = {
 	.hlist = HLIST_HEAD_INIT,
-	.lock = __SPIN_LOCK_UNLOCKED(pnsocks.lock),
+	.lock = __RW_LOCK_UNLOCKED(pnsocks.lock),
 };
 
 /*
@@ -65,7 +65,7 @@ struct sock *pn_find_sock_by_sa(struct net *net, const struct sockaddr_pn *spn)
 	u16 obj = pn_sockaddr_get_object(spn);
 	u8 res = spn->spn_resource;
 
-	spin_lock_bh(&pnsocks.lock);
+	read_lock_bh(&pnsocks.lock);
 
 	sk_for_each(sknode, node, &pnsocks.hlist) {
 		struct pn_sock *pn = pn_sk(sknode);
@@ -91,7 +91,7 @@ struct sock *pn_find_sock_by_sa(struct net *net, const struct sockaddr_pn *spn)
 		break;
 	}
 
-	spin_unlock_bh(&pnsocks.lock);
+	read_unlock_bh(&pnsocks.lock);
 
 	return rval;
 }
@@ -102,7 +102,7 @@ void pn_deliver_sock_broadcast(struct net *net, struct sk_buff *skb)
 	struct hlist_node *node;
 	struct sock *sknode;
 
-	spin_lock(&pnsocks.lock);
+	read_lock(&pnsocks.lock);
 	sk_for_each(sknode, node, &pnsocks.hlist) {
 		struct sk_buff *clone;
 
@@ -117,22 +117,22 @@ void pn_deliver_sock_broadcast(struct net *net, struct sk_buff *skb)
 			sk_receive_skb(sknode, clone, 0);
 		}
 	}
-	spin_unlock(&pnsocks.lock);
+	read_unlock(&pnsocks.lock);
 }
 
 void pn_sock_hash(struct sock *sk)
 {
-	spin_lock_bh(&pnsocks.lock);
+	write_lock_bh(&pnsocks.lock);
 	sk_add_node(sk, &pnsocks.hlist);
-	spin_unlock_bh(&pnsocks.lock);
+	write_unlock_bh(&pnsocks.lock);
 }
 EXPORT_SYMBOL(pn_sock_hash);
 
 void pn_sock_unhash(struct sock *sk)
 {
-	spin_lock_bh(&pnsocks.lock);
+	write_lock_bh(&pnsocks.lock);
 	sk_del_node_init(sk);
-	spin_unlock_bh(&pnsocks.lock);
+	write_unlock_bh(&pnsocks.lock);
 }
 EXPORT_SYMBOL(pn_sock_unhash);
 
@@ -466,7 +466,7 @@ static struct sock *pn_sock_get_next(struct seq_file *seq, struct sock *sk)
 static void *pn_sock_seq_start(struct seq_file *seq, loff_t *pos)
 	__acquires(pnsocks.lock)
 {
-	spin_lock_bh(&pnsocks.lock);
+	read_lock_bh(&pnsocks.lock);
 	return *pos ? pn_sock_get_idx(seq, *pos - 1) : SEQ_START_TOKEN;
 }
 
@@ -485,7 +485,7 @@ static void *pn_sock_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 static void pn_sock_seq_stop(struct seq_file *seq, void *v)
 	__releases(pnsocks.lock)
 {
-	spin_unlock_bh(&pnsocks.lock);
+	read_unlock_bh(&pnsocks.lock);
 }
 
 static int pn_sock_seq_show(struct seq_file *seq, void *v)
-- 
1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ