aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
authorJon Paul Maloy <jon.maloy@ericsson.com>2014-08-22 18:09:15 -0400
committerDavid S. Miller <davem@davemloft.net>2014-08-23 14:18:34 -0400
commit9b50fd087a9f1454d6a8b613fff376dfb6d6ea93 (patch)
treeaa33132baefa002ee81a2cd2603ed7891ee0eecd /net/tipc
parent5a9ee0be3371eb77d671a77e26261931c5c3fb31 (diff)
tipc: replace port pointer with socket pointer in registry
In order to make tipc_sock the only entity referencable from other parts of the stack, we add a tipc_sock pointer instead of a tipc_port pointer to the registry. As a consequence, we also let the function tipc_port_lock() return a pointer to a tipc_sock instead of a tipc_port. We keep the function's name for now, since the lock still is owned by the port. This is another step in the direction of eliminating port_lock, replacing its usage with lock_sock() and bh_lock_sock(). Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Reviewed-by: Erik Hugne <erik.hugne@ericsson.com> Reviewed-by: Ying Xue <ying.xue@windriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r--net/tipc/port.h4
-rw-r--r--net/tipc/socket.c23
2 files changed, 11 insertions, 16 deletions
diff --git a/net/tipc/port.h b/net/tipc/port.h
index 4a3c54e5d69c..33e52fe50e10 100644
--- a/net/tipc/port.h
+++ b/net/tipc/port.h
@@ -101,9 +101,9 @@ void tipc_port_reinit(void);
101/** 101/**
102 * tipc_port_lock - lock port instance referred to and return its pointer 102 * tipc_port_lock - lock port instance referred to and return its pointer
103 */ 103 */
104static inline struct tipc_port *tipc_port_lock(u32 ref) 104static inline struct tipc_sock *tipc_port_lock(u32 ref)
105{ 105{
106 return (struct tipc_port *)tipc_ref_lock(ref); 106 return (struct tipc_sock *)tipc_ref_lock(ref);
107} 107}
108 108
109/** 109/**
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index ddc2f8c6fced..247f245ff596 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -115,11 +115,7 @@ static struct proto tipc_proto_kern;
115*/ 115*/
116static struct tipc_sock *tipc_sk_lock_next(u32 *ref) 116static struct tipc_sock *tipc_sk_lock_next(u32 *ref)
117{ 117{
118 struct tipc_port *port = (struct tipc_port *)tipc_ref_lock_next(ref); 118 return (struct tipc_sock *)tipc_ref_lock_next(ref);
119
120 if (!port)
121 return NULL;
122 return tipc_port_to_sock(port);
123} 119}
124 120
125/** 121/**
@@ -204,7 +200,7 @@ static int tipc_sk_create(struct net *net, struct socket *sock,
204 200
205 tsk = tipc_sk(sk); 201 tsk = tipc_sk(sk);
206 port = &tsk->port; 202 port = &tsk->port;
207 ref = tipc_ref_acquire(port, &port->lock); 203 ref = tipc_ref_acquire(tsk, &port->lock);
208 if (!ref) { 204 if (!ref) {
209 pr_warn("Socket create failed; reference table exhausted\n"); 205 pr_warn("Socket create failed; reference table exhausted\n");
210 return -ENOMEM; 206 return -ENOMEM;
@@ -1655,13 +1651,12 @@ int tipc_sk_rcv(struct sk_buff *buf)
1655 u32 dnode; 1651 u32 dnode;
1656 1652
1657 /* Validate destination and message */ 1653 /* Validate destination and message */
1658 port = tipc_port_lock(dport); 1654 tsk = tipc_port_lock(dport);
1659 if (unlikely(!port)) { 1655 if (unlikely(!tsk)) {
1660 rc = tipc_msg_eval(buf, &dnode); 1656 rc = tipc_msg_eval(buf, &dnode);
1661 goto exit; 1657 goto exit;
1662 } 1658 }
1663 1659 port = &tsk->port;
1664 tsk = tipc_port_to_sock(port);
1665 sk = &tsk->sk; 1660 sk = &tsk->sk;
1666 1661
1667 /* Queue message */ 1662 /* Queue message */
@@ -2002,21 +1997,21 @@ restart:
2002 1997
2003static void tipc_sk_timeout(unsigned long ref) 1998static void tipc_sk_timeout(unsigned long ref)
2004{ 1999{
2005 struct tipc_port *port = tipc_port_lock(ref); 2000 struct tipc_sock *tsk = tipc_port_lock(ref);
2006 struct tipc_sock *tsk; 2001 struct tipc_port *port;
2007 struct sock *sk; 2002 struct sock *sk;
2008 struct sk_buff *buf = NULL; 2003 struct sk_buff *buf = NULL;
2009 struct tipc_msg *msg = NULL; 2004 struct tipc_msg *msg = NULL;
2010 u32 peer_port, peer_node; 2005 u32 peer_port, peer_node;
2011 2006
2012 if (!port) 2007 if (!tsk)
2013 return; 2008 return;
2014 2009
2010 port = &tsk->port;
2015 if (!port->connected) { 2011 if (!port->connected) {
2016 tipc_port_unlock(port); 2012 tipc_port_unlock(port);
2017 return; 2013 return;
2018 } 2014 }
2019 tsk = tipc_port_to_sock(port);
2020 sk = &tsk->sk; 2015 sk = &tsk->sk;
2021 bh_lock_sock(sk); 2016 bh_lock_sock(sk);
2022 peer_port = tipc_port_peerport(port); 2017 peer_port = tipc_port_peerport(port);