aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/socket.c
diff options
context:
space:
mode:
authorJon Paul Maloy <jon.maloy@ericsson.com>2014-03-12 11:31:10 -0400
committerDavid S. Miller <davem@davemloft.net>2014-03-12 15:53:49 -0400
commit24be34b5a0c9114541891d29dff1152bb1a8df34 (patch)
treefe5d550eb2328dfaea278a6b8c70dadf0deab4c6 /net/tipc/socket.c
parent8826cde655fb5ca3b35a112c851c90b3dccbb7b8 (diff)
tipc: eliminate upcall function pointers between port and socket
Due to the original one-to-many relation between port and user API layers, upcalls to the API have been performed via function pointers, installed in struct tipc_port at creation. Since this relation now always is one-to-one, we can instead use ordinary function calls. We remove the function pointers 'dispatcher' and ´wakeup' from struct tipc_port, and replace them with calls to the renamed functions tipc_sk_rcv() and tipc_sk_wakeup(). At the same time we change the name and signature of the functions tipc_createport() and tipc_deleteport() to reflect their new role as mere initialization/destruction functions. Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Reviewed-by: Ying Xue <ying.xue@windriver.com> Reviewed-by: Erik Hugne <erik.hugne@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/socket.c')
-rw-r--r--net/tipc/socket.c32
1 files changed, 6 insertions, 26 deletions
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 912665d409de..d147eaaa6d58 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -44,10 +44,7 @@
44 44
45#define CONN_TIMEOUT_DEFAULT 8000 /* default connect timeout = 8s */ 45#define CONN_TIMEOUT_DEFAULT 8000 /* default connect timeout = 8s */
46 46
47
48static int backlog_rcv(struct sock *sk, struct sk_buff *skb); 47static int backlog_rcv(struct sock *sk, struct sk_buff *skb);
49static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf);
50static void wakeupdispatch(struct tipc_port *tport);
51static void tipc_data_ready(struct sock *sk, int len); 48static void tipc_data_ready(struct sock *sk, int len);
52static void tipc_write_space(struct sock *sk); 49static void tipc_write_space(struct sock *sk);
53static int tipc_release(struct socket *sock); 50static int tipc_release(struct socket *sock);
@@ -181,10 +178,8 @@ static int tipc_sk_create(struct net *net, struct socket *sock, int protocol,
181 if (sk == NULL) 178 if (sk == NULL)
182 return -ENOMEM; 179 return -ENOMEM;
183 180
184 /* Allocate TIPC port for socket to use */ 181 tp_ptr = tipc_sk_port(sk);
185 tp_ptr = tipc_createport(sk, &dispatch, &wakeupdispatch, 182 if (!tipc_port_init(tp_ptr, TIPC_LOW_IMPORTANCE)) {
186 TIPC_LOW_IMPORTANCE);
187 if (unlikely(!tp_ptr)) {
188 sk_free(sk); 183 sk_free(sk);
189 return -ENOMEM; 184 return -ENOMEM;
190 } 185 }
@@ -199,7 +194,6 @@ static int tipc_sk_create(struct net *net, struct socket *sock, int protocol,
199 sk->sk_data_ready = tipc_data_ready; 194 sk->sk_data_ready = tipc_data_ready;
200 sk->sk_write_space = tipc_write_space; 195 sk->sk_write_space = tipc_write_space;
201 tipc_sk(sk)->conn_timeout = CONN_TIMEOUT_DEFAULT; 196 tipc_sk(sk)->conn_timeout = CONN_TIMEOUT_DEFAULT;
202
203 spin_unlock_bh(tp_ptr->lock); 197 spin_unlock_bh(tp_ptr->lock);
204 198
205 if (sock->state == SS_READY) { 199 if (sock->state == SS_READY) {
@@ -207,7 +201,6 @@ static int tipc_sk_create(struct net *net, struct socket *sock, int protocol,
207 if (sock->type == SOCK_DGRAM) 201 if (sock->type == SOCK_DGRAM)
208 tipc_set_portunreliable(tp_ptr->ref, 1); 202 tipc_set_portunreliable(tp_ptr->ref, 1);
209 } 203 }
210
211 return 0; 204 return 0;
212} 205}
213 206
@@ -337,7 +330,7 @@ static int tipc_release(struct socket *sock)
337 * Delete TIPC port; this ensures no more messages are queued 330 * Delete TIPC port; this ensures no more messages are queued
338 * (also disconnects an active connection & sends a 'FIN-' to peer) 331 * (also disconnects an active connection & sends a 'FIN-' to peer)
339 */ 332 */
340 res = tipc_deleteport(tport); 333 tipc_port_destroy(tport);
341 334
342 /* Discard any remaining (connection-based) messages in receive queue */ 335 /* Discard any remaining (connection-based) messages in receive queue */
343 __skb_queue_purge(&sk->sk_receive_queue); 336 __skb_queue_purge(&sk->sk_receive_queue);
@@ -1430,17 +1423,16 @@ static int backlog_rcv(struct sock *sk, struct sk_buff *buf)
1430} 1423}
1431 1424
1432/** 1425/**
1433 * dispatch - handle incoming message 1426 * tipc_sk_rcv - handle incoming message
1434 * @tport: TIPC port that received message 1427 * @sk: socket receiving message
1435 * @buf: message 1428 * @buf: message
1436 * 1429 *
1437 * Called with port lock already taken. 1430 * Called with port lock already taken.
1438 * 1431 *
1439 * Returns TIPC error status code (TIPC_OK if message is not to be rejected) 1432 * Returns TIPC error status code (TIPC_OK if message is not to be rejected)
1440 */ 1433 */
1441static u32 dispatch(struct tipc_port *port, struct sk_buff *buf) 1434u32 tipc_sk_rcv(struct sock *sk, struct sk_buff *buf)
1442{ 1435{
1443 struct sock *sk = tipc_port_to_sk(port);
1444 u32 res; 1436 u32 res;
1445 1437
1446 /* 1438 /*
@@ -1463,18 +1455,6 @@ static u32 dispatch(struct tipc_port *port, struct sk_buff *buf)
1463 return res; 1455 return res;
1464} 1456}
1465 1457
1466/**
1467 * wakeupdispatch - wake up port after congestion
1468 * @tport: port to wakeup
1469 *
1470 * Called with port lock already taken.
1471 */
1472static void wakeupdispatch(struct tipc_port *port)
1473{
1474 struct sock *sk = tipc_port_to_sk(port);
1475 sk->sk_write_space(sk);
1476}
1477
1478static int tipc_wait_for_connect(struct socket *sock, long *timeo_p) 1458static int tipc_wait_for_connect(struct socket *sock, long *timeo_p)
1479{ 1459{
1480 struct sock *sk = sock->sk; 1460 struct sock *sk = sock->sk;